├── .gitignore ├── README.md ├── mlmacros.cwl ├── mlmacros.pdf ├── mlmacros.py ├── mlmacros.sty ├── mlmacros.tex ├── nonpaperheader.tex ├── opinion.pdf ├── opinion.tex ├── secs ├── mlmacros │ ├── autocomplete.tex │ ├── operators.tex │ ├── probdists.tex │ ├── style.tex │ ├── subindexing.tex │ ├── syntacticsugar.tex │ └── variables.tex └── opinion │ ├── bibliography.tex │ ├── goldenrules.tex │ ├── math.tex │ ├── misc.tex │ ├── systemsetup.tex │ └── versioncontrol.tex └── standardheader.tex /.gitignore: -------------------------------------------------------------------------------- 1 | ## Core latex/pdflatex auxiliary files: 2 | *.aux 3 | *.lof 4 | *.log 5 | *.lot 6 | *.fls 7 | *.out 8 | *.toc 9 | *.fmt 10 | *.fot 11 | *.cb 12 | *.cb2 13 | 14 | ## Intermediate documents: 15 | *.dvi 16 | *-converted-to.* 17 | # these rules might exclude image files for figures etc. 18 | # *.ps 19 | # *.eps 20 | # *.pdf 21 | 22 | ## Bibliography auxiliary files (bibtex/biblatex/biber): 23 | *.bbl 24 | *.bcf 25 | *.blg 26 | *-blx.aux 27 | *-blx.bib 28 | *.brf 29 | *.run.xml 30 | 31 | ## Build tool auxiliary files: 32 | *.fdb_latexmk 33 | *.synctex 34 | *.synctex.gz 35 | *.synctex.gz(busy) 36 | *.pdfsync 37 | 38 | ## Auxiliary and intermediate files from other packages: 39 | # algorithms 40 | *.alg 41 | *.loa 42 | 43 | # achemso 44 | acs-*.bib 45 | 46 | # amsthm 47 | *.thm 48 | 49 | # beamer 50 | *.nav 51 | *.snm 52 | *.vrb 53 | 54 | # cprotect 55 | *.cpt 56 | 57 | # fixme 58 | *.lox 59 | 60 | #(r)(e)ledmac/(r)(e)ledpar 61 | *.end 62 | *.?end 63 | *.[1-9] 64 | *.[1-9][0-9] 65 | *.[1-9][0-9][0-9] 66 | *.[1-9]R 67 | *.[1-9][0-9]R 68 | *.[1-9][0-9][0-9]R 69 | *.eledsec[1-9] 70 | *.eledsec[1-9]R 71 | *.eledsec[1-9][0-9] 72 | *.eledsec[1-9][0-9]R 73 | *.eledsec[1-9][0-9][0-9] 74 | *.eledsec[1-9][0-9][0-9]R 75 | 76 | # glossaries 77 | *.acn 78 | *.acr 79 | *.glg 80 | *.glo 81 | *.gls 82 | *.glsdefs 83 | 84 | # gnuplottex 85 | *-gnuplottex-* 86 | 87 | # hyperref 88 | *.brf 89 | 90 | # knitr 91 | *-concordance.tex 92 | # TODO Comment the next line if you want to keep your tikz graphics files 93 | *.tikz 94 | *-tikzDictionary 95 | 96 | # listings 97 | *.lol 98 | 99 | # makeidx 100 | *.idx 101 | *.ilg 102 | *.ind 103 | *.ist 104 | 105 | # minitoc 106 | *.maf 107 | *.mlf 108 | *.mlt 109 | *.mtc 110 | *.mtc[0-9] 111 | *.mtc[1-9][0-9] 112 | 113 | # minted 114 | _minted* 115 | *.pyg 116 | 117 | # morewrites 118 | *.mw 119 | 120 | # mylatexformat 121 | *.fmt 122 | 123 | # nomencl 124 | *.nlo 125 | 126 | # sagetex 127 | *.sagetex.sage 128 | *.sagetex.py 129 | *.sagetex.scmd 130 | 131 | # sympy 132 | *.sout 133 | *.sympy 134 | sympy-plots-for-*.tex/ 135 | 136 | # pdfcomment 137 | *.upa 138 | *.upb 139 | 140 | # pythontex 141 | *.pytxcode 142 | pythontex-files-*/ 143 | 144 | # thmtools 145 | *.loe 146 | 147 | # TikZ & PGF 148 | *.dpth 149 | *.md5 150 | *.auxlock 151 | 152 | # todonotes 153 | *.tdo 154 | 155 | # xindy 156 | *.xdy 157 | 158 | # xypic precompiled matrices 159 | *.xyc 160 | 161 | # endfloat 162 | *.ttt 163 | *.fff 164 | 165 | # Latexian 166 | TSWLatexianTemp* 167 | 168 | ## Editors: 169 | # WinEdt 170 | *.bak 171 | *.sav 172 | 173 | # Texpad 174 | .texpadtmp 175 | 176 | # Kile 177 | *.backup 178 | 179 | # KBibTeX 180 | *~[0-9]* 181 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # tex 2 | This repository provides convenient and readable macros for commonly used syntax when writing scientific articles about machine learning. 3 | The functionality is in the package `mlmacros.sty`. 4 | The documentation can be found in `mlmacros.pdf`. 5 | 6 | Moreover, `opinion.pdf` provides some opinionated best practices gathered over the years. -------------------------------------------------------------------------------- /mlmacros.cwl: -------------------------------------------------------------------------------- 1 | # TeXStudio auto-completion for the custom LaTeX package msoelch. 2 | # Last updated 2016-06-16. 3 | # To be saved in %appdata%\texstudio\completion\user (Windows). 4 | \wrt 5 | \ie 6 | \Ie 7 | \eg 8 | \Eg 9 | \etc 10 | 11 | \NN 12 | \RR 13 | \PP 14 | \EE 15 | \ind 16 | \mcX 17 | \mcU 18 | \mcZ 19 | \mcD 20 | \data 21 | 22 | \relmiddle 23 | \midd 24 | \shallbe 25 | \dint 26 | 27 | \abs{arg} 28 | \set{arg} 29 | \interval{arg} 30 | \gauss{arg} 31 | 32 | \kl{p}{q} 33 | \loss{arg} 34 | \loss[index]{arg} 35 | 36 | \variables{listofvariables} 37 | \probdists{listofprobdists} 38 | 39 | \expc{arg} 40 | \expc{arg}{cond} 41 | \expc[index]{arg} 42 | \expc[index]{arg}{cond} 43 | \var{arg} 44 | \var{arg}{cond} 45 | \var[index]{arg} 46 | \var[index]{arg}{cond} 47 | \loss{arg} 48 | \loss{arg}{cond} 49 | \loss[index]{arg} 50 | \loss[index]{arg}{cond} 51 | \cost{arg} 52 | \cost{arg}{cond} 53 | \cost[index]{arg} 54 | \cost[index]{arg}{cond} 55 | \entropy{arg} 56 | \entropy{arg}{cond} 57 | \entropy[index]{arg} 58 | \entropy[index]{arg}{cond} 59 | 60 | \expc*{arg} 61 | \expc*{arg}{cond} 62 | \expc*[index]{arg} 63 | \expc*[index]{arg}{cond} 64 | \var*{arg} 65 | \var*{arg}{cond} 66 | \var*[index]{arg} 67 | \var*[index]{arg}{cond} 68 | \loss*{arg} 69 | \loss*{arg}{cond} 70 | \loss*[index]{arg} 71 | \loss*[index]{arg}{cond} 72 | \cost*{arg} 73 | \cost*{arg}{cond} 74 | \cost*[index]{arg} 75 | \cost*[index]{arg}{cond} 76 | \entropy*{arg} 77 | \entropy*{arg}{cond} 78 | \entropy*[index]{arg} 79 | \entropy*[index]{arg}{cond} 80 | 81 | \magic 82 | \magic{fix} 83 | \magically 84 | \magically{fix} 85 | \addref 86 | \addref{listofrefs} 87 | 88 | \eq{alignbody} 89 | \numberthis 90 | 91 | \shortminus 92 | \shortplus 93 | 94 | \tminus 95 | \tplus 96 | \Tminus 97 | \Tplus 98 | \tsub{idx} 99 | \tsub{from}{to} 100 | \ts 101 | \tm 102 | \tp 103 | \tsm 104 | \tsp 105 | \Ts 106 | \Tm 107 | \Tp 108 | \Tsm 109 | \Tsp 110 | 111 | 112 | \p{arg} 113 | \p{arg}{cond} 114 | \p[index]{arg} 115 | \p[index]{arg}{cond} 116 | 117 | \p*{arg} 118 | \p*{arg}{cond} 119 | \p*[index]{arg} 120 | \p*[index]{arg}{cond} 121 | 122 | \q{arg} 123 | \q{arg}{cond} 124 | \q[index]{arg} 125 | \q[index]{arg}{cond} 126 | 127 | \q*{arg} 128 | \q*{arg}{cond} 129 | \q*[index]{arg} 130 | \q*[index]{arg}{cond} -------------------------------------------------------------------------------- /mlmacros.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/msoelch/tex/21496ec3731882c045eb0ae174086d5898602b8c/mlmacros.pdf -------------------------------------------------------------------------------- /mlmacros.py: -------------------------------------------------------------------------------- 1 | """Naval Fate. 2 | 3 | Usage: 4 | mlmacros variables [--macros=] [--main_file=

] [--variables_file=] [--typora] 5 | mlmacros -h | --help 6 | 7 | Options: 8 | --main_file= main 9 | -h --help Show this screen. 10 | """ 11 | import docopt 12 | import os 13 | 14 | 15 | typora_header = """% % % % % % % % 16 | % typora mlmacros light 17 | % % % % % % % % 18 | \\newcommand{\\ts}{_{1:t}} 19 | \\newcommand{\\tm}{_{t-1}} 20 | \\newcommand{\\tp}{_{t+1}} 21 | \\newcommand{\\tsm}{_{1:t-1}} 22 | \\newcommand{\\tsp}{_{1:t+1}} 23 | 24 | \\newcommand{\\Ts}{_{1:T}} 25 | \\newcommand{\\Tm}{_{T-1}} 26 | \\newcommand{\\Tp}{_{T+1}} 27 | \\newcommand{\\Tsm}{_{1:T-1}} 28 | \\newcommand{\\Tsp}{_{1:T+1}} 29 | 30 | """ 31 | 32 | var_template = """% % % % % % % % 33 | % macro name: {var} 34 | % macro value: {macro} 35 | % % % % % % % % 36 | \\newcommand{{\\{var}}}{{{macro}}} 37 | \\newcommand{{\\{var}seq}}{{\\overline{{\\{var}}}}} 38 | \\newcommand{{\\{var}all}}{{\\{var}\Ts}} 39 | \\newcommand{{\\{var}past}}{{\\{var}\\tsm}} 40 | \\newcommand{{\\{var}filter}}{{\\{var}\\ts}} 41 | \\newcommand{{\\{var}future}}{{\\{var}\\tsub{{\\tplus1}}{{T}}}} 42 | 43 | \\newcommand{{\\b{var}}}{{\\boldsymbol{{\\mathbf{{\\{var}}}}}}} 44 | \\newcommand{{\\b{var}seq}}{{\\bar{{\\b{var}}}}} 45 | \\newcommand{{\\b{var}all}}{{\\b{var}\Ts}} 46 | \\newcommand{{\\b{var}past}}{{\\b{var}\\tsm}} 47 | \\newcommand{{\\b{var}filter}}{{\\b{var}\\ts}} 48 | \\newcommand{{\\b{var}future}}{{\\b{var}\\tsub{{\\tplus1}}{{T}}}} 49 | 50 | """ 51 | 52 | 53 | def get_file_paths(args): 54 | 55 | is_variables = args["variables"] 56 | filename = "variables.tex" 57 | 58 | main_file = args["--main_file"] 59 | variables_file = args["--variables_file"] 60 | 61 | if variables_file is None: 62 | if main_file is not None: 63 | target_dir = os.path.dirname(main_file) 64 | variables_file = os.path.join(target_dir, filename) 65 | 66 | return variables_file, main_file 67 | 68 | 69 | def write_to_file(preamble): 70 | variables_file, main_file = get_file_paths(args) 71 | 72 | if main_file is not None: 73 | raise NotImplementedError() 74 | 75 | if os.path.exists(variables_file) and os.path.getsize(variables_file) > 0: 76 | raise NotImplementedError("writing to a non-empty file is currently not supported.") 77 | else: 78 | with open(variables_file, 'w') as f: 79 | f.write(preamble) 80 | 81 | # the following is currently unreachable, unfinished code to support the 82 | # NotImplementedError scenarios. 83 | if main_file is not None: 84 | rel_variables_file = os.path.relpath( 85 | variables_file, start=os.path.dirname(main_file)) 86 | with open(main_file, "r+") as f: 87 | main_text = f.read() 88 | contains_mlmacros = "\\usepackage{mlmacros}" in main_text 89 | contains_filename = "\\input{{{filename}}}".format( 90 | filename=rel_variables_file) in main_text 91 | 92 | if not contains_mlmacros: 93 | main_text = main_text.replace( 94 | "\n\\begin{document}", 95 | "\n\\usepackage{mlmacros}\n\n\\begin{document}") 96 | with open(main_file, "r+") as f: 97 | f.write(main_text) 98 | 99 | if not contains_filename: 100 | main_text = main_text.replace( 101 | "\n\\begin{document}", 102 | "\n\\input{{{filename}}}\n\n\\begin{{document}}".format( 103 | filename=rel_variables_file)) 104 | 105 | if not contains_filename or not contains_mlmacros: 106 | with open(main_file, "r+") as f: 107 | f.write(main_text) 108 | 109 | 110 | if __name__ == "__main__": 111 | args = docopt.docopt(__doc__) 112 | 113 | # add simplified macros for typora 114 | if args["--typora"]: 115 | preamble = typora_header 116 | else: 117 | preamble = "" 118 | 119 | # make a dict with pairs variables and macros 120 | vars = args[""].split(",") 121 | if args["--macros"] is not None: 122 | macros = args["--macros"].split(",") 123 | assert len(vars) == len(macros), "different number of variables and macros" 124 | else: 125 | macros = vars 126 | vars_dict = {v: m for v, m in zip(vars, macros)} 127 | 128 | # add a block per variable 129 | for var, macro in vars_dict.items(): 130 | preamble += var_template.format(var=var, macro=macro) 131 | 132 | # put everything in a math block for typora 133 | if args["--typora"]: 134 | preamble = f"$$\n{preamble}$$" 135 | 136 | if args["--main_file"] is None and args["--variables_file"] is None: 137 | print(preamble) 138 | else: 139 | write_to_file(preamble) 140 | 141 | -------------------------------------------------------------------------------- /mlmacros.sty: -------------------------------------------------------------------------------- 1 | \NeedsTeXFormat{LaTeX2e}%[2015/01/01] % fixed via latexrelease package, see below 2 | \ProvidesPackage{mlmacros}[2018/06/26 custom frequently used machine learning commands] 3 | 4 | \usepackage{xparse} % necessary for hacking overloaded commands and iterating overlists 5 | \usepackage{xspace} 6 | \usepackage{mleftright} % for nicer spacing before \left in the presence of indices 7 | \mleftright % redefines \left and \right as \mleft and \mright 8 | \usepackage{amsfonts} % for \mathbb 9 | \usepackage{dsfont} % for mathbb style indicator function 1 10 | \usepackage{soul} % provides \texthl 11 | \usepackage{xcolor} 12 | \usepackage{relsize} % required for smaller math subscripts 13 | \usepackage{bm} % bold math for e.g. Greek symbols 14 | \usepackage{amsmath} 15 | 16 | \newcommand\numberthis{\addtocounter{equation}{1}\tag{\theequation}} 17 | 18 | % Convenient macros with correct spacing 19 | \DeclareRobustCommand\onedot{\futurelet\@let@token\@onedot} 20 | \def\@onedot{\ifx\@let@token.\else.\null\fi\xspace} 21 | 22 | \newcommand{\eg}{{e.\,g}\onedot} 23 | \newcommand{\Eg}{{E.\,g}\onedot} 24 | \newcommand{\ie}{{i.\,e}\onedot} 25 | \newcommand{\Ie}{{I.\,e}\onedot} 26 | \newcommand{\cf}{{cf}\onedot} 27 | \newcommand{\Cf}{{Cf}\onedot} 28 | \newcommand{\etc}{{etc}\onedot} 29 | \newcommand{\vs}{{vs}\onedot} 30 | \newcommand{\wrt}{w.\,r.\,t\onedot} 31 | \newcommand{\dof}{d.\,o.\,f\onedot} 32 | \newcommand{\etal}{{et al}\onedot} 33 | \newcommand{\NB}{N.\,B\onedot} 34 | \newcommand{\transpose}{^{\!\top\!}} 35 | \newcommand{\iid}{i.\,i.\,d\onedot} 36 | \makeatother 37 | 38 | \usepackage{cancel} % easy cancelling of terms: \cancel{expression} 39 | \renewcommand{\cancelto}[2]{\overset{#2}{\cancel{#1}}} 40 | \usepackage{pifont} 41 | \newcommand{\cmark}{\ding{51}\xspace}% 42 | \newcommand{\xmark}{\ding{55}\xspace}% 43 | \newcommand{\super}[1]{^{{(}#1{)}}} 44 | 45 | % Math macros 46 | \newcommand{\NN}{\ensuremath{\mathbb{N}}} 47 | \newcommand{\RR}{\ensuremath{\mathbb{R}}} 48 | \newcommand{\PP}{\ensuremath{\mathbb{P}}} 49 | \newcommand{\EE}{\ensuremath{\mathbb{E}}} 50 | \newcommand{\ind}{\ensuremath{\mathds{1}}} 51 | 52 | \newcommand{\mcX}{\ensuremath{\mathcal{X}}} 53 | \newcommand{\mcU}{\ensuremath{\mathcal{U}}} 54 | \newcommand{\mcZ}{\ensuremath{\mathcal{Z}}} 55 | \newcommand{\mcD}{\ensuremath{\mathcal{D}}} 56 | 57 | \newcommand{\data}{\mcD} 58 | 59 | \NewDocumentCommand{\grad}{e{_^}}{% 60 | \mathop{}\!% \mathop for good spacing before \nabla 61 | \nabla 62 | \IfValueT{#1}{_{\!#1}}% tuck in the subscript 63 | \IfValueT{#2}{^{#2}}% possible superscript 64 | } 65 | 66 | % https://tex.stackexchange.com/questions/5502/how-to-get-a-mid-binary-relation-that-grows 67 | \newcommand{\relmiddle}[1]{\mathrel{}\middle#1\mathrel{}} 68 | \DeclareDocumentCommand{\midd}{}{\relmiddle|} 69 | 70 | \DeclareDocumentCommand{\shallbe}{}{\mathbin{\overset{!}=}} 71 | \DeclareDocumentCommand{\dint}{}{\,\mathrm d} 72 | \DeclareDocumentCommand{\abs}{m}{{\left\lvert#1\right\rvert}} 73 | \DeclareDocumentCommand{\set}{m}{{\left\{#1\right\}}} 74 | \DeclareDocumentCommand{\interval}{m}{{\left[#1\right]}} 75 | \DeclareDocumentCommand{\divergence}{somm}{\ensuremath{\operatorname{D} 76 | \IfBooleanTF{#1} 77 | {\IfNoValueOrEmptyTF{#2}{}{_{#2}}(#3 \mid\mid #4)} 78 | {\IfNoValueOrEmptyTF{#2}{}{_{#2}}\mleft(#3\midd\midd#4\mright)} 79 | }} 80 | \DeclareDocumentCommand{\kl}{smm}{\ensuremath{\operatorname{KL} 81 | \IfBooleanTF{#1} 82 | {(#2 \mid\mid #3)} 83 | {\mleft(#2\midd\midd#3\mright)} 84 | }} 85 | 86 | % iterate over zip of two lists 87 | % original code http://tex.stackexchange.com/questions/12187/iterating-through-two-lists 88 | \usepackage{xstring} 89 | \usepackage{etoolbox} 90 | 91 | \def\forlistlooptwo#1#2#3{% 92 | \ifboolexpr{test{\IfSubStr{#2}{,}} and test{\IfSubStr{#3}{,}}}{% 93 | % Evaluate first pair and call back with reduced lists if there are at least two elements in each list.. 94 | \forlistlooptwohelper{#1}#2;#3;% 95 | }{% 96 | \ifboolexpr{test{\notblank{#2}} and test{\notblank{#3}}}{% 97 | % Evaluate last pair, if there is one element in each list. 98 | #1{#2}{#3}% 99 | }{}% 100 | }% 101 | } 102 | \def\forlistlooptwohelper#1#2,#3;#4,#5;{% 103 | % Call the handler with the first pair as the two arguments. 104 | #1{#2}{#4}% 105 | % Call the loop macro again with the lists reduced by the first pair. 106 | \forlistlooptwo{#1}{#3}{#5}% 107 | } 108 | %\newcommand{\shortminus}{\scalebox{0.5}[1.0]{\( - \)}} 109 | %\newcommand{\shortminus}{% 110 | % \setbox0=\hbox{-}% 111 | % \vcenter{% 112 | % \hrule width\wd0 height \the\fontdimen8\textfont3% 113 | % }% 114 | %} 115 | \newcommand{\shortminus}{\mathbin{\mathsmaller{-}}} 116 | \newcommand{\shortplus}{\mathbin{\mathsmaller{+}}} 117 | \newcommand{\tminus}{t\shortminus} 118 | \newcommand{\tplus}{t\shortplus} 119 | \newcommand{\Tminus}{T\shortminus} 120 | \newcommand{\Tplus}{T\shortplus} 121 | 122 | \DeclareDocumentCommand\tsub{m G{}}{ 123 | _{#1\IfNoValueOrEmptyTF{#2}{}{:#2}} 124 | } 125 | 126 | \newcommand{\ts}{\tsub{1}{t}} 127 | \DeclareDocumentCommand\tm{G{}}{\tsub{\tminus\IfNoValueOrEmptyTF{#1}{1}{#1}}} 128 | \DeclareDocumentCommand\tp{G{}}{\tsub{\tplus\IfNoValueOrEmptyTF{#1}{1}{#1}}} 129 | \DeclareDocumentCommand\tsm{G{}}{\tsub{1}{\tminus\IfNoValueOrEmptyTF{#1}{1}{#1}}} 130 | \DeclareDocumentCommand\tsp{G{}}{\tsub{1}{\tplus\IfNoValueOrEmptyTF{#1}{1}{#1}}} 131 | 132 | \newcommand{\Ts}{\tsub{1}{T}} 133 | \DeclareDocumentCommand\Tm{G{}}{\tsub{\Tminus\IfNoValueOrEmptyTF{#1}{1}{#1}}} 134 | \DeclareDocumentCommand\Tp{G{}}{\tsub{\Tplus\IfNoValueOrEmptyTF{#1}{1}{#1}}} 135 | \DeclareDocumentCommand\Tsm{G{}}{\tsub{1}{\Tminus\IfNoValueOrEmptyTF{#1}{1}{#1}}} 136 | \DeclareDocumentCommand\Tsp{G{}}{\tsub{1}{\Tplus\IfNoValueOrEmptyTF{#1}{1}{#1}}} 137 | 138 | 139 | \newcommand\mlbold[1]{% 140 | \ifcat\noexpand#1\relax % check if the argument is a control sequence 141 | \bm{#1}% probably Greek 142 | \else 143 | \mathbf{#1}% single character 144 | \fi 145 | } 146 | 147 | % add macros for time indices and include bold versions for vectors/matrices 148 | \newcommand{\varmacros}[2]{ 149 | %base 150 | \expandafter\def\csname #1\endcsname{\ensuremath{#2}} 151 | \expandafter\def\csname b#1\endcsname{\ensuremath{\mlbold{#2}}} 152 | % seq 153 | \expandafter\def\csname #1seq\endcsname{\ensuremath{\overline{\csname #1\endcsname}}} 154 | \expandafter\def\csname b#1seq\endcsname{\ensuremath{\overline{\csname b#1\endcsname}}} 155 | % all 156 | \expandafter\def\csname #1all\endcsname{\ensuremath{\csname #1\endcsname\Ts}} 157 | \expandafter\def\csname b#1all\endcsname{\ensuremath{\csname b#1\endcsname\Ts}} 158 | % past 159 | \expandafter\def\csname #1past\endcsname{\ensuremath{\csname #1\endcsname\tsm}} 160 | \expandafter\def\csname b#1past\endcsname{\ensuremath{\csname b#1\endcsname\tsm}} 161 | % future 162 | \expandafter\def\csname #1future\endcsname{\ensuremath{\csname #1\endcsname\tsub{\tplus1}{T}}} 163 | \expandafter\def\csname b#1future\endcsname{\ensuremath{\csname b#1\endcsname\tsub{\tplus1}{T}}} 164 | % filter 165 | \expandafter\def\csname #1filter\endcsname{\ensuremath{\csname #1\endcsname\ts}} 166 | \expandafter\def\csname b#1filter\endcsname{\ensuremath{\csname b#1\endcsname\ts}} 167 | } 168 | % \variables 169 | % loop over list and create respective commands 170 | % can be given optional arguments if escaped characters are to be used 171 | % e.g., \variables{a}--> \ba vs. \variables[m,a]{\mu, a} --> \bm, \ba 172 | \DeclareDocumentCommand{\variables}{om}{\IfValueTF{#1} 173 | {\forlistlooptwo{\varmacros}{#1}{#2}} 174 | {\forlistlooptwo{\varmacros}{#2}{#2}} 175 | } 176 | 177 | 178 | % \probdists 179 | % dynamically create overloaded command for probability distributions 180 | % mandatory argument is the argument of the distribution, e.g., 181 | % \MkProbDist{p} implies \p{x} 182 | % first optional argument is a conditional, second optional argument parametrizes the distribution as a subscript 183 | 184 | % define if statement that defaults to false even when the argument is just empty 185 | % this way, the overloaded function may be used with the third argument only with a different layout (e.g., if no argument is supplied, no brackets are needed) 186 | \ExplSyntaxOn 187 | \DeclareExpandableDocumentCommand{\IfNoValueOrEmptyTF}{mmm} 188 | { 189 | \IfNoValueTF{#1}{#2} 190 | { 191 | \tl_if_empty:nTF {#1} {#2} {#3} 192 | } 193 | } 194 | \ExplSyntaxOff 195 | 196 | \makeatletter 197 | \newcommand{\splitatbar}[1]{ 198 | \protected@edef\split@temp{#1}% 199 | \saveexpandmode 200 | \expandarg\StrCut{\split@temp}{|}{\thisarg}{\thiscond}% 201 | \restoreexpandmode 202 | } 203 | \makeatother 204 | 205 | \DeclareDocumentCommand{\overloadedfunction}{smoogmmg}{ 206 | #2\IfNoValueOrEmptyTF{#3}{}{_{#3}}\IfNoValueOrEmptyTF{#4}{}{^{#4}} 207 | \IfNoValueOrEmptyTF{#5} 208 | {} 209 | { 210 | \IfNoValueOrEmptyTF{#8} 211 | { 212 | \splitatbar{#5} 213 | } 214 | { % false part is for backward compat 215 | \def\thisarg{#5} 216 | \def\thiscond{#8} 217 | } 218 | \IfBooleanTF{#1} 219 | { 220 | \ifdefempty{\thiscond} {#6\thisarg#7} {#6\thisarg \mid \thiscond#7} 221 | } 222 | { 223 | \ifdefempty{\thiscond} {\mleft #6 \thisarg \mright #7} {\mleft#6 \thisarg \midd \thiscond \mright#7} 224 | } 225 | } 226 | } 227 | \newcommand{\MkProbDist}[2]{ 228 | \expandafter\DeclareDocumentCommand\csname#1\endcsname{sooG{}G{}}{\ensuremath{ 229 | \IfBooleanTF{##1} 230 | {\overloadedfunction*{#2}[##2][##3]{##4}{(}{)}{##5}} 231 | {\overloadedfunction{#2}[##2][##3]{##4}{(}{)}{##5}} 232 | }} 233 | } 234 | 235 | \DeclareDocumentCommand{\probdists}{om}{\IfValueTF{#1} 236 | {\forlistlooptwo{\MkProbDist}{#1}{#2}} 237 | {\forlistlooptwo{\MkProbDist}{#2}{#2}} 238 | } 239 | 240 | % \mi 241 | % overloaded command for mutual information 242 | \DeclareDocumentCommand\mi{soG{}}{\ensuremath{ 243 | \IfBooleanTF{#1} 244 | {\overloadedfunction*{\operatorname{MI}}[#2]{#3}{(}{)}} 245 | {\overloadedfunction{\operatorname{MI}}[#2]{#3}{(}{)}} 246 | }} 247 | 248 | % \expc 249 | % overloaded command for expected value 250 | \DeclareDocumentCommand\expc{soG{}}{\ensuremath{ 251 | \IfBooleanTF{#1} 252 | {\overloadedfunction*{\EE}[#2]{#3}{[}{]}} 253 | {\overloadedfunction{\EE}[#2]{#3}{[}{]}} 254 | }} 255 | 256 | % \var 257 | % overloaded command for variance 258 | \DeclareDocumentCommand\var{soG{}}{\ensuremath{ 259 | \IfBooleanTF{#1} 260 | {\overloadedfunction*{\operatorname{Var}}[#2]{#3}{[}{]}} 261 | {\overloadedfunction{\operatorname{Var}}[#2]{#3}{[}{]}} 262 | }} 263 | 264 | % \gauss 265 | \DeclareDocumentCommand{\gauss}{sm}{\ensuremath{ 266 | \IfBooleanTF{#1} 267 | { 268 | \overloadedfunction*{\mathcal{N}}{#2}{(}{)} 269 | } 270 | { 271 | \overloadedfunction{\mathcal{N}}{#2}{(}{)} 272 | } 273 | }} 274 | 275 | \DeclareDocumentCommand{\entropy}{m}{\ensuremath{\operatorname{\mathbb{H}}\mleft(#1\mright)}} 276 | \DeclareDocumentCommand\entropy{soG{}}{\ensuremath{ 277 | \IfBooleanTF{#1} 278 | {\overloadedfunction*{\mathbb H}[#2]{#3}{(}{)}} 279 | {\overloadedfunction{\mathbb H}[#2]{#3}{(}{)}} 280 | }} 281 | \DeclareDocumentCommand\loss{soG{}}{\ensuremath{ 282 | \IfBooleanTF{#1} 283 | {\overloadedfunction*{\mathcal L}[#2]{#3}{(}{)}} 284 | {\overloadedfunction{\mathcal L}[#2]{#3}{(}{)}} 285 | }} 286 | \DeclareDocumentCommand\cost{soG{}}{\ensuremath{ 287 | \IfBooleanTF{#1} 288 | {\overloadedfunction*{\mathcal C}[#2]{#3}{(}{)}} 289 | {\overloadedfunction{\mathcal C}[#2]{#3}{(}{)}} 290 | }} 291 | 292 | 293 | 294 | -------------------------------------------------------------------------------- /mlmacros.tex: -------------------------------------------------------------------------------- 1 | % example document 2 | \PassOptionsToPackage{table}{xcolor} % xcolor tends to produce option clashes because it is imported from all sorts of packages. This forces the table option to be inserted everywhere. https://tex.stackexchange.com/a/5375 3 | \documentclass 4 | [ 5 | %fontsize=11pt, % Document font size 6 | %twoside, % Shifts odd pages to the left for easier reading when printed, can be changed to oneside 7 | %captions=tableheading, 8 | %index=totoc, 9 | %hyperref 10 | ] 11 | {article} 12 | \input{standardheader} 13 | \usepackage{mlmacros} % custom commmands, mostly math 14 | \input{nonpaperheader} 15 | 16 | % % % % % % % % % % % % % % % % % % % % 17 | % new custom commands go here 18 | \variables{x,y,A} 19 | \variables[mean,std]{\mu,\sigma} 20 | \varmacros{E}{\mathcal{E}} 21 | 22 | \probdists{p,q} 23 | \probdists[policy]{\pi} 24 | \MkProbDist{P}{\mathbb{P}} 25 | 26 | \usepackage{fancyvrb} 27 | % % % % % % % % % % % % % % % % % % % % 28 | 29 | \title{Documentation for \texttt{mlmacros.sty}} 30 | \author{Maximilian Soelch} 31 | 32 | \begin{document} 33 | \maketitle 34 | The \verb|mlmacros| package provides convenient and readable macros for commonly used syntax when writing scientific articles about machine learning. 35 | 36 | \input{secs/mlmacros/subindexing.tex} 37 | 38 | \input{secs/mlmacros/variables.tex} 39 | 40 | \input{secs/mlmacros/probdists.tex} 41 | 42 | \input{secs/mlmacros/operators.tex} 43 | 44 | \input{secs/mlmacros/syntacticsugar.tex} 45 | 46 | \input{secs/mlmacros/style.tex} 47 | 48 | \input{secs/mlmacros/autocomplete.tex} 49 | 50 | \end{document} -------------------------------------------------------------------------------- /nonpaperheader.tex: -------------------------------------------------------------------------------- 1 | % These packages are very nice features for a note. 2 | % However, they are typically incompatible with a conference style. 3 | % Hence, they are separated into a second header file 4 | 5 | % % % % % % % % % % 6 | % FONTS & STYLE 7 | % % % % % % % % % % 8 | \usepackage[osf,sc]{mathpazo} % Palatino as the main font 9 | \linespread{1.05}\selectfont % Palatino needs some extra spacing, here 5% extra 10 | %%\usepackage[scaled=0.85]{beramono} 11 | \usepackage[euler-digits]{eulervm} % nicer math font 12 | \renewcommand{\mathbf}{\mathbold} % necessary for greek letters in this math font to be displayed correctly 13 | \usepackage[parfill]{parskip} % blank lines between paragraphs instead of indent 14 | 15 | \usepackage[ 16 | %showframe, 17 | paperwidth=210mm, 18 | paperheight=297mm, 19 | left=80pt, 20 | top=80pt, 21 | textwidth=350pt, 22 | marginparsep=20pt, 23 | marginparwidth=124pt, 24 | textheight=692pt, 25 | footskip=50pt 26 | ] 27 | {geometry} 28 | 29 | 30 | % % % % % % % % % % 31 | % BIBLIOGRAPY 32 | % % % % % % % % % % 33 | 34 | \usepackage[ 35 | backend=biber, %instead of bibtex 36 | %backend=bibtex8, 37 | bibencoding=utf8,% 38 | language=auto,% 39 | style=authoryear,% 40 | %style=authoryear-comp, % Author 1999, 2010 41 | %bibstyle=authoryear,dashed=false, % dashed: substitute rep. author with --- 42 | sorting=nyt, % name, year, title 43 | maxcitenames=2, 44 | maxbibnames=4, % default: 3, et al. 45 | uniquelist=false, 46 | %doi=false, 47 | %isbn=false, 48 | url=false, 49 | date=year, 50 | %backref=true,% 51 | natbib=true % natbib compatibility mode (\citep and \citet still work) 52 | ]{biblatex} 53 | % alternative: \usepackage{natbib} 54 | 55 | %\addbibresource{example.bib} 56 | 57 | % fixing URLs: non-monospace font and proper linebreaks 58 | \urlstyle{same} 59 | % https://texwelt.de/fragen/7008/zeilenumbruche-in-bibliografielinks 60 | \apptocmd{\UrlBreaks}{\do\f\do\m}{}{} 61 | \setcounter{biburllcpenalty}{9000}% Kleinbuchstaben 62 | \setcounter{biburlucpenalty}{9000}% Großbuchstaben 63 | 64 | %\urlstyle{sf} 65 | \makeatletter 66 | % taken from https://www.joachim-breitner.de/blog/519-Nicer_URL_formatting_in_LaTeX 67 | % Inspired by http://anti.teamidiot.de/nei/2009/09/latex_url_slash_spacingkerning/ 68 | % but slightly less kern and shorter underscore 69 | \let\UrlSpecialsOld\UrlSpecials 70 | \def\UrlSpecials{\UrlSpecialsOld\do\/{\Url@slash}\do\_{\Url@underscore}}% 71 | \def\Url@slash{\@ifnextchar/{\kern-.11em\mathchar47\kern-.2em}% 72 | {\kern-.0em\mathchar47\kern-.08em\penalty\UrlBigBreakPenalty}} 73 | \def\Url@underscore{\nfss@text{\leavevmode \kern.06em\vbox{\hrule\@width.3em}}} 74 | \makeatother -------------------------------------------------------------------------------- /opinion.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/msoelch/tex/21496ec3731882c045eb0ae174086d5898602b8c/opinion.pdf -------------------------------------------------------------------------------- /opinion.tex: -------------------------------------------------------------------------------- 1 | \documentclass{article} 2 | 3 | \usepackage{tocloft} 4 | \renewcommand{\cftsecleader}{\relax}% Content between section title and page number 5 | \renewcommand{\cftsecafterpnum}{\hfill\mbox{}}% Content after section page number 6 | \renewcommand{\cftsubsecleader}{~}% Content between subsection title and page number 7 | \renewcommand{\cftsubsecafterpnum}{\hfill\mbox{}}% Content after subsection page number} 8 | \renewcommand{\cftsubsubsecleader}{~}% Content between subsection title and page number 9 | \renewcommand{\cftsubsubsecafterpnum}{\hfill\mbox{}}% Content after subsection page number} 10 | 11 | 12 | \input{standardheader} 13 | \usepackage{mlmacros} % custom commmands, mostly math 14 | \input{nonpaperheader} 15 | 16 | \usepackage{nccmath} % for demonstration purposes only 17 | \usepackage{fancyvrb} 18 | \usepackage{multicol} 19 | 20 | \DeclareMathOperator*{\mymin}{min} 21 | 22 | 23 | \title{Opinions and Experiences Writing Scientific Articles in \LaTeX} 24 | \author{Maximilian Soelch} 25 | 26 | \begin{document} 27 | 28 | \maketitle 29 | 30 | This document provides what I consider best practices for writing in \LaTeX. 31 | Many of these are subjective---ignore them at your discretion! 32 | This guide is biased towards scientific articles, yet many recommendations hold generally. 33 | To keep this document at a reasonable length, you will find a brief recommendation accompanied with a useful pointer to a more detailed resource. 34 | If you find any of the recommendations valuable or objectionable, let me know! 35 | 36 | \tableofcontents 37 | \vfill 38 | \newpage 39 | 40 | \input{secs/opinion/goldenrules.tex} 41 | 42 | \input{secs/opinion/systemsetup.tex} 43 | 44 | \input{secs/opinion/versioncontrol.tex} 45 | 46 | \input{secs/opinion/bibliography.tex} 47 | 48 | \input{secs/opinion/math.tex} 49 | 50 | \input{secs/opinion/misc.tex} 51 | 52 | \end{document} -------------------------------------------------------------------------------- /secs/mlmacros/autocomplete.tex: -------------------------------------------------------------------------------- 1 | \section{\TeX studio autocomplete} 2 | Along with this style file and example document, a \verb|cwl| file is provided. 3 | By adding it to your \TeX studio, autocomplete for the static macros is provided. 4 | Autocompletion of the dynamically produced \verb|variables| and \verb|probdists| is not included. 5 | 6 | Under Windows 10, it has to be copied to the directory 7 | 8 | \begin{Verbatim} 9 | %appdata%\texstudio\completion\user. 10 | \end{Verbatim} 11 | 12 | Under Ubuntu 16.04 and 18.04, it has to be copied to the directory 13 | 14 | \begin{Verbatim} 15 | ~/.config/texstudio}. 16 | \end{Verbatim} -------------------------------------------------------------------------------- /secs/mlmacros/operators.tex: -------------------------------------------------------------------------------- 1 | \section{\texttt{\textbackslash expc}, \texttt{\textbackslash var}, \texttt{\textbackslash loss}, \texttt{\textbackslash cost}, \texttt{\textbackslash entropy}} 2 | For expectation and variance, this package provides overloaded macros similar to the dynamic macros provided by \texttt{\textbackslash probdists} in \cref{sec:probdists}. 3 | 4 | The application is straightforward: 5 | 6 | \begin{table}[h!] 7 | \centering 8 | \begin{tabular}{llll} 9 | \verb|\expc{x}| & \verb+\expc{x|z}+ &\verb+\expc[y]{x|z}+ &\verb|\expc[y]{x}|\\ 10 | \expc{x} & \expc{x|z} & \expc[y]{x|z} & \expc[y]{x} \\ 11 | \end{tabular} 12 | \end{table} 13 | and analogously 14 | 15 | \begin{table}[h!] 16 | \centering 17 | 18 | \begin{tabular}{*{3}{l}} 19 | 20 | \verb+\var[y]{x|z}+ & \verb+\loss[y]{x|z}+ & \verb+\cost[y]{x|z}+\\ 21 | \var[y]{x|z} & \loss[y]{x|z} & \cost[y]{x|z} \\[1em] 22 | \verb+\entropy[y]{x|z}+& \verb+\mi[y]{x|z}+ \\ 23 | \entropy[y]{x|z} & \mi[y]{x|z} 24 | \end{tabular} 25 | \end{table} 26 | All comments from \cref{sec:probdists} apply here as well. -------------------------------------------------------------------------------- /secs/mlmacros/probdists.tex: -------------------------------------------------------------------------------- 1 | \section{\texttt{\textbackslash probdists}}\label{sec:probdists} 2 | The \verb|\probdists| macro provides a rich macro for probability distributions. 3 | The call \verb|\probdists{p}| provides a command that can be used in any of the following ways: 4 | 5 | \begin{table}[h!] 6 | \centering 7 | \begin{tabular}{llllll} 8 | \verb|\p| & \verb|\p{x}| & \verb=\p{x|z}= & \verb=\p[y]{x|z}= & \verb|\p[y]{x}| & \verb|\p[y]|\\ 9 | \p & \p{x} & \p{x|z} & \p[y]{x|z} & \p[y]{x} & \p[y] 10 | \end{tabular} 11 | \end{table} 12 | The \verb|\p| macro dynamically decides which parts to display. This allows for rapid adjustment of the syntax. The parentheses adjust dynamically via internal usage of \verb|\mleft| and \verb|\mright|, unless starred commands (\verb|\p*| \etc) are used, 13 | \begin{equation} 14 | \p{x^2 | y_t} \text{ vs. starred } \p*{x^2 | y_t}. 15 | \end{equation} 16 | 17 | \verb|\p| ignores arguments not given in braces, \eg \verb|\p{x}z| yields $\p{x}z$. 18 | 19 | Of course, \verb|probdists| can be called with a list of letters, \eg \verb|\probdists{p,q}|. 20 | Similarly as the \verb|\variables| macro, we can use, \eg Greek letters, by passing optional arguments: 21 | \verb|\probdists[policy]{\pi}| provides macros such as \verb=\policy{u|x}= for $\policy{u|x}$. 22 | 23 | At this point, complicated constructions like $\mathbb{P}$ can be achieved by calling the underlying \verb|\MkProbDist|, \eg \verb|\MkProbDist{P}{\mathbb{P}}| for $\P{x}$. 24 | 25 | \emph{Warning:} The macros provided by \verb|probdists| overwrite any previously created macro of the same name. -------------------------------------------------------------------------------- /secs/mlmacros/style.tex: -------------------------------------------------------------------------------- 1 | \section{Style of this document} 2 | The default style of this document uses Palantino as the main font via 3 | 4 | \begin{Verbatim}[tabsize=4] 5 | \usepackage[osf,sc]{mathpazo}{} 6 | \linespread{{1.05}}\selectfont 7 | \end{Verbatim} 8 | 9 | with some extra spacing between lines. Moreover, the Euler math font is used: 10 | 11 | \begin{Verbatim}[tabsize=4] 12 | \verb|\usepackage[euler-digits]{{eulervm}}| 13 | \end{Verbatim} 14 | 15 | The \verb|amsmath| package is loaded with the \verb|fleqn| for left flush of equations. 16 | 17 | All these changes were taken from the highly recommended \href{https://bitbucket.org/amiede/classicthesis/wiki/Home}{$\rightarrow$\texttt{classicthesis}} package by Andr\'e Miede. 18 | 19 | Other recommended nice-to-have packages for convenient and good-looking typewriting are \verb|cleveref| for extremely clever referencing, \verb|nicefrac| for better handling of inline fractions, and \verb|microtype|, which takes care of small typesetting issues that improve the overall document appearance. -------------------------------------------------------------------------------- /secs/mlmacros/subindexing.tex: -------------------------------------------------------------------------------- 1 | \section{Subindexing sequence data} 2 | When writing about algorithms on sequence data, we often refer to variables at a specific time by subindexing, \eg $x\tsub{t}, x\tm,x\Tp{2}$, or $x\tsub{i}{j} = (x_i, \dots, x_j)$ for a sequence. 3 | This package provides shortcuts for the most common indexes: 4 | 5 | \begin{table}[h!] 6 | \centering 7 | \begin{tabular}[t]{lllll} 8 | \verb|x\tm| & \verb|x\tp| & \verb|x\ts| & \verb|x\tsm| & \verb|x\tsp|\\ 9 | $x\tm$ & $x\tp$ & $x\ts$ & $x\tsm$ & $x\tsp$\\[1.5em] 10 | 11 | \verb|x\tm{k}| & \verb|x\tp{k}| & & \verb|x\tsm{k}| & \verb|x\tsp{k}|\\ 12 | $x\tm{k}$ & $x\tp{k}$ & & $x\tsm{k}$ & $x\tsp{k}$\\[1.5em] 13 | 14 | \verb|x\Tm| & \verb|x\Tp| & \verb|x\Ts| & \verb|x\Tsm| & \verb|x\Tsp|\\ 15 | $x\Tm$ & $x\Tp$ & $x\Ts$ & $x\Tsm$ & $x\Tsp$\\[1.5em] 16 | 17 | \verb|x\Tm{k}| & \verb|x\Tp{k}| & & \verb|x\Tsm{k}| & \verb|x\Tsp{k}|\\ 18 | $x\Tm{k}$ & $x\Tp{k}$ & & $x\Tsm{k}$ & $x\Tsp{k}$\\[1.5em] 19 | 20 | \verb|x\tsub{k}| & & & \verb|x\tsub{i}{j}| & \\ 21 | $x\tsub{k}$ & & & $x\tsub{i}{j}$ & 22 | \end{tabular} 23 | \end{table} 24 | The logic behind the commands is the following: 25 | \begin{itemize} 26 | \item Start with the desired upper or lower case \verb|t|. 27 | \item Optionally add an \verb|s| for a sequence starting at $1$. 28 | \item Add \verb|m| or \verb|p| for minus or plus. 29 | \item Optionally add an argument to replace the default $1$. 30 | \end{itemize} 31 | 32 | Notice that the plus and minus signs are slightly shortened, cf. 33 | \begin{align*} 34 | &x_{t-1:T+K}\\ 35 | &x\tsub{t\shortminus1}{T\shortplus K} 36 | \end{align*} 37 | Use \verb|\shortminus| or \verb|\shortplus| to make use of these. 38 | Alternatively, you can use \verb|\tminus| or \verb|\tplus| instead of \verb|t\shortminus| or \verb|t\shortplus|, respectively. -------------------------------------------------------------------------------- /secs/mlmacros/syntacticsugar.tex: -------------------------------------------------------------------------------- 1 | \section{Syntactic sugar} 2 | \subsection{Math} 3 | Some general, commonly used math expressions are provided by short, readable macros: 4 | \begin{itemize} 5 | \item \verb|mathbb| wrappers: \verb|\NN| for \NN, \verb|\RR| for \RR, \verb|\PP| for \PP, \verb|\EE| for \EE. 6 | \item \verb|mathcal| wrappers: \verb|\mcX| for \mcX, \verb|\mcU| for \mcU, \verb|\mcZ| for \mcZ, \verb|\mcD| for \mcD. 7 | \item \verb|\data| for \data. 8 | \item \verb|\ind| for \ind. 9 | \item \verb|\left\right| wrappers: 10 | \begin{itemize} 11 | \item \verb|\abs{}|: $ \abs{\frac a b }$ 12 | \item \verb|\set{}|: $ \set{\frac ab }$ 13 | \item\verb|\interval{}|: $ \interval{\frac ab} $ 14 | \end{itemize} 15 | \item Divergences: \verb|\divergence[a]{b}{c}| for $\divergence[a]{b}{c}$ 16 | \item Kullback-Leibler divergence: \verb|\kl{p}{q}| for $\kl{p}{q}$. 17 | The parentheses adjust to the height of the arguments unless you use \verb|\kl*|. 18 | \item Gaussian/Normal distributions: \verb|\gauss{0,1}| for $\gauss{0, 1}$. The parentheses adjust to the height of the arguments unless \verb|\gauss*| is used. 19 | Can be used for conditionals as well: \verb+\gauss{x | \mu, \sigma}+ gives $\gauss{x | \mu, \sigma}$. 20 | \item Integrals: \verb|\dint| for nicer integrals. 21 | 22 | \verb|\int x \dint x| for $\int x \dint x$ instead of \verb|\int x dx|:$\int x dx$ 23 | \item Equations that are to be proven: \verb|x \shallbe y| for $x \shallbe y$. 24 | \item Transpositions: \verb|A\transpose| for $A\transpose$ (with minor spacing adjustments compared to $A^\top$). 25 | \item Cancelling: use \verb|\cancelto{a}{b}| for $\cancelto{a}{b}$ 26 | \item Superscripts: use \verb|x\super{i}| for $x\super{i}$ 27 | \item Gradients: use \verb|\grad\_{\theta}| for $\grad_{\theta}$ for better spacing than $\nabla_\theta$ 28 | \end{itemize} 29 | \subsection{Abbreviations} 30 | One of the most cumbersome typesetting issues is the correct spacing after abbreviations. 31 | The following abbreviations are provided by \verb|mlmacros|: 32 | \begin{center} 33 | \begin{tabular}{lll} 34 | \textsc{Abbrev.} & \textsc{Macro} & \textsc{Meaning}\\[.5em] 35 | \cf & \verb|\cf| & conferatur; compare\\ 36 | \dof & \verb|\dof| & degrees of freedom\\ 37 | \eg, \Eg & \verb|\eg|, \verb|\Eg| & exempli gratia; for instance\\ 38 | \etal & \verb|\etal| & et alii; and others\\ 39 | \etc & \verb|\etc| & et cetera\\ 40 | \ie, \Ie & \verb|\ie|, \verb|\Ie| & id est; that is\\ 41 | \iid & \verb|\iid| & independent and identically distributed\\ 42 | \NB & \verb|\NB| & Nota Bene; note well\\ 43 | \vs & \verb|\vs| & versus\\ 44 | \wrt & \verb|\wrt| & with respect to 45 | \end{tabular} 46 | \end{center} 47 | All these macros check for a following dot. 48 | 49 | To understand the difference, compare the spacing in 50 | 51 | \begin{tabular}{l} 52 | \verb|There are examples, e.\ g.\ this, that and the other.|\\ 53 | There are examples, e. g. this, that and the other.\\ 54 | \verb|There are examples, \eg this, that and the other.|\\ 55 | There are examples, \eg this, that and the other. 56 | \end{tabular} 57 | 58 | \subsection{Other} 59 | For easy use in, \eg, tables: \verb|\xmark| and \verb|\cmark| for \xmark and \cmark. -------------------------------------------------------------------------------- /secs/mlmacros/variables.tex: -------------------------------------------------------------------------------- 1 | \section{\texttt{\textbackslash variables}} 2 | Macros can help a great deal to stick with conventions while maintaining readability of the source file. 3 | However, with an increasing number of conventions, maintenance of the macros becomes just as hard. 4 | 5 | The \verb|\variables| macro eases some of that pain. 6 | Call it in the preamble with a list of variables and dynamically creates macros based on this list. 7 | For example, the call \verb|\variables{x}| automatically provides the following macros: 8 | 9 | \begin{table}[h!] 10 | \centering 11 | \begin{tabular}{llllll} 12 | 13 | \verb|\x| & \verb|\xseq| & \verb|\xall| & \verb|\xpast| & \verb|\xfilter| & \verb|\xfuture|\\ 14 | \x & \xseq & \xall & \xpast & \xfilter & \xfuture\\[1.5em] 15 | 16 | \verb|\bx| & \verb|\bxseq| & \verb|\bxall| & \verb|\bxpast| & \verb|\bxfilter| & \verb|\bxfuture|\\ 17 | \bx & \bxseq & \bxall & \bxpast & \bxfilter & \bxfuture 18 | \end{tabular} 19 | \end{table} 20 | 21 | It works with more complicated replacements, such as greek letters or other math symbols. 22 | Calling \verb|\variables[mean,std]{\mu,\sigma}| provides commands such as \verb|\mean| for $\mean$, \verb|\bmeanseq| for $\bmeanseq$ or \verb|\stdall| for $\stdall$. 23 | Notice that the list delimiter currently needs to be a comma \emph{without enclosing spaces}. 24 | 25 | More complicated macro substitutions currently do not work with \verb|\variables|. However, you can exploit the underlying command \verb|\varmacros| for every pair: \verb|\varmacros{E}{\mathcal{E}}| for commands like \verb|\bE|, which yields $\bE$. 26 | 27 | Further automatically created macros can easily be edited and/or extended by adjusting the \verb|mlmacros.sty| file. -------------------------------------------------------------------------------- /secs/opinion/bibliography.tex: -------------------------------------------------------------------------------- 1 | \section{Bibliography} 2 | Bibliography is one of the features where {\LaTeX} really shines, but it can be a bit confusing to start. 3 | To work with bibliographies you need two tools. 4 | 5 | The first is a package that defines commands for referencing and the looks of your references and bibliography. 6 | There are two major contenders: \texttt{natbib} and \texttt{biblatex}. 7 | 8 | The second is a bibliography compiler. 9 | This compiler is the link between your \texttt{tex} and \texttt{bib} files. 10 | Again, there are two contenders: \texttt{bibtex} and \texttt{biber}. 11 | 12 | If there are no constraints, the choice is easy. 13 | The combination \texttt{biblatex} and \texttt{biber} is the more modern and thus strictly superior combination if you fancy support of, among many other things, UTF encoding and media from this millennium in your bibliography.% 14 | \footnote{For a more detailed and nuanced take, see \url{https://tex.stackexchange.com/questions/25701/bibtex-vs-biber-and-biblatex-vs-natbib}} 15 | The only---unfortunately rather common---exception is when your template forces you to use something else, usually \texttt{natbib} and \texttt{bibtex}. 16 | 17 | Use \texttt{biblatex} via \verb|\usepackage[...]{biblatex}| and tweak the looks of both your references and your bibliography to your liking via package options. 18 | For a suggested default, see the provided \texttt{nonpaperheader.tex}. 19 | A best practice is to \emph{never} use the \verb|\cite| command unless you are writing a macro of your own. 20 | Instead, use \verb|\textcite| when your reference is part of a sentence or \verb|\parencite| when your reference is in parentheses at the end of a sentence for the most common use cases, and check the docs if you need something else.% 21 | \footnote{ 22 | If you have to use \texttt{natbib}, the equivalent commands are \texttt{\textbackslash citet} and \texttt{\textbackslash citep}. 23 | Via the \texttt{natbib=true} option of \texttt{biblatex}, you can enable backward compatibility of these commands. 24 | } 25 | 26 | Then there is the actual bibliography. 27 | I would recommend using a dedicated bibliography tool rather than managing your \verb|.bib| file manually. 28 | There are many good and some bad options out there but no universally good one. 29 | I have personally made good experiences with the free, open-source tool Zotero in combination with the add-on Better Bib\TeX\ as well as the browser plugin for Firefox. 30 | It can conveniently export a \TeX-compatible bibliography file and also keep it updated if new papers are added or the data of a reference change. 31 | Conversely, Zotero can import a bibliography entry from a Bib\TeX\ entry. 32 | 33 | The best source for bibliography \emph{entries} is the dblp computer science bibliography data base (\url{https://dblp.uni-trier.de/}). 34 | It usually has the cleanest and most consistent data. 35 | It just struggles with arXiv preprints, for which I have had the best results by using the Zotero browser plugin directly on the arXiv page of the respective paper. -------------------------------------------------------------------------------- /secs/opinion/goldenrules.tex: -------------------------------------------------------------------------------- 1 | \section{Golden Rules} 2 | 3 | \paragraph{There is no such thing as too many macros.} 4 | Macros can feel like overkill at first. 5 | After all, you are only writing a note, are you not? 6 | Then the note turns into a paper. 7 | There will always be a point where you change your mind with respect to notation. 8 | And if you do it right, your source code becomes much more readable, particularly math equations. 9 | 10 | \paragraph{Space is everything.} 11 | A lot of what \LaTeX\ does is spacing your content gracefully. 12 | Gradually grasping the inner workings is key to writing nice documents but also understanding when it fails. 13 | 14 | A simple example is the difference between the dot after an acronym as in \etc and the full stop at the end of a sentence. 15 | The space between sentences is larger than that between words. 16 | You need to tell \LaTeX\ the dot after \etc is not a full stop. 17 | Otherwise it looks awkwared, e. g., if you write like this instead of, \eg, like this. 18 | See the difference? 19 | 20 | \paragraph{Avoid hard-coding.} 21 | 22 | Avoid hard-coding a certain look of the document, be it via setting specific lengths, positions, font modifications. 23 | Instead, use macros, packages, commands, variables. 24 | Leave as much flexibility to the compiler as possible and your document will have a higher chance of looking good. 25 | 26 | There will be advanced examples below, here is one for illustration: you want to \emph{emphasize} a word? 27 | Instead of italics, \verb|\textit|, use \verb|\emph|. 28 | By default, it will use italics---but you can change your mind! And, while we're at it, \verb|\emph| \textit{changes \emph{behavior} in italics!} 29 | 30 | \paragraph{Stackoverflow is your friend.} 31 | \LaTeX\ has a steep learning curve. 32 | The key is to learn how to search the right queries. 33 | There are very few new problems in \LaTeX. 34 | You'll get the hang of it! 35 | 36 | \paragraph{Be consistent.} 37 | Many of the suggestions in this document are only that---suggestions. 38 | Whether you choose to adhere to them is often a matter of personal taste. 39 | If you choose to follow some different standard, the key is to be conscious and consistent. -------------------------------------------------------------------------------- /secs/opinion/math.tex: -------------------------------------------------------------------------------- 1 | \section{Math} 2 | 3 | \subsection{The Correct Math Environment} 4 | There are a number of ways to display equations. 5 | Without going into the details, use the \verb|equation| environment. 6 | Using \verb|$$ ... $$| is discouraged, as is \verb|align|. 7 | If you need the latter, use an \verb|aligned| environment inside the \verb|equation| environment.% 8 | \footnote{As for the reasons, check out \url{https://tex.stackexchange.com/questions/321/align-vs-equation} and \url{https://tex.stackexchange.com/questions/503/why-is-preferable-to}.} 9 | 10 | \subsection{Equation Numbering} 11 | Number every equation unless you have a good reason not to. 12 | Not wanting to break the line is often not a good reason, unless you are on a really tight budget with space. 13 | You may not need to reference it. 14 | But your co-authors, colleagues, peers, reviewers, or students might. 15 | That third equation in the right column on page six does not roll of the tongue quite as well as \cref{eq:bad_emc2}. 16 | 17 | \subsection{Flushing Equations} 18 | 19 | Flush equations left if you have the choice. 20 | You can most easily achieve this with the \texttt{fleqn} option to the \texttt{amsmath} package. 21 | 22 | An equation like 23 | \begin{equation} 24 | E = mc^2 25 | \end{equation} 26 | reads better than 27 | {\setlength{\mathindent}{0cm}\begin{equation} 28 | \noindent\hfill E = mc^2\hfill\label{eq:bad_emc2} 29 | \end{equation}} 30 | in my opinion, but your tastes may differ. 31 | 32 | \subsection{Operations} 33 | A common trap in setting math is misunderstanding space. 34 | An easy way to avoid that is to not hardcode certain symbols. 35 | An example is \verb+|+. 36 | If you type \verb+$A | B$+, you get $A|B$. 37 | \LaTeX\ does not understand that the pipe relates the two adjacent symbols. 38 | What you actually want is the operator: \verb|$A \mid B$| gives you $A \mid B$. 39 | 40 | Note how, \eg, \verb|$A + B$|, gives you $A+B$ with correct spacing even without a macro. 41 | \LaTeX\ invokes the correct spacing for the most common operators like $+$, $-$, $>$ \etc. 42 | Beyond those, you're on your own. 43 | 44 | \subsection{Text in Math Blocks} 45 | If you write $min$ (\verb|$min$|), you need to define $m$, $i$, and $n$.% 46 | \footnote{ 47 | Caveat lector: my document defaults make this less pronounced, more by coincidence than by design. 48 | I assure you that in the default default, it just looks ugly. 49 | } 50 | The quickest fix is to write \verb|$\min$| for $\min$. 51 | In cases where the predefined macros do not exist, the quick-and-dirty fix is \verb|$\text{min}$|. 52 | The correct fix is to understand the semantics and tell \LaTeX\ explicitly, for instance by declaring something an operator with \verb|$\DeclareMathOperator*{\mymin}{min}$| for $\mymin$. 53 | This looks the same as the \verb|\text| solution, but subsequently gets other spacing right, for instance with indexing: 54 | \begin{equation} 55 | \texttt{\textbackslash text: }\text{min}_x\qquad\text{\vs}\qquad\texttt{\textbackslash mymin: } \mymin_x 56 | \end{equation} 57 | The correct way of handling it depends on your downstream needs. 58 | 59 | \subsection{Parentheses} 60 | To automatically scale your parentheses to an appropriate height, use the \verb|\left| and \verb|\right| commands as in 61 | \verb|\left(\frac12\right)| for 62 | \begin{equation}\label{eq:fullstop} 63 | \left(\frac12\right). 64 | \end{equation} 65 | I have found that there are not too uncommon special cases where this solution adds too much spacing on both sides. 66 | My default fix is to use the \verb|mleftright| package which provides drop-in replacements \verb|\mleft| and \verb|\mright|, and if you add \verb|\mleftright| in your preamble you can even keep using \verb|\left| and \verb|\right|. 67 | 68 | \subsection{Punctuation} 69 | Equation blocks require punctuation just like text. 70 | See the full stop in \cref{eq:fullstop}. 71 | If you have multiple equations, separate them with commas or full stops. 72 | The rule of thumb is easy: 73 | read the equation block like prose, and put commas where appropriate. -------------------------------------------------------------------------------- /secs/opinion/misc.tex: -------------------------------------------------------------------------------- 1 | \section{Miscallenous} 2 | 3 | \subsection{References \& Citations} 4 | 5 | 6 | You probably know the \verb|\ref| command to reference a section, equation, figure \etc. 7 | Use the \texttt{cleveref} package and the \verb|\cref| command as a drop-in replacement. 8 | It gives you a lot of options to configure, looks good by default, and you can change your mind at any time. 9 | No more inconsistencies between Figure~5, figure~5, and fig.~5. 10 | 11 | 12 | When you label things that you want to reference, add a tag to the label, \eg, use \verb|\label{sec:introduction}| or \verb|\label{eq:Emc2}|. 13 | That makes it much easier to see at a glance what it is you are referencing. 14 | Also, your editor might have auto-completions, and these tags are an easy way to filter. 15 | 16 | \subsubsection{Links and URLs} 17 | The defaults used in most documents for links both to the internet as well as to references within the text are stuck in the previous century. 18 | Write URLs in the font of your text.% 19 | \footnote{And here is some correction for nicer URL formatting: \url{https://www.joachim-breitner.de/blog/519-Nicer_URL_formatting_in_LaTeX}} 20 | Mono-space font for URLs is a relic from times when people were surprised to see them. 21 | 22 | 23 | Switch off those neon boxes!% 24 | \footnote{And here is how to do that including some alternatives: \url{https://tex.stackexchange.com/questions/823/remove-ugly-borders-around-clickable-cross-references-and-hyperlinks}} 25 | Their use is very limited, they look horrific, and worst of all they make reading your text unnecessarily hard. 26 | I know where I can click, and if I do not, I likely did not want to in the first place. 27 | 28 | \subsection{Figures} 29 | Make your figures as large as necessary, but not larger. 30 | Try to keep the overall file size low. 31 | This reduces the danger of your reviewer being annoyed by having to work to get your stuff printed because their printer runs out of memory when trying to print your paper. 32 | I have been this reviewer. 33 | 34 | Use vector graphics wherever possible, \ie, use pdf outputs of your matplotlib figures. 35 | An exception to this rule are plots with lots of elements. 36 | This is typically the case when you have scatter plots with $>100$ points. 37 | Convert those into png or some fixed format. 38 | If you want to keep vector graphic axes and labels, scatter plots also have a keyword argument \verb|rasterized=True| that is a good compromise. 39 | 40 | As for the right package and commands, I have had the most consistently good results with the \verb|subfig| package. 41 | 42 | 43 | \subsection{Acronyms} 44 | Use a package and macros for all acronyms. 45 | This gives your acronyms consistency, and again it is easy to change your mind later. 46 | I have made good experiences with the \verb|acronym| package. 47 | As with many things \LaTeX, it seems superfluous at first. 48 | Once you have a sizable collection of acronyms to carry over from document to document, it is the much more efficient option. 49 | 50 | 51 | \subsection{Tables} 52 | Tables are an art in and of itself. 53 | Arguably, it is one of the more annoying subjects with \TeX. 54 | Here are some very incomplete, general recommendations to give you a start: 55 | \begin{itemize} 56 | \item Vertical lines as dividers are a sign your layout is incorrect. 57 | Use them sparingly, ideally never. 58 | White space is almost always the better option as a separator. 59 | \item Align your columns correctly. 60 | The alignment is determined by the content, and the column header has the same alignment. 61 | Text is left-aligned by default. 62 | Numbers are right-aligned by default. 63 | \item \textsc{Small Caps} are often, not always, a good default for column headers, the command is \verb|\textsc{Column Title}|. 64 | \item Make use of \verb|\toprule|, \verb|\midrule|, and \verb|\bottomrule| from the \verb|booktabs| package; but use them with care also. 65 | Consider white space, which you can add with \verb|...\\[1em]| at the end of a table line, where \verb|1em| is the amount of white space you want to add. 66 | \item Make sure your table is not overburdened by content. 67 | Choose appropriate font sizes to get enough white space in. 68 | Cut insignificant digits. 69 | Imply duplicate values by clever grouping and white space instead of printing it in every row. 70 | This is not an SQL table, your target audience is human for the time being. 71 | \end{itemize} 72 | A recurring pattern here is white space. 73 | Mastering white space is the key to readable, informative tables.% 74 | \footnote{If you want to see these principles at work, look at this example: \url{https://github.com/Wookai/paper-tips-and-tricks\#tables}} 75 | 76 | \subsection{Numbers} 77 | Setting numbers in text correctly is not trivial. 78 | Did you run 50 or $50$ experiments? 79 | Are you sowing the results in section 5 or $5$? 80 | Did you run them in 1994 or $1994$? 81 | 82 | Once again, consistency is key. 83 | The distinction that I have settled on is between \emph{text} and \emph{math} numerals.% 84 | \footnote{It is always a good sign when you can quote Donald Knuth to back your opinion, \cf the last paragraph on page 31: https://tug.org/TUGboat/tb10-1/tb23knut.pdf} 85 | At times, those notions are a bit ephemeral, but a good rule of thumb is whether you would be likely to assign the number to a variable. 86 | You ran $N=50$ experiments, hence math mode even though you do not perform math on the number. 87 | You ran them in 1994 and recorded them in section 5, these numerals are part of the prose. 88 | 89 | Do not fall for the but-the-result-is-the-same trap. 90 | If you want to know why, read the Knuth comment above. 91 | 92 | It is often recommended to use the package \verb|siunitx|, but I have little to no experience with it. 93 | 94 | \subsection{Footnotes} 95 | Footnotes are great to add a little information or pointer on the side. 96 | If you put the footnote at the end of a sentence, put no space behind the full stop. 97 | If you want to put the footnote on a new line in your source code---for instance, because you adhere to the version control best practices in \cref{sec:versioncontrol}---you need to use a little trick to avoid the space. 98 | Escape the newline with a comment! 99 | Put a \texttt{\%} at the end of your line, then start the footnote on the next line.% 100 | \footnote{ 101 | This trick of escaping the end of a line can be useful elsewhere to avoid spurious white spaces in your document. 102 | } 103 | 104 | 105 | \subsection{Quotes} 106 | Punctuating quotes correctly is a bit annoying. 107 | Firstly, different languages have wildly different conventions. 108 | Secondly, \LaTeX\ has many different ways to typeset them. 109 | The consistently easiest way to deal with this in my book is the \verb|csquotes| package with the \verb|\enquote| command. 110 | Then it becomes a matter of setting up your preamble, specifically the document language, correctly and everything remains nice and consistent. 111 | 112 | 113 | 114 | \subsection{Table of Content} 115 | In your table of content, do not align the page numbers to the right. 116 | It may look fancy, especially with those filling dots you get by default. 117 | Form follows function. Help your reader find pages, not sum them. 118 | 119 | \subsection{Log} 120 | When you compile your document, take the logs seriously even when they only produce warnings. 121 | A document is only ready for publication when it has no warnings that you have not at least googled and understood why you will not fix it. 122 | 123 | If you are brave, add \verb|\usepackage[orthodox]{nag}| to your preamble. 124 | 125 | \subsubsection{Overfull and Underfull Boxes} 126 | The most common warning that should be purged completely are overfull or underfull boxes. 127 | The compiler throws these warnings when it cannot arrange your content with acceptable spacing. 128 | Often, this means excessive spacing when the box, a line or a page, is underfull or content bleeding into margins when the box is overfull. 129 | There are many small ways to fix these, manually breaking the line, telling the compiler how a certain word is hyphenated, reordering or rephrasing a sentence, and many more. 130 | 131 | If you have trouble finding the culprit, there are tricks to find them. 132 | For overfull boxes, add the \verb|draft| option to the documentclass options. 133 | This will add a black marker on the margin next to the overfull box. 134 | To see where the box ends, it can be useful to display frames with \verb|\usepackage{showframe}|. 135 | 136 | Underfull boxes are a little trickier, but with \verb|showframe| and a keen eye for superfluous white space they are usually easier to spot in the document. 137 | 138 | \subsection{Publishing Source Files} 139 | With the majority of papers uploaded to arXiv these days, it is quite common to share not only your article but also the source code. 140 | Keeping in mind that the source code on arXiv is made public, it is good practice to purge your source files specifically for upload. 141 | 142 | Run the following commands: 143 | \begin{Verbatim} 144 | latexpand --empty-comments paper.tex > paper-full.tex 145 | sed -i '/^\s*%/d' paper-full.tex 146 | cat -s paper-full.tex | sponge paper-full.tex 147 | \end{Verbatim} 148 | The first line combines your source code distributed across several files back into one big file. 149 | The other two lines remove all comments and superfluous white space in your source file. 150 | This way, you do not accidentally publish comments that were not meant for the public eye. 151 | 152 | There is a nice python script% 153 | \footnote{\url{https://github.com/google-research/arxiv-latex-cleaner}} 154 | that analyzes your source code and removes comments, temporary files etc. 155 | 156 | It is particularly good for deleting unused files. 157 | It also can help you with resizing your images if you have a large paper. 158 | It can be a bit too liberal in its compression, so be sure to check the results or deactivate. 159 | Either way, it is better to not trust a script with handling your figures. 160 | 161 | In any case, be sure to check that this cleaned-up version of your source produces same result. 162 | 163 | \subsection{Title Casing} 164 | 165 | Be sure to have consistent title casing. 166 | I personally prefer mixed upper- and lower-case title casing, but there are many alternatives. 167 | The key, once again, is consistency. 168 | There are resources to help you: \url{https://capitalizemytitle.com/} -------------------------------------------------------------------------------- /secs/opinion/systemsetup.tex: -------------------------------------------------------------------------------- 1 | \section{System Setup} 2 | 3 | \paragraph{Distribution} 4 | Unless you are on a tight disk space budget, install a \TeX\ distribution with lots of included packages like \verb|texlive-full| for Linux. 5 | 6 | \paragraph{Compiler} 7 | The best default for compiling your document is the \verb|latexmk -pdf| command, which should be included in your \TeX\ distribution. 8 | It can detect which parts of the infamous multiple build runs, including the bibliography, need to be run based on changes in the files. 9 | 10 | \paragraph{Editor} 11 | Using a versatile plugin or dedicated \TeX\ editor is recommended. 12 | I personally use \TeX Studio. 13 | It is good-not-great, so you may find a solution that suits your preferences better. 14 | I have found its following features useful: 15 | \begin{itemize} 16 | \item Side-by-side display of source and pdf, which are tightly coupled so one can jump from the pdf to the respective source and vice versa. 17 | \item Easy setup of compiler and bibliography tool, including support of the aforementioned \verb|latexmk|. 18 | \item Auto-completion of commands from used standard libraries as well your references in the document. 19 | \item Good integration of the log, jumping to the line that throws the error or warning. 20 | \item Seamless handling of multiple source files for a document. 21 | \end{itemize} -------------------------------------------------------------------------------- /secs/opinion/versioncontrol.tex: -------------------------------------------------------------------------------- 1 | \section{Version Control}\label{sec:versioncontrol} 2 | It is generally recommended to use version control for your source code. 3 | Following some rules makes using version control with \TeX\ documents that much smoother: 4 | 5 | Put each sentence on its own line in the source code, it makes comparing changes much easier. 6 | 7 | Split large documents into multiple files. 8 | One file per section, integrated into the main document with \verb|\input| or \verb|\include|, is a good rule of thumb. 9 | That way, changing the order of sections has you change two lines, rather than several hundred insertions and deletions. 10 | 11 | Do \emph{not} commit the auxiliary files produced while compiling the document. 12 | Use, \eg, \verb|.gitignore| templates% 13 | \footnote{\url{https://www.toptal.com/developers/gitignore}} 14 | to exclude them. 15 | 16 | Avoid committing the final document. 17 | This will create very large repositories that hold \emph{every} committed revision. 18 | To make the latest pdf easily available, use continuous integration. 19 | With gitlab, it is as easy as adding a file 20 | \begin{Verbatim}[tabsize=4] 21 | build_pdf: 22 | image: aergus/latex 23 | script: 24 | - latexmk -pdf -cd relative/path/to/paper.tex 25 | artifacts: 26 | paths: 27 | - relative/path/to/paper.pdf 28 | \end{Verbatim} 29 | as \verb|.gitlab-ci.yml|. 30 | The final pdf can then be found at \url{/-/jobs/artifacts/master/raw/relative/path/to/paper.pdf?job=build_pdf}. 31 | With github, this is currently more convoluted, the main barrier being that the pdf is zipped, which is inconvenient. -------------------------------------------------------------------------------- /standardheader.tex: -------------------------------------------------------------------------------- 1 | \usepackage[orthodox]{nag} 2 | 3 | 4 | % % % % % % % % % % 5 | % MATH 6 | % % % % % % % % % % 7 | \usepackage[fleqn]{amsmath} % fleqn for left alignment of math blocks (as in classicthesis) 8 | \usepackage{amssymb} 9 | \usepackage{amsfonts} 10 | \usepackage{amsthm} 11 | \newtheorem{definition}{Definition}%[chapter] 12 | \newtheorem{theorem}{Theorem}%[chapter] 13 | \newtheorem{corollary}{Corollary}%[chapter] 14 | 15 | 16 | % % % % % % % % % % 17 | % FLOATS, FIGURAES, AND TABLES 18 | % % % % % % % % % % 19 | \usepackage{graphicx} % Required for including images 20 | \graphicspath{{gfx/}} 21 | \usepackage{caption} 22 | \captionsetup{font=small} % format=hang, 23 | \usepackage{subfig} 24 | \usepackage{tabularx} 25 | \setlength{\extrarowheight}{3pt} % increase table row height 26 | \usepackage{pbox} % for linebreaking in cells 27 | \usepackage{multicol, multirow} 28 | \usepackage{makecell} 29 | \usepackage{tikz} 30 | \usepackage{tikzsymbols} 31 | \usetikzlibrary{fit,arrows,shapes} 32 | \usetikzlibrary{decorations.pathreplacing} 33 | \usetikzlibrary{shadows} 34 | \tikzset{>=latex} 35 | \tikzset{every picture/.style=thick} 36 | 37 | 38 | % % % % % % % % % % 39 | % MISC 40 | % % % % % % % % % % 41 | \usepackage 42 | [ 43 | %disable 44 | ]{todonotes} 45 | \usepackage[utf8]{inputenc} % allow utf-8 input 46 | \usepackage[T1]{fontenc} % use 8-bit T1 fonts 47 | %\usepackage[english]{babel} % hyphenation, special characters, ... 48 | \usepackage{csquotes} % recommended with babel for quotes 49 | \usepackage[hidelinks,breaklinks]{hyperref} % hyperlinks 50 | \usepackage{cleveref} % provides \cref for nice in-document refs 51 | \usepackage{url} % simple URL typesetting 52 | \usepackage{nicefrac} % compact symbols for 1/2, etc. 53 | \usepackage{booktabs} 54 | %\usepackage 55 | %[ 56 | %activate={true,nocompatibility}, % activate protrusion and expansion 57 | %final, % enable microtype; use "draft" to disable 58 | %tracking=true, 59 | %kerning=true, 60 | %spacing=true, 61 | %factor=1100, % add 10% to the protrusion amount (default: 1000) 62 | %stretch=10, % reduce stretchability (default: 20) 63 | %shrink=10 % reduce shrinkability (default: 20) 64 | %] 65 | %{microtype} 66 | %\microtypecontext{spacing=nonfrench} 67 | \usepackage{cancel} % easy cancelling of terms: \cancel{expression} 68 | \usepackage[shortcuts]{extdash} % use, e.g., \-/ for hyphen within a word to indicate that the word may be broken here 69 | \usepackage[printonlyused]{acronym} 70 | \renewcommand{\acffont}[1]{\emph{#1}} 71 | \renewcommand{\acfsfont}[1]{\normalfont #1} 72 | \newcommand{\accite}[2]{\acffont{\acl{#1}} (\acsu{#1}; \cite{#2})\xspace} 73 | \newcommand{\acpcite}[2]{\acffont{\aclp{#1}} (\acsp{#1}\acused{#1}; \cite{#2})\xspace} --------------------------------------------------------------------------------