Fixing some formatting
[themediocreprogrammer.git] / Pandoc / templates / cs-6x9-pdf.latex
1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %%%%%%%%%%%%%%%%%%% BASE DOCUMENT SETTINGS
4 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6 %% Set document class
7 \documentclass%
8 [crop=true,varwidth,border=0.50001bp,11pt]
9 {book} % Set document Class
10
11 %% Set page size and margins
12 \usepackage{geometry}
13   \geometry{
14   paperheight=228.6mm, %actual height measurement of the page
15   paperwidth=152.4mm, %actual width measurement of the page
16   total={108.65mm, 142.53mm}, % widht/height of the "text box"/text area on the page
17   top=30.0mm, % top margin
18   bottom=27.0mm, %bottom margin
19   inner=22.0mm, %inner/gutter margin
20   outer=19.0mm, %outer margin
21   }
22
23 %% Set line spacing
24 % 1.0 = single space
25 % 1.3 = 1.5 space
26 % 1.6 = double space
27 \linespread{1.3}
28   
29 %% Set lineheight / distance between lines
30 %\setlength{\baselineskip}{16pt}
31
32 %% Set no additional space between paragraphs
33 \setlength{\parskip}{0pt}
34
35 %% Use this package to enable tables  
36 \usepackage{longtable,booktabs}
37
38 %% Hide the toprule
39 \renewcommand{\toprule}{}
40
41 %% Hide the bottomrule
42 \renewcommand{\bottomrule}{}
43
44 \setlength{\LTpost}{0pt}
45
46 %% Set language and hyphenation rules
47 \usepackage[english]{babel}
48
49 %% Set encoding
50 %\usepackage[utf8]{inputenc}
51
52 %% Enable widow/orphan control
53 %\usepackage[all,defaultlines=3]{nowidow}
54 \widowpenalty=10000
55 %\clubpenalty=10000
56
57 %% Prevent lines from spilling over
58 \setlength{\emergencystretch}{3em}
59 \providecommand{\tightlist}{\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
60
61 %%%%%%%%% PDF-X stuff, IF USING xelatex %%%%%%%%%
62 % Thanks to LSinev for most of this PDF X-1a stuff;
63 % https://gist.github.com/LSinev/74ea05423c9208d6677d
64
65 %(mm size * 72)/25.4 = bp size
66 \usepackage{atbegshi}
67 \AtBeginShipout{% %A hook that is executed for every page (after first one)
68     \special{pdf: put @thispage
69       <<
70         /TrimBox [0 0 360 576] %put here other numbers = size of page in bp
71       >>
72     }
73 }
74 \special{pdf: put @thispage
75   <<
76     /TrimBox [0 0 360 576] %put here other numbers = size of page in bp
77   >>
78 }
79 \special{pdf:docinfo
80   <<
81     /GTS_PDFXVersion (PDF/X-1:2001)
82     /GTS_PDFXConformance (PDF/X-1a:2001)
83   >>
84 }
85
86 \special{pdf:put @catalog
87 <<
88   /PageMode /UseNone
89   /OutputIntents [
90     <<
91       /Info (none)
92       /Type /OutputIntent
93       /S /GTS_PDFX
94       /OutputConditionIdentifier (Custom)
95       /RegistryName (http://www.color.org/)
96     >>
97   ]
98 >>
99 }%
100
101 \usepackage{datetime} % for \pdfdate command
102
103 %% URL / Hyperlink style
104 \usepackage[bookmarks=true]{hyperref}
105
106
107 \hypersetup{pdfstartpage={}}
108
109 \hypersetup{unicode=true,
110 $if(title-meta)$
111             pdftitle={$title-meta$}, %set pdftitle metadata from Yaml front matter
112 $endif$
113             pdfinfo={% Setting some more PDF/X stuff for xelatex
114                 ModDate={D:\pdfdate},% PDF/X document should have a modification date
115                 Trapped={False},% PDF/X document should have Trapped tag set
116             },
117 $if(author-meta)$
118             pdfauthor={$author-meta$}, %set pdfauthor metadata from Yaml front matter
119 $endif$
120 $if(keywords)$
121             pdfkeywords={$for(keywords)$$keywords$$sep$; $endfor$}, %set pdfkeywords metadata from Yaml front matter
122 $endif$
123 $if(colorlinks)$
124             colorlinks=true,
125             linkcolor=$if(linkcolor)$$linkcolor$$else$Maroon$endif$,
126             citecolor=$if(citecolor)$$citecolor$$else$Blue$endif$,
127             urlcolor=$if(urlcolor)$$urlcolor$$else$Blue$endif$,
128 $else$
129             pdfborder={0 0 0}, %turn off the url border that normally gets added to urls in pdfs
130 $endif$
131             breaklinks=true}
132             
133 \urlstyle{same}  % don't use monospace font for urls
134
135 %% Export PDF as PDF/X-1a for best Createspace results
136 %\usepackage[X-1a]{pdfx}
137
138
139 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
140 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
141 %%%%%%%%%%%%%%%%%%% TITLE SETTINGS
142 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
143 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
144 %% Needed for styling chapter title headings
145 \usepackage{titlesec}
146
147 % Turn off subsection numbering for titles
148 \renewcommand{\thesection}{}
149
150 %% Style the chapter title that appears on the first page of each chapter
151 \titlespacing*{\chapter}
152 {0pt}%left margin
153 {150pt}%top margin
154 {25pt}%bottom margin
155
156 % This tells it to style the titleformat for chapters
157 \titleformat{\chapter}[display]{\bfseries\titlefont}{\Large Chapter \thechapter \normalfont}{0.5mm}{\small}
158
159 %%%%%%%%%%%%%%%%%%
160 %% This part says to style the titles for "chapters"
161 % \titleformat{\chapter}[display]
162
163 %% Use this font
164 %{\garamondL}
165
166 %% This styles the "Chapter 1" part
167 %{\Large Chapter \thechapter \normalfont}
168
169 %% This is the spacing between the "Chapter 1" and the actual chapter title
170 %{0.5ex}
171
172 %% This is the size of the chapter title
173 %{\small}%
174
175 % Add spacing for the chapter title that appears on the first page of each chapter
176 %%%%%%%%%%%%%%%%%%%
177
178 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
179 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
180 %%%%%%%%%%%%%%%%%%% HEADERS AND FOOTERS
181 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
182 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
183 %% Needed for headers and footers
184 \usepackage{fancyhdr}
185
186 %% Prevent headers from appearing on empty pages
187 \usepackage{emptypage}
188
189 %% Remove header/footer from the first page of every chapter
190 \fancypagestyle{plain}{ 
191 \fancyhf{} %remove/clear header/footer content
192 \renewcommand{\headrulewidth}{0.0pt} %remove black line/"rule" from header
193 }
194
195 %% Set the header height in: in, mm, cm, pt
196 \setlength{\headheight}{0.10in}
197
198 %% Set the space between header and text
199 \setlength{\headsep}{.25in}
200
201 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
202 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
203 %%%%%%%%%%%%%%%%%%% FONTS
204 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
205 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
206 %% Use TrueType system fonts
207 \usepackage{fontspec}
208
209 %% Used to set some things to all caps
210 \usepackage{textcase}
211
212 %% Set Main Fonts
213 %\setmainfont[
214   %Ligatures=TeX,
215   %ItalicFont={Linux Libertine O:style=Italic},
216   %BoldFont={Linux Libertine O:style=Bold},
217   %BoldItalicFont={Linux Libertine O:style=Bold Italic},
218 %]{Linux Libertine O}
219 \setmainfont[
220   Ligatures=TeX,
221   ItalicFont={Linux Biolinum O:style=Italic},
222   BoldFont={Linux Biolinum O:style=Bold},
223   BoldItalicFont={Linux Biolinum O:style=Bold Italic},
224 ]{Linux Biolinum O}
225
226 %\setmainfont[
227 %  Ligatures=TeX,
228 %  BoldFont={Aboriginal Serif Bold},
229 %  ItalicFont={Aboriginal Serif Italic},
230 %  BoldItalicFont={Aboriginal Serif Bold Italic},
231 %  SmallCapsFont={TeX Gyre Termes},
232 %  SmallCapsFeatures={Letters=SmallCaps},
233 %]{Minion Pro}
234
235 %% Make our quotes curly
236 \defaultfontfeatures{Mapping=tex-text}
237
238 %% Provides Creative Commons Icons
239 \usepackage{ccicons}
240
241 %% Set Adobe Garamond Pro Bold macro \garmondL
242 %\newcommand*{\garamondL}{\fontspec[Scale=2.0]{Adobe Garamond Pro Bold}\selectfont}
243 %\newcommand*{\garamond}{\fontspec{Adobe Garamond Pro}\selectfont}
244
245 %% Set URW Gothic macro \goth
246 % This command uses locally installed OTF/TTF Fonts
247 %\newcommand*{\goth}{\fontspec{URW Gothic L}\selectfont}
248
249 % These commands use free TeX fonts from CTAN that are nearly identical
250 \usepackage{tgadventor}
251 \usepackage[T1]{fontenc}
252 \newfontfamily\sansfont{TeX Gyre Adventor}
253
254
255 %% Set Minion Pro macro \minion
256 % This command uses locally installed OTF/TTF Fonts
257 %\newcommand*{\minion}{\fontspec{Minion Pro}\selectfont}
258 %\newcommand*{\minionHead}{\fontspec{MinionPro-BoldIt}\selectfont}
259
260 % These commands use free TeX fonts from CTAN that are nearly identical
261 %\usepackage{gentium}
262 %\usepackage[T1]{fontenc}
263 %\newfontfamily\minion{Gentium Book Basic}
264
265 \usepackage{libertine}
266 \usepackage[T1]{fontenc}
267 % \newfontfamily\primaryfont[Ligatures=TeX, Numbers=OldStyle]{Linux Libertine O}
268 %\newfontfamily\titlefont[Scale=1.75, Ligatures=TeX]{Linux Libertine O}
269 \newfontfamily\setmainfont[Ligatures=TeX, Numbers=OldStyle]{Linux Biolinum O}
270 \newfontfamily\primaryfont[Ligatures=TeX, Numbers=OldStyle]{Linux Biolinum O}
271 \newfontfamily\idtitlefont[Ligatures=TeX, Numbers=OldStyle]{Linux Biolinum O}
272 \newfontfamily\headerfont[Ligatures=TeX, Numbers=OldStyle]{Linux Biolinum O}
273 \newfontfamily\normalfont[Ligatures=TeX, Numbers=OldStyle]{Linux Biolinum O}
274 \newfontfamily\titlefont[Scale=1.75, Ligatures=TeX]{Linux Biolinum O}
275
276 %\setmainfont
277 %\renewcommand{\sfdefault}{URW Gothic}
278 %\setmonofont
279
280 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
281 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
282 %%%%%%%%%%%%%%%%%%% METADATA and MACROS
283 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
284 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
285
286 %% Set Title from Yaml Metadata
287 \title{$title$}
288
289 %% Set subtitle if it exists in Yaml Metadata
290 $if(subtitle)$
291 \newcommand{\subtitle}{$subtitle$}
292 $endif$
293
294 %% Set author from Yaml Metadata
295 \author{$for(author)$$author$$endfor$}
296
297 %% Set editor from Yaml Metadata
298 \def\editor{$for(contributors)$$contributors.editor$$endfor$}
299
300 %% Set cover artist from Yaml Metadata
301 \def\artist{$for(contributors)$$contributors.artist$$endfor$}
302
303 %% Set designer from Yaml Metadata
304 \def\designer{$for(contributors)$$contributors.designer$$endfor$}
305
306 %% Set publisher from Yaml Metadata
307 \def\publisher{$for(publisher)$$publisher$$endfor$}
308
309 %% Set website from Yaml Metadata
310 \def\website{$for(website)$$website$$endfor$}
311
312 %% Use the year instead of the full date
313 \date{$year$}
314
315 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
316 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
317 %%%%%%%%%%%%%%%%%%% START THE DOCUMENT
318 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
319 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
320 \begin{document}
321
322 %% Start with the frontmatter
323 % These pages don't count for document page numbering
324 \frontmatter
325
326 %%%%%%%%%%%%%%%%%%%%%%%%%%%
327 %%%%%%%%%%%%%%%%%%%%%%%%%%%
328 %% Create a titlepage
329 %%%%%%%%%%%%%%%%%%%%%%%%%%%
330 %%%%%%%%%%%%%%%%%%%%%%%%%%%
331 % No headers/footers
332 \pagestyle{empty}
333 % Center everything
334   \begin{center}
335
336 % Add a vertical space
337   \vspace*{3cm}
338   
339 % Write the Book Title
340   \makeatletter \Huge \bfseries \titlefont \textbf{\textsc{\@title}} \par \makeatother    
341
342 % Add a vertical space
343   \vspace{1cm}
344     
345 % Write the subtitle
346 $if(subtitle)$
347   \Large \primaryfont $subtitle$ \par
348 $endif$
349     
350 % Add a vertical space
351   \vspace{4cm}
352     
353 % Write the author name
354   \Large \normalfont \sansfont  \makeatletter \MakeUppercase\@author \makeatother \par
355
356 % Stop centering everythign
357   \end{center}
358
359 % End the page
360 \clearpage
361
362 %%%%%%%%%%%%%%%%%%%%%%%%%%%
363 %%%%%%%%%%%%%%%%%%%%%%%%%%%
364 %% Create a copyright page
365 %%%%%%%%%%%%%%%%%%%%%%%%%%%
366 %%%%%%%%%%%%%%%%%%%%%%%%%%%
367 % No headers/footers
368 \pagestyle{empty}
369
370 % Center everything
371   \begin{center} 
372
373 % Use Sans font
374   \sansfont
375   
376 % Write the Book Titlecopyright page
377   \makeatletter  \small \@title \par \makeatother
378     
379 % Write the CC logo, year, and author
380     Copyright \ccLogo\ \makeatletter \@date \ \@author \makeatother \par
381     Some rights reserved. \par
382     
383 % Add a vertical space
384     \vspace{0.4cm}
385
386 % Write what country it was published in
387     Published in the United States by \par
388     
389 % Write the publisher name
390     \publisher \par
391     
392 % Write the website
393     \website \par
394     
395 % Add a vertical space
396     \vspace{0.4cm}
397
398 % Write the specific license name
399     This book is distributed under a Creative Commons Attribution-Sharealike 4.0 License. \par
400
401 % Add a vertical space
402     \vspace{0.4cm}
403
404 % Write the Creative Commons Icons
405     \ccbysa
406     
407 % Stop centering everythign
408   \end{center}
409        
410 % Write license text
411    \scriptsize
412    \noindent \sansfont
413     That means you are free:
414       \begin{itemize}
415         \setlength{\itemsep}{0pt}
416         \setlength{\parskip}{0pt}
417         \setlength{\parsep}{0pt} 
418           \item \textbf{To Share} -- copy and redistribute the material in any medium or format.
419          \item \textbf{To Adapt} -- remix, transform, and build upon the material.
420       \end{itemize}
421     The licensor cannot revoke these freedoms as long as you follow the license terms: \par
422       \begin{itemize}
423         \setlength{\itemsep}{0pt}
424         \setlength{\parskip}{0pt}
425         \setlength{\parsep}{0pt}
426           \item \textbf{Attribution} -- You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use. \par
427           % \item \textbf{NonCommercial} -- You may not use the material for commercial purposes. \par
428           \item \textbf{Share Alike} -- If you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original. \par
429       \end{itemize}
430     \textbf No additional restrictions — You may not apply legal terms or technological measures that legally restrict others from doing anything the license permits.
431     
432 % Add a vertical space
433     \vspace{.5cm}
434     
435 % Start centering again
436     \begin{center}
437
438 % Attribute the cover artist
439       $for(contributors)$$if(contributors.artist)$ Cover Artist: \artist \par$endif$$endfor$
440       
441 % Attribute the editor
442       $for(contributors)$$if(contributors.editor)$ Editor: \editor \par$endif$$endfor$
443       
444 % Attribute the designer (hey, that's me)
445       $for(contributors)$$if(contributors.designer)$ Design: \designer \par$endif$$endfor$
446    
447 % Add a vertical space
448       \vspace{0.4cm}
449       
450 % If ISBNs are defined in Yaml front matter then write them here
451       $if(paperback-isbn)$Paperback ISBN: {$paperback-isbn$} \par $endif$
452       $if(hardcover-isbn)$HardcoverISBN: {$hardcover-isbn$}\par $endif$
453       $if(epub-isbn)$ePub ISBN: {$epub-isbn$} \par $endif$
454       
455 % Stop centering
456     \end{center}
457     
458 % End the page
459 \clearpage
460
461 %%%%%%%%%%%%%%%%%%%%%%%%%%%
462 %%%%%%%%%%%%%%%%%%%%%%%%%%%
463 %% Create a dedication page
464 %%%%%%%%%%%%%%%%%%%%%%%%%%%
465 %%%%%%%%%%%%%%%%%%%%%%%%%%%
466 % No headers/footers
467 \pagestyle{empty}
468
469 % Center everything
470   \begin{center}
471
472 % Vertically center
473 \topskip0pt
474 \vspace*{\fill}
475   
476 % Write the Book Title
477   \normalfont\normalsize $dedication$ \par
478
479 % Stop centering
480 \vspace*{\fill}
481     \end{center}
482     
483 % End the page
484 \clearpage
485
486 %%%%%%%%%%%%%%%%%%%%%%%%%%%
487 %%%%%%%%%%%%%%%%%%%%%%%%%%%
488 %% Create the chapters
489 %%%%%%%%%%%%%%%%%%%%%%%%%%%
490 %%%%%%%%%%%%%%%%%%%%%%%%%%%
491 % This styles the header/footer for normal 'chapter' pages
492 \makeatletter
493 \pagestyle{fancy}
494 %\renewcommand{\chaptermark}[1]{\markboth{#1}{}} % This removes the 'Chapter x' from the header
495 \renewcommand{\chaptermark}[1]{\markboth {\@chapapp\ \thechapter \hspace{1mm}-\hspace{1mm}{#1}}{}}
496
497 \fancyfoot[C]{} % remove numbered footers
498 \fancyhead[RO,LE]{\primaryfont\bfseries \thepage} % add page numbers to the header
499 \fancyhead[LO]{\primaryfont\bfseries \textsc \leftmark} % add subtitle to header
500 \fancyhead[RE]{\primaryfont\bfseries \textsc \@title}
501 \renewcommand{\headrulewidth}{0.0pt} 
502 \makeatother
503
504 % This says to start the page numbering
505 \mainmatter
506
507 % Write the body/chapters
508 \primaryfont \normalsize \flushbottom $body$
509
510 %%%%%%%%%%%%%%%%%%%%%%%%%%%
511 %%%%%%%%%%%%%%%%%%%%%%%%%%%
512 %% Create the bio page
513 %%%%%%%%%%%%%%%%%%%%%%%%%%%
514 %%%%%%%%%%%%%%%%%%%%%%%%%%%
515 % add blank even page before backmatter starts
516 \newcommand*\cleartoleftpage{%
517   \clearpage
518   \ifodd\value{page}\hbox{}\thispagestyle{empty}\newpage\fi
519 }
520
521 \cleartoleftpage
522
523 % Label as backmatter
524 \backmatter
525
526 % No headers/footers
527 \pagestyle{empty}
528
529 % Add space before/after the page title
530 \titlespacing*{\section}
531 {0pt}%left
532 {150pt}%top
533 {25pt}%bottom
534
535 % This designs the page title
536 \titleformat{\section}[display]{\bfseries\titlefont}{}{0.5mm}{\centering \Large} % Don't say 'chapter X'
537
538 % Don't indent new paragraphs
539 \setlength{\parindent}{0mm}
540
541 % Add space between paragraphs
542 \parskip = \baselineskip
543
544 % Include the file(s) we specified via the pandoc command, in this case our bio.md
545 $include-after$
546
547 % End the document
548 \end{document} 
549