Text FormattingProblem with hyperref in the Contents

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
mcnguyen
Posts: 4
Joined: Wed Jan 06, 2016 12:56 pm

Problem with hyperref in the Contents

Post by mcnguyen »

Hi all,

The package "hyperref" does not work correctly on the links which contain captions link (\cite ou \ref) in the Contents (\tableofcontents) or Table of figures (\tableoffigures) when I compile by latex standard (latex-dvipdf). However, it is good when I use pdflatex.

Who could explain this difference, and how I can correctly obtain when I want to use latex-dvipdf.

Attached tex file and two pdf files compiled by latex and pdflatex.

Thank you very much.
Minh Chien

Code: Select all

\documentclass{report}
\usepackage{hyperref}

\begin{document}
\tableofcontents

\chapter{Test chapter\label{chapter}}
\section{Test Section 1}
\section{Test Section \ref{chapter}}


\end{document}
Attachments
main-pdflatex.pdf
(37.32 KiB) Downloaded 341 times
main-latex.pdf
(12.17 KiB) Downloaded 326 times
main.tex
(197 Bytes) Downloaded 353 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Re: Problem with hyperref in the Contents

Post by Johannes_B »

All links work as expected for me, can you outrule a viewer issue?


Apart from the technical side, i don't recommend using references in sectional titles.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
mcnguyen
Posts: 4
Joined: Wed Jan 06, 2016 12:56 pm

Re: Problem with hyperref in the Contents

Post by mcnguyen »

I enclose the difference in a pdf file.

Thank you for your attention.
Minh Chien
Attachments
difference.pdf
(31.77 KiB) Downloaded 337 times
User avatar
Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Problem with hyperref in the Contents

Post by Stefan Kottwitz »

Hi Minh,

you could work with LaTeX --> DVI --> PS --> PDF using latex, dvips and ps2pdf. That's the old-fashioned way which should work with hyperref. LaTeX editors often have this compiling chain as an option.

hyperref doesn't have a dvipdf driver support. However, it provides dvipdfm and dvipdfmx as options. In case you use one of those converters, you can specify it, or just give each a try:

Code: Select all

\usepackage[dvipdfmx]{hyperref}
Stefan
LaTeX.org admin
mcnguyen
Posts: 4
Joined: Wed Jan 06, 2016 12:56 pm

Re: Problem with hyperref in the Contents

Post by mcnguyen »

Hi Stefan,

Thank you for your answer, the problem is solved by dvipdfm and dvipdfmx backend.

However, I prefer dvips backend even if the problem does not work correctly.

Minh Chien
User avatar
Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Problem with hyperref in the Contents

Post by Stefan Kottwitz »

dvipdfm and dvipdfmx still use standard LaTeX in dvi mode. Just the conversion to PDF is done differently. So it's not pdfLaTeX.

You said latex-dvipdf, so I assumed it's not the way over ps. In the case of latex-dvi-ps-pdf, you can try

Code: Select all

\usepackage[dvips]{hyperref}
though hyperref should choose the correct driver automatically.

Stefan
LaTeX.org admin
mcnguyen
Posts: 4
Joined: Wed Jan 06, 2016 12:56 pm

Re: Problem with hyperref in the Contents

Post by mcnguyen »

Here, I simply say dvipdf, mean latex-dvi-ps-pdf using latex dvips ps2pdf.

I think that dvips option is selected by default in standard latex. Although I have chosen this option \usepackage[dvips]{hyperref} and I use latex-dvi-ps2pdf, I have always this problem.

Minh Chien
Post Reply