-
Notifications
You must be signed in to change notification settings - Fork 675
/
latexmkrc
438 lines (386 loc) · 8.69 KB
/
latexmkrc
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
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
# -*- mode: perl; -*-
$DRAFTON = $ENV{DRAFTON};
$DRAFTON //= '';
$SHOWMARKUP = $ENV{SHOWMARKUP};
$SHOWMARKUP //= '';
$FONTFAMILY = $ENV{FONTFAMILY};
$FONTFAMILY //= '';
$ALTFONT = $ENV{ALTFONT};
$ALTFONT //= '';
$USEBIBER = $ENV{USEBIBER};
$USEBIBER //= '';
$USEFOOTCITE = $ENV{USEFOOTCITE};
$USEFOOTCITE //= '';
$BIBGROUPED = $ENV{BIBGROUPED};
$BIBGROUPED //= '';
$IMGCOMPILE = $ENV{IMGCOMPILE};
$IMGCOMPILE //= '';
$NOTESON = $ENV{NOTESON};
$NOTESON //= '';
$LATEXFLAGS = $ENV{LATEXFLAGS};
$LATEXFLAGS //= '';
$BIBERFLAGS = $ENV{BIBERFLAGS};
$BIBERFLAGS //= '';
$REGEXDIRS = $ENV{REGEXDIRS};
$REGEXDIRS //= '. Dissertation Synopsis Presentation';
$TIMERON = $ENV{TIMERON};
$TIMERON //= '0';
$TIKZFILE = $ENV{TIKZFILE};
$TIKZFILE //= '';
$USEDEV = $ENV{USEDEV};
$USEDEV //= '';
$texargs = '';
if ($DRAFTON ne '') {
$texargs = $texargs . '\newcounter{draft}' .
'\setcounter{draft}' . '{' . $DRAFTON . '}';
}
if ($SHOWMARKUP ne '') {
$texargs = $texargs . '\newcounter{showmarkup}' .
'\setcounter{showmarkup}' . '{' . $SHOWMARKUP . '}';
}
if ($FONTFAMILY ne '') {
$texargs = $texargs . '\newcounter{fontfamily}' .
'\setcounter{fontfamily}' . '{' . $FONTFAMILY . '}';
}
if ($ALTFONT ne '') {
$texargs = $texargs . '\newcounter{usealtfont}' .
'\setcounter{usealtfont}' . '{' . $ALTFONT . '}';
}
if ($USEBIBER ne '') {
$texargs = $texargs . '\newcounter{bibliosel}' .
'\setcounter{bibliosel}' . '{' . $USEBIBER . '}';
}
if ($USEFOOTCITE ne '') {
$texargs = $texargs . '\newcounter{usefootcite}' .
'\setcounter{usefootcite}' . '{' . $USEFOOTCITE . '}';
}
if ($BIBGROUPED ne '') {
$texargs = $texargs . '\newcounter{bibgrouped}' .
'\setcounter{bibgrouped}' . '{' . $BIBGROUPED . '}';
}
if ($IMGCOMPILE ne '') {
$texargs = $texargs . '\newcounter{imgprecompile}' .
'\setcounter{imgprecompile}' . '{' . $IMGCOMPILE . '}';
}
if ($IMGCOMPILE ne '') {
$LATEXFLAGS = $LATEXFLAGS . ' -shell-escape'
}
if ($NOTESON ne '') {
$texargs = $texargs . '\newcounter{presnotes}' .
'\setcounter{presnotes}' . '{' . $NOTESON . '}';
}
if ($TIKZFILE ne '') {
$texargs = $texargs . '\def' . '\tikzfilename' .
'{' . $TIKZFILE . '}';
}
# set options for all *latex
if ( (! defined &set_tex_cmds) || (! defined $pre_tex_code) ) {
if ($xelatex_default_switches eq '') { # for latexmk < 4.59
$xelatex_default_switches = '-no-pdf';
}
$tex_cmds = $LATEXFLAGS . ' %O ' . $texargs . '\input{%T}';
$pdflatex = 'pdflatex ' . $tex_cmds;
$xelatex = 'xelatex ' . $tex_cmds;
$lualatex = 'lualatex ' . $tex_cmds;
} else { # for latexmk >= 4.61
set_tex_cmds($LATEXFLAGS . ' %O %P');
$pre_tex_code = $texargs;
}
if ($USEDEV ne '') {
$pdflatex =~ s/pdflatex/pdflatex-dev/g;
$xelatex =~ s/xelatex/xelatex-dev/g;
$lualatex =~ s/lualatex/lualatex-dev/g;
}
$biber = 'biber ' . $BIBERFLAGS . ' %O %S';
$bibtex = 'bibtex8 -B -c utf8cyrillic.csf %B';
# set to 1 to count CPU time
$show_time = $TIMERON;
# maximum number of passes
$max_repeat = 7;
# record access files
$recorder = 1;
# delete bibtex generated files
$bibtex_use = 2;
# extensions to clean with -c flag
$clean_ext = '%R.bbl %R.aux %R.lof %R.log %R.lot %R.fls %R.out %R.toc %R.run.xml %R.xdv %R.snm %R.nav %R.fmt %R.nls %R.nlo';
# extensions to clean with -C flag
$clean_full_ext = '%R.bbl %R.aux %R.lof %R.log %R.lot %R.fls %R.out %R.toc %R.run.xml %R.xdv %R.snm %R.nav %R.nls %R.nlo';
# this option is for debugging
# 0 to silently delete files, 1 to show what would be deleted
$remove_dryrun = 0;
## Core latex/pdflatex auxiliary files:
@clean_regexp = ('*.aux',
'*.lof',
'*.log',
'*.lot',
'*.fls',
'*.out',
'*.toc',
'*.fmt');
## Intermediate documents:
# these rules might exclude image files for figures etc.
# *.ps
# *.eps
# *.pdf
push(@clean_regexp,
'*.dvi',
'*-converted-to.*',
'*xdv'
);
## Bibliography auxiliary files (bibtex/biblatex/biber):
push(@clean_regexp,
'*.bbl',
'*.bcf',
'*.blg',
'*-blx.aux',
'*-blx.bib',
'*.brf',
'*.run.xml'
);
## Build tool auxiliary files:
push(@clean_regexp,
'*.fdb_latexmk',
'*.synctex',
'*.synctex.gz',
'*.synctex.gz\(busy\)',
'*.pdfsync',
);
## Auxiliary and intermediate files from other packages:
# algorithms
push(@clean_regexp,
'*.alg',
'*.loa',
);
# achemso
push(@clean_regexp,
'acs-*.bib',
);
# amsthm
push(@clean_regexp,
'*.thm',
);
# beamer
push(@clean_regexp,
'*.nav',
'*.snm',
'*.vrb',
);
#(e)ledmac/(e)ledpar
push(@clean_regexp,
'*.end',
'*.[1-9]',
'*.[1-9][0-9]',
'*.[1-9][0-9][0-9]',
'*.[1-9]R',
'*.[1-9][0-9]R',
'*.[1-9][0-9][0-9]R',
'*.eledsec[1-9]',
'*.eledsec[1-9]R',
'*.eledsec[1-9][0-9]',
'*.eledsec[1-9][0-9]R',
'*.eledsec[1-9][0-9][0-9]',
'*.eledsec[1-9][0-9][0-9]R',
);
# glossaries
push(@clean_regexp,
'*.acn',
'*.acr',
'*.glg',
'*.glo',
'*.gls',
);
# gnuplottex
push(@clean_regexp,
'*-gnuplottex-*',
);
# hyperref
push(@clean_regexp,
'*.brf',
);
# knitr
push(@clean_regexp,
'*-concordance.tex',
'*-tikzDictionary',
);
# '*.tikz',
# listings
push(@clean_regexp,
'*.lol',
);
# makeidx
push(@clean_regexp,
'*.idx',
'*.ilg',
'*.ind',
'*.ist',
);
# minitoc
push(@clean_regexp,
'*.maf',
'*.mtc',
'*.mtc[0-9]',
'*.mtc[1-9][0-9]',
);
# minted
push(@clean_regexp,
'_minted*',
'*.pyg',
);
# morewrites
push(@clean_regexp,
'*.mw',
);
# mylatexformat
push(@clean_regexp,
'*.fmt',
);
# nomencl
push(@clean_regexp,
'*.nlo',
);
# sagetex
push(@clean_regexp,
'*.sagetex.sage',
'*.sagetex.py',
'*.sagetex.scmd',
);
# sympy
push(@clean_regexp,
'*.sout',
'*.sympy',
);
# sympy-plots-for-*.tex/
# pdfcomment
push(@clean_regexp,
'*.upa',
'*.upb',
);
# pythontex
push(@clean_regexp,
'*.pytxcode',
);
# pythontex-files-*/
# Texpad
push(@clean_regexp,
'.texpadtmp',
);
# TikZ & PGF
push(@clean_regexp,
'*.dpth',
'*.md5',
'*.auxlock',
);
# todonotes
push(@clean_regexp,
'*.tdo',
);
# xindy
push(@clean_regexp,
'*.xdy',
);
# WinEdt
push(@clean_regexp,
'*.bak',
'*.sav',
);
# GnuEmacs
push(@clean_regexp,
'*~',
);
# endfloat
push(@clean_regexp,
'*.ttt',
'*.fff',
'*.aux',
'*.bbl',
'*.blg',
'*.dvi',
'*.fdb_latexmk',
'*.fls',
'*.glg',
'*.glo',
'*.gls',
'*.idx',
'*.ilg',
'*.ind',
'*.ist',
'*.lof',
'*.log',
'*.lot',
'*.nav',
'*.nlo',
'*.out',
'*.pdfsync',
'*.ps',
'*.snm',
'*.synctex.gz',
'*.toc',
'*.vrb',
'*.maf',
'*.mtc',
'*.mtc0',
'*.bak',
'*.bcf',
'*.run.xml',
);
# latexindent backup
push(@clean_regexp,
'*.bak[0-9]',
);
# compressed pdf file
push(@clean_regexp,
'*_compressed.pdf',
);
# biber tool
push(@clean_regexp,
'bibcheck.log',
'*_bibertool.bib',
);
########################################################
# functions
# Custom dependency and function for nomencl package
add_cus_dep( 'nlo', 'nls', 0, 'makenlo2nls' );
sub makenlo2nls {
system( "makeindex -s nomencl.ist -o \"$_[0].nls\" \"$_[0].nlo\"" );
}
sub regexp_cleanup {
my @clean_regexp_dirs = split /(?<=\s)/, $REGEXDIRS;
foreach my $dir (@clean_regexp_dirs) {
$dir =~ s/^\s*(.*?)\s*$/$1/;
foreach my $pattern (@clean_regexp)
{
my @files = glob "$dir/$pattern";
foreach my $file (@files) {
if ($remove_dryrun == 0) {
unlink_or_move( glob( "$file" ) );
} else {
print "Would be removed: $file\n";
}
}
}
}
}
{
no warnings 'redefine';
sub cleanup1 {
# Usage: cleanup1( directory, exts_without_period, ... )
#
# The directory and the root file name are fixed names, so I must escape
# any glob metacharacters in them:
my $dir = fix_pattern( shift );
my $root_fixed = fix_pattern( $root_filename );
foreach (@_) {
my $name = /%R/ ? $_ : "%R.$_";
$name =~ s/%R/${root_fixed}/;
$name = $dir.$name;
if ($remove_dryrun == 0) {
unlink_or_move( glob( "$name" ) );
} else {
print "Would be removed: $name\n";
}
}
if ($cleanup_mode == 1) {
regexp_cleanup();
}
} #END cleanup1
}