-
Notifications
You must be signed in to change notification settings - Fork 2
/
skeleton_standalone.Rmd
1089 lines (978 loc) · 27.7 KB
/
skeleton_standalone.Rmd
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
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
---
title: Template for RFMO working papers
author:
- name: Alice Anonymous
email: [email protected]
corresponding_author: TRUE # Automatic author note including email address
affiliation:
- ABC
- DEF
- name: Bob Security
email: [email protected]
affiliation: DEF
footnote: 1 # Author note using reference
- name: Cat Memes
email: [email protected]
affiliation: Another University
footnote:
- 1
- 2
address:
- code: ABC
address: University of Somewhere
- code: DEF
address: Address in one element deprecated, but works
- code: Another University
address: Address for Another University
footnote:
- code: 1
text: "Equal contribution"
- code: 2
text: "Current email address: [[email protected]](mailto:[email protected])"
#classoptions:
# - a4paper # Can also be here
bibliography: mybibfile.bib
csl: dmk-format.csl # Use any CSL style. Ignored if citation_package: natbib
link-citations: TRUE
output:
pdf_document:
keep_tex: TRUE
template: generic_template.tex
md_extensions: "-autolink_bare_uris"
number_sections: TRUE
citation_package: default # Can also be "natbib"
lang: en # Main document language in BCP47 format
geometry: "margin=25mm"
papersize: a4
#linestretch: 2 # for double spacing
endfloat: TRUE
# endfloatoption:
# - tablesfirst # Default
# - nomarkers # Default
numberlines: FALSE
authblk: FALSE # Set to false to put author affiliations in footnotes
footnotehyper: FALSE # Needed to be able to use French blocks
urlcolor: blue
linkcolor: blue
citecolor: blue
graphics: TRUE
tables: TRUE
fancyhdr:
first:
headleft: "Report No. 1"
headright: "Kaplan et al. (2021)"
headrulewidth: 0pt
#footleft: A left foot
footrulewidth: 0pt
subsequent:
headright: "*Kaplan et al. (2021)*" # Italics
headrulewidth: 1pt
footrulewidth: 0pt
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE) # By default, hide code; set to TRUE to see code
knitr::opts_chunk$set(fig.pos = 'th') # Places figures at top or here
knitr::opts_chunk$set(out.width = '100%', dpi=300) # Figure resolution and size
knitr::opts_chunk$set(fig.env="figure") # Latex figure environment
options(knitr.table.format="latex") # For kable tables to work without setting format option
# If package not installed, install it
if (!requireNamespace("knitrdata")) {
if (!requireNamespace("remotes"))
install.packages("remotes")
remotes::install_github("dmkaplan2000/knitrdata",build_vignettes = TRUE)
}
library(knitrdata) # load package
```
::: {.abstract data-latex="" lang=en}
An abstract text.
Second paragraph.
:::
::: {.keywords data-latex="" lang=en}
Keyword1; Keyword2
:::
<!-- Define as portuguese as spanish causes weird failure -->
<!-- Use class renameableabstract to give abstract a different title -->
::: {.renameableabstract data-latex="[Resumen]" lang=pt}
Un poco de texto.
:::
::: {.keywords data-latex="[Palabras Claves]" lang=pt}
Palabra1; Palabra2
:::
::: {.abstract data-latex="" lang=fr}
Un peu de texte.
:::
::: {.keywords data-latex="[Mots clés]" lang=fr}
Mot1; Mot2
:::
# Introduction
This template is a generic paper template that can be used for lots of tasks, including creating working group papers and as a starter format for publications for which one has not yet decided on a final format.
## A subsection
A numbered list:
1) First point
2) Second point
- Subpoint
A bullet list:
* First point
* Second point
# Literature citations
By default, citations are handled using CSQL style files, but `natbib` citations are also possible.
Here are two sample references:
* **author (year) example:** @horvath2018dna showed some really cool things.
* **(author year) example:** This is a well known result [@ji20123d].
The bibliography will appear at the end of the document.
# Equations
An equation without a label for cross-referencing:
$$
E=mc^2
$$
An inline equation: $y=ax+b$
An equation with a label for cross-referencing:
\begin{equation}\label{eq:eq1}
\int^{r_2}_0 F(r,\varphi){\rm d}r\,{\rm d}\varphi = 1
\end{equation}
This equation can be referenced as follows: Eq. \ref{eq:eq1}
# Inserting R figures
The code below creates a figure. The code is included in the output because `echo=TRUE`.
```{r fig1, fig.cap="This is the first figure.",echo=TRUE}
plot(1:10,main="Some data",xlab="Distance (cm)",
ylab="Time (hours)")
```
You can reference this figure as follows: Fig. \ref{fig:fig1}.
# Tables
## Generate a table using `xtable`
```{r xtabletable, results="asis", echo=TRUE}
df = data.frame(ID=1:3,code=letters[1:3])
# Creates tables that follow OUP guidelines
# using xtable
library(xtable)
print(xtable(df,caption="This is a xtable table.",
label="tab:tab1"),
comment=FALSE,caption.placement="top")
```
You can reference this table as follows: Table \ref{tab:tab1}.
## Generate a table using `kable`
```{r kabletable, echo=TRUE}
df = data.frame(ID=1:3,code=letters[1:3])
# kable can alse be used for creating tables
knitr::kable(df,caption="This is a kable table.",
#format="latex",
booktabs=TRUE,label="tab2")
```
You can reference this table as follows: Table \ref{tab:tab2}.
# Cross-referencing sections
You can cross-reference sections and subsections as follows: Section \ref{literature-citations} and Section \ref{a-subsection}.
For more portable and flexible referencing of sections, equations, figures and tables, use [`bookdown::pdf_document2`](https://github.com/rstudio/bookdown).
***Note:*** the last section in the document will be used as the section title for the bibliography.
<!-- An unnumbered section with the acknowledgements-->
# Acknowledgements {-}
This is an acknowledgement.
It consists of two paragraphs.
# References
<!-- Don't edit after this point. Creates latex template for document. -->
```{data generictemplatetex, format = "text", encoding = "asis", output.file = "generic_template.tex", echo = FALSE, eval=!file.exists("generic_template.tex"),line.sep="\n"}
% Options for packages loaded elsewhere
\PassOptionsToPackage{unicode$for(hyperrefoptions)$,$hyperrefoptions$$endfor$}{hyperref}
\PassOptionsToPackage{hyphens}{url}
$if(colorlinks)$
\PassOptionsToPackage{dvipsnames,svgnames,x11names}{xcolor}
$endif$
$if(dir)$
$if(latex-dir-rtl)$
\PassOptionsToPackage{RTLdocument}{bidi}
$endif$
$endif$
$if(CJKmainfont)$
\PassOptionsToPackage{space}{xeCJK}
$endif$
%
\documentclass[
$if(fontsize)$
$fontsize$,
$endif$
$if(lang)$
$babel-lang$,
$endif$
$if(papersize)$
$papersize$paper,
$endif$
$if(beamer)$
ignorenonframetext,
$if(handout)$
handout,
$endif$
$if(aspectratio)$
aspectratio=$aspectratio$,
$endif$
$endif$
$for(classoption)$
$classoption$$sep$,
$endfor$
]{$documentclass$}
$if(beamer)$
$if(background-image)$
\usebackgroundtemplate{%
\includegraphics[width=\paperwidth]{$background-image$}%
}
$endif$
\usepackage{pgfpages}
\setbeamertemplate{caption}[numbered]
\setbeamertemplate{caption label separator}{: }
\setbeamercolor{caption name}{fg=normal text.fg}
\beamertemplatenavigationsymbols$if(navigation)$$navigation$$else$empty$endif$
$for(beameroption)$
\setbeameroption{$beameroption$}
$endfor$
% Prevent slide breaks in the middle of a paragraph
\widowpenalties 1 10000
\raggedbottom
$if(section-titles)$
\setbeamertemplate{part page}{
\centering
\begin{beamercolorbox}[sep=16pt,center]{part title}
\usebeamerfont{part title}\insertpart\par
\end{beamercolorbox}
}
\setbeamertemplate{section page}{
\centering
\begin{beamercolorbox}[sep=12pt,center]{part title}
\usebeamerfont{section title}\insertsection\par
\end{beamercolorbox}
}
\setbeamertemplate{subsection page}{
\centering
\begin{beamercolorbox}[sep=8pt,center]{part title}
\usebeamerfont{subsection title}\insertsubsection\par
\end{beamercolorbox}
}
\AtBeginPart{
\frame{\partpage}
}
\AtBeginSection{
\ifbibliography
\else
\frame{\sectionpage}
\fi
}
\AtBeginSubsection{
\frame{\subsectionpage}
}
$endif$
$endif$
$if(beamerarticle)$
\usepackage{beamerarticle} % needs to be loaded first
$endif$
\usepackage{amsmath,amssymb}
$if(fontfamily)$
\usepackage[$for(fontfamilyoptions)$$fontfamilyoptions$$sep$,$endfor$]{$fontfamily$}
$else$
\usepackage{lmodern}
$endif$
$if(linestretch)$
\usepackage{setspace}
$endif$
\usepackage{iftex}
\ifPDFTeX
\usepackage[$if(fontenc)$$fontenc$$else$T1$endif$]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{textcomp} % provide euro and other symbols
\else % if luatex or xetex
$if(mathspec)$
\ifXeTeX
\usepackage{mathspec}
\else
\usepackage{unicode-math}
\fi
$else$
\usepackage{unicode-math}
$endif$
\defaultfontfeatures{Scale=MatchLowercase}
\defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1}
$if(mainfont)$
\setmainfont[$for(mainfontoptions)$$mainfontoptions$$sep$,$endfor$]{$mainfont$}
$endif$
$if(sansfont)$
\setsansfont[$for(sansfontoptions)$$sansfontoptions$$sep$,$endfor$]{$sansfont$}
$endif$
$if(monofont)$
\setmonofont[$for(monofontoptions)$$monofontoptions$$sep$,$endfor$]{$monofont$}
$endif$
$for(fontfamilies)$
\newfontfamily{$fontfamilies.name$}[$for(fontfamilies.options)$$fontfamilies.options$$sep$,$endfor$]{$fontfamilies.font$}
$endfor$
$if(mathfont)$
$if(mathspec)$
\ifXeTeX
\setmathfont(Digits,Latin,Greek)[$for(mathfontoptions)$$mathfontoptions$$sep$,$endfor$]{$mathfont$}
\else
\setmathfont[$for(mathfontoptions)$$mathfontoptions$$sep$,$endfor$]{$mathfont$}
\fi
$else$
\setmathfont[$for(mathfontoptions)$$mathfontoptions$$sep$,$endfor$]{$mathfont$}
$endif$
$endif$
$if(CJKmainfont)$
\ifXeTeX
\usepackage{xeCJK}
\setCJKmainfont[$for(CJKoptions)$$CJKoptions$$sep$,$endfor$]{$CJKmainfont$}
\fi
$endif$
$if(luatexjapresetoptions)$
\ifLuaTeX
\usepackage[$for(luatexjapresetoptions)$$luatexjapresetoptions$$sep$,$endfor$]{luatexja-preset}
\fi
$endif$
$if(CJKmainfont)$
\ifLuaTeX
\usepackage[$for(luatexjafontspecoptions)$$luatexjafontspecoptions$$sep$,$endfor$]{luatexja-fontspec}
\setmainjfont[$for(CJKoptions)$$CJKoptions$$sep$,$endfor$]{$CJKmainfont$}
\fi
$endif$
\fi
$if(zero-width-non-joiner)$
%% Support for zero-width non-joiner characters.
\makeatletter
\def\zerowidthnonjoiner{%
% Prevent ligatures and adjust kerning, but still support hyphenating.
\texorpdfstring{%
\textormath{\nobreak\discretionary{-}{}{\kern.03em}%
\ifvmode\else\nobreak\hskip\z@skip\fi}{}%
}{}%
}
\makeatother
\ifPDFTeX
\DeclareUnicodeCharacter{200C}{\zerowidthnonjoiner}
\else
\catcode`^^^^200c=\active
\protected\def ^^^^200c{\zerowidthnonjoiner}
\fi
%% End of ZWNJ support
$endif$
$if(beamer)$
$if(theme)$
\usetheme[$for(themeoptions)$$themeoptions$$sep$,$endfor$]{$theme$}
$endif$
$if(colortheme)$
\usecolortheme{$colortheme$}
$endif$
$if(fonttheme)$
\usefonttheme{$fonttheme$}
$endif$
$if(mainfont)$
\usefonttheme{serif} % use mainfont rather than sansfont for slide text
$endif$
$if(innertheme)$
\useinnertheme{$innertheme$}
$endif$
$if(outertheme)$
\useoutertheme{$outertheme$}
$endif$
$endif$
% Use upquote if available, for straight quotes in verbatim environments
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
\IfFileExists{microtype.sty}{% use microtype if available
\usepackage[$for(microtypeoptions)$$microtypeoptions$$sep$,$endfor$]{microtype}
\UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
}{}
$if(indent)$
$else$
\makeatletter
\@ifundefined{KOMAClassName}{% if non-KOMA class
\IfFileExists{parskip.sty}{%
\usepackage{parskip}
}{% else
\setlength{\parindent}{0pt}
\setlength{\parskip}{6pt plus 2pt minus 1pt}}
}{% if KOMA class
\KOMAoptions{parskip=half}}
\makeatother
$endif$
$if(verbatim-in-note)$
\usepackage{fancyvrb}
$endif$
\usepackage{xcolor}
\IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available
\IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}}
\hypersetup{
$if(title-meta)$
pdftitle={$title-meta$},
$endif$
$if(author-meta)$
pdfauthor={$author-meta$},
$endif$
$if(lang)$
pdflang={$lang$},
$endif$
$if(subject)$
pdfsubject={$subject$},
$endif$
$if(keywords)$
pdfkeywords={$for(keywords)$$keywords$$sep$, $endfor$},
$endif$
$if(colorlinks)$
colorlinks=true,
linkcolor={$if(linkcolor)$$linkcolor$$else$Maroon$endif$},
filecolor={$if(filecolor)$$filecolor$$else$Maroon$endif$},
citecolor={$if(citecolor)$$citecolor$$else$Blue$endif$},
urlcolor={$if(urlcolor)$$urlcolor$$else$Blue$endif$},
$else$
hidelinks,
$endif$
pdfcreator={LaTeX via pandoc}}
\urlstyle{same} % disable monospaced font for URLs
$if(verbatim-in-note)$
\VerbatimFootnotes % allow verbatim text in footnotes
$endif$
$if(geometry)$
$if(beamer)$
\geometry{$for(geometry)$$geometry$$sep$,$endfor$}
$else$
\usepackage[$for(geometry)$$geometry$$sep$,$endfor$]{geometry}
$endif$
$endif$
$if(beamer)$
\newif\ifbibliography
$endif$
$if(listings)$
\usepackage{listings}
\newcommand{\passthrough}[1]{#1}
\lstset{defaultdialect=[5.3]Lua}
\lstset{defaultdialect=[x86masm]Assembler}
$endif$
$if(lhs)$
\lstnewenvironment{code}{\lstset{language=Haskell,basicstyle=\small\ttfamily}}{}
$endif$
$if(highlighting-macros)$
$highlighting-macros$
$endif$
$if(tables)$
\usepackage{longtable,booktabs,array}
$if(multirow)$
\usepackage{multirow}
$endif$
\usepackage{calc} % for calculating minipage widths
$if(beamer)$
\usepackage{caption}
% Make caption package work with longtable
\makeatletter
\def\fnum@table{\tablename~\thetable}
\makeatother
$else$
% Correct order of tables after \paragraph or \subparagraph
\usepackage{etoolbox}
\makeatletter
\patchcmd\longtable{\par}{\if@noskipsec\mbox{}\fi\par}{}{}
\makeatother
% Allow footnotes in longtable head/foot
$if(footnotehyper)$
\IfFileExists{footnotehyper.sty}{\usepackage{footnotehyper}}{\usepackage{footnote}}
$else$
\usepackage{footnote} % For some unknown reason, footnotehyper clashes with French
$endif$
\makesavenoteenv{longtable}
$endif$
$endif$
$if(graphics)$
\usepackage{graphicx}
\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}
% Set default figure placement to htbp
\makeatletter
\def\fps@figure{htbp}
\makeatother
$endif$
$if(links-as-notes)$
% Make links footnotes instead of hotlinks:
\DeclareRobustCommand{\href}[2]{#2\footnote{\url{#1}}}
$endif$
$if(strikeout)$
$-- also used for underline
\usepackage[normalem]{ulem}
% Avoid problems with \sout in headers with hyperref
\pdfstringdefDisableCommands{\renewcommand{\sout}{}}
$endif$
\setlength{\emergencystretch}{3em} % prevent overfull lines
\providecommand{\tightlist}{%
\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
$if(numbersections)$
\setcounter{secnumdepth}{$if(secnumdepth)$$secnumdepth$$else$5$endif$}
$else$
\setcounter{secnumdepth}{-\maxdimen} % remove section numbering
$endif$
$if(beamer)$
$else$
$if(block-headings)$
% Make \paragraph and \subparagraph free-standing
\ifx\paragraph\undefined\else
\let\oldparagraph\paragraph
\renewcommand{\paragraph}[1]{\oldparagraph{#1}\mbox{}}
\fi
\ifx\subparagraph\undefined\else
\let\oldsubparagraph\subparagraph
\renewcommand{\subparagraph}[1]{\oldsubparagraph{#1}\mbox{}}
\fi
$endif$
$endif$
$if(pagestyle)$
\pagestyle{$pagestyle$}
$endif$
$if(csl-refs)$
\newlength{\cslhangindent}
\setlength{\cslhangindent}{1.5em}
\newlength{\csllabelwidth}
\setlength{\csllabelwidth}{3em}
\newlength{\cslentryspacingunit} % times entry-spacing
\setlength{\cslentryspacingunit}{\parskip}
\newenvironment{CSLReferences}[2] % #1 hanging-ident, #2 entry spacing
{% dont indent paragraphs
\setlength{\parindent}{0pt}
% turn on hanging indent if param 1 is 1
\ifodd #1
\let\oldpar\par
\def\par{\hangindent=\cslhangindent\oldpar}
\fi
% set entry spacing
\setlength{\parskip}{#2\cslentryspacingunit}
}%
{}
\usepackage{calc}
\newcommand{\CSLBlock}[1]{#1\hfill\break}
\newcommand{\CSLLeftMargin}[1]{\parbox[t]{\csllabelwidth}{#1}}
\newcommand{\CSLRightInline}[1]{\parbox[t]{\linewidth - \csllabelwidth}{#1}\break}
\newcommand{\CSLIndent}[1]{\hspace{\cslhangindent}#1}
$endif$
%%%%%%%% START HEADER PARTIAL %%%%%%%%%%%%
% Formatting of tables & knitr::kable and kableExtra functionality
\usepackage{float}
\usepackage{colortbl}
\usepackage{pdflscape}
\usepackage{tabu}
\usepackage{threeparttable}
% Line numbering
$if(numberlines)$
\usepackage$if(numberlines-options)$[$numberlines-options[,]$]$endif${lineno}
\linenumbers
$endif$
% endfloat stuff
$if(endfloat)$
\usepackage[$if(endfloatoption)$$for(endfloatoption)$$endfloatoption$$sep$,$endfor$$else$tablesfirst,nomarkers$endif$]{endfloat}
$endif$
% fancyhdr pagestyle
$if(fancyhdr)$
\usepackage{fancyhdr}
$if(fancyhdr.first)$
\fancypagestyle{myfirst}{%
\fancyfoot[C]{\thepage}% Default to just page number
%
$if(fancyhdr.first.headleft)$
\fancyhead[L]{$fancyhdr.first.headleft$}%
$endif$
$if(fancyhdr.first.headcenter)$
\fancyhead[C]{$fancyhdr.first.headcenter$}%
$endif$
$if(fancyhdr.first.headright)$
\fancyhead[R]{$fancyhdr.first.headright$}%
$endif$
$if(fancyhdr.first.headrulewidth)$
\renewcommand{\headrulewidth}{$fancyhdr.first.headrulewidth$}
$endif$
%
$if(fancyhdr.first.footleft)$
\fancyfoot[L]{$fancyhdr.first.footleft$}%
$endif$
$if(fancyhdr.first.footcenter)$
\fancyfoot[C]{$fancyhdr.first.footcenter$}%
$endif$
$if(fancyhdr.first.footright)$
\fancyfoot[R]{$fancyhdr.first.footright$}%
$endif$
$if(fancyhdr.first.footrulewidth)$
\renewcommand{\footrulewidth}{$fancyhdr.first.footrulewidth$}
$endif$
}
$endif$
$if(fancyhdr.subsequent)$
\fancypagestyle{mysubsequent}{%
\fancyfoot[C]{\thepage}% Default to just page number
%
$if(fancyhdr.subsequent.headleft)$
\fancyhead[L]{$fancyhdr.subsequent.headleft$}%
$endif$
$if(fancyhdr.subsequent.headcenter)$
\fancyhead[C]{$fancyhdr.subsequent.headcenter$}%
$endif$
$if(fancyhdr.subsequent.headright)$
\fancyhead[R]{$fancyhdr.subsequent.headright$}%
$endif$
$if(fancyhdr.subsequent.headrulewidth)$
\renewcommand{\headrulewidth}{$fancyhdr.subsequent.headrulewidth$}
$endif$
%
$if(fancyhdr.subsequent.footleft)$
\fancyfoot[L]{$fancyhdr.subsequent.footleft$}%
$endif$
$if(fancyhdr.subsequent.footcenter)$
\fancyfoot[C]{$fancyhdr.subsequent.footcenter$}%
$endif$
$if(fancyhdr.subsequent.footright)$
\fancyfoot[R]{$fancyhdr.subsequent.footright$}%
$endif$
$if(fancyhdr.subsequent.footrulewidth)$
\renewcommand{\footrulewidth}{$fancyhdr.subsequent.footrulewidth$}
$endif$
}
$endif$
$endif$
% Environment for keywords
\makeatletter
\newcommand\keywordsname{Keywords}
\newenvironment*{keywords}[1][\keywordsname]{\if@twocolumn \else \small \quotation \fi \textbf{\textit{#1 ---}}}{\if@twocolumn \else \small \endquotation \fi}
\makeatother
% Environment for abstract that takes new abstract name
\newenvironment{renameableabstract}[1][\abstractname]{\let\oldabstractname\abstractname \renewcommand{\abstractname}{#1} \begin{abstract}}{\end{abstract} \renewcommand{\abstractname}{\oldabstractname}}
%%%%%%%% END HEADER PARTIAL %%%%%%%%%%%%
$for(header-includes)$
$header-includes$
$endfor$
$if(lang)$
\ifXeTeX
% Load polyglossia as late as possible: uses bidi with RTL langages (e.g. Hebrew, Arabic)
\usepackage{polyglossia}
\setmainlanguage[$for(polyglossia-lang.options)$$polyglossia-lang.options$$sep$,$endfor$]{$polyglossia-lang.name$}
$for(polyglossia-otherlangs)$
\setotherlanguage[$for(polyglossia-otherlangs.options)$$polyglossia-otherlangs.options$$sep$,$endfor$]{$polyglossia-otherlangs.name$}
$endfor$
\else
\usepackage[$for(babel-otherlangs)$$babel-otherlangs$,$endfor$main=$babel-lang$]{babel}
% get rid of language-specific shorthands (see #6817):
\let\LanguageShortHands\languageshorthands
\def\languageshorthands#1{}
$if(babel-newcommands)$
$babel-newcommands$
$endif$
\fi
$endif$
\ifLuaTeX
\usepackage{selnolig} % disable illegal ligatures
\fi
$if(dir)$
\ifXeTeX
% Load bidi as late as possible as it modifies e.g. graphicx
\usepackage{bidi}
\fi
\ifPDFTeX
\TeXXeTstate=1
\newcommand{\RL}[1]{\beginR #1\endR}
\newcommand{\LR}[1]{\beginL #1\endL}
\newenvironment{RTL}{\beginR}{\endR}
\newenvironment{LTR}{\beginL}{\endL}
\fi
$endif$
$if(natbib)$
\usepackage[$natbiboptions$]{natbib}
\bibliographystyle{$if(biblio-style)$$biblio-style$$else$plainnat$endif$}
$endif$
$if(biblatex)$
\usepackage[$if(biblio-style)$style=$biblio-style$,$endif$$for(biblatexoptions)$$biblatexoptions$$sep$,$endfor$]{biblatex}
$for(bibliography)$
\addbibresource{$bibliography$}
$endfor$
$endif$
$if(nocite-ids)$
\nocite{$for(nocite-ids)$$it$$sep$, $endfor$}
$endif$
$if(csquotes)$
\usepackage{csquotes}
$endif$
$if(title)$
\title{$title$$if(thanks)$\thanks{$thanks$}$endif$}
$endif$
$if(subtitle)$
$if(beamer)$
$else$
\usepackage{etoolbox}
\makeatletter
\providecommand{\subtitle}[1]{% add subtitle to \maketitle
\apptocmd{\@title}{\par {\large #1 \par}}{}{}
}
\makeatother
$endif$
\subtitle{$subtitle$}
$endif$
%%%%%%% START AUTHOR PARTIAL %%%%%%%%%%%%%%%
%%%%% Authors, affiliations and author notes stuff %%%%%
% Macros for creating and referencing stored reference
\makeatletter
\def\MyNewLabel#1#2#3{\expandafter\gdef\csname #1@#2\endcsname{#3}}
\def\MyRef#1#2{\@ifundefined{#1@#2}{???}{\csname #1@#2\endcsname}}
\newcommand*\ifcounter[1]{%
\ifcsname c@#1\endcsname
\expandafter\@firstoftwo
\else
\expandafter\@secondoftwo
\fi
}
\makeatother
% Create labels for Addresses if the are given by code
$for(address)$
\MyNewLabel{ADDRTXT}{$address.code$}{$address.address$}
$endfor$
% Create labels for Footnotes if they are given by code
$for(footnote)$
\MyNewLabel{ANOTETXT}{$footnote.code$}{$footnote.text$}
$endfor$
%%% Special footnotes for addresses and author footnotes
\usepackage{bigfoot}
\DeclareNewFootnote{Addr}[arabic] % Only used for NOT authblk
\DeclareNewFootnote{ANote}[fnsymbol]
%%% Address and author notes as a function of format %%%
$if(authblk)$ % Use authblk for affiliations %%%%%%%%%%%
\usepackage{authblk}
% Always separate by commas
\renewcommand\Authsep{, }
\renewcommand\Authand{, }
\renewcommand\Authands{, }
% Counter for addresses and footnotes
\newcounter{addrcnt}
% thanks definition that doesnt produce superscript marks
\makeatletter
\newcommand*\createaddrlblbycode[1]{%
\ifcounter{ADDRLBL@#1}
{}
{\refstepcounter{addrcnt}\newcounter{ADDRLBL@#1}\setcounter{ADDRLBL@#1}{\value{addrcnt}}}%
}
\newcommand*\addrlblbycode[1]{\arabic{ADDRLBL@#1}}
\newcommand*\addrbycode[1]{%
\ifcounter{ADDR@#1}
{}
{\newcounter{ADDR@#1}%
\affil[\addrlblbycode{#1}]{\MyRef{ADDRTXT}{#1}}}%
}
\newcommand*\createanotelblbycode[1]{%
\ifcounter{ANOTELBL@#1}
{}
{\refstepcounter{footnoteANote}\newcounter{ANOTELBL@#1}\setcounter{ANOTELBL@#1}{\value{footnoteANote}}}%
}
\newcommand*\anotelblbycode[1]{\fnsymbol{ANOTELBL@#1}}
\newcommand*\anotebycode[1]{%
\ifcounter{ANOTE@#1}
{}
{\newcounter{ANOTE@#1}%
\footnotetextANote[\value{ANOTELBL@#1}]{\MyRef{ANOTETXT}{#1}}}%
}
\makeatother
$for(author)$
$for(author.affiliation)$
\createaddrlblbycode{$author.affiliation$}
$endfor$
$if(author.corresponding_author)$
\MyNewLabel{ANOTETXT}{$author.name$@CORRESP}{Corresponding author. \href{mailto:$author.email$}{\nolinkurl{$author.email$}}}
\makeatletter\createanotelblbycode{$author.name$@CORRESP}\makeatother
$endif$
$for(author.footnote)$
\createanotelblbycode{$author.footnote$}
$endfor$
\author[%
$for(author.affiliation)$
\addrlblbycode{$author.affiliation$}%
$sep$,%
$endfor$
$if(author.corresponding_author)$
$if(author.affiliation)$,$endif$%
\makeatletter\anotelblbycode{$author.name$@CORRESP}\makeatother
$endif$
$if(author.footnote)$
$if(author.corresponding_author)$,$elseif(author.affiliation)$,$endif$%
$for(author.footnote)$
$$\anotelblbycode{$author.footnote$}$$%
$sep$,%
$endfor$
$endif$
]{$author.name$}
$for(author.affiliation)$
\addrbycode{$author.affiliation$}
$endfor$
$endfor$
$else$ % Use footnotes for affiliations %%%%%%%%%%%%%
% Get rid of redefinition of \@makefnmark in \maketitle
% Gets rid of spacing issues
\usepackage{etoolbox}
\makeatletter
\patchcmd\maketitle{\def\@makefnmark{\rlap{\@textsuperscript{\normalfont\@thefnmark}}}}{}{}{}
\makeatother
% Hook into the \@thanks command
\makeatletter
\def\thanksAddr#1{% <--- These %'s are necessary for spacing
\footnotemarkAddr\protected@xdef\@thanks{\@thanks%
\protect\footnotetextAddr[\the \c@footnoteAddr]{#1}}%
}
\def\thanksANote#1{%
\footnotemarkANote%
\protected@xdef\@thanks{\@thanks%
\protect\footnotetextANote[\the \c@footnoteANote]{#1}}%
}
\newcommand*\thanksAddrbycode[1]{%
\ifcounter{ADDR@#1}
{\footnotemarkAddr[\value{ADDR@#1}]}
{\newcounter{ADDR@#1}%
\thanksAddr{\MyRef{ADDRTXT}{#1}}%
\setcounter{ADDR@#1}{\value{footnoteAddr}}} % Note sure this will work
}
\newcommand*\thanksANotebycode[1]{%
\ifcounter{ANOTE@#1}
{\footnotemarkANote[\value{ANOTE@#1}]}
{\newcounter{ANOTE@#1}%
\thanksANote{\MyRef{ANOTETXT}{#1}}%
\setcounter{ANOTE@#1}{\value{footnoteANote}}} % Note sure this will work
}
\makeatother
\newcommand*\authsep{, }
\newcommand*\thankssep{$$^{,}$$}
$if(author)$
\author{%
$for(author)$
$author.name$%
$for(author.affiliation)$
\thanksAddrbycode{$author.affiliation$}%
$sep$\thankssep%
$endfor$
$if(author.corresponding_author)$
$if(author.affiliation)$\thankssep$endif$% extra comma
\thanksANote{Corresponding author. \href{mailto:$author.email$}{\nolinkurl{$author.email$}}} % space here seems necessary to get spacing right
$endif$
$if(author.footnote)$$if(author.affiliation)$\thankssep$elseif(author.corresponding_author)$\thankssep$endif$$endif$% extra comma
$for(author.footnote)$
\thanksANotebycode{$author.footnote$}%
$sep$\thankssep%
$endfor$
$sep$\authsep%
$endfor$
}
$endif$%endif(author)
$endif$%endif(authblk)
%%%%%%%%% END AUTHOR PARTIAL %%%%%%%%
\date{$date$}
$if(beamer)$
$if(institute)$
\institute{$for(institute)$$institute$$sep$ \and $endfor$}
$endif$
$if(titlegraphic)$
\titlegraphic{\includegraphics{$titlegraphic$}}
$endif$
$if(logo)$
\logo{\includegraphics{$logo$}}
$endif$
$endif$
\begin{document}
$if(has-frontmatter)$
\frontmatter
$endif$
$if(title)$
$if(beamer)$
\frame{\titlepage}
$else$
\maketitle
$endif$
%%%%%%%%%% START AFTER TITLE PARTIAL %%%%%%%%%%%%%
$if(authblk)$
$for(author)$
$if(author.corresponding_author)$
\makeatletter\anotebycode{$author.name$@CORRESP}\makeatother
$endif$
$for(author.footnote)$
\anotebycode{$author.footnote$}
$endfor$
$endfor$
$endif$
$if(fancyhdr.first)$
\thispagestyle{myfirst}
$endif$
$if(fancyhdr.subsequent)$
\pagestyle{mysubsequent}
$endif$