-
Notifications
You must be signed in to change notification settings - Fork 0
/
texmakefile
362 lines (279 loc) · 9.49 KB
/
texmakefile
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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
export GITIGNORE_ALL
export DFD_STORE
export EMPTY_LHS
# ------------------------------------------------------------
# Verbosity
# ------------------------------------------------------------
why = printf "* texmakefile: $? -> $@\n"
# ------------------------------------------------------------
# how to call LaTeX
# ------------------------------------------------------------
pdfLatex = pdflatex -halt-on-error -interaction=errorstopmode
# handmade LaTeX call
LatexCrude = $(pdfLatex) $(<F)
# using latexmk to invoke texfot to invode pfdlatex
texIgnore = Overful|Underfull|Font Warning|This.is|Collected|Package|Latexmk
LatexMk = texfot --no-stderr --ignore "$(texIgnore)" --quiet latexmk -pdf -pdflatex=$(pdfLatex) $(<F)
Latex = $(LatexMk)
hline = @echo "------------------------------------------------------------"
indent = @printf "%-20s%s\n"
# ------------------------------------------------------------
# creating pdf files
# ------------------------------------------------------------
%.pdf: %.eps
@$(why)
ps2pdf -sPAPERSIZE=a3 $?
%.pdf: %.tex
@$(why)
cd $(@D) ; $(Latex) && touch $(@F)
@wmctrl -a $(notdir $@) || { echo No viewer running; }
# ------------------------------------------------------------
# creating image files via graphviz
# ------------------------------------------------------------
%.eps $(DOC)/%.eps: %.dot
@$(why)
dot -T eps -l dfd.ps $? -o $@
%.jpeg $(DOC)/%.jepg: %.dot
@$(why)
dot -T jpeg -l dfd.ps $? -o $@
# ------------------------------------------------------------
# Plain Haskell using a2ps
# ------------------------------------------------------------
$(DOC)/%.ps %.ps: %.hs
@$(why)
a2ps -g --prolog=color --columns=1 -R -o $@ funWithCurryHowardCorrespondence.hs
# ------------------------------------------------------------
# Literate-Haskell using lhs2TeX
# ------------------------------------------------------------
$(DOC)/%.tex %.tex: %.lhs
@$(why)
lhs2TeX --tt $? > $@
# ------------------------------------------------------------
# Haskell profiling
# ------------------------------------------------------------
%.heap: %.hs
@$(why)
# ghc -O2 -prof -auto-all -caf-all -fforce-recomp -rtsopts -o $(?:.hs=) $?
ghc -O2 -prof -caf-all -fforce-recomp -rtsopts -o $(?:.hs=) $?
# $(?:.hs=) +RTS -hc -p
$(?:.hs=) +RTS -hy -p
hp2ps -c -e8in $(?:.hs=.hp)
okular $(?:.hs=.ps) 2>/dev/null &
%.prof: %.hs
@$(why)
ghc -O2 -prof -auto-all -caf-all -rtsopts -fforce-recomp $?
$(@:.prof=) +RTS -p -RTS
# ------------------------------------------------------------
# Cleanup
# ------------------------------------------------------------
texFiles = *.pdf *.dvi *.fdb_latexmk *.fls *.toc *.aux *.lof *.log
ghcFiles = *.hi *.o *.out *.prof heaptest* a.out
bakFiles = *~ xx*
tmpFiles = $(texFiles) $(ghcFiles) $(bakFiles)
clean:
@rm -fv $(tmpFiles) $(addprefix $(DOC)/,$(tmpFiles)) $(TEXFILES)
# ------------------------------------------------------------
# Miscellaneous
# ------------------------------------------------------------
#%.view: %.pdf # open pdfviewer
# "C:/Program Files/SumatraPDF/sumatrapdf" $? &
view: $(.DEFAULT_GOAL) # open pdf
@okular $? 2>$(basename $?).okular-log &
# Helper for printing targets with awk
define awkTarget
if ($$0 !~ "^[# :]" && $$0 !="") { \
split($$0,A,":"); \
printf ("%20s%-24s:%s\n", "", A[1], A[2]) \
}
endef
# list targets
list help:
$(hline)
$(indent) "Default goal:" "$(strip $(.DEFAULT_GOAL))"
$(indent) "Makefile list:" "$(strip $(MAKEFILE_LIST))"
$(hline)
@echo "Implicit rules: "
# $(MAKE) -pRrq -f $? : 2>/dev/null | awk -v RS= -F: '/^# Implicit Rules/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' #| sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$'
@$(MAKE) -pRrq -f makefile : 2>/dev/null | awk '/^# Implicit Rules/,/^# Files/ {$(awkTarget)}'
@echo "Files: "
@$(MAKE) -pRrq -f makefile : 2>/dev/null | awk '/^# Files/,/^# Finished Make data base/ {$(awkTarget)}'
$(hline)
# ------------------------------------------------------------
# verbatim files
# ------------------------------------------------------------
%.docnew:
mkdir doc
echo "$$GITIGNORE_ALL" > doc/.gitignore
# dataflow diagram ps file
%.dfdnew:
echo "$$DFD_STORE" > $(dir $@)/dfd.ps
%.lhsnew:
echo "$$EMPTY_LHS" > $(@:.lhsnew=.lhs)
# --- postscript file for dataflow store component (dfd.ps) ---
define DFD_STORE
/dfd_store {
{
4 ne { stop } if % sanity-check number of sides
aload pop
pop pop
8 4 roll
moveto
lineto
lineto
lineto
fill
}
{
4 ne { stop } if % sanity-check number of sides
aload pop
pop pop
8 4 roll
moveto
lineto
moveto
lineto
stroke
}
ifelse
} bind def
endef
# --- empty lhs document ---
define EMPTY_LHS
\\documentclass[a4paper]{article}
% ==================== lhs2TeX setup ====================
%include lhs2TeX.fmt
%include greek.fmt
%options ghci -fglasgow-exts
% ==================== graphics ====================
% include eps, png png and jpg via \\includegraphics
\\usepackage{graphicx}
% --- draw graphics right in the document
\\usepackage{tikz}
\\usepackage{pgf}
\\usetikzlibrary{arrows,mindmap,backgrounds}
\\usetikzlibrary{calc}
\\usetikzlibrary{decorations}
\\usetikzlibrary{plotmarks}
\\usetikzlibrary{arrows}
\\usetikzlibrary{chains,fit,shapes}
% ==================== Formatting ====================
% --- CommonFormatting uses Verbatim (not verbatim) from fancyvrb
\\usepackage{fancyvrb}
% --- Common useful packages
\\usepackage{needspace}
\\usepackage{amsmath}
% --- put vertical space between paragraphs
\\usepackage[parfill]{parskip}
% --- print 1st, 2nd, 2rd with correct superscript
\\usepackage[super]{nth}
% --- better versions of enumerate, itemize and description
\\usepackage{enumitem}
\\setlist[description]{leftmargin=3cm,style=sameline}
% ---- hyperlinks
\\usepackage{hyperref}
\\hypersetup{colorlinks=true, linkcolor=blue, pdftoolbar=true}
% --- format source code
%\\usepackage{listing}
%\\usepackage{xcolor}
% --- tables
\\usepackage{ctable}
%\\usepackage{capt-of}
%\\usepackage{colortbl}
% --- frames
%\\usepackage[framemethod=tikz]{mdframed}
% --- alingn
% \\s= puts more space around euqls sign
\\newcommand\\s[1]{\\quad{#1} \\quad}
% ==================== page layout ====================
% --- Put chapter names in header
\\usepackage{fancyhdr}
\\pagestyle{fancy}
% --- hyphenation and justification
\\usepackage{ragged2e}
%\\setlength{\\RaggedRightRightskip}{1em} % agressive
\\setlength{\\RaggedRightRightskip}{3em} % medium
%\\setlength{\\RaggedRightRightskip}{5em} % relaxed
% Put \\RaggedRight after \\begin{document}
% --- start each section on a new page
\\usepackage{titlesec}
\\newcommand{\\sectionbreak}{\\needspace{24em}}
% ==================== multi language and unicode ====================
% --- Text companion fonts
%\\usepackage{textcomp}
% --- unicode
% Searchable unicode characters:
% http://xahlee.info/comp/unicode_index.html
% For LaTeX symbols, see
% https://oeis.org/wiki/List_of_LaTeX_mathematical_symbols
\\usepackage[utf8]{inputenc}
\\newcommand{\\myOperator}[2] {
\\DeclareUnicodeCharacter{#1}{\\ifmmode{\\small#2}\\else{\\boldmath\\small$#2$}\\fi}
}
% ⊕ = 2295
\\myOperator{2295}{\\oplus}
% ⊖ = 2296
\\myOperator{2296}{\\ominus}
% ⊗ = 2297
\\myOperator{2297}{\\otimes}
% ⊘ = 2298
\\myOperator{2298}{\\oslash}
% ⊙ = 2299
\\myOperator{2299}{\\odot}
% ∙ = 2219
\\myOperator{2219}{\\bullet}
% --- language and hyphenation
\\usepackage[english]{babel}
% Put \\selectlanguage{english} after \\begin{document} in
% multil-language documents (rare)
% ==================== environments ====================
% --- a quote environement with a sans font
\\newenvironment{sfquote}{\\begin{quote}\\sffamily}{\\end{quote}}
% --- intermediate headers, not in TOC
\\newcommand{\\head}[1]{\\needspace{4em}\\medskip\\textsf{\\textbf{#1}}\\par}
% --- put something into a box titled "Example"
%\\newmdenv[frametitle=Example,skipabove=1em,backgroundcolor=gray!05,roundcorner=2pt]{run}
% ==================== end ====================
\\author{Martin Drautzburg}
\\title{How Infections Spread
}
\\begin{document}
\\RaggedRight
\\maketitle
\\begin{abstract}
We present simple simulation about the spread of an infection. It
computes the number of deaths and the spread of immunity over
time. Using the simulation, We examine the effect of Social Distancing
on the death toll.
This paper contains the full source code of the simulation.
\\end{abstract}
\\tableofcontents
\\listoffigures
\\listoftables
To get the number of new infections, we must multiply with the number
of susceptibles $S$.
\\begin{align}
dI & \\s= S \\cdot \\left[1 - (1 - R_c)^{C \\frac{I}{P}}\\right] \\nonumber\\\\
& \\s= S \\cdot \\left[1 - e^{C \\frac{I}{P} ln(1 - R_c)}\\right] \\label{equB}
\\end{align}
\\begin{figure}[htb!]
\\centering
\\begin{tikzpicture}[domain=0:100, scale=1, x=1cm, y=1cm,font=\\sffamily\\small]
\\begin{scope}[very thin,color=gray]
\\draw[xstep=1cm, ystep=0.5cm] (0,-1) grid (6.5,1);
\\foreach \\x in {1,2,3,4,5,6}
\\draw(\\x,-1) -- (\\x,-1.1) node[below] {$\\x$};
\\foreach \\y in {-1,-0.5,0,0.5,1}
\\draw(-0,\\y) -- (-0.1,\\y) node[left] {$\\y$};
\\end{scope}
\\perform{draw "orange, thick" exSin}
\\perform{draw "blue, thick" exCos}
\\end{tikzpicture}
\\caption{Example output of plot}
\\end{figure}
endef
define GITIGNORE_ALL
# Ignore everything in this directory
*
# Except this file
!.gitignore
endef