ce44c5eecbec969bcb03f1fe2c2db880066442d2
[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
220 %\setmainfont[
221 %  Ligatures=TeX,
222 %  BoldFont={Aboriginal Serif Bold},
223 %  ItalicFont={Aboriginal Serif Italic},
224 %  BoldItalicFont={Aboriginal Serif Bold Italic},
225 %  SmallCapsFont={TeX Gyre Termes},
226 %  SmallCapsFeatures={Letters=SmallCaps},
227 %]{Minion Pro}
228
229 %% Make our quotes curly
230 \defaultfontfeatures{Mapping=tex-text}
231
232 %% Provides Creative Commons Icons
233 \usepackage{ccicons}
234
235 %% Set Adobe Garamond Pro Bold macro \garmondL
236 %\newcommand*{\garamondL}{\fontspec[Scale=2.0]{Adobe Garamond Pro Bold}\selectfont}
237 %\newcommand*{\garamond}{\fontspec{Adobe Garamond Pro}\selectfont}
238
239 %% Set URW Gothic macro \goth
240 % This command uses locally installed OTF/TTF Fonts
241 %\newcommand*{\goth}{\fontspec{URW Gothic L}\selectfont}
242
243 % These commands use free TeX fonts from CTAN that are nearly identical
244 \usepackage{tgadventor}
245 \usepackage[T1]{fontenc}
246 \newfontfamily\sansfont{TeX Gyre Adventor}
247
248
249 %% Set Minion Pro macro \minion
250 % This command uses locally installed OTF/TTF Fonts
251 %\newcommand*{\minion}{\fontspec{Minion Pro}\selectfont}
252 %\newcommand*{\minionHead}{\fontspec{MinionPro-BoldIt}\selectfont}
253
254 % These commands use free TeX fonts from CTAN that are nearly identical
255 %\usepackage{gentium}
256 %\usepackage[T1]{fontenc}
257 %\newfontfamily\minion{Gentium Book Basic}
258
259 \usepackage{libertine}
260 \usepackage[T1]{fontenc}
261 \newfontfamily\primaryfont[Ligatures=TeX, Numbers=OldStyle]{Linux Libertine O}
262 \newfontfamily\titlefont[Scale=1.75, Ligatures=TeX]{Linux Libertine O}
263
264 %\setmainfont
265 %\renewcommand{\sfdefault}{URW Gothic}
266 %\setmonofont
267
268 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
269 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
270 %%%%%%%%%%%%%%%%%%% METADATA and MACROS
271 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
272 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
273
274 %% Set Title from Yaml Metadata
275 \title{$title$}
276
277 %% Set subtitle if it exists in Yaml Metadata
278 $if(subtitle)$
279 \newcommand{\subtitle}{$subtitle$}
280 $endif$
281
282 %% Set author from Yaml Metadata
283 \author{$for(author)$$author$$endfor$}
284
285 %% Set editor from Yaml Metadata
286 \def\editor{$for(contributors)$$contributors.editor$$endfor$}
287
288 %% Set cover artist from Yaml Metadata
289 \def\artist{$for(contributors)$$contributors.artist$$endfor$}
290
291 %% Set designer from Yaml Metadata
292 \def\designer{$for(contributors)$$contributors.designer$$endfor$}
293
294 %% Set publisher from Yaml Metadata
295 \def\publisher{$for(publisher)$$publisher$$endfor$}
296
297 %% Set website from Yaml Metadata
298 \def\website{$for(website)$$website$$endfor$}
299
300 %% Use the year instead of the full date
301 \date{$year$}
302
303 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
304 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
305 %%%%%%%%%%%%%%%%%%% START THE DOCUMENT
306 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
307 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
308 \begin{document}
309
310 %% Start with the frontmatter
311 % These pages don't count for document page numbering
312 \frontmatter
313
314 %%%%%%%%%%%%%%%%%%%%%%%%%%%
315 %%%%%%%%%%%%%%%%%%%%%%%%%%%
316 %% Create a titlepage
317 %%%%%%%%%%%%%%%%%%%%%%%%%%%
318 %%%%%%%%%%%%%%%%%%%%%%%%%%%
319 % No headers/footers
320 \pagestyle{empty}
321 % Center everything
322   \begin{center}
323
324 % Add a vertical space
325   \vspace*{3cm}
326   
327 % Write the Book Title
328   \makeatletter \Huge \bfseries \titlefont \textbf{\textsc{\@title}} \par \makeatother    
329
330 % Add a vertical space
331   \vspace{1cm}
332     
333 % Write the subtitle
334 $if(subtitle)$
335   \Large \primaryfont $subtitle$ \par
336 $endif$
337     
338 % Add a vertical space
339   \vspace{4cm}
340     
341 % Write the author name
342   \Large \normalfont \sansfont  \makeatletter \MakeUppercase\@author \makeatother \par
343
344 % Stop centering everythign
345   \end{center}
346
347 % End the page
348 \clearpage
349
350 %%%%%%%%%%%%%%%%%%%%%%%%%%%
351 %%%%%%%%%%%%%%%%%%%%%%%%%%%
352 %% Create a copyright page
353 %%%%%%%%%%%%%%%%%%%%%%%%%%%
354 %%%%%%%%%%%%%%%%%%%%%%%%%%%
355 % No headers/footers
356 \pagestyle{empty}
357
358 % Center everything
359   \begin{center} 
360
361 % Use Sans font
362   \sansfont
363   
364 % Write the Book Titlecopyright page
365   \makeatletter  \small \@title \par \makeatother
366     
367 % Write the CC logo, year, and author
368     Copyright \ccLogo\ \makeatletter \@date \ \@author \makeatother \par
369     Some rights reserved. \par
370     
371 % Add a vertical space
372     \vspace{0.4cm}
373
374 % Write what country it was published in
375     Published in the United States by \par
376     
377 % Write the publisher name
378     \publisher \par
379     
380 % Write the website
381     \website \par
382     
383 % Add a vertical space
384     \vspace{0.4cm}
385
386 % Write the specific license name
387     This book is distributed under a Creative Commons Attribution-Sharealike 4.0 License. \par
388
389 % Add a vertical space
390     \vspace{0.4cm}
391
392 % Write the Creative Commons Icons
393     \ccbysa
394     
395 % Stop centering everythign
396   \end{center}
397        
398 % Write license text
399    \scriptsize
400    \noindent \sansfont
401     That means you are free:
402       \begin{itemize}
403         \setlength{\itemsep}{0pt}
404         \setlength{\parskip}{0pt}
405         \setlength{\parsep}{0pt} 
406           \item \textbf{To Share} -- copy and redistribute the material in any medium or format.
407          \item \textbf{To Adapt} -- remix, transform, and build upon the material.
408       \end{itemize}
409     The licensor cannot revoke these freedoms as long as you follow the license terms: \par
410       \begin{itemize}
411         \setlength{\itemsep}{0pt}
412         \setlength{\parskip}{0pt}
413         \setlength{\parsep}{0pt}
414           \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
415           % \item \textbf{NonCommercial} -- You may not use the material for commercial purposes. \par
416           \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
417       \end{itemize}
418     \textbf No additional restrictions — You may not apply legal terms or technological measures that legally restrict others from doing anything the license permits.
419     
420 % Add a vertical space
421     \vspace{.5cm}
422     
423 % Start centering again
424     \begin{center}
425
426 % Attribute the cover artist
427       $for(contributors)$$if(contributors.artist)$ Cover Artist: \artist \par$endif$$endfor$
428       
429 % Attribute the editor
430       $for(contributors)$$if(contributors.editor)$ Editor: \editor \par$endif$$endfor$
431       
432 % Attribute the designer (hey, that's me)
433       $for(contributors)$$if(contributors.designer)$ Design: \designer \par$endif$$endfor$
434    
435 % Add a vertical space
436       \vspace{0.4cm}
437       
438 % If ISBNs are defined in Yaml front matter then write them here
439       $if(paperback-isbn)$Paperback ISBN: {$paperback-isbn$} \par $endif$
440       $if(hardcover-isbn)$HardcoverISBN: {$hardcover-isbn$}\par $endif$
441       $if(epub-isbn)$ePub ISBN: {$epub-isbn$} \par $endif$
442       
443 % Stop centering
444     \end{center}
445     
446 % End the page
447 \clearpage
448
449 %%%%%%%%%%%%%%%%%%%%%%%%%%%
450 %%%%%%%%%%%%%%%%%%%%%%%%%%%
451 %% Create a dedication page
452 %%%%%%%%%%%%%%%%%%%%%%%%%%%
453 %%%%%%%%%%%%%%%%%%%%%%%%%%%
454 % No headers/footers
455 \pagestyle{empty}
456
457 % Center everything
458   \begin{center}
459
460 % Vertically center
461 \topskip0pt
462 \vspace*{\fill}
463   
464 % Write the Book Title
465   \normalfont\normalsize $dedication$ \par
466
467 % Stop centering
468 \vspace*{\fill}
469     \end{center}
470     
471 % End the page
472 \clearpage
473
474 %%%%%%%%%%%%%%%%%%%%%%%%%%%
475 %%%%%%%%%%%%%%%%%%%%%%%%%%%
476 %% Create the chapters
477 %%%%%%%%%%%%%%%%%%%%%%%%%%%
478 %%%%%%%%%%%%%%%%%%%%%%%%%%%
479 % This styles the header/footer for normal 'chapter' pages
480 \makeatletter
481 \pagestyle{fancy}
482 %\renewcommand{\chaptermark}[1]{\markboth{#1}{}} % This removes the 'Chapter x' from the header
483 \renewcommand{\chaptermark}[1]{\markboth {\@chapapp\ \thechapter \hspace{1mm}-\hspace{1mm}{#1}}{}}
484
485 \fancyfoot[C]{} % remove numbered footers
486 \fancyhead[RO,LE]{\primaryfont\bfseries \thepage} % add page numbers to the header
487 \fancyhead[LO]{\primaryfont\bfseries \textsc \leftmark} % add subtitle to header
488 \fancyhead[RE]{\primaryfont\bfseries \textsc \@title}
489 \renewcommand{\headrulewidth}{0.0pt} 
490 \makeatother
491
492 % This says to start the page numbering
493 \mainmatter
494
495 % Write the body/chapters
496 \primaryfont \normalsize \flushbottom $body$
497
498 %%%%%%%%%%%%%%%%%%%%%%%%%%%
499 %%%%%%%%%%%%%%%%%%%%%%%%%%%
500 %% Create the bio page
501 %%%%%%%%%%%%%%%%%%%%%%%%%%%
502 %%%%%%%%%%%%%%%%%%%%%%%%%%%
503 % add blank even page before backmatter starts
504 \newcommand*\cleartoleftpage{%
505   \clearpage
506   \ifodd\value{page}\hbox{}\thispagestyle{empty}\newpage\fi
507 }
508
509 \cleartoleftpage
510
511 % Label as backmatter
512 \backmatter
513
514 % No headers/footers
515 \pagestyle{empty}
516
517 % Add space before/after the page title
518 \titlespacing*{\section}
519 {0pt}%left
520 {150pt}%top
521 {25pt}%bottom
522
523 % This designs the page title
524 \titleformat{\section}[display]{\bfseries\titlefont}{}{0.5mm}{\centering \Large} % Don't say 'chapter X'
525
526 % Don't indent new paragraphs
527 \setlength{\parindent}{0mm}
528
529 % Add space between paragraphs
530 \parskip = \baselineskip
531
532 % Include the file(s) we specified via the pandoc command, in this case our bio.md
533 $include-after$
534
535 % End the document
536 \end{document} 
537