Generated directory

I found many ways to generate PDF bookmarks/directories/Outlines while modifying the Latex templates, so I’ll do a little bit of reorganizing here.

Assuming that multiple levels of titles are already generated in Latex, we use the command:

\tableofcontents

Examples of code to generate directories:

\documentclass[UTF8]{ctexart} \title{author} \date{today} % margin \usepackage{geometry} \newgeometry{left = 3cm, right = 3cm, top=2.5cm, Bottom =1.5cm} \begin{document} \maketitle{\textbf{Abstract}} ~\\ % empty line \tableofcontents % \section{Python} % first level title Subsection {Leetcode} % second subsection title section{writing} % first subsection title section{other} % first subsection title \subsection{Latex} % second subsection title \subsection{blog} % second subsection title \end{document}Copy the code

Can automatically generate directory, as shown below:

Generate PDF bookmarks/catalogs/Outlines – Method 1

Add the following command:

\usepackage{hyperref}

PDF bookmarks can be generated with the following code:

\usepackage{hyperref} % \begin{document} \begin{document}Copy the code

The result is shown here (with Adobe Acrobat eye color as background) :

At this point, clicking on the bookmark’s title entry will jump directly to the title page

However, the contents in the PDF document have red boxes, so we can use the following command:

\usepackage{hyperref} %%%% \ %%%% \hypersetup{hidelinks, colorlinks=true,
	allcolors=black,
	pdfstartview=Fit,
	breaklinks=true
}
Copy the code

The following information is displayed:

Generate PDF bookmarks/catalogs/Outlines – Method 2

Another way is to use a command:

\usepackage{pdfcomment}

Code:

\usepackage{pdfcomment} % New writeCopy the code

Or it could go like this:

\usepackage{pdfcomment} \newcommand{\commentontext}[2]{\colorbox{yellow! 60} {# 1} \ pdfcomment [color = {0.234, 0.867, 0.211}, hoffset = 6 pt, voffset = 10 pt, opacity = 0.5] {2}}\ newcommand {\ commentatside} [1] {\ pdfcomment [color = {0.045, 0.278, 0.643}, icon = Note] {# 1}}
\newcommand{\todo}[1]{\commentatside{# 1}}
\newcommand{\TODO}[1]{\commentatside{# 1}}
Copy the code

\usepackage{pdfcomment} \usepackage{hyperref} \usepackage{pdfcomment} \usepackage{hyperref}

To drop the red box in this environment, you can use the following code:

\usepackage{pdfcomment} \newcommand{\commentontext}[2]{\colorbox{yellow! 60} {# 1} \ pdfcomment [color = {0.234, 0.867, 0.211}, hoffset = 6 pt, voffset = 10 pt, opacity = 0.5] {2}}\ newcommand {\ commentatside} [1] {\ pdfcomment [color = {0.045, 0.278, 0.643}, icon = Note] {# 1}}
\newcommand{\todo}[1]{\commentatside{# 1}}
\newcommand{\TODO}[1]{\commentatside{# 1}}%\usepackage{hyperref} %\usepackage{pdfcomment} \hypersetup{hidelinks, colorlinks=true,
	allcolors=black,
	pdfstartview=Fit,
	breaklinks=true
}
Copy the code

The effect is as follows:

Remove bookmarks/contents/Outlines

If you want to remove the bookmark, just delete all of the code that appears above