LaTeX template: move hyperref near end of preamble.

It now comes after header-includes and right before title, author, date,
abstract.

The hyperref documentation says: “Make sure it comes last of your loaded
packages”. The reason is that it redefines many LaTeX commands.

For example, loading it after titlesec (which might be loaded in
header-includes) causes links in the table of contents to point to
the wrong page ().

Closes .

Note:  Users who presuppose hyperref in their header-includes
will now have to add `\usepackage{hyperref}` to their header-includes
to make it available there.  (The redundant `\usepackage` will
do no harm in this case.)
This commit is contained in:
John MacFarlane 2022-03-13 10:48:09 -07:00
parent 6b79e944bb
commit f3fcdd52c8
5 changed files with 46 additions and 46 deletions

View file

@ -211,33 +211,6 @@ $if(verbatim-in-note)$
$endif$ $endif$
\usepackage{xcolor} \usepackage{xcolor}
\IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available \IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available
\IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}}
\hypersetup{
$if(title-meta)$
pdftitle={$title-meta$},
$endif$
$if(author-meta)$
pdfauthor={$author-meta$},
$endif$
$if(lang)$
pdflang={$lang$},
$endif$
$if(subject)$
pdfsubject={$subject$},
$endif$
$if(keywords)$
pdfkeywords={$for(keywords)$$keywords$$sep$, $endfor$},
$endif$
$if(colorlinks)$
colorlinks=true,
linkcolor={$if(linkcolor)$$linkcolor$$else$Maroon$endif$},
filecolor={$if(filecolor)$$filecolor$$else$Maroon$endif$},
citecolor={$if(citecolor)$$citecolor$$else$Blue$endif$},
urlcolor={$if(urlcolor)$$urlcolor$$else$Blue$endif$},
$else$
hidelinks,
$endif$
pdfcreator={LaTeX via pandoc}}
\urlstyle{same} % disable monospaced font for URLs \urlstyle{same} % disable monospaced font for URLs
$if(verbatim-in-note)$ $if(verbatim-in-note)$
\VerbatimFootnotes % allow verbatim text in footnotes \VerbatimFootnotes % allow verbatim text in footnotes
@ -409,6 +382,33 @@ $endif$
$if(csquotes)$ $if(csquotes)$
\usepackage{csquotes} \usepackage{csquotes}
$endif$ $endif$
\IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}}
\hypersetup{
$if(title-meta)$
pdftitle={$title-meta$},
$endif$
$if(author-meta)$
pdfauthor={$author-meta$},
$endif$
$if(lang)$
pdflang={$lang$},
$endif$
$if(subject)$
pdfsubject={$subject$},
$endif$
$if(keywords)$
pdfkeywords={$for(keywords)$$keywords$$sep$, $endfor$},
$endif$
$if(colorlinks)$
colorlinks=true,
linkcolor={$if(linkcolor)$$linkcolor$$else$Maroon$endif$},
filecolor={$if(filecolor)$$filecolor$$else$Maroon$endif$},
citecolor={$if(citecolor)$$citecolor$$else$Blue$endif$},
urlcolor={$if(urlcolor)$$urlcolor$$else$Blue$endif$},
$else$
hidelinks,
$endif$
pdfcreator={LaTeX via pandoc}}
$if(title)$ $if(title)$
\title{$title$$if(thanks)$\thanks{$thanks$}$endif$} \title{$title$$if(thanks)$\thanks{$thanks$}$endif$}

View file

@ -34,10 +34,6 @@
\makeatother \makeatother
\usepackage{xcolor} \usepackage{xcolor}
\IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available \IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available
\IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}}
\hypersetup{
hidelinks,
pdfcreator={LaTeX via pandoc}}
\urlstyle{same} % disable monospaced font for URLs \urlstyle{same} % disable monospaced font for URLs
\usepackage{color} \usepackage{color}
\usepackage{fancyvrb} \usepackage{fancyvrb}
@ -84,6 +80,10 @@
\ifLuaTeX \ifLuaTeX
\usepackage{selnolig} % disable illegal ligatures \usepackage{selnolig} % disable illegal ligatures
\fi \fi
\IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}}
\hypersetup{
hidelinks,
pdfcreator={LaTeX via pandoc}}
\author{} \author{}
\date{} \date{}

View file

@ -34,10 +34,6 @@
\makeatother \makeatother
\usepackage{xcolor} \usepackage{xcolor}
\IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available \IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available
\IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}}
\hypersetup{
hidelinks,
pdfcreator={LaTeX via pandoc}}
\urlstyle{same} % disable monospaced font for URLs \urlstyle{same} % disable monospaced font for URLs
\usepackage{listings} \usepackage{listings}
\newcommand{\passthrough}[1]{#1} \newcommand{\passthrough}[1]{#1}
@ -51,6 +47,10 @@
\ifLuaTeX \ifLuaTeX
\usepackage{selnolig} % disable illegal ligatures \usepackage{selnolig} % disable illegal ligatures
\fi \fi
\IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}}
\hypersetup{
hidelinks,
pdfcreator={LaTeX via pandoc}}
\author{} \author{}
\date{} \date{}

View file

@ -35,12 +35,6 @@
\usepackage{fancyvrb} \usepackage{fancyvrb}
\usepackage{xcolor} \usepackage{xcolor}
\IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available \IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available
\IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}}
\hypersetup{
pdftitle={Pandoc Test Suite},
pdfauthor={John MacFarlane; Anonymous},
hidelinks,
pdfcreator={LaTeX via pandoc}}
\urlstyle{same} % disable monospaced font for URLs \urlstyle{same} % disable monospaced font for URLs
\VerbatimFootnotes % allow verbatim text in footnotes \VerbatimFootnotes % allow verbatim text in footnotes
\usepackage{graphicx} \usepackage{graphicx}
@ -66,6 +60,12 @@
\ifLuaTeX \ifLuaTeX
\usepackage{selnolig} % disable illegal ligatures \usepackage{selnolig} % disable illegal ligatures
\fi \fi
\IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}}
\hypersetup{
pdftitle={Pandoc Test Suite},
pdfauthor={John MacFarlane; Anonymous},
hidelinks,
pdfcreator={LaTeX via pandoc}}
\title{Pandoc Test Suite} \title{Pandoc Test Suite}
\author{John MacFarlane \and Anonymous} \author{John MacFarlane \and Anonymous}

View file

@ -34,11 +34,6 @@
\makeatother \makeatother
\usepackage{xcolor} \usepackage{xcolor}
\IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available \IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available
\IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}}
\hypersetup{
pdflang={en},
hidelinks,
pdfcreator={LaTeX via pandoc}}
\urlstyle{same} % disable monospaced font for URLs \urlstyle{same} % disable monospaced font for URLs
\setlength{\emergencystretch}{3em} % prevent overfull lines \setlength{\emergencystretch}{3em} % prevent overfull lines
\providecommand{\tightlist}{% \providecommand{\tightlist}{%
@ -68,6 +63,11 @@
\newenvironment{RTL}{\beginR}{\endR} \newenvironment{RTL}{\beginR}{\endR}
\newenvironment{LTR}{\beginL}{\endL} \newenvironment{LTR}{\beginL}{\endL}
\fi \fi
\IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}}
\hypersetup{
pdflang={en},
hidelinks,
pdfcreator={LaTeX via pandoc}}
\author{} \author{}
\date{} \date{}