Difference between revisions of "LaTeX/C3/Links-and-URLs/English"
Ketkinaina (Talk | contribs) (Created page with "'''Title of the script: Links and URLs ''' '''Authors: Ambika Vanchinathan''' '''Keywords:''' LaTeX, hyperref, url, clickable links, line breaks, URLs, email links, internal...") |
|||
| Line 13: | Line 13: | ||
'''Title Slide''' | '''Title Slide''' | ||
| − | || Welcome to this Spoken tutorial on''' Links and URLs''' in''' LaTeX.''' | + | || Welcome to this Spoken tutorial on ''' Links and URLs''' in''' LaTeX.''' |
|- | |- | ||
|| '''Slide 2''' | || '''Slide 2''' | ||
| Line 45: | Line 45: | ||
'''1. hyperref-eg.tex''' | '''1. hyperref-eg.tex''' | ||
| − | This file is provided in the Code Files link of this tutorial page. | + | This file is provided in the '''Code Files''' link of this tutorial page. |
|| The following code file is required to practice this tutorial. | || The following code file is required to practice this tutorial. | ||
| − | This file is provided in the Code Files link of this tutorial page. | + | This file is provided in the '''Code Files''' link of this tutorial page. |
| − | + | ||
| Line 90: | Line 89: | ||
Make sure to load this command before '''hyperref''', as it loads the '''url''' package. | Make sure to load this command before '''hyperref''', as it loads the '''url''' package. | ||
| − | We add this command to enable the '''hyphens''' option for better line breaks.The hyphens allow long '''URLs''' to break at '''hyphens''' when they don’t fit the line. | + | We add this command to enable the '''hyphens''' option for better line breaks. |
| + | |||
| + | The hyphens allow long '''URLs''' to break at '''hyphens''' when they don’t fit the line. | ||
|- | |- | ||
|| '''Highlight:''' | || '''Highlight:''' | ||
| Line 99: | Line 100: | ||
'''Highlight: \url''' | '''Highlight: \url''' | ||
| − | || We used this command to get the '''clickable link''' in the document | + | || We used this command to get the '''clickable link''' in the document. |
| − | The '''\url '''command takes a '''url '''as its argument and typesets it as a clickable link | + | The '''\url ''' command takes a '''url ''' as its argument and typesets it as a clickable link. |
|- | |- | ||
| − | || Click on the green Typeset button to run the | + | || Click on the green Typeset button to run the code. |
| + | |||
| + | Click on the link and select Yes. | ||
Click the url and point the cursor to the website. | Click the url and point the cursor to the website. | ||
| Line 128: | Line 131: | ||
Let's wrap the second URL as well. | Let's wrap the second URL as well. | ||
|- | |- | ||
| − | || Uncomment the lines 10 to 16 | + | || Uncomment the lines 10 to 16. |
|| Uncomment the lines 10 to 16. | || Uncomment the lines 10 to 16. | ||
|- | |- | ||
| Line 139: | Line 142: | ||
'''\do\k\do\l\do\m\do\n\do\o\do\p\do\q\do\r\do\s\do\t%''' | '''\do\k\do\l\do\m\do\n\do\o\do\p\do\q\do\r\do\s\do\t%''' | ||
| − | '''\do\u\do\v\do\w\do\x\do\y\do\z\do\A\do\B\do\C\do\D\do\E\do\F\do\G\do\H\do\I\do\J%''' | + | '''\do\u\do\v\do\w\do\x\do\y\do\z''' |
| + | |||
| + | '''\do\A\do\B\do\C\do\D\do\E\do\F\do\G\do\H\do\I\do\J%''' | ||
'''\do\K\do\L\do\M\do\N\do\O\do\P\do\Q\do\R\do\S\do\T%''' | '''\do\K\do\L\do\M\do\N\do\O\do\P\do\Q\do\R\do\S\do\T%''' | ||
| Line 179: | Line 184: | ||
This command takes 2 arguments. | This command takes 2 arguments. | ||
| − | + | '''URL:''' The hyperlink target (web addresses, email, or internal reference). | |
| − | + | '''text''': The visible, clickable text. | |
|- | |- | ||
|| Click on the green typeset button to show the output. | || Click on the green typeset button to show the output. | ||
| Line 194: | Line 199: | ||
Let us click on the '''email link''' | Let us click on the '''email link''' | ||
| − | Clicking this link opens the default email client | + | Clicking this link opens the default email client. |
| − | Let us see how to code it | + | Let us see how to code it. |
|- | |- | ||
|| Comment line 59 | || Comment line 59 | ||
| Line 204: | Line 209: | ||
line 62 | line 62 | ||
| − | || The '''\href''' command can also display custom link text instead of showing the full URL | + | || The '''\href''' command can also display custom link text instead of showing the full URL. |
| − | Here, clicking on '''Spoken Tutorial''' opens the specified webpage | + | Here, clicking on '''Spoken Tutorial''' opens the specified webpage. |
|- | |- | ||
|| Run the code | || Run the code | ||
| Line 214: | Line 219: | ||
|| Run the code | || Run the code | ||
| − | The output shows an external link | + | The output shows an external link. |
Let us click on it | Let us click on it | ||
| − | It takes us to the | + | It takes us to the Spoken Tutorial website. |
|- | |- | ||
| − | || comment the line 65 | + | || comment the line 65. |
| − | || Comment the line 65 | + | || Comment the line 65. |
|- | |- | ||
|| '''Highlight:''' | || '''Highlight:''' | ||
| Line 230: | Line 235: | ||
It takes 2 arguments | It takes 2 arguments | ||
| − | 1.'''label:''' The name of the label to link to which is defined earlier with '''\label''' command | + | 1.'''label:''' The name of the label to link to which is defined earlier with '''\label''' command. |
| − | 2.'''link text''': The clickable text shown in the document | + | 2.'''link text''': The clickable text shown in the document. |
Here, it takes us to the '''section''' labelled '''sec:target''' | Here, it takes us to the '''section''' labelled '''sec:target''' | ||
| Line 250: | Line 255: | ||
|| LaTeX builds the document in multiple steps. | || LaTeX builds the document in multiple steps. | ||
| − | Let us run the code | + | Let us run the code. |
In the first run, it collects information for labels, references, page numbers etc | In the first run, it collects information for labels, references, page numbers etc | ||
| Line 279: | Line 284: | ||
'''Summary''' | '''Summary''' | ||
| − | + | In this tutorial, we have learnt to: | |
| − | * | + | * Create clickable URLs. |
| − | * | + | * Use url package to break long URLs. |
| − | * | + | * Set email, external & internal links. |
| − | * | + | * Customize link colors and styles with hyperref package. |
|| With this we come to the end of this tutorial. | || With this we come to the end of this tutorial. | ||
Latest revision as of 23:44, 10 October 2025
Title of the script: Links and URLs
Authors: Ambika Vanchinathan
Keywords: LaTeX, hyperref, url, clickable links, line breaks, URLs, email links, internal links, PDF bookmarks, video tutorial.
| Visual Cue | Narration |
| Slide 1
Title Slide |
Welcome to this Spoken tutorial on Links and URLs in LaTeX. |
| Slide 2
Learning Objectives |
In this tutorial we will learn to,
|
| Slide 3
System Requirements |
To record this tutorial, I am using:
|
| Slide 4
Pre-requisites |
To follow this tutorial, learners should have basic knowledge of LaTeX. |
| Slide 5
Code files The following code file is required to practice this tutorial. 1. hyperref-eg.tex This file is provided in the Code Files link of this tutorial page. |
The following code file is required to practice this tutorial.
This file is provided in the Code Files link of this tutorial page.
|
| Let us get started. | |
| Highlight :
lines 19 to 26 \usepackage[ colorlinks=true, % color the text of links linkcolor=blue, % color for internal links urlcolor=magenta, % color for URLs breaklinks=true, % allow links to break across lines pdfborder={0 0 0}, % remove borders around links bookmarks=true % enable PDF bookmarks ]{hyperref} |
These commands import the hyperref package with various options. |
| Highlight:
line 6 for all the lines in this row. \usepackage[hyphens]{url} Highlight line 26 {hyperref} |
\usepackage[hyphens]{url} imports the url package with the hyphens option.
Make sure to load this command before hyperref, as it loads the url package. We add this command to enable the hyphens option for better line breaks. The hyphens allow long URLs to break at hyphens when they don’t fit the line. |
| Highlight:
line 39 \url{https://spoken-tutorial.org} Highlight: \url |
We used this command to get the clickable link in the document.
The \url command takes a url as its argument and typesets it as a clickable link. |
| Click on the green Typeset button to run the code.
Click on the link and select Yes. Click the url and point the cursor to the website. |
Click on the green Typeset button to run the code.
A pop up Open URL opens with a warning message. Read the message and click on the Yes button. Spoken tutorial page opens. |
| Comment the line 41. | Comment the line 41. |
| Run the code and show the output | Let's run the code
We see 2 long URLs. One URL is wrapped to the next line, while the other extends to the margin. One is wrapped because it breaks at the / (forward slash) automatically. Let's wrap the second URL as well. |
| Uncomment the lines 10 to 16. | Uncomment the lines 10 to 16. |
| Highlight:
lines 10 to 16 \do\a\do\b\do\c\do\d\do\e\do\f\do\g\do\h\do\i\do\j% \do\k\do\l\do\m\do\n\do\o\do\p\do\q\do\r\do\s\do\t% \do\u\do\v\do\w\do\x\do\y\do\z \do\A\do\B\do\C\do\D\do\E\do\F\do\G\do\H\do\I\do\J% \do\K\do\L\do\M\do\N\do\O\do\P\do\Q\do\R\do\S\do\T% \do\U\do\V\do\W\do\X\do\Y\do\Z} |
This macro allows the URLs to wrap correctly.
This command allows URL breaks after any lowercase or uppercase letter from A to Z. |
| Click on the green typeset button to run the code.
Point the cursor to the second long URL. Click on the link. Click Yes in the warning pop up window. Page directed to the website. |
Let’s run the code.
We now see that the second long URL wraps neatly to the next line. This is because we allowed line breaks after every alphabet in the URL. Let us click on the link. If the pop up appears please click the Yes button. The link takes us to its website. |
| Comment the line 53 | Comment the line 53 |
| Highlight:
line 56 |
The command \href creates an email link.
This command takes 2 arguments. URL: The hyperlink target (web addresses, email, or internal reference). text: The visible, clickable text. |
| Click on the green typeset button to show the output.
Click Yes in the warning pop up window. Point the cursor to the Email link. |
Run the code.
The output shows an Email link Let us click on the email link Clicking this link opens the default email client. Let us see how to code it. |
| Comment line 59 | Comment line 59. |
| Highlight:
line 62 |
The \href command can also display custom link text instead of showing the full URL.
Here, clicking on Spoken Tutorial opens the specified webpage. |
| Run the code
Show the output Click Yes in the warning pop up window. |
Run the code
The output shows an external link. Let us click on it It takes us to the Spoken Tutorial website. |
| comment the line 65. | Comment the line 65. |
| Highlight:
line 67 |
The \hyperref command creates internal links within the document
It takes 2 arguments 1.label: The name of the label to link to which is defined earlier with \label command. 2.link text: The clickable text shown in the document. Here, it takes us to the section labelled sec:target |
| Highlight:
line 71, 72 |
This is the section referred to using an internal link.
Here is the target section labeled sec:target which the internal link jumps to. |
| Run the code
Show the output We run the code twice. |
LaTeX builds the document in multiple steps.
Let us run the code. In the first run, it collects information for labels, references, page numbers etc At this point \ref, \pageref, \autoref used by hyperref don’t have values yet. |
| Run the code.
Cursor on the output. Point the cursor to the clickable url. Click on it. Cursor to the target section. |
Let us run the code again.
This time it uses the stored info and creates hyperlinks, bookmarks, TOC etc. Now we can see a clickable url after the second run which takes us to a website. Let us click on it. It takes us to the target section. |
| Slide 6
Summary In this tutorial, we have learnt to:
|
With this we come to the end of this tutorial.
Let us summarise. |
| Slide 7
Assignment As an assignment, 1. Create an external link with custom text 2. Create an internal link to a labeled section within your document |
As an assignment, please do the following: |
| Slide 8
Thank you |
Thank you for joining |