General ⇒ table of contents and hyperref
-
- Posts: 7
- Joined: Fri Jan 04, 2019 6:41 pm
table of contents and hyperref
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
- Stefan Kottwitz
- Site Admin
- Posts: 10360
- Joined: Mon Mar 10, 2008 9:44 pm
table of contents and hyperref
welcome to the forum!
Since it's hard to guess what went wrong without seeing the code - can you post your code please? A reduced (compilable) example would be good, no need for actual text content.
Stefan
-
- Posts: 7
- Joined: Fri Jan 04, 2019 6:41 pm
table of contents and hyperref
Code: Select all
\documentclass[12pt]{article}
\usepackage[ansinew]{inputenc}
\usepackage{array}
\usepackage{color}
\usepackage{amsmath,amsthm}
\usepackage{amsxtra}
\usepackage{amstext}
\usepackage{amssymb}
\usepackage{latexsym}
\usepackage{graphicx}
\usepackage{enumerate}
\usepackage{hyperref}
\begin{document}
\begin{center}
\hypertarget{loretta}{\LARGE{Home Page}}
\end{center}
\tableofcontents
\newpage
\addcontentsline{toc}{section}{Welcome}
\section*{Welcome}
Text...
\hyperlink{loretta}{Home Page}
\newpage
\addcontentsline{toc}{section}{Chapter 1}
\section*{Chapter 1}
Text...
\hyperlink{loretta}{Home Page}
\newpage
\addcontentsline{toc}{section}{Chapter 2}
\section*{Chapter 2}
Text...
\hyperlink{loretta}{Home Page}
\newpage
\end{document}
- Stefan Kottwitz
- Site Admin
- Posts: 10360
- Joined: Mon Mar 10, 2008 9:44 pm
table of contents and hyperref
now that I see the code, it's clear. The starred
\section*
commands don't produce an anchor for hyperref
, since they are not intended to be shown in the table of contents, with a link. You added a contents entry manually. Then you also need to add a manual link. That can be done by \phantomsection
. In this order:Code: Select all
\section*{Chapter 1}
\phantomsection
\addcontentsline{toc}{section}{Chapter 1}
...
\section*{Chapter 2}
\phantomsection
\addcontentsline{toc}{section}{Chapter 2}
-
- Posts: 7
- Joined: Fri Jan 04, 2019 6:41 pm