LaTeX
  • How I learn LaTeX?
  • Installation and Customization
    • Online
    • Offline
  • LaTeX Basics
  • Text Manipulation
    • Fonts, Size and Styles
  • Math Manipulation
  • Advanced Math Manipulation
  • Lists
  • Tables
  • Pictures, Figures
  • Unit in LaTeX
  • Document Structure
  • Document Formatting
    • Headers and Footers, Page Numbering
    • Spacing in Paragraphs
    • Page size, Margins
    • Coloring
    • Footnotes
  • Multi-file LaTeX project
Powered by GitBook
On this page
  • Sections and Chapters
  • Table of Contents
  • Cross-referencing
  • Glossaries
  • Nomenclatures
  • Hyperlinks

Document Structure

Another huge step to make your work more organized and professional!

PreviousUnit in LaTeXNextDocument Formatting

Last updated 1 year ago

Sections and Chapters

LaTeX\LaTeXLATE​X supports the creation of a document structure and also enables customization of sectioning and numbering. In LaTeX\LaTeXLATE​X, there are 7 levels of depth for defining sections depending on the document class:

Priority

-1

\part

0

\chapter

1

\section

2

\subsection

3

\subsubsection

4

\paragraph

5

\subparagraph

For \part and \chapter, you need to declare document class to book/chapter to make these commands work.

Different document class may have different behaviours for these commands.

If you want your section to be unnumbered, place an asterisk * after the section command.

Table of Contents

To create the table of contents , use the command \tableofcontents. Sections, subsections and chapters are included in the table of contents. By default, it will look like this:

However, if you want to change the title from "Contents" to something you prefer, you can use \renewcommand*\contentsname{Something you like}.

Cross-referencing

Some noteworthy commands:

  • \label{something} - label your element

  • \ref{something} - refer your element, it should print the numerical order of your element, also add a hyperlink to it.

  • \pageref{something} - refer to the page number where your element is placed.

Section

The label is set once you've put \label after \section.

Equation

To refer equation, your equation must be placed in equation environment, and have \label command.

Glossaries

When writing a document that contains some field-specific concepts it might be convenient to add a glossary. A glossary is a list of terms in a particular domain of knowledge with definitions for those terms.

Let's start with an example to explain how glossary works:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{glossaries}

\makeglossaries

\newglossaryentry{latex}
{
    name=latex,
    description={Is a markup language specially suited 
    for scientific documents}
}

\newglossaryentry{maths}
{
    name=mathematics,
    description={Mathematics is what mathematicians do}
}

\title{How to create a glossary}
\author{ }
\date{ }

\begin{document}
\maketitle

The \Gls{latex} typesetting markup language is specially suitable 
for documents that include \gls{maths}. 

\clearpage

\printglossaries

\end{document}

In order to make glossary, you need a package called glossaries, let's jump to the code:

  • \makeglossaries - instantiate the package - must be placed in the preamble

  • \newglossaryentry{x} - create a glossary entry, with x being the name that can be referenced later using \gls. It takes 2 parameter, name and description.

  • \printglossaries, render the list of words and definitions typed in each entry, with the title "Glossary". This command can be placed at any place in the document.

Nomenclatures

A list of abbreviations and symbols is common in many scientific documents. These types of lists can be created with LaTeX\LaTeXLATE​X by means on the nomencl package.

Let's look at an example:

\documentclass{article}
\usepackage{nomencl}
\makenomenclature

\begin{document}
Here is an example:
\nomenclature{\(c\)}{Speed of light in a vacuum}
\nomenclature{\(h\)}{Planck constant}

\printnomenclature
\end{document}

and how it's displayed:

As in the example, here is some important command to create a nomenclature:

  • \makenomenclature - put in the preamble to instantiate the package

  • \nomenclature{}{} - Used to define the nomenclature entries themselves. Takes two arguments, the symbol and the corresponding description.

  • \printnomenclatures - print the nomenclature itself

Customizing nomenclatures

When importing the nomencl package, there are a few options we can use:

  • intoc - include the nomenclature in table of contents

  • language - as far as I concern, vietnamese is not supported

If you want to change the default title "Nomenclature", you can use this command:

\renewcommand{\nomname}{List of Symbols}

Hyperlinks

LaTeX\LaTeXLATE​X provides a simple yet powerful way to include hyperlinks in your documents, allowing you to seamlessly navigate between different sections, external websites, or even specific locations within your document.

By importing hyperref, the first thing you notice is that all cross-referenced elements now become hyperlinks.

In order to create hyperlinks leading to the Internet, you can use the following syntax: \url{https://example.com} or \href{https://example.com}{A webpage}

\documentclass{article}
\usepackage{hyperref}
\begin{document}
For further reference, please visit \href{http://example.com}{this link}. 

For intensive information, \url{https://google.com} may help.
\end{document}

Insert links manually

Previously, you have known that all cross-referenced elements become links once hyperref is imported, so we can use \label anywhere in the document and refer later those labels to create links. However, hyperref has 2 commands to create user-defined links - which is better than using \label:

  • \hyperlink{thesentence}{any sentence} - This command prints the text "any sentence" as a clickable element that redirects to the element whose identifier is "thesentence".

  • \hypertarget{thesentence}{this sentence} - Create an identifier for your element. The first parameter is the name of the identifier, in this case thesentence, the second parameter is the text you want to print.

Let's take a look at this example:

\begin{document}
It's also possible to link directly any word 
or \hyperlink{thesentence}{any sentence} in you document.

If you read this text, you will get no information.  Really?  
Is there no information?

For instance \hypertarget{thesentence}{this sentence}.
\end{document}

In this case, when you click on "any sentence", the document will bring you to the sentence "For instance this sentence".

Customize your hyperlinks

In previous examples, I have made all hyperlinks blue as it enhances visibility and attracts attention. This is the syntax for doing it:

\documentclass{article}
\usepackage{hyperref}
\hypersetup{
    colorlinks=true,
    linkcolor=blue,      
    urlcolor=red,
    urlstyle{same},
    pdftitle={Overleaf Example},
    pdfpagemode=FullScreen,
    }
  • \hypersetup{ ... } - This will set the options to configure the behaviour of the links within the document. Every parameter must be comma-separated and the syntax must be in the format parameter=value.

  • colorlinks=true - Links will be coloured, the default colour is red.

  • linkcolor=blue - Internal links, those generated by cross-referenced elements, are displayed in blue.

  • urlcolor=cyan - Links to web sites are set to cyan colour.

  • urlstyle{same} - Default settings print links in mono-style spaced fonts, this command changes that and displays the links in the same style as the rest of the text.

Below is some PDF-specific options:

  • pdftitle={Titlehere} - Is the title of the PDF output file, to be displayed in the title bar of the window.

  • pdfpagemode=FullScreen - The document will be displayed in fullscreen mode (not sure if this works)

If you'd like to delve deeper into the topic, feel free to explore the following links for additional information:

For cross-referencing figures and pictures, please check .

hyperref should be imported last in your preamble. Check for reference.

this
https://www.overleaf.com/learn/latex/Hyperlinks
https://ctan.org/pkg/hyperref
Labelling and cross-referencing