From 2c2d1224720a0f13f8328362b075c6479c2a81ef Mon Sep 17 00:00:00 2001 From: Chris Fenner Date: Sat, 9 Dec 2023 12:28:34 -0800 Subject: [PATCH] Clean up the template (#44) * fix some instances of commands not terminated with {} (chktex 1) * add spaces to ifs * undo spaces in ifs * remove debugs from before begin document * delete ifs for beamers * remove a few more ifs on variables we aren't using * clean up documentclass * remove a bunch more stuff that's not used * revert change to highlighting-macros --- sample3.md | 6 +- template/eisvogel.latex | 396 +++++----------------------------------- 2 files changed, 52 insertions(+), 350 deletions(-) diff --git a/sample3.md b/sample3.md index 9d8bd4d..c77a3df 100644 --- a/sample3.md +++ b/sample3.md @@ -260,4 +260,8 @@ contents longer than one page. ## Thing 47 ## Thing 48 ## Thing 49 -## Thing 50 \ No newline at end of file +## Thing 50 + +Test? + +--- \ No newline at end of file diff --git a/template/eisvogel.latex b/template/eisvogel.latex index 7c044df..0103b3a 100644 --- a/template/eisvogel.latex +++ b/template/eisvogel.latex @@ -34,10 +34,11 @@ %% %% Enable useful error output. -\errorcontextlines 10000 +\errorcontextlines=10000 %% -% This is the Eisvogel pandoc LaTeX template. +% This template has been heavily customized for Trusted Computing Group. +% It started out as the Eisvogel pandoc LaTeX template. % % For usage information and examples visit the official GitHub page: % https://github.com/Wandmalfarbe/pandoc-latex-template @@ -57,99 +58,19 @@ $if(CJKmainfont)$ $endif$ % \documentclass[ -$if(fontsize)$ - $fontsize$, -$endif$ -$if(lang)$ - $babel-lang$, -$endif$ -paper=letter, -$if(beamer)$ - ignorenonframetext, -$if(handout)$ - handout, -$endif$ -$if(aspectratio)$ - aspectratio=$aspectratio$, -$endif$ -$endif$ -$for(classoption)$ - $classoption$$sep$, -$endfor$ - ,captions=tableheading, + paper=letter, + captions=tableheading, toc=sectionentrywithdots -]{$if(beamer)$$documentclass$$else$$if(book)$scrbook$else$scrartcl$endif$$endif$} -$if(beamer)$ -$if(background-image)$ -\usebackgroundtemplate{% - \includegraphics[width=\paperwidth]{$background-image$}% -} -$endif$ +]{scrartcl} -\usepackage{pgfpages} -\setbeamertemplate{caption}[numbered] -\setbeamertemplate{caption label separator}{: } -\setbeamercolor{caption name}{fg=normal text.fg} -\beamertemplatenavigationsymbols$if(navigation)$$navigation$$else$empty$endif$ -$for(beameroption)$ -\setbeameroption{$beameroption$} -$endfor$ -% Prevent slide breaks in the middle of a paragraph -\widowpenalties 1 10000 -\raggedbottom -$if(section-titles)$ -\setbeamertemplate{part page}{ - \centering - \begin{beamercolorbox}[sep=16pt,center]{part title} - \usebeamerfont{part title}\insertpart\par - \end{beamercolorbox} -} -\setbeamertemplate{section page}{ - \centering - \begin{beamercolorbox}[sep=12pt,center]{part title} - \usebeamerfont{section title}\insertsection\par - \end{beamercolorbox} -} -\setbeamertemplate{subsection page}{ - \centering - \begin{beamercolorbox}[sep=8pt,center]{part title} - \usebeamerfont{subsection title}\insertsubsection\par - \end{beamercolorbox} -} -\AtBeginPart{ - \frame{\partpage} -} -\AtBeginSection{ - \ifbibliography - \else - \frame{\sectionpage} - \fi -} -\AtBeginSubsection{ - \frame{\subsectionpage} -} -$endif$ -$endif$ -$if(beamerarticle)$ -\usepackage{beamerarticle} % needs to be loaded first -$endif$ \usepackage{amsmath,amssymb} \usepackage{mathtools} -$if(linestretch)$ -\usepackage{setspace} -$else$ \usepackage{setspace} \setstretch{1.0} -$endif$ \usepackage[absolute,overlay]{textpos} \usepackage{ifxetex,ifluatex} -\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex - \usepackage[$if(fontenc)$$fontenc$$else$T1$endif$]{fontenc} - \usepackage[utf8]{inputenc} - \usepackage{textcomp} % provide euro and other symbols -\else % if luatex or xetex $if(mathspec)$ - \ifxetex + \ifxetex{} \usepackage{mathspec} \else \usepackage{unicode-math} @@ -162,11 +83,10 @@ $endif$ \defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1} $if(luatexjapresetoptions)$ - \ifluatex + \ifluatex{} \usepackage[$for(luatexjapresetoptions)$$luatexjapresetoptions$$sep$,$endfor$]{luatexja-preset} \fi $endif$ -\fi % Use upquote if available, for straight quotes in verbatim environments \IfFileExists{upquote.sty}{\usepackage{upquote}}{} @@ -174,8 +94,7 @@ $endif$ \usepackage[$for(microtypeoptions)$$microtypeoptions$$sep$,$endfor$]{microtype} \UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts }{} -$if(indent)$ -$else$ + \makeatletter \@ifundefined{KOMAClassName}{% if non-KOMA class \IfFileExists{parskip.sty}{% @@ -186,15 +105,14 @@ $else$ }{% if KOMA class \KOMAoptions{parskip=half}} \makeatother -$endif$ -$if(verbatim-in-note)$ -\usepackage{fancyvrb} -$endif$ + \usepackage{xcolor} \definecolor{default-linkcolor}{HTML}{4077C0} \definecolor{default-filecolor}{HTML}{4077C0} \definecolor{default-citecolor}{HTML}{4077C0} \definecolor{default-urlcolor}{HTML}{4077C0} + +% TODO: Do we need this feature? $if(footnotes-pretty)$ % load footmisc in order to customize footnotes (footmisc has to be loaded before hyperref, cf. https://tex.stackexchange.com/a/169124/144087) \usepackage[hang,flushmargin,bottom,multiple]{footmisc} @@ -203,7 +121,10 @@ $if(footnotes-pretty)$ \setlength{\skip\footins}{0.3cm} % set space between page content and footnote \setlength{\footskip}{0.9cm} % set space between footnote and page bottom $endif$ + \IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}} + +% PDF metadata \hypersetup{ $if(title-meta)$ pdftitle={$title-meta$}, @@ -230,23 +151,16 @@ $else$ hidelinks, $endif$ breaklinks=true, - pdfcreator={LaTeX via pandoc with the Eisvogel template}} + pdfcreator={Trusted Computing Group}} + + \urlstyle{same} % disable monospaced font for URLs -$if(verbatim-in-note)$ -\VerbatimFootnotes % allow verbatim text in footnotes -$endif$ + $if(geometry)$ -$if(beamer)$ -\geometry{$for(geometry)$$geometry$$sep$,$endfor$} -$else$ \usepackage[$for(geometry)$$geometry$$sep$,$endfor$]{geometry} -$endif$ -$else$ -$if(beamer)$ $else$ \usepackage[top=0.5in,left=0.5in,right=0.5in,bottom=0.8in,$for(geometry)$$geometry$$sep$,$endfor$]{geometry} $endif$ -$endif$ \setlength{\paperheight}{11in} \setlength{\paperwidth}{8.5in} @@ -258,23 +172,7 @@ $if(logo)$ \usepackage{rotating} \usepackage{transparent} $endif$ -$if(beamer)$ -\newif\ifbibliography -$endif$ -$if(listings)$ -\usepackage{listings} -\newcommand{\passthrough}[1]{#1} -\lstset{defaultdialect=[5.3]Lua} -\lstset{defaultdialect=[x86masm]Assembler} -$endif$ -$if(listings-no-page-break)$ -\usepackage{etoolbox} -\BeforeBeginEnvironment{lstlisting}{\par\noindent\begin{minipage}{\linewidth}} -\AfterEndEnvironment{lstlisting}{\end{minipage}\par\addvspace{\topskip}} -$endif$ -$if(lhs)$ -\lstnewenvironment{code}{\lstset{language=Haskell,basicstyle=\small\ttfamily}}{} -$endif$ + $if(highlighting-macros)$ $highlighting-macros$ @@ -290,23 +188,17 @@ $highlighting-macros$ % Left-justify the document. \usepackage[document]{ragged2e} -\RaggedRight +\RaggedRight{} \sloppy - $endif$ + +% Customizations to the behavior of tables $if(tables)$ \usepackage{longtable,booktabs,array} $if(multirow)$ \usepackage{multirow} $endif$ \usepackage{calc} % for calculating minipage widths -$if(beamer)$ -\usepackage{caption} -% Make caption package work with longtable -\makeatletter -\def\fnum@table{\tablename~\thetable} -\makeatother -$else$ % Correct order of tables after \paragraph or \subparagraph \usepackage{etoolbox} \makeatletter @@ -316,12 +208,8 @@ $else$ \IfFileExists{footnotehyper.sty}{\usepackage{footnotehyper}}{\usepackage{footnote}} \makesavenoteenv{longtable} $endif$ -$endif$ -% add backlinks to footnote references, cf. https://tex.stackexchange.com/questions/302266/make-footnote-clickable-both-ways -$if(footnotes-disable-backlinks)$ -$else$ + \usepackage{footnotebackref} -$endif$ $if(graphics)$ \usepackage{graphicx} \makeatletter @@ -337,15 +225,13 @@ $if(graphics)$ \def\fps@figure{htbp} \makeatother $endif$ -$if(links-as-notes)$ -% Make links footnotes instead of hotlinks: -\DeclareRobustCommand{\href}[2]{#2\footnote{\url{#1}}} -$endif$ + $if(strikeout)$ \usepackage[normalem]{ulem} % Avoid problems with \sout in headers with hyperref \pdfstringdefDisableCommands{\renewcommand{\sout}{}} $endif$ + \setlength{\emergencystretch}{3em} % prevent overfull lines \providecommand{\tightlist}{% \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}} @@ -354,23 +240,18 @@ $if(numbersections)$ $else$ \setcounter{secnumdepth}{-\maxdimen} % remove section numbering $endif$ -$if(beamer)$ -$else$ + $if(block-headings)$ % Make \paragraph and \subparagraph free-standing \ifx\paragraph\undefined\else - \let\oldparagraph\paragraph + \let\oldparagraph\paragraph{} \renewcommand{\paragraph}[1]{\oldparagraph{#1}\mbox{}} \fi \ifx\subparagraph\undefined\else - \let\oldsubparagraph\subparagraph + \let\oldsubparagraph\subparagraph{} \renewcommand{\subparagraph}[1]{\oldsubparagraph{#1}\mbox{}} \fi $endif$ -$endif$ -$if(pagestyle)$ -\pagestyle{$pagestyle$} -$endif$ % Make use of float-package and set default placement for figures to H. % The option H means 'PUT IT HERE' (as opposed to the standard h option which means 'You may put it here if you like'). @@ -381,7 +262,8 @@ $for(header-includes)$ $header-includes$ $endfor$ -%% TCG docs tend to have deeply nested lists, too deep for Pandoc/Latex defaults. +% TCG docs tend to have deeply nested lists, too deep for Pandoc/Latex defaults. +% Increase the limit to 9. \usepackage{enumitem} \setlistdepth{9} \setlist[itemize]{label=\textbullet} @@ -389,32 +271,10 @@ $endfor$ \setlist[enumerate]{label=\arabic*.} \renewlist{enumerate}{enumerate}{9} -$if(lang)$ -\ifxetex - $if(mainfont)$ - $else$ - % See issue https://github.com/reutenauer/polyglossia/issues/127 - \renewcommand*\familydefault{\sfdefault} - $endif$ - % Load polyglossia as late as possible: uses bidi with RTL langages (e.g. Hebrew, Arabic) - \usepackage{polyglossia} - \setmainlanguage[$for(polyglossia-lang.options)$$polyglossia-lang.options$$sep$,$endfor$]{$polyglossia-lang.name$} -$for(polyglossia-otherlangs)$ - \setotherlanguage[$for(polyglossia-otherlangs.options)$$polyglossia-otherlangs.options$$sep$,$endfor$]{$polyglossia-otherlangs.name$} -$endfor$ -\else - \usepackage[$for(babel-otherlangs)$$babel-otherlangs$,$endfor$main=$babel-lang$]{babel} -% get rid of language-specific shorthands (see #6817): -\let\LanguageShortHands\languageshorthands -\def\languageshorthands#1{} -$if(babel-newcommands)$ - $babel-newcommands$ -$endif$ -\fi -$endif$ \ifluatex \usepackage{selnolig} % disable illegal ligatures \fi + $if(dir)$ \ifxetex % Load bidi as late as possible as it modifies e.g. graphicx @@ -428,38 +288,7 @@ $if(dir)$ \newenvironment{LTR}{\beginL}{\endL} \fi $endif$ -$if(natbib)$ -\usepackage[$natbiboptions$]{natbib} -\bibliographystyle{$if(biblio-style)$$biblio-style$$else$plainnat$endif$} -$endif$ -$if(biblatex)$ -\usepackage[$if(biblio-style)$style=$biblio-style$,$endif$$for(biblatexoptions)$$biblatexoptions$$sep$,$endfor$]{biblatex} -$for(bibliography)$ -\addbibresource{$bibliography$} -$endfor$ -$endif$ -$if(csl-refs)$ -\newlength{\cslhangindent} -\setlength{\cslhangindent}{1.5em} -\newlength{\csllabelwidth} -\setlength{\csllabelwidth}{3em} -\newenvironment{CSLReferences}[2] % #1 hanging-ident, #2 entry spacing - {% don't indent paragraphs - \setlength{\parindent}{0pt} - % turn on hanging indent if param 1 is 1 - \ifodd #1 \everypar{\setlength{\hangindent}{\cslhangindent}}\ignorespaces\fi - % set entry spacing - \ifnum #2 > 0 - \setlength{\parskip}{#2\baselineskip} - \fi - }% - {} -\usepackage{calc} -\newcommand{\CSLBlock}[1]{#1\hfill\break} -\newcommand{\CSLLeftMargin}[1]{\parbox[t]{\csllabelwidth}{#1}} -\newcommand{\CSLRightInline}[1]{\parbox[t]{\linewidth - \csllabelwidth}{#1}\break} -\newcommand{\CSLIndent}[1]{\hspace{\cslhangindent}#1} -$endif$ + $if(csquotes)$ \usepackage{csquotes} $endif$ @@ -468,67 +297,31 @@ $if(title)$ \title{$title$$if(thanks)$\thanks{$thanks$}$endif$} $endif$ $if(subtitle)$ -$if(beamer)$ -$else$ \usepackage{etoolbox} \makeatletter \providecommand{\subtitle}[1]{% add subtitle to \maketitle \apptocmd{\@title}{\par {\large #1 \par}}{}{} } \makeatother -$endif$ \subtitle{$subtitle$} $endif$ \author{$for(author)$$author$$sep$ \and $endfor$} \date{$date$} -$if(beamer)$ -$if(institute)$ -\institute{$for(institute)$$institute$$sep$ \and $endfor$} -$endif$ -$if(titlegraphic)$ -\titlegraphic{\includegraphics{$titlegraphic$}} -$endif$ -$if(logo)$ -\logo{\includegraphics{$logo$}} -$endif$ -$endif$ - -%% -%% added -%% -% -% language specification -% -% If no language is specified, use English as the default main document language. -% -$if(lang)$$else$ -\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex - \usepackage[shorthands=off,$for(babel-otherlangs)$$babel-otherlangs$,$endfor$main=english]{babel} -$if(babel-newcommands)$ - $babel-newcommands$ -$endif$ -\else - $if(mainfont)$ - $else$ - % Workaround for bug in Polyglossia that breaks `\familydefault` when `\setmainlanguage` is used. - % See https://github.com/Wandmalfarbe/pandoc-latex-template/issues/8 - % See https://github.com/reutenauer/polyglossia/issues/186 - % See https://github.com/reutenauer/polyglossia/issues/127 - \renewcommand*\familydefault{\sfdefault} - $endif$ - % load polyglossia as late as possible as it *could* call bidi if RTL lang (e.g. Hebrew or Arabic) - \usepackage{polyglossia} - \setmainlanguage[]{english} +$if(mainfont)$ +$else$ +% Workaround for bug in Polyglossia that breaks `\familydefault` when `\setmainlanguage` is used. +% See https://github.com/Wandmalfarbe/pandoc-latex-template/issues/8 +% See https://github.com/reutenauer/polyglossia/issues/186 +% See https://github.com/reutenauer/polyglossia/issues/127 +\renewcommand*\familydefault{\sfdefault} +$endif$ +% load polyglossia as late as possible as it *could* call bidi if RTL lang (e.g. Hebrew or Arabic) +\usepackage{polyglossia} +\setmainlanguage[]{english} $for(polyglossia-otherlangs)$ \setotherlanguage[$polyglossia-otherlangs.options$]{$polyglossia-otherlangs.name$} $endfor$ -\fi -$endif$ - -$if(page-background)$ -\usepackage[pages=all]{background} -$endif$ % % for the background color of the title page @@ -558,11 +351,8 @@ $endif$ % captions % \definecolor{caption-color}{HTML}{777777} -$if(beamer)$ -$else$ \usepackage[font={stretch=1.2}, textfont={color=caption-color}, position=top, skip=4mm, labelfont=bf, singlelinecheck=false, justification=centering]{caption} \setcapindent{0em} -$endif$ % % blockquote (repurposed for "informative text" blocks) @@ -610,24 +400,15 @@ $endif$ % heading color % \definecolor{heading-color}{RGB}{35,61,130} -$if(beamer)$ -$else$ \addtokomafont{section}{\color{heading-color}} -$endif$ -% When using the classes report, scrreprt, book, -% scrbook or memoir, uncomment the following line. -%\addtokomafont{chapter}{\color{heading-color}} % % variables for title, author and date % -$if(beamer)$ -$else$ \usepackage{titling} \title{$title$} \author{$for(author)$$author$$sep$, $endfor$} \date{$date$} -$endif$ % % tables @@ -654,7 +435,7 @@ $endif$ $endif$ % -% remove paragraph indention +% remove paragraph indentation % \setlength{\parindent}{0pt} \setlength{\parskip}{6pt plus 2pt minus 1pt} @@ -667,7 +448,6 @@ $endif$ % $if(listings)$ - % % general listing colors % @@ -787,8 +567,6 @@ $endif$ % % header and footer % -$if(beamer)$ -$else$ $if(disable-header-and-footer)$ $else$ \usepackage{fancyhdr} @@ -809,11 +587,6 @@ $else$ } {} } \fancyfoot{} - % \lhead[$if(header-right)$$header-right$$else$$date$$endif$]{$if(header-left)$$header-left$$else$title$endif$} - % \chead[$if(header-center)$$header-center$$else$$endif$]{$if(header-center)$$header-center$$else$$endif$} - % \rhead[$if(header-left)$$header-left$$else$title$endif$]{$if(header-right)$$header-right$$else$$date$$endif$} - % \lfoot[$if(footer-right)$$footer-right$$else$\thepage$endif$]{$if(footer-left)$$footer-left$$else$$for(author)$$author$$sep$, $endfor$$endif$} - % \cfoot[$if(footer-center)$$footer-center$$else$$endif$]{$if(footer-center)$$footer-center$$else$$endif$} \fancyfoot[C] { \begin{textblock*}{8.5in}(0in,10.7in) @@ -857,7 +630,6 @@ contents={% } $endif$ $endif$ -$endif$ %% %% end added @@ -941,8 +713,6 @@ $endif$ %% %% begin titlepage %% -$if(beamer)$ -$else$ $if(titlepage)$ \begin{titlepage} \newgeometry{top=2cm, right=4cm, bottom=3cm, left=4cm} @@ -1011,19 +781,12 @@ $endif$ \end{titlepage} \restoregeometry $endif$ -$endif$ %% %% end titlepage %% -$if(has-frontmatter)$ -\frontmatter -$endif$ $if(title)$ -$if(beamer)$ -\frame{\titlepage} -$endif$ $if(abstract)$ \begin{abstract} $abstract$ @@ -1031,82 +794,17 @@ $abstract$ $endif$ $endif$ -$if(first-chapter)$ -\setcounter{chapter}{$first-chapter$} -\addtocounter{chapter}{-1} -$endif$ - $for(include-before)$ $include-before$ $endfor$ -$if(toc)$ -$if(toc-title)$ -\renewcommand*\contentsname{$toc-title$} -$endif$ -$if(beamer)$ -\begin{frame}[allowframebreaks] -$if(toc-title)$ - \frametitle{$toc-title$} -$endif$ -\tableofcontents[hideallsubsections] -\end{frame} -$if(toc-own-page)$ -\newpage -$endif$ -$else$ -{ -$if(colorlinks)$ -\hypersetup{linkcolor=$if(toccolor)$$toccolor$$else$$endif$} -$endif$ -\setcounter{tocdepth}{$toc-depth$} -$if(toc-own-page)$ -\newpage -$endif$ -} -$endif$ -$endif$ -$if(linestretch)$ -\setstretch{$linestretch$} -$endif$ $if(has-frontmatter)$ -\mainmatter +\mainmatter{} $endif$ $body$ $if(has-frontmatter)$ -\backmatter -$endif$ -$if(natbib)$ -$if(bibliography)$ -$if(biblio-title)$ -$if(has-chapters)$ -\renewcommand\bibname{$biblio-title$} -$else$ -\renewcommand\refname{$biblio-title$} -$endif$ -$endif$ -$if(beamer)$ -\begin{frame}[allowframebreaks]{$biblio-title$} - \bibliographytrue -$endif$ - \bibliography{$for(bibliography)$$bibliography$$sep$,$endfor$} -$if(beamer)$ -\end{frame} -$endif$ - -$endif$ -$endif$ -$if(biblatex)$ -$if(beamer)$ -\begin{frame}[allowframebreaks]{$biblio-title$} - \bibliographytrue - \printbibliography[heading=none] -\end{frame} -$else$ -\printbibliography$if(biblio-title)$[title=$biblio-title$]$endif$ -$endif$ - +\backmatter{} $endif$ $for(include-after)$ $include-after$