git.iko.soy/typeable/pandoc
on master help sign in
LaTeX template: Improve readability (#5363)

+ LaTeX template: Improve template readability Use `hidelinks` option for hyperref, which has the same effect as `pdfborder={0 0 0}`, but its purpose is clearer. Use a simpler conditional for Polyglossia/Babel. Format comments more consistently. + Update tests + Remove hyperref breaklinks option. According to the documentation, hyperref sets this automatically as appropriate to the driver.

commitbbe2da390e5ec49ce6c88e00ba5f1c7f2b4c7c80 authorAndrew Dunning <adunning@users.noreply.github.com> dateWed 13 Mar 2019, 20:22 (8 years ago) parent8d58c61
5 files changed+63−58
data/templates/default.latex+19−18 test/lhs-test.latex+8−7 test/lhs-test.latex+lhs+8−7 test/writer.latex+9−8 test/writers-lang-and-dir.latex+19−18
data/templates/default.latex+19−18
@@ -1,4 +1,5 @@
1−\PassOptionsToPackage{unicode=true$for(hyperrefoptions)$,$hyperrefoptions$$endfor$}{hyperref} % options for packages loaded elsewhere
1+% Options for packages loaded elsewhere
2+\PassOptionsToPackage{unicode=true$for(hyperrefoptions)$,$hyperrefoptions$$endfor$}{hyperref}
23\PassOptionsToPackage{hyphens}{url}
34$if(colorlinks)$
45\PassOptionsToPackage{dvipsnames,svgnames*,x11names*}{xcolor}
@@ -46,7 +47,7 @@ $endif$
4647$for(beameroption)$
4748\setbeameroption{$beameroption$}
4849$endfor$
49−% Prevent slide breaks in the middle of a paragraph:
50+% Prevent slide breaks in the middle of a paragraph
5051\widowpenalties 1 10000
5152\raggedbottom
5253$if(section-titles)$
@@ -173,7 +174,7 @@ $if(outertheme)$
173174\useoutertheme{$outertheme$}
174175$endif$
175176$endif$
176−% use upquote if available, for straight quotes in verbatim environments
177+% Use upquote if available, for straight quotes in verbatim environments
177178\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
178179\IfFileExists{microtype.sty}{% use microtype if available
179180 \usepackage[$for(microtypeoptions)$$microtypeoptions$$sep$,$endfor$]{microtype}
@@ -218,10 +219,10 @@ $if(colorlinks)$
218219 citecolor=$if(citecolor)$$citecolor$$else$Blue$endif$,
219220 urlcolor=$if(urlcolor)$$urlcolor$$else$Blue$endif$,
220221$else$
221− pdfborder={0 0 0},
222+ hidelinks,
222223$endif$
223− breaklinks=true}
224−\urlstyle{same} % don't use monospace font for urls
224+}
225+\urlstyle{same} % disable monospaced font for URLs
225226$if(verbatim-in-note)$
226227\VerbatimFootnotes % allows verbatim text in footnotes
227228$endif$
@@ -247,7 +248,7 @@ $if(tables)$
247248\usepackage{longtable,booktabs}
248249$if(beamer)$
249250\usepackage{caption}
250−% These lines are needed to make table captions work with longtable:
251+% Make caption package work with longtable
251252\makeatletter
252253\def\fnum@table{\tablename~\thetable}
253254\makeatother
@@ -274,10 +275,10 @@ $if(links-as-notes)$
274275$endif$
275276$if(strikeout)$
276277\usepackage[normalem]{ulem}
277−% avoid problems with \sout in headers with hyperref:
278+% Avoid problems with \sout in headers with hyperref
278279\pdfstringdefDisableCommands{\renewcommand{\sout}{}}
279280$endif$
280−\setlength{\emergencystretch}{3em} % prevent overfull lines
281+\setlength{\emergencystretch}{3em} % prevent overfull lines
281282\providecommand{\tightlist}{%
282283 \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
283284$if(numbersections)$
@@ -304,7 +305,7 @@ $if(pagestyle)$
304305\pagestyle{$pagestyle$}
305306$endif$
306307
307−% set default figure placement to htbp
308+% Set default figure placement to htbp
308309\makeatletter
309310\def\fps@figure{htbp}
310311\makeatother
@@ -313,23 +314,23 @@ $for(header-includes)$
313314$header-includes$
314315$endfor$
315316$if(lang)$
316−\ifnum 0\ifxetex 1\fi=0 % if pdftex or luatex
317− \usepackage[shorthands=off,$for(babel-otherlangs)$$babel-otherlangs$,$endfor$main=$babel-lang$]{babel}
318−$if(babel-newcommands)$
319− $babel-newcommands$
320−$endif$
321−\else % if xetex
322− % load polyglossia as late as possible as it *could* call bidi if RTL lang (e.g. Hebrew or Arabic)
317+\ifxetex
318+ % Load polyglossia as late as possible: uses bidi with RTL langages (e.g. Hebrew, Arabic)
323319 \usepackage{polyglossia}
324320 \setmainlanguage[$polyglossia-lang.options$]{$polyglossia-lang.name$}
325321$for(polyglossia-otherlangs)$
326322 \setotherlanguage[$polyglossia-otherlangs.options$]{$polyglossia-otherlangs.name$}
327323$endfor$
324+\else
325+ \usepackage[shorthands=off,$for(babel-otherlangs)$$babel-otherlangs$,$endfor$main=$babel-lang$]{babel}
326+$if(babel-newcommands)$
327+ $babel-newcommands$
328+$endif$
328329\fi
329330$endif$
330331$if(dir)$
331332\ifxetex
332− % load bidi as late as possible as it modifies e.g. graphicx
333+ % Load bidi as late as possible as it modifies e.g. graphicx
333334 \usepackage{bidi}
334335\fi
335336\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
test/lhs-test.latex+8−7
@@ -1,4 +1,5 @@
1−\PassOptionsToPackage{unicode=true}{hyperref} % options for packages loaded elsewhere
1+% Options for packages loaded elsewhere
2+\PassOptionsToPackage{unicode=true}{hyperref}
23\PassOptionsToPackage{hyphens}{url}
34%
45\documentclass[
@@ -15,7 +16,7 @@
1516 \defaultfontfeatures{Scale=MatchLowercase}
1617 \defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1}
1718\fi
18−% use upquote if available, for straight quotes in verbatim environments
19+% Use upquote if available, for straight quotes in verbatim environments
1920\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
2021\IfFileExists{microtype.sty}{% use microtype if available
2122 \usepackage[]{microtype}
@@ -35,9 +36,9 @@
3536\IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available
3637\IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}}
3738\hypersetup{
38− pdfborder={0 0 0},
39− breaklinks=true}
40−\urlstyle{same} % don't use monospace font for urls
39+ hidelinks,
40+}
41+\urlstyle{same} % disable monospaced font for URLs
4142\usepackage{color}
4243\usepackage{fancyvrb}
4344\newcommand{\VerbBar}{|}
@@ -76,7 +77,7 @@
7677\newcommand{\VariableTok}[1]{\textcolor[rgb]{0.10,0.09,0.49}{#1}}
7778\newcommand{\VerbatimStringTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{#1}}
7879\newcommand{\WarningTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textbf{\textit{#1}}}}
79−\setlength{\emergencystretch}{3em} % prevent overfull lines
80+\setlength{\emergencystretch}{3em} % prevent overfull lines
8081\providecommand{\tightlist}{%
8182 \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
8283\setcounter{secnumdepth}{-\maxdimen} % remove section numbering
@@ -90,7 +91,7 @@
9091 \renewcommand{\subparagraph}[1]{\oldsubparagraph{#1}\mbox{}}
9192\fi
9293
93−% set default figure placement to htbp
94+% Set default figure placement to htbp
9495\makeatletter
9596\def\fps@figure{htbp}
9697\makeatother
test/lhs-test.latex+lhs+8−7
@@ -1,4 +1,5 @@
1−\PassOptionsToPackage{unicode=true}{hyperref} % options for packages loaded elsewhere
1+% Options for packages loaded elsewhere
2+\PassOptionsToPackage{unicode=true}{hyperref}
23\PassOptionsToPackage{hyphens}{url}
34%
45\documentclass[
@@ -15,7 +16,7 @@
1516 \defaultfontfeatures{Scale=MatchLowercase}
1617 \defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1}
1718\fi
18−% use upquote if available, for straight quotes in verbatim environments
19+% Use upquote if available, for straight quotes in verbatim environments
1920\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
2021\IfFileExists{microtype.sty}{% use microtype if available
2122 \usepackage[]{microtype}
@@ -35,15 +36,15 @@
3536\IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available
3637\IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}}
3738\hypersetup{
38− pdfborder={0 0 0},
39− breaklinks=true}
40−\urlstyle{same} % don't use monospace font for urls
39+ hidelinks,
40+}
41+\urlstyle{same} % disable monospaced font for URLs
4142\usepackage{listings}
4243\newcommand{\passthrough}[1]{#1}
4344\lstset{defaultdialect=[5.3]Lua}
4445\lstset{defaultdialect=[x86masm]Assembler}
4546\lstnewenvironment{code}{\lstset{language=Haskell,basicstyle=\small\ttfamily}}{}
46−\setlength{\emergencystretch}{3em} % prevent overfull lines
47+\setlength{\emergencystretch}{3em} % prevent overfull lines
4748\providecommand{\tightlist}{%
4849 \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
4950\setcounter{secnumdepth}{-\maxdimen} % remove section numbering
@@ -57,7 +58,7 @@
5758 \renewcommand{\subparagraph}[1]{\oldsubparagraph{#1}\mbox{}}
5859\fi
5960
60−% set default figure placement to htbp
61+% Set default figure placement to htbp
6162\makeatletter
6263\def\fps@figure{htbp}
6364\makeatother
test/writer.latex+9−8
@@ -1,4 +1,5 @@
1−\PassOptionsToPackage{unicode=true}{hyperref} % options for packages loaded elsewhere
1+% Options for packages loaded elsewhere
2+\PassOptionsToPackage{unicode=true}{hyperref}
23\PassOptionsToPackage{hyphens}{url}
34%
45\documentclass[
@@ -15,7 +16,7 @@
1516 \defaultfontfeatures{Scale=MatchLowercase}
1617 \defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1}
1718\fi
18−% use upquote if available, for straight quotes in verbatim environments
19+% Use upquote if available, for straight quotes in verbatim environments
1920\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
2021\IfFileExists{microtype.sty}{% use microtype if available
2122 \usepackage[]{microtype}
@@ -38,9 +39,9 @@
3839\hypersetup{
3940 pdftitle={Pandoc Test Suite},
4041 pdfauthor={John MacFarlane; Anonymous},
41− pdfborder={0 0 0},
42− breaklinks=true}
43−\urlstyle{same} % don't use monospace font for urls
42+ hidelinks,
43+}
44+\urlstyle{same} % disable monospaced font for URLs
4445\VerbatimFootnotes % allows verbatim text in footnotes
4546\usepackage{graphicx,grffile}
4647\makeatletter
@@ -52,9 +53,9 @@
5253% using explicit options in \includegraphics[width, height, ...]{}
5354\setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}
5455\usepackage[normalem]{ulem}
55−% avoid problems with \sout in headers with hyperref:
56+% Avoid problems with \sout in headers with hyperref
5657\pdfstringdefDisableCommands{\renewcommand{\sout}{}}
57−\setlength{\emergencystretch}{3em} % prevent overfull lines
58+\setlength{\emergencystretch}{3em} % prevent overfull lines
5859\providecommand{\tightlist}{%
5960 \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
6061\setcounter{secnumdepth}{-\maxdimen} % remove section numbering
@@ -68,7 +69,7 @@
6869 \renewcommand{\subparagraph}[1]{\oldsubparagraph{#1}\mbox{}}
6970\fi
7071
71−% set default figure placement to htbp
72+% Set default figure placement to htbp
7273\makeatletter
7374\def\fps@figure{htbp}
7475\makeatother
test/writers-lang-and-dir.latex+19−18
@@ -1,4 +1,5 @@
1−\PassOptionsToPackage{unicode=true}{hyperref} % options for packages loaded elsewhere
1+% Options for packages loaded elsewhere
2+\PassOptionsToPackage{unicode=true}{hyperref}
23\PassOptionsToPackage{hyphens}{url}
34%
45\documentclass[
@@ -16,7 +17,7 @@
1617 \defaultfontfeatures{Scale=MatchLowercase}
1718 \defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1}
1819\fi
19−% use upquote if available, for straight quotes in verbatim environments
20+% Use upquote if available, for straight quotes in verbatim environments
2021\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
2122\IfFileExists{microtype.sty}{% use microtype if available
2223 \usepackage[]{microtype}
@@ -36,10 +37,10 @@
3637\IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available
3738\IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}}
3839\hypersetup{
39− pdfborder={0 0 0},
40− breaklinks=true}
41−\urlstyle{same} % don't use monospace font for urls
42−\setlength{\emergencystretch}{3em} % prevent overfull lines
40+ hidelinks,
41+}
42+\urlstyle{same} % disable monospaced font for URLs
43+\setlength{\emergencystretch}{3em} % prevent overfull lines
4344\providecommand{\tightlist}{%
4445 \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
4546\setcounter{secnumdepth}{-\maxdimen} % remove section numbering
@@ -53,12 +54,21 @@
5354 \renewcommand{\subparagraph}[1]{\oldsubparagraph{#1}\mbox{}}
5455\fi
5556
56−% set default figure placement to htbp
57+% Set default figure placement to htbp
5758\makeatletter
5859\def\fps@figure{htbp}
5960\makeatother
6061
61−\ifnum 0\ifxetex 1\fi=0 % if pdftex or luatex
62+\ifxetex
63+ % Load polyglossia as late as possible: uses bidi with RTL langages (e.g. Hebrew, Arabic)
64+ \usepackage{polyglossia}
65+ \setmainlanguage[]{english}
66+ \setotherlanguage[]{german}
67+ \setotherlanguage[variant=british]{english}
68+ \setotherlanguage[variant=swiss]{german}
69+ \setotherlanguage[]{spanish}
70+ \setotherlanguage[]{french}
71+\else
6272 \usepackage[shorthands=off,ngerman,british,nswissgerman,spanish,french,main=english]{babel}
6373 \newcommand{\textgerman}[2][]{\foreignlanguage{ngerman}{#2}}
6474 \newenvironment{german}[2][]{\begin{otherlanguage}{ngerman}}{\end{otherlanguage}}
@@ -69,18 +79,9 @@
6979 \AddBabelHook{spanish}{afterextras}{\renewcommand{\textspanish}[2][]{\foreignlanguage{spanish}{##2}}}
7080 \newcommand{\textfrench}[2][]{\foreignlanguage{french}{#2}}
7181 \newenvironment{french}[2][]{\begin{otherlanguage}{french}}{\end{otherlanguage}}
72−\else % if xetex
73− % load polyglossia as late as possible as it *could* call bidi if RTL lang (e.g. Hebrew or Arabic)
74− \usepackage{polyglossia}
75− \setmainlanguage[]{english}
76− \setotherlanguage[]{german}
77− \setotherlanguage[variant=british]{english}
78− \setotherlanguage[variant=swiss]{german}
79− \setotherlanguage[]{spanish}
80− \setotherlanguage[]{french}
8182\fi
8283\ifxetex
83− % load bidi as late as possible as it modifies e.g. graphicx
84+ % Load bidi as late as possible as it modifies e.g. graphicx
8485 \usepackage{bidi}
8586\fi
8687\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex