-
Notifications
You must be signed in to change notification settings - Fork 0
/
manuscript.latex
278 lines (219 loc) · 7.96 KB
/
manuscript.latex
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
271
272
273
274
275
276
277
%
% manuscript.latex
%
% Copyright (c) 2022 Don Melton
%
% LaTeX template for Pandoc to create PDFs in standard manuscript format
% with both short story and novel layouts.
%
% Version: 2022052301
%
% Usage:
% pandoc in.md --pdf-engine xelatex --template manuscript.latex -o out.pdf
%
% YAML metadata or Pandoc command line options are used for configuration.
%
% Basic keys:
% title: full title (default: Untitled)
% author: pen name (default: Unknown)
% wordcount: formatted and rounded number string
% surname: last name in numbered page header ("author" if defined)
% keyword: shortened title in numbered page header ("title" if defined)
% version: optional label centered in page footer
% novel: boolean to select novel layout instead of default short story
%
% Contact information keys:
% name: full name (can be "author" if defined)
% address: street address
% location: city, state and zip code
% phone: telephone number
% email: email address
% extra: optional extra information
%
% Appearance keys:
% mainfont: main document font (default: Times New Roman)
% monofont: mono document font (default: Courier New)
% underline: boolean to use underline instead of italic for emphasis
% papername: document size (default: letterpaper)
% margin: document margin on all four sides (default: 1.1in)
% uppercase: boolean to uppercase all titles
% subtitles: boolean to use paired second- and third-level chapter titles
%
% Pandoc "title-meta," "author-meta," "header-includes," "include-before"
% and "include-after" variables are also supported.
%
% Markdown conversion:
% "# Text" book part or chapter title
% "## Text" chapter title
% "### Text" sub-chapter title
% "***" scene break rendered as "#" character
%
% Avoid using block quotations, lists, verbatim blocks, tables, footnotes
% or other non-typical fiction manuscript content.
%
% BEGIN PROLOGUE
% configure document to use 12-point text
\documentclass[12pt]{scrartcl}
% configure document fonts
\usepackage{fontspec}
\setmainfont{$if(mainfont)$$mainfont$$else$Times New Roman$endif$}
\setmonofont{$if(monofont)$$monofont$$else$Courier New$endif$}
% dynamically configure allowing strikeout text and/or
% optionally configure using underline instead of italic text for emphasis
$if(strikeout)$
\usepackage[$if(underline)$$else$normalem$endif$]{ulem}
$elseif(underline)$
\usepackage[ULforem]{ulem}
$endif$
% configure document size and margin
% use 1.41-inch margin for 25 lines of text per page
\usepackage[
$if(papername)$$papername$$else$letterpaper$endif$,
margin=$if(margin)$$margin$$else$1.1in$endif$
]{geometry}
% enable fancy header and footer
\usepackage{fancyhdr}
\pagestyle{fancy}
% enable double spacing
\usepackage{setspace}
\doublespacing
% configure all sections to use same font and font size as paragraph text
\usepackage{sectsty}
\allsectionsfont{\normalfont\normalsize\nohang\centering\selectfont
$if(uppercase)$\MakeUppercase$endif$}
% required package for some conditional logic
\usepackage{ifthen}
% use counter to ensure only one chapter is visible per page
\newcounter{chaptercount}
% create alias for starting chapter page
\newcommand{\startchapter}{\clearpage\vspace*{144pt}}
% configure top-level sections ("# Text" in Markdown)
\RedeclareSectionCommand[
beforeskip=0sp,
afterskip=24pt,
font=\ifthenelse{\equal{\thepage}{1}}
% on first numbered page: start new page if not first chapter
{\ifthenelse{\equal{\value{chaptercount}}{0}}{}{\startchapter}}
% on other numbered page: always start chapter on new page
{\startchapter}
\normalfont\normalsize\nohang\centering\selectfont
% increment chapter count
\stepcounter{chaptercount}
$if(uppercase)$\MakeUppercase$endif$]{section}
% configure second-level sections ("## Text" in Markdown)
\RedeclareSectionCommand[
beforeskip=0sp,
afterskip=$if(subtitles)$1sp$else$24pt$endif$,
font=\ifthenelse{\equal{\thepage}{1}}
% on first numbered page: start new page if not first chapter
{\ifthenelse{\equal{\value{chaptercount}}{0}}{}{\startchapter}}
% on other numbered page: always start chapter on new page
{\startchapter}
\normalfont\normalsize\nohang\centering\selectfont
% increment chapter count
\stepcounter{chaptercount}
$if(uppercase)$\MakeUppercase$endif$]{subsection}
% configure third-level sections ("### Text" in Markdown)
\RedeclareSectionCommand[
beforeskip=24pt,
afterskip=24pt,
font=\normalfont\normalsize\nohang\centering\selectfont
$if(uppercase)$\MakeUppercase$endif$]{subsubsection}
% don't number sections
\setcounter{secnumdepth}{0}
% configure PDF metadata
\usepackage{hyperref}
$if(title-meta)$\hypersetup{pdftitle={$title-meta$}}$endif$
$if(author-meta)$\hypersetup{pdfauthor={$author-meta$}}$endif$
% configure lists
\providecommand{\tightlist}{
\setlength{\itemsep}{0sp}\setlength{\parskip}{0sp}
}
% configure tables
$if(tables)$\usepackage{longtable,booktabs,array}$endif$
% replace any horizonal rule ("***" in Markdown) with "#" character
\renewcommand{\rule}[2]{\#}
% force first line of all sections be indented to match paragraphs
\usepackage{indentfirst}
% disable default header rule
\renewcommand{\headrulewidth}{0sp}
% disable left-side header
\lhead{}
% configure right-side header
% hide it on first page of short stories and title page of novels
\rhead{\ifthenelse{\equal{\thepage}{$if(novel)$0$else$1$endif$}}{}{
$if(surname)$$surname$$elseif(author)$$author$$else$Unknown$endif$~/~%
$if(uppercase)$\MakeUppercase$endif$%
{$if(keyword)$$keyword$$elseif(title)$$title$$else$Untitled$endif$}~/~%
\thepage
}}
% configure center footer for optional version string
\cfoot{$if(version)$$version$$endif$}
% required for boolean commands
\usepackage{etoolbox}
% insert Pandoc header content here
$for(header-includes)$
$header-includes$
$endfor$
% END PROLOGUE / BEGIN DOCUMENT
\begin{document}
% disable default paragraph indent
\setlength\parindent{0pt}
% temporarily disable double spacing BEFORE minipage
\begin{singlespace}
% begin minipage with rigid height allowing flexible content
\begin{minipage}[c][144pt][t]{\textwidth}
% use "author" as "name" only if another contact information field is defined
\newbool{showauthor}\booltrue{showauthor}
$if(address)$$elseif(location)$$elseif(phone)$$elseif(email)$$elseif(extra)$
$else$\boolfalse{showauthor}$endif$
% insert contact information along with word count for short stories
$if(name)$$name$$elseif(author)$\ifbool{showauthor}{$author$}$endif$
$if(novel)$$elseif(wordcount)$\hfill About $wordcount$ words$endif$
$if(address)$$address$$endif$
$if(location)$$location$$endif$
$if(phone)$$phone$$endif$
$if(email)$$email$$endif$
$if(extra)$$extra$$endif$
% end rigid-height minipage
\end{minipage}
% restore double spacing AFTER minipage
\end{singlespace}
% center everything in title area for short story and entire page for novel
\begin{center}
% insert manuscript title
$if(uppercase)$\MakeUppercase$endif${$if(title)$$title$$else$Untitled$endif$}
% insert author byline
by $if(author)$$author$$else$Unknown$endif$
$if(novel)$ % FOR NOVEL
% fill remainder of page with blank space to position word count at bottom
$if(wordcount)$\vfill About $wordcount$ words$endif$
% change title page number to "0" so next page will be "1"
\setcounter{page}{0}
% force title page completion drawing any headers and footers
\clearpage
% insert vertical space to align with other chapter page titles
\vspace*{132pt}
$else$ % FOR STORY
% insert vertical space before start of story
\vspace{48pt}
$endif$ % FOR BOTH
% titling complete so disable centering
\end{center}
% disable default justification
\raggedright
\raggedbottom
% configure paragraph indent AFTER setting justification
\setlength\parindent{.5in}
% insert Pandoc before-body content here
$for(include-before)$
$include-before$
$endfor$
% insert Pandoc formatted body content here
$body$
% insert Pandoc after-body content here
$for(include-after)$
$include-after$
$endfor$
% END DOCUMENT
\end{document}