LaTeX/C3/Links-and-URLs/English

From Script | Spoken-Tutorial
Revision as of 23:44, 10 October 2025 by Madhurig (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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,
  • Create clickable URLs.
  • Use url package to break long URLs.
  • Set email, external & internal links.
  • Customize link colors and styles with hyperref package.
Slide 3

System Requirements

To record this tutorial, I am using:
  • Linux Mint version 21.3
  • TeXworks version 0.6.6
  • A working internet connection.
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:

  • 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.

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

Contributors and Content Editors

Ketkinaina, Madhurig