-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.tex
271 lines (220 loc) · 6.26 KB
/
template.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
{{=<< >>=}} % Use <<&foo>> to include (non HTML-escape) variable foo instead of {{{foo}}}
\documentclass<<#has_tex_size>>[<<&tex_size>>pt]<</has_tex_size>>{<<&class>>}
%% Pacake inclusion
<<#xelatex>>
% Unicode support if xelatex is used
\usepackage{fontspec}
\usepackage{xunicode}
<</xelatex>>
<<^xelatex>>
% Unicode support if xelatex is not used
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
% Even with inputenc, not all unicode chars are recognized when not using xelatex. This a
% listof some I stumbled upon and manually added to fix
\usepackage{newunicodechar}
\newunicodechar{ }{ } % thin non breaking space
\newunicodechar{°}{$^{\circ}$}
% Force LaTeX not to overflow page e.g. when there is long words
% (e.g. filenames, urls, ...). The result is not necesarily very
% beautiful, though, but at least it's readable.
\setlength\emergencystretch{.5\textwidth}
<</xelatex>>
\usepackage[<<&tex_lang>>]{babel} % Language support
\usepackage{fancyhdr} % Headers
% Allows hyphenatations in \texttt
\usepackage[htt]{hyphenat}
<<#use_strikethrough>>
% Only included if strikethrough is used in the document
\usepackage[normalem]{ulem}
<</use_strikethrough>>
<<#use_taskitem>>
\usepackage{amssymb}
<</use_taskitem>>
% Set hyperlinks and metadata
\usepackage[colorlinks=true,breaklinks=true,hypertexnames=false]{hyperref}
\hypersetup{pdfauthor={<<&author>>},
pdftitle={<<&title>>},
pdfsubject={<<&description>>}
}
<<^xelatex>>
\usepackage[anythingbreaks]{breakurl}
<</xelatex>>
<<#initials>>
% Only included if use_initials is set to true
\usepackage{lettrine}
<</initials>>
<<#stdpage>>
% Only included if the stdpage option is set to true
\usepackage[<<&papersize>>]{geometry}
\usepackage[hyphen=false, parskip]{stdpage}
<</stdpage>>
<<^stdpage>>
% Included if the stdpage option if set to false
\usepackage[<<&papersize>>, top=<<&margin_top>>, bottom=<<&margin_bottom>>,
left=<<&margin_left>>,right=<<&margin_right>>]{geometry} % Set dimensions/margins of the parge
<</stdpage>>
\makeatletter
\date{<<&date>>}
<<^stdpage>>
<<#book>>
% Redefine the \maketitle command, only for book class (not used if stdpage option is set to true)
\renewcommand{\maketitle}{
% First page with only the title
\thispagestyle{empty}
\vspace*{\stretch{1}}
\begin{center}
{\Huge \@title \\[5mm]}
\end{center}
\vspace*{\stretch{2}}
\newpage
% Empty left page
\thispagestyle{empty}
\cleardoublepage
% Main title page, with author, title, subtitle, date
\begin{center}
\thispagestyle{empty}
\vspace*{\baselineskip}
\rule{\textwidth}{1.6pt}\vspace*{-\baselineskip}\vspace*{2pt}
\rule{\textwidth}{0.4pt}\\[\baselineskip]
{\Huge\scshape \@title \\[5mm]}
{\Large <<&subtitle>>}
\rule{\textwidth}{0.4pt}\vspace*{-\baselineskip}\vspace{3.2pt}
\rule{\textwidth}{1.6pt}\\[\baselineskip]
\vspace*{4\baselineskip}
{\Large \@author}
<<#has_autograph>>
\vspace*{10\baselineskip}
<<&autograph>>
<</has_autograph>>
\vfill
<<#has_date>>\@date<</has_date>>
\end{center}
\pagebreak
\newpage
% Copyright page with author, version, and license
\thispagestyle{empty}
\null\vfill
\noindent
\begin{center}
{\emph{\@title}<<#has_version>>{, <<&version>>}<</has_version>><<#has_author>>, © \@author<</has_author>>.\\[5mm]}
<<#has_license>>{<<&license>>\\[5mm]}<</has_license>>
\end{center}
\pagebreak
\newpage
}
<</book>>
% Redefine headers
\pagestyle{fancy}
\fancyhead{}
\fancyhead[CO,CE]{\thepage}
\fancyfoot{}
\renewcommand{\familydefault}{\sfdefault}
<</stdpage>>
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Command and environment definitions
%
% Here, commands are defined for all Markdown element (even if some
% of them do nothing in this template).
%
% If you want to change the rendering of some elements, this is probably
% what you should modify.
%
% Note that elements that already have a LaTeX semantic equivalent aren't redefined
% : if you want to redefine headers, you'll have to renew \chapter, \section, \subsection,
% ..., commands. If you want to change how emphasis is displayed, you'll have to renew
% the \emph command, for list the itemize one, for ordered list the enumerate one,
% for super/subscript the \textsuper/subscript ones.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Strong
\newcommand\mdstrong[1]{\textbf{#1}}
% Code
\newcommand\mdcode[1]{\texttt{#1}}
% Rule
% Default impl : (displays centered asterisks)
\newcommand\mdrule{
\nopagebreak
{\vskip 1em}
\nopagebreak
\begin{center}
***
\end{center}
\nopagebreak
{\vskip 1em}
\nopagebreak
}
% Hardbreak
\newcommand\mdhardbreak{\\}
% Block quote$
\newenvironment{mdblockquote}{%
\begin{quotation}
\itshape
}{%
\end{quotation}
}
% Code block
%
% Only used if syntect is used for syntax highlighting is used, else
% the spverbatim environment is preferred.
<<#use_codeblocks>> % This part is only included if document contains code blocks
\usepackage{spverbatim}
\usepackage{color}
\usepackage[
topline=false,
rightline=false,
bottomline=false]{mdframed}
\newenvironment{mdcodeblock}{%
\begin{mdframed}
}{%
\end{mdframed}
}
<</use_codeblocks>>
<<#use_images>>
% Only included if document contains images
\usepackage{graphicx}
% Standalone image
% (an image alone in its paragraph)
\newcommand\mdstandaloneimage[1]{
\begin{center}
\includegraphics[width=0.8\linewidth]{#1}
\end{center}
}
% Image
% (an image embedded in a pagraph or other element)
\newcommand\mdimage[1]{\includegraphics{#1}}
<</use_images>>
<<#use_tables>>
% Only included if document contains tables
\usepackage{tabularx}
% Table environment
% Crowbook currently always insert \hline at beginning and end of the table
\newenvironment{mdtable}[1]{%
\center
\tabularx{\textwidth}{#1}
\hline
}{%
\endtabularx
\endcenter
}
<</use_tables>>
<<&additional_code>>
\makeatother
\title{<<&title>>}
\author{<<&author>>}
\begin{document}
% Redefine chapter and part names if they needs to be
% Needs to be after \begin{document} because babel
<<#chapter_name>>
\makeatletter
\renewcommand{\@chapapp}{<<&chapter_name>>}
\makeatother
<</chapter_name>>
<<#part_name>>
\renewcommand{\partname}{<<&part_name>>}
<</part_name>>
<<#tex_title>>
\maketitle
<</tex_title>>
<<&content>>
\end{document}