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