-
Notifications
You must be signed in to change notification settings - Fork 9
/
template.pdf.p
225 lines (188 loc) Β· 8.01 KB
/
template.pdf.p
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
β(local-require racket/file racket/system racket/list racket/string)
β(define (print-if thing fmt)
(if thing (format fmt thing) ""))
β(define latex-source βstring-append{
\documentclass[12pt]{article}
\usepackage{ragged2e} % For \RaggedRight immediately following \begin
\usepackage{amssymb,amsmath}
\usepackage[T1]{fontenc}
%\usepackage[utf8]{inputenc}
\usepackage{eurosym}
\usepackage{fancyvrb}
\usepackage{longtable,booktabs}
\usepackage{attrib}
\usepackage{graphicx}
\usepackage{mathspec}
\usepackage{xltxtra,xunicode}
\usepackage{xspace}
\def\faFileAlt{\symbol{"F0F6}} %"
\newfontfamily{\FA}{FontAwesome}
\def\fileicon{{\FA\faFileAlt}}
\defaultfontfeatures{Scale=MatchLowercase}
\usepackage{microtype}
\usepackage{fontspec}
%% Typography defaults
\newfontfamily\linenumberfont[Mapping=tex-text]{Fira Mono OT}
\setsansfont[
ItalicFont = HelveticaNeue-Italic,
BoldFont = HelveticaNeue-Bold,
BoldItalicFont = HelveticaNeue-BoldItalic]{HelveticaNeue}
\setmainfont[Mapping=tex-text,SmallCapsFeatures={LetterSpace=5.5}]{Source Sans Pro}
\setmonofont[Scale=0.8]{Triplicate T4c}
\newfontfamily\NHLight[
ItalicFont = HelveticaNeue-LightItalic,
BoldFont = HelveticaNeue-UltraLight,
BoldItalicFont = HelveticaNeue-UltraLightItalic]{HelveticaNeue-Light}
\usepackage{xcolor}
\definecolor{mygray}{rgb}{0.7,0.7,0.7}
\definecolor{light-gray}{gray}{0.95}
\definecolor{tweet-cyan}{RGB}{154,228,232}
\usepackage[framemethod=PSTricks]{mdframed} % used for embedding tweets
\global\mdfdefinestyle{tweet}{%
linecolor=tweet-cyan,middlelinewidth=6pt,%
leftmargin=2.5cm,rightmargin=2.5cm,roundcorner=10
}
% Manually reimplement \newthought from Tufte-LaTeX
\newskip\tufteskipamount
\tufteskipamount=1.0\baselineskip plus 0.5ex minus 0.2ex
\newcommand{\tuftebreak}{\par\ifdim\lastskip<\tufteskipamount
\removelastskip\penalty-100\tufteskip\fi}
\newcommand{\tufteskip}{\vspace\tufteskipamount}
\newcommand{\newthought}[1]{%
\tuftebreak
\noindent\textsc{#1}%
}
\usepackage{textcomp}
\usepackage{upquote}
\usepackage{listingsutf8}
\lstset{
inputencoding=utf8,
extendedchars=true,
basicstyle=\scriptsize\ttfamily,
columns=flexible,
breaklines=true,
numbers=left,
upquote=true,
backgroundcolor=\color{light-gray},
numbersep=5pt,
frame=single,
framesep=\fboxsep,
framerule=\fboxrule,
rulecolor=\color{black},
xleftmargin=\dimexpr\fboxsep+\fboxrule,
xrightmargin=\dimexpr\fboxsep+\fboxrule,
framexleftmargin=.25in,
% belowcaptionskip=0pt,
numberstyle=\scriptsize\color{mygray}\linenumberfont
}
% Add the lozenge to the list of extended characters in the `listings`
% environment. This is a limited workaround for a problem where Unicod
% characters appear out of order in code listings.
% See https://tex.stackexchange.com/q/81674
%
\begingroup
\catcode0=12 %
\makeatletter
\g@addto@macro\lst@DefEC{%
\lst@CCECUse\lst@ProcessLetter
β"β"% *** add Unicode characters ***
^^00% end marker
}%
\endgroup
% see http://tex.stackexchange.com/questions/11263/how-can-i-remove-listing-from-listings-caption
% and http://tex.stackexchange.com/questions/209764/how-can-i-make-the-width-of-the-caption-match-that-of-the-listing
\usepackage{calc}
\usepackage[skip=0pt,position=auto]{caption}
\DeclareCaptionFont{white}{\scriptsize\color{white}\ttfamily}
\DeclareCaptionFormat{listing}{%
\fcolorbox{black}{gray}{\parbox{\textwidth-2\fboxsep-2\fboxrule}{#1#2#3}}%
}
\captionsetup[lstlisting]{format=listing,labelfont=white,textfont=white}
\makeatletter
\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi}
\def\maxheight{\ifdim\Gin@nat@height>\textheight\textheight\else\Gin@nat@height\fi}
\makeatother
% Scale images if necessary, so that they will not overflow the page
% margins by default, and it is still possible to overwrite the defaults
% using explicit options in \includegraphics[width, height, ...]{}
\setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}
\usepackage[setpagesize=false, % page size defined by xetex
unicode=false, % unicode breaks when used with xetex
xetex]{hyperref}
\hypersetup{breaklinks=true,
bookmarks=true,
pdfauthor={β(print-if (select-from-metas 'author metas) "~a")},
pdftitle={β(ltx-escape-str (select-from-metas 'title metas))},
colorlinks=true,
citecolor=blue,
urlcolor=blue,
linkcolor=magenta,
pdfborder={0 0 0}}
\urlstyle{same} % don't use monospace font for urls
% Make links footnotes instead of hotlinks:
\renewcommand{\href}[2]{#2\footnote{\url{#1}}}
% Make margin notes (from Tufte-LaTeX) into regular footnotes
\newcommand{\marginnote}[1]{\footnote{#1}}
\newcommand{\smallcaps}[1]{\textsc{#1}}
\setlength{\parindent}{0pt}
\setlength{\parskip}{6pt plus 2pt minus 1pt}
\setlength{\emergencystretch}{3em} % prevent overfull lines
\setcounter{secnumdepth}{0}
\VerbatimFootnotes % allows verbatim text in footnotes
%% Titling package allows for macros \thetitle \theauthor, etc
\usepackage{titling}
\title{β(ltx-escape-str (select-from-metas 'title metas))}
β(print-if (select-from-metas 'author metas) "\\author{~a}")
\date{β(unless (not (select-from-metas 'published metas)) (pubdate->english (select-from-metas 'published metas)))}
%% Reduced margins
%\usepackage[margin=1.2in]{geometry}
%% Paragraph and line spacing
%\linespread{1.05} % a bit more vertical space
%\setlength{\parskip}{\baselineskip} % space between paragraphs spacing is one baseline unit
%% Sections headings spacing: one baseline unit before, none after
\usepackage{titlesec}
\titlespacing{\section}{0pt}{\baselineskip}{0pt}
\titlespacing{\subsection}{0pt}{\baselineskip}{0pt}
\titlespacing{\subsubsection}{0pt}{\baselineskip}{0pt}
% Customize footnotes so that, within the footnote, the footnote number is
% the same size as the footnote text (per Bringhurst).
%
\usepackage[splitrule,multiple,hang]{footmisc}
\makeatletter
\renewcommand\@makefntext[1]{\parindent 1em%
\noindent
\hb@xt@0em{\hss\normalfont\@thefnmark.} #1}
\def\splitfootnoterule{\kern-3\p@ \hrule width 1in \kern2.6\p@}
\makeatother
\renewcommand\footnotesize{\fontsize{10}{12} \selectfont}
\renewcommand{\thefootnote}{\arabic{footnote}}
% Allow use of \st for strikethrough
\usepackage{soul}
%% Main doc
\begin{document}
\RaggedRight
\begingroup
\centering
{\LARGE\bf \thetitle}\\[1em]
\normalsize\sc \thedate\\[1.5em]
\par
\endgroup
β(apply string-append (cdr doc))
\end{document}
})
β(define working-directory
(build-path (current-project-root) "latex-tmp"))
β(unless (directory-exists? working-directory)
(make-directory working-directory))
β(define ltx-source (string-replace
(pdfname (select-from-metas 'here-path metas))
"pdf"
"ltx"))
β(define pdf-temp (string-replace ltx-source ".ltx" ""))
β(define temp-ltx-path (build-path working-directory ltx-source))
β(display-to-file latex-source temp-ltx-path #:exists 'replace)
β(define echo-sep "echo \"\e[1;32mββββββββββββββββ\e[0m\"")
β(define command (format "~a; xelatex -jobname=~a -halt-on-error -interaction=batchmode -output-directory='~a' '~a'" echo-sep pdf-temp working-directory temp-ltx-path))
β(if (system command)
(file->bytes (build-path working-directory (format "~a.pdf" pdf-temp)))
(error "xelatex: rendering error"))