Skip to content

Commit 9ab69d4

Browse files
author
Peter Humburg
committed
LaTeX support for structured author information
1 parent 87e2fe5 commit 9ab69d4

File tree

3 files changed

+211
-2
lines changed

3 files changed

+211
-2
lines changed

example.pandoc

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ include-in-header: include/equation.js
1616

1717
t: latex
1818
latex-engine: xelatex
19+
template: include/report.latex
1920
V: geometry:margin=2cm
2021
geometry:driver=xetex
2122
documentclass:report

include/report.latex

+208
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,208 @@
1+
\documentclass[$if(fontsize)$$fontsize$,$endif$$if(lang)$$lang$,$endif$$if(papersize)$$papersize$,$endif$$for(classoption)$$classoption$$sep$,$endfor$]{$documentclass$}
2+
$if(fontfamily)$
3+
\usepackage{$fontfamily$}
4+
$else$
5+
\usepackage{lmodern}
6+
$endif$
7+
$if(linestretch)$
8+
\usepackage{setspace}
9+
\setstretch{$linestretch$}
10+
$endif$
11+
\usepackage{amssymb,amsmath}
12+
\usepackage{ifxetex,ifluatex}
13+
\usepackage{fixltx2e} % provides \textsubscript
14+
\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
15+
\usepackage[T1]{fontenc}
16+
\usepackage[utf8]{inputenc}
17+
$if(euro)$
18+
\usepackage{eurosym}
19+
$endif$
20+
\else % if luatex or xelatex
21+
\ifxetex
22+
\usepackage{mathspec}
23+
\usepackage{xltxtra,xunicode}
24+
\else
25+
\usepackage{fontspec}
26+
\fi
27+
\defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase}
28+
\newcommand{\euro}{€}
29+
$if(mainfont)$
30+
\setmainfont{$mainfont$}
31+
$endif$
32+
$if(sansfont)$
33+
\setsansfont{$sansfont$}
34+
$endif$
35+
$if(monofont)$
36+
\setmonofont[Mapping=tex-ansi]{$monofont$}
37+
$endif$
38+
$if(mathfont)$
39+
\setmathfont(Digits,Latin,Greek){$mathfont$}
40+
$endif$
41+
\fi
42+
% use upquote if available, for straight quotes in verbatim environments
43+
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
44+
% use microtype if available
45+
\IfFileExists{microtype.sty}{\usepackage{microtype}}{}
46+
$if(geometry)$
47+
\usepackage[$for(geometry)$$geometry$$sep$,$endfor$]{geometry}
48+
$endif$
49+
$if(natbib)$
50+
\usepackage{natbib}
51+
\bibliographystyle{$if(biblio-style)$$biblio-style$$else$plainnat$endif$}
52+
$endif$
53+
$if(biblatex)$
54+
\usepackage{biblatex}
55+
$if(biblio-files)$
56+
\bibliography{$biblio-files$}
57+
$endif$
58+
$endif$
59+
$if(listings)$
60+
\usepackage{listings}
61+
$endif$
62+
$if(lhs)$
63+
\lstnewenvironment{code}{\lstset{language=Haskell,basicstyle=\small\ttfamily}}{}
64+
$endif$
65+
$if(highlighting-macros)$
66+
$highlighting-macros$
67+
$endif$
68+
$if(verbatim-in-note)$
69+
\usepackage{fancyvrb}
70+
$endif$
71+
$if(tables)$
72+
\usepackage{longtable,booktabs}
73+
$endif$
74+
$if(graphics)$
75+
\usepackage{graphicx}
76+
\makeatletter
77+
\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi}
78+
\def\maxheight{\ifdim\Gin@nat@height>\textheight\textheight\else\Gin@nat@height\fi}
79+
\makeatother
80+
% Scale images if necessary, so that they will not overflow the page
81+
% margins by default, and it is still possible to overwrite the defaults
82+
% using explicit options in \includegraphics[width, height, ...]{}
83+
\setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}
84+
$endif$
85+
\ifxetex
86+
\usepackage[setpagesize=false, % page size defined by xetex
87+
unicode=false, % unicode breaks when used with xetex
88+
xetex]{hyperref}
89+
\else
90+
\usepackage[unicode=true]{hyperref}
91+
\fi
92+
\hypersetup{breaklinks=true,
93+
bookmarks=true,
94+
pdfauthor={$author-meta$},
95+
pdftitle={$title-meta$},
96+
colorlinks=true,
97+
citecolor=$if(citecolor)$$citecolor$$else$blue$endif$,
98+
urlcolor=$if(urlcolor)$$urlcolor$$else$blue$endif$,
99+
linkcolor=$if(linkcolor)$$linkcolor$$else$magenta$endif$,
100+
pdfborder={0 0 0}}
101+
\urlstyle{same} % don't use monospace font for urls
102+
$if(links-as-notes)$
103+
% Make links footnotes instead of hotlinks:
104+
\renewcommand{\href}[2]{#2\footnote{\url{#1}}}
105+
$endif$
106+
$if(strikeout)$
107+
\usepackage[normalem]{ulem}
108+
% avoid problems with \sout in headers with hyperref:
109+
\pdfstringdefDisableCommands{\renewcommand{\sout}{}}
110+
$endif$
111+
\setlength{\parindent}{0pt}
112+
\setlength{\parskip}{6pt plus 2pt minus 1pt}
113+
\setlength{\emergencystretch}{3em} % prevent overfull lines
114+
$if(numbersections)$
115+
\setcounter{secnumdepth}{5}
116+
$else$
117+
\setcounter{secnumdepth}{0}
118+
$endif$
119+
$if(verbatim-in-note)$
120+
\VerbatimFootnotes % allows verbatim text in footnotes
121+
$endif$
122+
$if(lang)$
123+
\ifxetex
124+
\usepackage{polyglossia}
125+
\setmainlanguage{$mainlang$}
126+
\else
127+
\usepackage[$lang$]{babel}
128+
\fi
129+
$endif$
130+
131+
$if(title)$
132+
\title{$title$$if(subtitle)$\\\vspace{0.5em}{\large $subtitle$}$endif$}
133+
$endif$
134+
$if(author)$
135+
\usepackage{authblk}
136+
$if(address)$
137+
$for(author)$
138+
\author[$author.affiliation$]{$author.name$}
139+
$endfor$
140+
$for(address)$
141+
\affil[$address.code$]{$address.address$}
142+
$endfor$
143+
$else$
144+
$for(author)$
145+
$if(author.name)$
146+
\author{$author.name$}
147+
$else$
148+
\author{$author$}
149+
$endif$
150+
$endfor$
151+
$endif$
152+
$endif$
153+
\date{$date$}
154+
$for(header-includes)$
155+
$header-includes$
156+
$endfor$
157+
158+
\begin{document}
159+
$if(title)$
160+
\maketitle
161+
$endif$
162+
$if(abstract)$
163+
\begin{abstract}
164+
$abstract$
165+
\end{abstract}
166+
$endif$
167+
168+
$for(include-before)$
169+
$include-before$
170+
171+
$endfor$
172+
$if(toc)$
173+
{
174+
\hypersetup{linkcolor=black}
175+
\setcounter{tocdepth}{$toc-depth$}
176+
\tableofcontents
177+
}
178+
$endif$
179+
$if(lot)$
180+
\listoftables
181+
$endif$
182+
$if(lof)$
183+
\listoffigures
184+
$endif$
185+
$body$
186+
187+
$if(natbib)$
188+
$if(biblio-files)$
189+
$if(biblio-title)$
190+
$if(book-class)$
191+
\renewcommand\bibname{$biblio-title$}
192+
$else$
193+
\renewcommand\refname{$biblio-title$}
194+
$endif$
195+
$endif$
196+
\bibliography{$biblio-files$}
197+
198+
$endif$
199+
$endif$
200+
$if(biblatex)$
201+
\printbibliography$if(biblio-title)$[title=$biblio-title$]$endif$
202+
203+
$endif$
204+
$for(include-after)$
205+
$include-after$
206+
207+
$endfor$
208+
\end{document}

metadata.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
title: Using knitr and pandoc to create reproducible scientific reports
33
author:
44
- name: Peter Humburg
5-
affiliation: WTCHG
5+
affiliation: 1
66
address:
7-
- code: WTCHG
7+
- code: 1
88
address: Wellcome Trust Centre for Human Genetics, University of Oxford, Roosevelt Dr., Oxford, OX3 7BN, UK
99
date: `r format(Sys.time(), "%a %d %b %Y")`
1010
abstract: |

0 commit comments

Comments
 (0)