├── .gitignore ├── Makefile ├── agda.lagda.tex ├── agda.pdf ├── agda.sty ├── biblio.bib ├── tufte-book.cls ├── tufte-common.def ├── tufte-handout.cls └── tufte.bst /.gitignore: -------------------------------------------------------------------------------- 1 | \#*\# 2 | /.emacs.desktop 3 | /.emacs.desktop.lock 4 | auto-save-list 5 | latex 6 | tramp 7 | .\#* 8 | *~ 9 | *.agdai 10 | *.aux 11 | *_aux 12 | *.bak 13 | *.bbl 14 | *.blg 15 | *.bin 16 | *.dvi 17 | *.dyn_hi 18 | *.dyn_o 19 | *.elc 20 | *.fdb_latexmk 21 | *.fls 22 | *.hi 23 | *.log 24 | *.o 25 | *.out 26 | *.ptb 27 | *.snm 28 | *.tmp 29 | *.tmp.* 30 | *.toc 31 | *.xcp 32 | *.xdv 33 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | .PHONY : clean realclean 2 | .PRECIOUS : %.tex 3 | 4 | default: agda.pdf 5 | 6 | %.pdf : latex/%.tex agda.sty 7 | latexmk --pdf -pdflatex="pdflatex -interaction=nonstopmode" -use-make $< 8 | 9 | latex/%.tex : %.lagda.tex 10 | agda-2.6.5 --latex $< 11 | 12 | clean: 13 | rm -f *.aux *.log *.out *.ptb *.blg *.fdb_latexmk *.agdai *.fls *.toc *~ 14 | 15 | realclean: clean 16 | rm -f *.glob *.vo *.bbl latex/* agda.pdf 17 | 18 | 19 | -------------------------------------------------------------------------------- /agda.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jespercockx/agda-lecture-notes/fa1f8e2587b0eebc7e2613fcd389b4b9e3377072/agda.pdf -------------------------------------------------------------------------------- /agda.sty: -------------------------------------------------------------------------------- 1 | % ---------------------------------------------------------------------- 2 | % Some useful commands when doing highlighting of Agda code in LaTeX. 3 | % ---------------------------------------------------------------------- 4 | 5 | \ProvidesPackage{agda} 6 | 7 | \RequirePackage{ifxetex, ifluatex, xifthen, xcolor, polytable, etoolbox, 8 | calc, environ, xparse, xkeyval} 9 | 10 | % https://tex.stackexchange.com/questions/47576/combining-ifxetex-and-ifluatex-with-the-logical-or-operation 11 | \newif\ifxetexorluatex 12 | \ifxetex 13 | \xetexorluatextrue 14 | \else 15 | \ifluatex 16 | \xetexorluatextrue 17 | \else 18 | \xetexorluatexfalse 19 | \fi 20 | \fi 21 | 22 | % ---------------------------------------------------------------------- 23 | % Options 24 | 25 | \DeclareOption{bw} {\newcommand{\AgdaColourScheme}{bw}} 26 | \DeclareOption{conor}{\newcommand{\AgdaColourScheme}{conor}} 27 | 28 | \newif\if@AgdaEnableReferences\@AgdaEnableReferencesfalse 29 | \DeclareOption{references}{ 30 | \@AgdaEnableReferencestrue 31 | } 32 | 33 | \newif\if@AgdaEnableLinks\@AgdaEnableLinksfalse 34 | \DeclareOption{links}{ 35 | \@AgdaEnableLinkstrue 36 | } 37 | 38 | \ProcessOptions\relax 39 | 40 | % ---------------------------------------------------------------------- 41 | % Font setup 42 | 43 | \tracinglostchars=2 % If the font is missing some symbol, then say 44 | % so in the compilation output. 45 | 46 | % ---------------------------------------------------------------------- 47 | % Colour schemes. 48 | 49 | \providecommand{\AgdaColourScheme}{standard} 50 | 51 | % ---------------------------------------------------------------------- 52 | % References to code (needs additional post-processing of tex files to 53 | % work, see wiki for details). 54 | 55 | \if@AgdaEnableReferences 56 | \RequirePackage{catchfilebetweentags, xstring} 57 | \newcommand{\AgdaRef}[2][]{% 58 | \StrSubstitute{#2}{\_}{AgdaUnderscore}[\tmp]% 59 | \ifthenelse{\isempty{#1}}% 60 | {\ExecuteMetaData{AgdaTag-\tmp}}% 61 | {\ExecuteMetaData{#1}{AgdaTag-\tmp}} 62 | } 63 | \fi 64 | 65 | \providecommand{\AgdaRef}[2][]{#2} 66 | 67 | % ---------------------------------------------------------------------- 68 | % Links (only done if the option is passed and the user has loaded the 69 | % hyperref package). 70 | 71 | \if@AgdaEnableLinks 72 | \@ifpackageloaded{hyperref}{ 73 | 74 | % List that holds added targets. 75 | \newcommand{\AgdaList}[0]{} 76 | 77 | \newtoggle{AgdaIsElem} 78 | \newcounter{AgdaIndex} 79 | \newcommand{\AgdaLookup}[3]{% 80 | \togglefalse{AgdaIsElem}% 81 | \setcounter{AgdaIndex}{0}% 82 | \renewcommand*{\do}[1]{% 83 | \ifstrequal{#1}{##1}% 84 | {\toggletrue{AgdaIsElem}\listbreak}% 85 | {\stepcounter{AgdaIndex}}}% 86 | \dolistloop{\AgdaList}% 87 | \iftoggle{AgdaIsElem}{#2}{#3}% 88 | } 89 | 90 | \newcommand*{\AgdaTargetHelper}[1]{% 91 | \AgdaLookup{#1}% 92 | {\PackageError{agda}{``#1'' used as target more than once}% 93 | {Overloaded identifiers and links do not% 94 | work well, consider using unique% 95 | \MessageBreak identifiers instead.}% 96 | }% 97 | {\listadd{\AgdaList}{#1}% 98 | \hypertarget{Agda\theAgdaIndex}{}% 99 | }% 100 | } 101 | 102 | \newcommand{\AgdaTarget}[1]{\forcsvlist{\AgdaTargetHelper}{#1}} 103 | 104 | \newcommand{\AgdaLink}[1]{% 105 | \AgdaLookup{#1}% 106 | {\hyperlink{Agda\theAgdaIndex}{#1}}% 107 | {#1}% 108 | } 109 | }{\PackageError{agda}{Load the hyperref package before the agda package}{}} 110 | \fi 111 | 112 | \providecommand{\AgdaTarget}[1]{} 113 | \providecommand{\AgdaLink}[1]{#1} 114 | 115 | % ---------------------------------------------------------------------- 116 | % Font styles. 117 | 118 | \newcommand{\AgdaFontStyle}[1]{\texttt{#1}} 119 | \ifthenelse{\equal{\AgdaColourScheme}{bw}}{ 120 | \newcommand{\AgdaKeywordFontStyle}[1]{\underline{#1}} 121 | }{ 122 | \newcommand{\AgdaKeywordFontStyle}[1]{\texttt{#1}} 123 | } 124 | \newcommand{\AgdaStringFontStyle}[1]{\texttt{#1}} 125 | \newcommand{\AgdaCommentFontStyle}[1]{\texttt{#1}} 126 | \newcommand{\AgdaBoundFontStyle}[1]{\textit{#1}} 127 | 128 | % ---------------------------------------------------------------------- 129 | % Colours. 130 | 131 | % ---------------------------------- 132 | % The black and white colour scheme. 133 | \ifthenelse{\equal{\AgdaColourScheme}{bw}}{ 134 | 135 | % Aspect colours. 136 | \definecolor{AgdaComment} {HTML}{000000} 137 | \definecolor{AgdaPragma} {HTML}{000000} 138 | \definecolor{AgdaKeyword} {HTML}{000000} 139 | \definecolor{AgdaString} {HTML}{000000} 140 | \definecolor{AgdaNumber} {HTML}{000000} 141 | \definecolor{AgdaSymbol} {HTML}{000000} 142 | \definecolor{AgdaPrimitiveType}{HTML}{000000} 143 | 144 | % NameKind colours. 145 | \definecolor{AgdaBound} {HTML}{000000} 146 | \definecolor{AgdaGeneralizable} {HTML}{000000} 147 | \definecolor{AgdaInductiveConstructor} {HTML}{000000} 148 | \definecolor{AgdaCoinductiveConstructor}{HTML}{000000} 149 | \definecolor{AgdaDatatype} {HTML}{000000} 150 | \definecolor{AgdaField} {HTML}{000000} 151 | \definecolor{AgdaFunction} {HTML}{000000} 152 | \definecolor{AgdaMacro} {HTML}{000000} 153 | \definecolor{AgdaModule} {HTML}{000000} 154 | \definecolor{AgdaPostulate} {HTML}{000000} 155 | \definecolor{AgdaPrimitive} {HTML}{000000} 156 | \definecolor{AgdaRecord} {HTML}{000000} 157 | \definecolor{AgdaArgument} {HTML}{000000} 158 | 159 | % Other aspect colours. 160 | \definecolor{AgdaDottedPattern} {HTML}{000000} 161 | \definecolor{AgdaUnsolvedMeta} {HTML}{D3D3D3} 162 | \definecolor{AgdaUnsolvedConstraint}{HTML}{D3D3D3} 163 | \definecolor{AgdaTerminationProblem}{HTML}{BEBEBE} 164 | \definecolor{AgdaIncompletePattern} {HTML}{D3D3D3} 165 | \definecolor{AgdaError} {HTML}{696969} 166 | 167 | % Misc. 168 | \definecolor{AgdaHole} {HTML}{BEBEBE} 169 | 170 | % ---------------------------------- 171 | % Conor McBride's colour scheme. 172 | }{ \ifthenelse{\equal{\AgdaColourScheme}{conor}}{ 173 | 174 | % Aspect colours. 175 | \definecolor{AgdaComment} {HTML}{B22222} 176 | \definecolor{AgdaPragma} {HTML}{000000} 177 | \definecolor{AgdaKeyword} {HTML}{000000} 178 | \definecolor{AgdaString} {HTML}{000000} 179 | \definecolor{AgdaNumber} {HTML}{000000} 180 | \definecolor{AgdaSymbol} {HTML}{000000} 181 | \definecolor{AgdaPrimitiveType}{HTML}{0000CD} 182 | 183 | % NameKind colours. 184 | \definecolor{AgdaBound} {HTML}{A020F0} 185 | \definecolor{AgdaGeneralizable} {HTML}{A020F0} 186 | \definecolor{AgdaInductiveConstructor} {HTML}{8B0000} 187 | \definecolor{AgdaCoinductiveConstructor}{HTML}{8B0000} 188 | \definecolor{AgdaDatatype} {HTML}{0000CD} 189 | \definecolor{AgdaField} {HTML}{8B0000} 190 | \definecolor{AgdaFunction} {HTML}{006400} 191 | \definecolor{AgdaMacro} {HTML}{006400} 192 | \definecolor{AgdaModule} {HTML}{006400} 193 | \definecolor{AgdaPostulate} {HTML}{006400} 194 | \definecolor{AgdaPrimitive} {HTML}{006400} 195 | \definecolor{AgdaRecord} {HTML}{0000CD} 196 | \definecolor{AgdaArgument} {HTML}{404040} 197 | 198 | % Other aspect colours. 199 | \definecolor{AgdaDottedPattern} {HTML}{000000} 200 | \definecolor{AgdaUnsolvedMeta} {HTML}{FFD700} 201 | \definecolor{AgdaUnsolvedConstraint}{HTML}{FFD700} 202 | \definecolor{AgdaTerminationProblem}{HTML}{FF0000} 203 | \definecolor{AgdaIncompletePattern} {HTML}{A020F0} 204 | \definecolor{AgdaError} {HTML}{F4A460} 205 | 206 | % Misc. 207 | \definecolor{AgdaHole} {HTML}{9DFF9D} 208 | 209 | % ---------------------------------- 210 | % The standard colour scheme. 211 | }{ 212 | % Aspect colours. 213 | \definecolor{AgdaComment} {HTML}{B22222} 214 | \definecolor{AgdaPragma} {HTML}{000000} 215 | \definecolor{AgdaKeyword} {HTML}{CD6600} 216 | \definecolor{AgdaString} {HTML}{B22222} 217 | \definecolor{AgdaNumber} {HTML}{A020F0} 218 | \definecolor{AgdaSymbol} {HTML}{404040} 219 | \definecolor{AgdaPrimitiveType}{HTML}{0000CD} 220 | 221 | % NameKind colours. 222 | \definecolor{AgdaBound} {HTML}{000000} 223 | \definecolor{AgdaGeneralizable} {HTML}{000000} 224 | \definecolor{AgdaInductiveConstructor} {HTML}{008B00} 225 | \definecolor{AgdaCoinductiveConstructor}{HTML}{8B7500} 226 | \definecolor{AgdaDatatype} {HTML}{0000CD} 227 | \definecolor{AgdaField} {HTML}{EE1289} 228 | \definecolor{AgdaFunction} {HTML}{0000CD} 229 | \definecolor{AgdaMacro} {HTML}{458B74} 230 | \definecolor{AgdaModule} {HTML}{A020F0} 231 | \definecolor{AgdaPostulate} {HTML}{0000CD} 232 | \definecolor{AgdaPrimitive} {HTML}{0000CD} 233 | \definecolor{AgdaRecord} {HTML}{0000CD} 234 | \definecolor{AgdaArgument} {HTML}{404040} 235 | 236 | % Other aspect colours. 237 | \definecolor{AgdaDottedPattern} {HTML}{000000} 238 | \definecolor{AgdaUnsolvedMeta} {HTML}{FFFF00} 239 | \definecolor{AgdaUnsolvedConstraint}{HTML}{FFFF00} 240 | \definecolor{AgdaTerminationProblem}{HTML}{FFA07A} 241 | \definecolor{AgdaIncompletePattern} {HTML}{F5DEB3} 242 | \definecolor{AgdaError} {HTML}{FF0000} 243 | 244 | % Misc. 245 | \definecolor{AgdaHole} {HTML}{9DFF9D} 246 | }} 247 | 248 | % ---------------------------------------------------------------------- 249 | % Commands. 250 | 251 | \newcommand{\AgdaNoSpaceMath}[1] 252 | {\begingroup\thickmuskip=0mu\medmuskip=0mu#1\endgroup} 253 | 254 | % Aspect commands. 255 | \newcommand{\AgdaComment} [1] 256 | {\AgdaNoSpaceMath{\AgdaCommentFontStyle{\textcolor{AgdaComment}{#1}}}} 257 | \newcommand{\AgdaPragma} [1] 258 | {\AgdaNoSpaceMath{\AgdaCommentFontStyle{\textcolor{AgdaPragma}{#1}}}} 259 | \newcommand{\AgdaKeyword} [1] 260 | {\AgdaNoSpaceMath{\AgdaKeywordFontStyle{\textcolor{AgdaKeyword}{#1}}}} 261 | \newcommand{\AgdaString} [1] 262 | {\AgdaNoSpaceMath{\AgdaStringFontStyle{\textcolor{AgdaString}{#1}}}} 263 | \newcommand{\AgdaNumber} [1] 264 | {\AgdaNoSpaceMath{\AgdaFontStyle{\textcolor{AgdaNumber}{#1}}}} 265 | \newcommand{\AgdaSymbol} [1] 266 | {\AgdaNoSpaceMath{\AgdaFontStyle{\textcolor{AgdaSymbol}{#1}}}} 267 | \newcommand{\AgdaPrimitiveType}[1] 268 | {\AgdaNoSpaceMath{\AgdaFontStyle{\textcolor{AgdaPrimitiveType}{#1}}}} 269 | % Note that, in code generated by the LaTeX backend, \AgdaOperator is 270 | % always applied to a NameKind command. 271 | \newcommand{\AgdaOperator} [1]{#1} 272 | 273 | % NameKind commands. 274 | 275 | % The user can control the typesetting of (certain) individual tokens 276 | % by redefining the following command. The first argument is the token 277 | % and the second argument the thing to be typeset (sometimes just the 278 | % token, sometimes \AgdaLink{}). Example: 279 | % 280 | % \usepackage{ifthen} 281 | % 282 | % % Insert extra space before some tokens. 283 | % \DeclareRobustCommand{\AgdaFormat}[2]{% 284 | % \ifthenelse{ 285 | % \equal{#1}{≡⟨} \OR 286 | % \equal{#1}{≡⟨⟩} \OR 287 | % \equal{#1}{∎} 288 | % }{\ }{}#2} 289 | % 290 | % Note the use of \DeclareRobustCommand. 291 | 292 | \newcommand{\AgdaFormat}[2]{#2} 293 | 294 | \newcommand{\AgdaBound}[1] 295 | {\AgdaNoSpaceMath{\AgdaBoundFontStyle{\textcolor{AgdaBound}{\AgdaFormat{#1}{#1}}}}} 296 | \newcommand{\AgdaGeneralizable}[1] 297 | {\AgdaNoSpaceMath{\AgdaBoundFontStyle{\textcolor{AgdaGeneralizable}{\AgdaFormat{#1}{#1}}}}} 298 | \newcommand{\AgdaInductiveConstructor}[1] 299 | {\AgdaNoSpaceMath{\AgdaFontStyle{\textcolor{AgdaInductiveConstructor}{\AgdaFormat{#1}{\AgdaLink{#1}}}}}} 300 | \newcommand{\AgdaCoinductiveConstructor}[1] 301 | {\AgdaNoSpaceMath{\AgdaFontStyle{\textcolor{AgdaCoinductiveConstructor}{\AgdaFormat{#1}{\AgdaLink{#1}}}}}} 302 | \newcommand{\AgdaDatatype}[1] 303 | {\AgdaNoSpaceMath{\AgdaFontStyle{\textcolor{AgdaDatatype}{\AgdaFormat{#1}{\AgdaLink{#1}}}}}} 304 | \newcommand{\AgdaField}[1] 305 | {\AgdaNoSpaceMath{\AgdaFontStyle{\textcolor{AgdaField}{\AgdaFormat{#1}{\AgdaLink{#1}}}}}} 306 | \newcommand{\AgdaFunction}[1] 307 | {\AgdaNoSpaceMath{\AgdaFontStyle{\textcolor{AgdaFunction}{\AgdaFormat{#1}{\AgdaLink{#1}}}}}} 308 | \newcommand{\AgdaMacro}[1] 309 | {\AgdaNoSpaceMath{\AgdaFontStyle{\textcolor{AgdaMacro}{\AgdaFormat{#1}{\AgdaLink{#1}}}}}} 310 | \newcommand{\AgdaModule}[1] 311 | {\AgdaNoSpaceMath{\AgdaFontStyle{\textcolor{AgdaModule}{\AgdaFormat{#1}{\AgdaLink{#1}}}}}} 312 | \newcommand{\AgdaPostulate}[1] 313 | {\AgdaNoSpaceMath{\AgdaFontStyle{\textcolor{AgdaPostulate}{\AgdaFormat{#1}{\AgdaLink{#1}}}}}} 314 | \newcommand{\AgdaPrimitive}[1] 315 | {\AgdaNoSpaceMath{\AgdaFontStyle{\textcolor{AgdaPrimitive}{\AgdaFormat{#1}{#1}}}}} 316 | \newcommand{\AgdaRecord}[1] 317 | {\AgdaNoSpaceMath{\AgdaFontStyle{\textcolor{AgdaRecord}{\AgdaFormat{#1}{\AgdaLink{#1}}}}}} 318 | \newcommand{\AgdaArgument}[1] 319 | {\AgdaNoSpaceMath{\AgdaBoundFontStyle{\textcolor{AgdaArgument}{\AgdaFormat{#1}{#1}}}}} 320 | 321 | % Other aspect commands. 322 | \newcommand{\AgdaFixityOp} [1]{\AgdaNoSpaceMath{$#1$}} 323 | \newcommand{\AgdaDottedPattern} [1]{\textcolor{AgdaDottedPattern}{#1}} 324 | \newcommand{\AgdaUnsolvedMeta} [1] 325 | {\AgdaFontStyle{\colorbox{AgdaUnsolvedMeta}{#1}}} 326 | \newcommand{\AgdaUnsolvedConstraint}[1] 327 | {\AgdaFontStyle{\colorbox{AgdaUnsolvedConstraint}{#1}}} 328 | \newcommand{\AgdaTerminationProblem}[1] 329 | {\AgdaFontStyle{\colorbox{AgdaTerminationProblem}{#1}}} 330 | \newcommand{\AgdaIncompletePattern} [1]{\colorbox{AgdaIncompletePattern}{#1}} 331 | \newcommand{\AgdaError} [1] 332 | {\AgdaFontStyle{\textcolor{AgdaError}{\underline{#1}}}} 333 | \newcommand{\AgdaCatchallClause} [1]{#1} % feel free to change this 334 | 335 | % Used to hide code from LaTeX. 336 | % 337 | % Note that this macro has been deprecated in favour of giving the 338 | % hide argument to the code environment. 339 | \long\def\AgdaHide#1{\ignorespaces} 340 | 341 | % Misc. 342 | \newcommand{\AgdaHole}[1]{\colorbox{AgdaHole}{#1}} 343 | 344 | % ---------------------------------------------------------------------- 345 | % The code environment. 346 | 347 | \newcommand{\AgdaCodeStyle}{} 348 | % \newcommand{\AgdaCodeStyle}{\tiny} 349 | 350 | \ifdefined\mathindent 351 | {} 352 | \else 353 | \newdimen\mathindent\mathindent\leftmargini 354 | \fi 355 | 356 | % Adds the given amount of vertical space and starts a new line. 357 | % 358 | % The implementation comes from lhs2TeX's polycode.fmt, written by 359 | % Andres Löh. 360 | \newcommand{\Agda@NewlineWithVerticalSpace}[1]{% 361 | {\parskip=0pt\parindent=0pt\par\vskip #1\noindent}} 362 | 363 | % Should there be space around code? 364 | \newboolean{Agda@SpaceAroundCode} 365 | 366 | % Use this command to avoid extra space around code blocks. 367 | \newcommand{\AgdaNoSpaceAroundCode}{% 368 | \setboolean{Agda@SpaceAroundCode}{false}} 369 | 370 | % Use this command to include extra space around code blocks. 371 | \newcommand{\AgdaSpaceAroundCode}{% 372 | \setboolean{Agda@SpaceAroundCode}{true}} 373 | 374 | % By default space is inserted around code blocks. 375 | \AgdaSpaceAroundCode{} 376 | 377 | % Sometimes one might want to break up a code block into multiple 378 | % pieces, but keep code in different blocks aligned with respect to 379 | % each other. Then one can use the AgdaAlign environment. Example 380 | % usage: 381 | % 382 | % \begin{AgdaAlign} 383 | % \begin{code} 384 | % code 385 | % code (more code) 386 | % \end{code} 387 | % Explanation... 388 | % \begin{code} 389 | % aligned with "code" 390 | % code (aligned with (more code)) 391 | % \end{code} 392 | % \end{AgdaAlign} 393 | % 394 | % Note that AgdaAlign environments should not be nested. 395 | % 396 | % Sometimes one might also want to hide code in the middle of a code 397 | % block. This can be accomplished in the following way: 398 | % 399 | % \begin{AgdaAlign} 400 | % \begin{code} 401 | % visible 402 | % \end{code} 403 | % \begin{code}[hide] 404 | % hidden 405 | % \end{code} 406 | % \begin{code} 407 | % visible 408 | % \end{code} 409 | % \end{AgdaAlign} 410 | % 411 | % However, the result may be ugly: extra space is perhaps inserted 412 | % around the code blocks. 413 | % 414 | % The AgdaSuppressSpace environment ensures that extra space is only 415 | % inserted before the first code block, and after the last one (but 416 | % not if \AgdaNoSpaceAroundCode{} is used). Example usage: 417 | % 418 | % \begin{AgdaAlign} 419 | % \begin{code} 420 | % code 421 | % more code 422 | % \end{code} 423 | % Explanation... 424 | % \begin{AgdaSuppressSpace} 425 | % \begin{code} 426 | % aligned with "code" 427 | % aligned with "more code" 428 | % \end{code} 429 | % \begin{code}[hide] 430 | % hidden code 431 | % \end{code} 432 | % \begin{code} 433 | % also aligned with "more code" 434 | % \end{code} 435 | % \end{AgdaSuppressSpace} 436 | % \end{AgdaAlign} 437 | % 438 | % Note that AgdaSuppressSpace environments should not be nested. 439 | % 440 | % There is also a combined environment, AgdaMultiCode, that combines 441 | % the effects of AgdaAlign and AgdaSuppressSpace. 442 | 443 | % The number of the current/next code block (excluding hidden ones). 444 | \newcounter{Agda@Current} 445 | \setcounter{Agda@Current}{0} 446 | 447 | % The number of the previous code block (excluding hidden ones), used 448 | % locally in \Agda@SuppressEnd. 449 | \newcounter{Agda@Previous} 450 | 451 | % Is AgdaAlign active? 452 | \newboolean{Agda@Align} 453 | \setboolean{Agda@Align}{false} 454 | 455 | % The number of the first code block (if any) in a given AgdaAlign 456 | % environment. 457 | \newcounter{Agda@AlignStart} 458 | 459 | \newcommand{\Agda@AlignStart}{% 460 | \ifthenelse{\boolean{Agda@Align}}{% 461 | \PackageError{agda}{Nested AgdaAlign environments}{% 462 | AgdaAlign and AgdaMultiCode environments must not be 463 | nested.}}{% 464 | \setboolean{Agda@Align}{true}% 465 | \setcounter{Agda@AlignStart}{\value{Agda@Current}}}} 466 | 467 | \newcommand{\Agda@AlignEnd}{\setboolean{Agda@Align}{false}} 468 | 469 | \newenvironment{AgdaAlign}{% 470 | \Agda@AlignStart{}}{% 471 | \Agda@AlignEnd{}% 472 | \ignorespacesafterend} 473 | 474 | % Is AgdaSuppressSpace active? 475 | \newboolean{Agda@Suppress} 476 | \setboolean{Agda@Suppress}{false} 477 | 478 | % The number of the first code block (if any) in a given 479 | % AgdaSuppressSpace environment. 480 | \newcounter{Agda@SuppressStart} 481 | 482 | % Does a "do not suppress space after" label exist for the current 483 | % code block? (This boolean is used locally in the code environment's 484 | % implementation.) 485 | \newboolean{Agda@DoNotSuppressSpaceAfter} 486 | 487 | \newcommand{\Agda@SuppressStart}{% 488 | \ifthenelse{\boolean{Agda@Suppress}}{% 489 | \PackageError{agda}{Nested AgdaSuppressSpace environments}{% 490 | AgdaSuppressSpace and AgdaMultiCode environments must not be 491 | nested.}}{% 492 | \setboolean{Agda@Suppress}{true}% 493 | \setcounter{Agda@SuppressStart}{\value{Agda@Current}}}} 494 | 495 | % Marks the given code block as one that space should not be 496 | % suppressed after (if AgdaSpaceAroundCode and AgdaSuppressSpace are 497 | % both active). 498 | \newcommand{\Agda@DoNotSuppressSpaceAfter}[1]{% 499 | % The use of labels is intended to ensure that LaTeX will provide a 500 | % warning if the document needs to be recompiled. 501 | \label{Agda@DoNotSuppressSpaceAfter@#1}} 502 | 503 | \newcommand{\Agda@SuppressEnd}{% 504 | \ifthenelse{\value{Agda@SuppressStart} = \value{Agda@Current}}{}{% 505 | % Mark the previous code block in the .aux file. 506 | \setcounter{Agda@Previous}{\theAgda@Current-1}% 507 | \immediate\write\@auxout{% 508 | \noexpand\Agda@DoNotSuppressSpaceAfter{\theAgda@Previous}}}% 509 | \setboolean{Agda@Suppress}{false}} 510 | 511 | \newenvironment{AgdaSuppressSpace}{% 512 | \Agda@SuppressStart{}}{% 513 | \Agda@SuppressEnd{}% 514 | \ignorespacesafterend} 515 | 516 | \newenvironment{AgdaMultiCode}{% 517 | \Agda@AlignStart{}% 518 | \Agda@SuppressStart{}}{% 519 | \Agda@SuppressEnd{}% 520 | \Agda@AlignEnd{}% 521 | \ignorespacesafterend} 522 | 523 | % Vertical space used for empty lines. By default \abovedisplayskip. 524 | \newlength{\AgdaEmptySkip} 525 | \setlength{\AgdaEmptySkip}{\abovedisplayskip} 526 | 527 | % Extra space to be inserted for empty lines (the difference between 528 | % \AgdaEmptySkip and \baselineskip). Used internally. 529 | \newlength{\AgdaEmptyExtraSkip} 530 | 531 | % Counter used for code numbers. 532 | \newcounter{AgdaCodeNumber} 533 | % Formats a code number. 534 | \newcommand{\AgdaFormatCodeNumber}[1]{(#1)} 535 | 536 | % A boolean used to handle the option number. 537 | \newboolean{Agda@Number} 538 | \setboolean{Agda@Number}{false} 539 | 540 | % A boolean used to handle the option inline*. (For some reason the 541 | % approach used for hide and inline does not work for inline*.) 542 | \newboolean{Agda@InlineStar} 543 | \setboolean{Agda@InlineStar}{false} 544 | 545 | % Keys used by the code environment. 546 | \define@boolkey[Agda]{code}{hide}[true]{} 547 | \define@boolkey[Agda]{code}{inline}[true]{} 548 | \define@boolkey[Agda]{code}{inline*}[true]{% 549 | \setboolean{Agda@InlineStar}{true}} 550 | \define@key[Agda]{code}{number}[]{% 551 | \ifthenelse{\boolean{Agda@Number}}{}{% 552 | \setboolean{Agda@Number}{true}% 553 | % Increase the counter if this has not already been done. 554 | \refstepcounter{AgdaCodeNumber}}% 555 | % If the label is non-empty, set it. Note that it is possible to 556 | % give several labels for a single code listing. 557 | \ifthenelse{\equal{#1}{}}{}{\label{#1}}} 558 | 559 | % The code environment. 560 | % 561 | % Options: 562 | % 563 | % * hide: The code is hidden. Other options are ignored. 564 | % 565 | % * number: Give the code an equation number. 566 | % 567 | % * number=l: Give the code an equation number and the label l. It is 568 | % possible to use this option several times with different labels. 569 | % 570 | % * inline/inline*: The code is inlined. In this case most of the 571 | % discussion above does not apply, alignment is not respected, and so 572 | % on. It is recommended to only use this option for a single line of 573 | % code, and to not use two consecutive spaces in this piece of code. 574 | % 575 | % Note that this environment ignores spaces after its end. If a space 576 | % (\AgdaSpace{}) should be inserted after the inline code, use 577 | % inline*, otherwise use inline. 578 | % 579 | % When this option is used number is ignored. 580 | % 581 | % The implementation is based on plainhscode in lhs2TeX's 582 | % polycode.fmt, written by Andres Löh. 583 | \NewEnviron{code}[1][]{% 584 | % Process the options. Complain about unknown options. 585 | \setkeys[Agda]{code}[number]{#1}% 586 | \ifAgda@code@hide% 587 | % Hide the code. 588 | \else% 589 | \ifAgda@code@inline% 590 | % Inline code. 591 | % 592 | % Make the polytable primitives emitted by the LaTeX backend 593 | % do nothing. 594 | \DeclareDocumentCommand{\>}{O{}O{}}{}% 595 | \DeclareDocumentCommand{\<}{O{}}{}% 596 | \AgdaCodeStyle\BODY% 597 | \else% 598 | \ifthenelse{\boolean{Agda@InlineStar}}{% 599 | % Inline code with space at the end. 600 | % 601 | \DeclareDocumentCommand{\>}{O{}O{}}{}% 602 | \DeclareDocumentCommand{\<}{O{}}{}% 603 | \AgdaCodeStyle\BODY\AgdaSpace{}}{% 604 | % 605 | % Displayed code. 606 | % 607 | % Conditionally emit space before the code block. Unconditionally 608 | % switch to a new line. 609 | \ifthenelse{\boolean{Agda@SpaceAroundCode} \and% 610 | \(\not \boolean{Agda@Suppress} \or% 611 | \value{Agda@SuppressStart} = \value{Agda@Current}\)}{% 612 | \Agda@NewlineWithVerticalSpace{\abovedisplayskip}}{% 613 | \Agda@NewlineWithVerticalSpace{0pt}}% 614 | % 615 | % Check if numbers have been requested. If they have, then a side 616 | % effect of this call is that Agda@Number is set to true, the code 617 | % number counter is increased, and the label (if any) is set. 618 | \setkeys[Agda]{code}[hide,inline,inline*]{#1}% 619 | \ifthenelse{\boolean{Agda@Number}}{% 620 | % Equation numbers have been requested. Use a minipage, so that 621 | % there is room for the code number to the right, and the code 622 | % number becomes centered vertically. 623 | \begin{minipage}{% 624 | \linewidth-% 625 | \widthof{% 626 | \AgdaSpace{}% 627 | \AgdaFormatCodeNumber{\theAgdaCodeNumber}}}}{}% 628 | % 629 | % Indent the entire code block. 630 | \advance\leftskip\mathindent% 631 | % 632 | % The code's style can be customised. 633 | \AgdaCodeStyle% 634 | % 635 | % Used to control the height of empty lines. 636 | \setlength{\AgdaEmptyExtraSkip}{\AgdaEmptySkip - \baselineskip}% 637 | % 638 | % The environment used to handle indentation (of individual lines) 639 | % and alignment. 640 | \begin{pboxed}% 641 | % 642 | % Conditionally preserve alignment between code blocks. 643 | \ifthenelse{\boolean{Agda@Align}}{% 644 | \ifthenelse{\value{Agda@AlignStart} = \value{Agda@Current}}{% 645 | \savecolumns}{% 646 | \restorecolumns}}{}% 647 | % 648 | % The code. 649 | \BODY% 650 | \end{pboxed}% 651 | % 652 | \ifthenelse{\boolean{Agda@Number}}{% 653 | % Equation numbers have been requested. 654 | \end{minipage}% 655 | % Insert the code number to the right. 656 | \hfill \AgdaFormatCodeNumber{\theAgdaCodeNumber}}{}% 657 | % 658 | % Does the label Agda@DoNotSuppressAfter@ exist? 660 | \ifcsdef{r@Agda@DoNotSuppressSpaceAfter@\theAgda@Current}{% 661 | \setboolean{Agda@DoNotSuppressSpaceAfter}{true}}{% 662 | \setboolean{Agda@DoNotSuppressSpaceAfter}{false}}% 663 | % 664 | % Conditionally emit space after the code block. Unconditionally 665 | % switch to a new line. 666 | \ifthenelse{\boolean{Agda@SpaceAroundCode} \and% 667 | \(\not \boolean{Agda@Suppress} \or% 668 | \boolean{Agda@DoNotSuppressSpaceAfter}\)}{% 669 | \Agda@NewlineWithVerticalSpace{\belowdisplayskip}}{% 670 | \Agda@NewlineWithVerticalSpace{0pt}}% 671 | % 672 | % Step the code block counter, but only for non-hidden code. 673 | \stepcounter{Agda@Current}}% 674 | \fi% 675 | \fi% 676 | % Reset Agda@Number and Agda@InlineStar. 677 | \setboolean{Agda@Number}{false}% 678 | \setboolean{Agda@InlineStar}{false}} 679 | 680 | % Space inserted after tokens. 681 | \newcommand{\AgdaSpace}{ } 682 | 683 | % Space inserted to indent something. 684 | \newcommand{\AgdaIndentSpace}{\AgdaSpace{}$\;\;$} 685 | 686 | % Default column for polytable. 687 | \defaultcolumn{@{}l@{\AgdaSpace{}}} 688 | 689 | % \AgdaIndent expects a non-negative integer as its only argument. 690 | % This integer should be the distance, in code blocks, to the thing 691 | % relative to which the text is indented. 692 | % 693 | % The default implementation only indents if the thing that the text 694 | % is indented relative to exists in the same code block or is wrapped 695 | % in the same AgdaAlign or AgdaMultiCode environment. 696 | \newcommand{\AgdaIndent}[1]{% 697 | \ifthenelse{#1 = 0 698 | \or 699 | \( \boolean{Agda@Align} 700 | \and 701 | \cnttest{\value{Agda@Current} - #1}{>=}{ 702 | \value{Agda@AlignStart}} 703 | \)}{\AgdaIndentSpace{}}{}} 704 | 705 | % Underscores are typeset using \AgdaUnderscore{}. 706 | \newcommand{\AgdaUnderscore}{\_} 707 | 708 | \endinput 709 | -------------------------------------------------------------------------------- /biblio.bib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jespercockx/agda-lecture-notes/fa1f8e2587b0eebc7e2613fcd389b4b9e3377072/biblio.bib -------------------------------------------------------------------------------- /tufte-book.cls: -------------------------------------------------------------------------------- 1 | \NeedsTeXFormat{LaTeX2e}[1994/06/01] 2 | 3 | \ProvidesClass{tufte-book}[2015/06/30 v3.5.3 Tufte-book class] 4 | 5 | %% 6 | % Declare we're tufte-book 7 | \newcommand{\@tufte@class}{book}% the base LaTeX class (defaults to the book style) 8 | \newcommand{\@tufte@pkgname}{tufte-book}% the name of the package (defaults to tufte-handout) 9 | 10 | %% 11 | % Load the common style elements 12 | \input{tufte-common.def} 13 | 14 | 15 | %% 16 | % Set up any book-specific stuff now 17 | 18 | %% 19 | % The front matter in Tufte's /Beautiful Evidence/ contains everything up 20 | % to the opening page of Chapter 1. The running heads, when they appear, 21 | % contain only the (arabic) page number in the outside corner. 22 | %\newif\if@mainmatter \@mainmattertrue 23 | \renewcommand\frontmatter{% 24 | \if@openright% 25 | \cleardoublepage% 26 | \else% 27 | \clearpage% 28 | \fi% 29 | \@mainmatterfalse% 30 | \pagenumbering{arabic}% 31 | %\pagestyle{plain}% 32 | \fancyhf{}% 33 | \ifthenelse{\boolean{@tufte@twoside}}% 34 | {\fancyhead[LE,RO]{\thepage}}% 35 | {\fancyhead[RE,RO]{\thepage}}% 36 | } 37 | 38 | 39 | %% 40 | % The main matter in Tufte's /Beautiful Evidence/ doesn't restart the page 41 | % numbering---it continues where it left off in the front matter. 42 | \renewcommand\mainmatter{% 43 | \if@openright% 44 | \cleardoublepage% 45 | \else% 46 | \clearpage% 47 | \fi% 48 | \@mainmattertrue% 49 | \fancyhf{}% 50 | \ifthenelse{\boolean{@tufte@twoside}}% 51 | {% two-side 52 | \renewcommand{\chaptermark}[1]{\markboth{##1}{}}% 53 | \fancyhead[LE]{\thepage\quad\smallcaps{\newlinetospace{\plaintitle}}}% book title 54 | \fancyhead[RO]{\smallcaps{\newlinetospace{\leftmark}}\quad\thepage}% chapter title 55 | }% 56 | {% one-side 57 | \fancyhead[RE,RO]{\smallcaps{\newlinetospace{\plaintitle}}\quad\thepage}% book title 58 | }% 59 | } 60 | 61 | 62 | %% 63 | % The back matter contains appendices, indices, glossaries, endnotes, 64 | % bibliographies, list of contributors, illustration credits, etc. 65 | \renewcommand\backmatter{% 66 | \if@openright% 67 | \cleardoublepage% 68 | \else% 69 | \clearpage% 70 | \fi% 71 | \@mainmatterfalse% 72 | } 73 | 74 | %% 75 | % Only show the chapter titles in the table of contents 76 | \setcounter{tocdepth}{0} 77 | 78 | %% 79 | % If there is a `tufte-book-local.sty' file, load it. 80 | 81 | \IfFileExists{tufte-book-local.tex}{% 82 | \@tufte@info@noline{Loading tufte-book-local.tex}% 83 | \input{tufte-book-local}% 84 | }{} 85 | 86 | %% 87 | % End of file 88 | \endinput 89 | -------------------------------------------------------------------------------- /tufte-common.def: -------------------------------------------------------------------------------- 1 | %% 2 | %% This file contains the code that is common to the Tufte-LaTeX document classes. 3 | %% 4 | 5 | \ProvidesFile{tufte-common.def}[2015/06/21 v3.5.2 Common code for the Tufte-LaTeX styles] 6 | 7 | %% 8 | % The `xkeyval' package simplifies the user interface for the document class options 9 | \RequirePackage{xkeyval} 10 | 11 | %% 12 | % We use the `xifthen' package to handle our package option switches 13 | \RequirePackage{xifthen} 14 | 15 | %% 16 | % Define some shortcut macros for error/warning/info logging. 17 | \RequirePackage{hardwrap} 18 | \GenerateClassLogMacros[@tufte]{\@tufte@pkgname} 19 | \newcommand{\@tufte@debug@info}[1]{\ifthenelse{\boolean{@tufte@debug}}{\@tufte@info{#1}}{}} 20 | \newcommand{\@tufte@debug@info@noline}[1]{\ifthenelse{\boolean{@tufte@debug}}{\@tufte@info@noline{#1}}{}} 21 | 22 | %% 23 | % `debug' option -- provides more information in the .log file for use in 24 | % troubleshooting problems 25 | \newboolean{@tufte@debug} 26 | \DeclareOptionX[tufte]{debug}{\setboolean{@tufte@debug}{true}} 27 | 28 | %% 29 | % `nofonts' option -- doesn't load any fonts 30 | % `fonts' option -- tries to load fonts 31 | \newboolean{@tufte@loadfonts}\setboolean{@tufte@loadfonts}{true} 32 | \DeclareOptionX[tufte]{fonts}{\setboolean{@tufte@loadfonts}{true}} 33 | \DeclareOptionX[tufte]{nofonts}{\setboolean{@tufte@loadfonts}{false}} 34 | 35 | %% 36 | % `nols' option -- doesn't configure letterspacing 37 | % `ls' option -- configures letterspacing 38 | \newboolean{@tufte@letterspace}\setboolean{@tufte@letterspace}{true} 39 | \DeclareOptionX[tufte]{ls}{\setboolean{@tufte@letterspace}{true}} 40 | \DeclareOptionX[tufte]{nols}{\setboolean{@tufte@letterspace}{false}} 41 | 42 | %% 43 | % `nobib' option -- doesn't load natbib or adjust the \cite command 44 | \newboolean{@tufte@loadnatbib}\setboolean{@tufte@loadnatbib}{true} 45 | \DeclareOptionX[tufte]{nobib}{\setboolean{@tufte@loadnatbib}{false}} 46 | 47 | %% 48 | % `titlepage' option -- creates a full title page with \maketitle 49 | 50 | \newboolean{@tufte@titlepage} 51 | \DeclareOptionX[tufte]{titlepage}{\setboolean{@tufte@titlepage}{true}} 52 | \DeclareOptionX[tufte]{notitlepage}{\setboolean{@tufte@titlepage}{false}} 53 | 54 | %% 55 | % `a4paper' option 56 | 57 | \newboolean{@tufte@afourpaper} 58 | \DeclareOptionX[tufte]{a4paper}{\setboolean{@tufte@afourpaper}{true}} 59 | 60 | %% 61 | % `b5paper' option 62 | 63 | \newboolean{@tufte@bfivepaper} 64 | \DeclareOptionX[tufte]{b5paper}{\setboolean{@tufte@bfivepaper}{true}} 65 | 66 | %% 67 | % `sfsidenotes' option -- typesets sidenotes in sans serif typeface 68 | 69 | \newboolean{@tufte@sfsidenotes} 70 | \DeclareOptionX[tufte]{sfsidenotes}{\setboolean{@tufte@sfsidenotes}{true}} 71 | 72 | %% 73 | % `symmetric' option -- puts marginpar space to the outside edge of the page 74 | % Note: this option forces the twoside option (see the .cls files) 75 | 76 | \newboolean{@tufte@symmetric} 77 | \DeclareOptionX[tufte]{symmetric}{ 78 | \setboolean{@tufte@symmetric}{true} 79 | \@tufte@info@noline{The `symmetric' option implies `twoside'} 80 | \ExecuteOptionsX[tufte]{twoside} 81 | } 82 | 83 | %% 84 | % `twoside' option -- alternates running heads 85 | 86 | \newboolean{@tufte@twoside} 87 | \DeclareOptionX[tufte]{twoside}{% 88 | \setboolean{@tufte@twoside}{true} 89 | \@tufte@info@noline{Passing the `twoside' option to the `\@tufte@class' class} 90 | \PassOptionsToClass{twoside}{\@tufte@class} 91 | } 92 | 93 | %% 94 | % `notoc' option -- suppresses the Tufte-style table of contents 95 | 96 | \newboolean{@tufte@toc} 97 | \setboolean{@tufte@toc}{true} 98 | \DeclareOptionX[tufte]{notoc}{\setboolean{@tufte@toc}{false}} 99 | \DeclareOptionX[tufte]{toc}{\setboolean{@tufte@toc}{true}} 100 | 101 | %% 102 | % `justified' option -- uses fully justified text (flush left and flush 103 | % right) instead of ragged right. 104 | 105 | \newboolean{@tufte@justified} 106 | \DeclareOptionX[tufte]{justified}{\setboolean{@tufte@justified}{true}} 107 | 108 | %% 109 | % `bidi' option -- loads the bidi package for bi-directional text 110 | 111 | \newboolean{@tufte@loadbidi} 112 | \DeclareOptionX[tufte]{bidi}{\setboolean{@tufte@loadbidi}{true}} 113 | \DeclareOptionX[tufte]{nobidi}{\setboolean{@tufte@loadbidi}{false}} 114 | 115 | %% 116 | % `nohyper' option -- suppresses loading of the hyperref package 117 | 118 | \newboolean{@tufte@loadhyper} 119 | \setboolean{@tufte@loadhyper}{true} 120 | \DeclareOptionX[tufte]{hyper}{\setboolean{@tufte@loadhyper}{true}} 121 | \DeclareOptionX[tufte]{nohyper}{\setboolean{@tufte@loadhyper}{false}} 122 | 123 | %% 124 | % `sidenote', `marginnote', `caption', `citation', `marginals' options 125 | % Each allows one of {justified,raggedleft,raggedright,raggedouter,auto}. 126 | 127 | \newcommand*{\@tufte@sidenote@justification}{\@tufte@justification@autodetect} 128 | \define@choicekey*+[tufte]{common}{sidenote}[\@tufte@kvtext\@tufte@kvnum]{justified,raggedleft,raggedright,raggedouter,auto}[auto]{% 129 | \ifcase\@tufte@kvnum\relax 130 | \renewcommand*{\@tufte@sidenote@justification}{\justifying}% justified 131 | \or 132 | \renewcommand*{\@tufte@sidenote@justification}{\RaggedLeft}% ragged left 133 | \or 134 | \renewcommand*{\@tufte@sidenote@justification}{\RaggedRight}% ragged right 135 | \or 136 | \renewcommand*{\@tufte@sidenote@justification}{\@tufte@justification@outer}% ragged outer (flush right on verso pages, flush left on recto pages) 137 | \or 138 | \renewcommand*{\@tufte@sidenote@justification}{\@tufte@justification@autodetect}% autodetects best justification mode based on all class options 139 | \fi 140 | }{% 141 | \@tufte@warning@noline{Invalid option `#1' for sidenote key. Must be one of: justified, raggedleft, raggedright, raggedouter, auto} 142 | \renewcommand*{\@tufte@sidenote@justification}{\@tufte@justification@autodetect}% autodetects best justification mode based on all class options 143 | } 144 | 145 | \newcommand*{\@tufte@marginnote@justification}{\@tufte@justification@autodetect} 146 | \define@choicekey*+[tufte]{common}{marginnote}[\@tufte@kvtext\@tufte@kvnum]{justified,raggedleft,raggedright,raggedouter,auto}[auto]{% 147 | \ifcase\@tufte@kvnum\relax 148 | \renewcommand*{\@tufte@marginnote@justification}{\justifying}% justified 149 | \or 150 | \renewcommand*{\@tufte@marginnote@justification}{\RaggedLeft}% ragged left 151 | \or 152 | \renewcommand*{\@tufte@marginnote@justification}{\RaggedRight}% ragged right 153 | \or 154 | \renewcommand*{\@tufte@marginnote@justification}{\@tufte@justification@outer}% ragged outer (flush right on verso pages, flush left on recto pages) 155 | \or 156 | \renewcommand*{\@tufte@marginnote@justification}{\@tufte@justification@autodetect}% autodetects best justification mode based on all class options 157 | \fi 158 | }{% 159 | \@tufte@warning@noline{Invalid option `#1' for marginnote key. Must be one of: justified, raggedleft, raggedright, raggedouter, auto} 160 | \renewcommand*{\@tufte@marginnote@justification}{\@tufte@justification@autodetect}% autodetects best justification mode based on all class options 161 | } 162 | 163 | \newcommand*{\@tufte@caption@justification}{\@tufte@justification@autodetect} 164 | \define@choicekey*+[tufte]{common}{caption}[\@tufte@kvtext\@tufte@kvnum]{justified,raggedleft,raggedright,raggedouter,auto}[auto]{% 165 | \ifcase\@tufte@kvnum\relax 166 | \renewcommand*{\@tufte@caption@justification}{\justifying}% justified 167 | \or 168 | \renewcommand*{\@tufte@caption@justification}{\RaggedLeft}% ragged left 169 | \or 170 | \renewcommand*{\@tufte@caption@justification}{\RaggedRight}% ragged right 171 | \or 172 | \renewcommand*{\@tufte@caption@justification}{\@tufte@justification@caption@outer}% ragged outer (flush right on verso pages, flush left on recto pages) 173 | \or 174 | \renewcommand*{\@tufte@caption@justification}{\@tufte@justification@autodetect}% autodetects best justification mode based on all class options 175 | \fi 176 | }{% 177 | \@tufte@warning@noline{Invalid option `#1' for caption key. Must be one of: justified, raggedleft, raggedright, raggedouter, auto} 178 | \renewcommand*{\@tufte@caption@justification}{\@tufte@justification@autodetect}% autodetects best justification mode based on all class options 179 | } 180 | 181 | \newcommand*{\@tufte@citation@justification}{\@tufte@justification@autodetect} 182 | \define@choicekey*+[tufte]{common}{citation}[\@tufte@kvtext\@tufte@kvnum]{justified,raggedleft,raggedright,raggedouter,auto}[auto]{% 183 | \ifcase\@tufte@kvnum\relax 184 | \renewcommand*{\@tufte@citation@justification}{\justifying}% justified 185 | \or 186 | \renewcommand*{\@tufte@citation@justification}{\RaggedLeft}% ragged left 187 | \or 188 | \renewcommand*{\@tufte@citation@justification}{\RaggedRight}% ragged right 189 | \or 190 | \renewcommand*{\@tufte@citation@justification}{\@tufte@justification@outer}% ragged outer (flush right on verso pages, flush left on recto pages) 191 | \or 192 | \renewcommand*{\@tufte@citation@justification}{\@tufte@justification@autodetect}% autodetects best justification mode based on all class options 193 | \fi 194 | }{% 195 | \@tufte@warning@noline{Invalid option `#1' for citation key. Must be one of: justified, raggedleft, raggedright, raggedouter, auto} 196 | \renewcommand*{\@tufte@citation@justification}{\@tufte@justification@autodetect}% autodetects best justification mode based on all class options 197 | } 198 | 199 | % The ``marginals'' key simultaneously sets the same justification for all marginal material 200 | \define@choicekey*+[tufte]{common}{marginals}[\@tufte@kvtext\@tufte@kvnum]{justified,raggedleft,raggedright,raggedouter,auto}[auto]{% 201 | \ifcase\@tufte@kvnum\relax 202 | \ExecuteOptionsX[tufte]{citation=justified,sidenote=justified,caption=justified,marginnote=justified}% justified 203 | \or 204 | \ExecuteOptionsX[tufte]{citation=raggedleft,sidenote=raggedleft,caption=raggedleft,marginnote=raggedleft}% ragged left 205 | \or 206 | \ExecuteOptionsX[tufte]{citation=raggedright,sidenote=raggedright,caption=raggedright,marginnote=raggedright}% ragged right 207 | \or 208 | \ExecuteOptionsX[tufte]{citation=raggedouter,sidenote=raggedouter,caption=raggedouter,marginnote=raggedouter}% ragged outer (flush right on verso pages, flush left on recto pages) 209 | \or 210 | \ExecuteOptionsX[tufte]{citation=auto,sidenote=auto,caption=auto,marginnote=auto}% autodetects best justification mode based on all class options 211 | \fi 212 | }{% 213 | \@tufte@warning@noline{Invalid option `#1' for marginals key. Must be one of: justified, raggedleft, raggedright, raggedouter, auto} 214 | \ExecuteOptionsX[tufte]{citation=auto,sidenote=auto,caption=auto,marginnote=auto}% autodetects best justification mode based on all class options 215 | } 216 | 217 | 218 | %% 219 | % Unsupported options 220 | 221 | \newcommand{\@tufte@unsupported@option}[1]{\@tufte@warning@noline{Option `#1' is not supported -- ignoring option}\OptionNotUsed} 222 | 223 | \DeclareOptionX[tufte]{10pt}{\@tufte@unsupported@option{\CurrentOption}} 224 | \DeclareOptionX[tufte]{11pt}{\@tufte@unsupported@option{\CurrentOption}} 225 | \DeclareOptionX[tufte]{12pt}{\@tufte@unsupported@option{\CurrentOption}} 226 | \DeclareOptionX[tufte]{a5paper}{\@tufte@unsupported@option{\CurrentOption}} 227 | \DeclareOptionX[tufte]{executivepaper}{\@tufte@unsupported@option{\CurrentOption}} 228 | \DeclareOptionX[tufte]{legalpaper}{\@tufte@unsupported@option{\CurrentOption}} 229 | \DeclareOptionX[tufte]{landscape}{\@tufte@unsupported@option{\CurrentOption}} 230 | \DeclareOptionX[tufte]{onecolumn}{\@tufte@unsupported@option{\CurrentOption}} 231 | \DeclareOptionX[tufte]{twocolumn}{\@tufte@unsupported@option{\CurrentOption}} 232 | 233 | %% 234 | % Default `book' and `handout' options 235 | 236 | \ifthenelse{\equal{\@tufte@pkgname}{tufte-book}} 237 | {\ExecuteOptionsX[tufte]{titlepage}} 238 | {\ExecuteOptionsX[tufte]{notitlepage}} 239 | 240 | 241 | \DeclareOptionX*{% 242 | \@tufte@info@noline{Passing \CurrentOption\space to the `\@tufte@class' class.}% 243 | \PassOptionsToClass{\CurrentOption}{\@tufte@class}% 244 | } 245 | \ProcessOptionsX*[tufte]\relax 246 | 247 | %% 248 | % Load the appropriate base class 249 | \@tufte@info@noline{Loading the base class `\@tufte@class'} 250 | \LoadClass{\@tufte@class} 251 | 252 | %% 253 | % Detect whether we're in two-side mode or not. (Used to set up running 254 | % heads later.) 255 | 256 | \ifthenelse{\boolean{@twoside}} 257 | {\setboolean{@tufte@twoside}{true}} 258 | {} 259 | 260 | 261 | 262 | %% 263 | % Detect if we're using pdfLaTeX 264 | 265 | \newboolean{@tufte@pdf} 266 | \IfFileExists{ifpdf.sty}{% 267 | \RequirePackage{ifpdf} 268 | \ifthenelse{\boolean{pdf}} 269 | {\setboolean{@tufte@pdf}{true}} 270 | {\setboolean{@tufte@pdf}{false}} 271 | }{% assume we're not using pdfTex? 272 | \setboolean{@tufte@pdf}{false} 273 | } 274 | 275 | %% 276 | % Detect if we're using XeLaTeX 277 | 278 | \newboolean{@tufte@xetex} 279 | \IfFileExists{ifxetex.sty}{% 280 | \RequirePackage{ifxetex} 281 | \ifthenelse{\boolean{xetex}} 282 | {\setboolean{@tufte@xetex}{true}} 283 | {\setboolean{@tufte@xetex}{false}} 284 | }{% not using xelatex 285 | \setboolean{@tufte@xetex}{false} 286 | } 287 | 288 | \ifthenelse{\boolean{@tufte@xetex}}{% 289 | \RequirePackage{xltxtra}% xltxtra loads xunicode and fontspec; must be loaded before bidi 290 | }{} 291 | 292 | %% 293 | % Detect if we're using LuaTeX 294 | 295 | \newboolean{@tufte@luatex} 296 | \IfFileExists{ifluatex.sty}{% 297 | \RequirePackage{ifluatex} 298 | \ifthenelse{\boolean{luatex}} 299 | {\setboolean{@tufte@luatex}{true}} 300 | {\setboolean{@tufte@luatex}{false}} 301 | }{% not using luatex 302 | \setboolean{@tufte@luatex}{false} 303 | } 304 | 305 | \ifthenelse{\boolean{@tufte@luatex}}{% 306 | \RequirePackage{fontspec} 307 | \RequirePackage[osf,sc]{mathpazo} 308 | \setmainfont[Renderer=Basic, Numbers=OldStyle, Scale = 1.0]{TeX Gyre Pagella} 309 | \setsansfont[Renderer=Basic, Scale=0.90]{TeX Gyre Heros} 310 | \setmonofont[Renderer=Basic]{TeX Gyre Cursor} 311 | }{} 312 | 313 | %% 314 | % Globally sets the length 315 | 316 | \newcommand*{\gsetlength}[2]{% 317 | \setlength{#1}{#2}% 318 | \global#1=#1\relax% 319 | } 320 | 321 | %% 322 | % Globally sets a boolean 323 | 324 | \newcommand*{\gsetboolean}[2]{% based on code from ifthen pkg 325 | \lowercase{\def\@tempa{#2}}% 326 | \@ifundefined{@tempswa\@tempa}% 327 | {\PackageError{ifthen}{You can only set a boolean to `true' or `false'}\@ehc}% 328 | {\@ifundefined{#1\@tempa}% 329 | {\PackageError{ifthen}{Boolean #1 undefined}\@ehc}% 330 | {\global\csname#1\@tempa\endcsname}% 331 | }% 332 | } 333 | 334 | %% 335 | % The titlesec and titletoc packages are used to change the style of the 336 | % section headings. These packages should be loaded before the hyperref 337 | % package. 338 | 339 | \RequirePackage{titlesec,titletoc} 340 | 341 | %%% 342 | %% Loads the hyperref package and sets some default options. 343 | 344 | \newcommand{\TufteLoadHyperref}{% 345 | \ifthenelse{\boolean{@tufte@xetex}} 346 | {\RequirePackage[unicode,hyperfootnotes=false,xetex]{hyperref}} 347 | {\RequirePackage[unicode,hyperfootnotes=false]{hyperref}} 348 | \hypersetup{% 349 | pdfborder = {0 0 0}, 350 | bookmarksdepth = section, 351 | citecolor = DarkGreen, 352 | linkcolor = DarkBlue, 353 | urlcolor = DarkGreen, 354 | }% 355 | } 356 | 357 | %%% 358 | %% Load the `hyperref' package. 359 | 360 | \ifthenelse{\boolean{@tufte@loadhyper}}{% 361 | \TufteLoadHyperref% 362 | }{% hyperfootnotes override our modifications to the \footnote* and \@footnote* commands. 363 | \PassOptionsToPackage{hyperfootnotes=false}{hyperref} 364 | } 365 | 366 | %% 367 | % Set the font sizes and baselines to match Tufte's books 368 | \renewcommand\normalsize{% 369 | \@setfontsize\normalsize\@xpt{14}% 370 | \abovedisplayskip 10\p@ \@plus2\p@ \@minus5\p@ 371 | \abovedisplayshortskip \z@ \@plus3\p@ 372 | \belowdisplayshortskip 6\p@ \@plus3\p@ \@minus3\p@ 373 | \belowdisplayskip \abovedisplayskip 374 | \let\@listi\@listI} 375 | \normalbaselineskip=14pt 376 | \normalsize 377 | \renewcommand\small{% 378 | \@setfontsize\small\@ixpt{12}% 379 | \abovedisplayskip 8.5\p@ \@plus3\p@ \@minus4\p@ 380 | \abovedisplayshortskip \z@ \@plus2\p@ 381 | \belowdisplayshortskip 4\p@ \@plus2\p@ \@minus2\p@ 382 | \def\@listi{\leftmargin\leftmargini 383 | \topsep 4\p@ \@plus2\p@ \@minus2\p@ 384 | \parsep 2\p@ \@plus\p@ \@minus\p@ 385 | \itemsep \parsep}% 386 | \belowdisplayskip \abovedisplayskip 387 | } 388 | \renewcommand\footnotesize{% 389 | \@setfontsize\footnotesize\@viiipt{10}% 390 | \abovedisplayskip 6\p@ \@plus2\p@ \@minus4\p@ 391 | \abovedisplayshortskip \z@ \@plus\p@ 392 | \belowdisplayshortskip 3\p@ \@plus\p@ \@minus2\p@ 393 | \def\@listi{\leftmargin\leftmargini 394 | \topsep 3\p@ \@plus\p@ \@minus\p@ 395 | \parsep 2\p@ \@plus\p@ \@minus\p@ 396 | \itemsep \parsep}% 397 | \belowdisplayskip \abovedisplayskip 398 | } 399 | \renewcommand\scriptsize{\@setfontsize\scriptsize\@viipt\@viiipt} 400 | \renewcommand\tiny{\@setfontsize\tiny\@vpt\@vipt} 401 | \renewcommand\large{\@setfontsize\large\@xipt{15}} 402 | \renewcommand\Large{\@setfontsize\Large\@xiipt{16}} 403 | \renewcommand\LARGE{\@setfontsize\LARGE\@xivpt{18}} 404 | \renewcommand\huge{\@setfontsize\huge\@xxpt{30}} 405 | \renewcommand\Huge{\@setfontsize\Huge{24}{36}} 406 | 407 | \setlength\leftmargini {1pc} 408 | \setlength\leftmarginii {1pc} 409 | \setlength\leftmarginiii {1pc} 410 | \setlength\leftmarginiv {1pc} 411 | \setlength\leftmarginv {1pc} 412 | \setlength\leftmarginvi {1pc} 413 | \setlength\labelsep {.5pc} 414 | \setlength\labelwidth {\leftmargini} 415 | \addtolength\labelwidth{-\labelsep} 416 | 417 | %% 418 | % \RaggedRight allows hyphenation 419 | 420 | \setlength{\parindent}{1.0pc}% 421 | \setlength{\parskip}{0pt}% 422 | \RequirePackage{ragged2e} 423 | \setlength{\RaggedRightRightskip}{\z@ plus 0.08\hsize} 424 | 425 | % Paragraph indentation and separation for normal text 426 | \newcommand{\@tufte@reset@par}{% 427 | \setlength{\RaggedRightParindent}{1.0pc}% 428 | \setlength{\JustifyingParindent}{1.0pc}% 429 | \setlength{\parindent}{1pc}% 430 | \setlength{\parskip}{0pt}% 431 | } 432 | \@tufte@reset@par 433 | 434 | % Paragraph indentation and separation for marginal text 435 | \newcommand{\@tufte@margin@par}{% 436 | \setlength{\RaggedRightParindent}{0.5pc}% 437 | \setlength{\JustifyingParindent}{0.5pc}% 438 | \setlength{\parindent}{0.5pc}% 439 | \setlength{\parskip}{0pt}% 440 | } 441 | 442 | 443 | %% 444 | % Set page layout geometry 445 | 446 | \RequirePackage[letterpaper,left=1in,top=1in,headsep=2\baselineskip,textwidth=26pc,marginparsep=2pc,marginparwidth=12pc,textheight=44\baselineskip,headheight=\baselineskip]{geometry} 447 | 448 | \ifthenelse{\boolean{@tufte@afourpaper}} 449 | {\geometry{a4paper,left=24.8mm,top=27.4mm,headsep=2\baselineskip,textwidth=107mm,marginparsep=8.2mm,marginparwidth=49.4mm,textheight=49\baselineskip,headheight=\baselineskip}} 450 | {} 451 | 452 | \ifthenelse{\boolean{@tufte@bfivepaper}} 453 | {\geometry{paperwidth=176mm,paperheight=250mm,left=14.66mm,top=13.88mm,textwidth=102.66mm,marginparsep=7.33mm,marginparwidth=36.66mm,textheight=38\baselineskip,includehead}} 454 | {} 455 | 456 | \ifthenelse{\boolean{@tufte@symmetric}} 457 | {} 458 | {\geometry{asymmetric}}% forces internal LaTeX `twoside' 459 | 460 | 461 | %% 462 | % Separation marginpars by a line's worth of space. 463 | 464 | \setlength\marginparpush{10pt} 465 | 466 | %% 467 | % Font for margin items 468 | 469 | \ifthenelse{\boolean{@tufte@sfsidenotes}} 470 | {\newcommand{\@tufte@marginfont}{\normalfont\footnotesize\sffamily}} 471 | {\newcommand{\@tufte@marginfont}{\normalfont\footnotesize}} 472 | 473 | \newcommand*{\@tufte@sidenote@font}{\@tufte@marginfont} 474 | \newcommand*{\@tufte@caption@font}{\@tufte@marginfont} 475 | \newcommand*{\@tufte@marginnote@font}{\@tufte@marginfont} 476 | \newcommand*{\@tufte@citation@font}{\@tufte@marginfont} 477 | 478 | \newcommand*{\setsidenotefont}[1]{\renewcommand*{\@tufte@sidenote@font}{#1}} 479 | \newcommand*{\setcaptionfont}[1]{\renewcommand*{\@tufte@caption@font}{#1}} 480 | \newcommand*{\setmarginnotefont}[1]{\renewcommand*{\@tufte@marginnote@font}{#1}} 481 | \newcommand*{\setcitationfont}[1]{\renewcommand*{\@tufte@citation@font}{#1}} 482 | 483 | %% 484 | % Set the justification based on the `justified' class option 485 | 486 | \newcommand{\@tufte@justification}{% 487 | \ifthenelse{\boolean{@tufte@justified}}% 488 | {\justifying}% 489 | {\RaggedRight}% 490 | } 491 | 492 | %% 493 | % Turn off section numbering 494 | 495 | \setcounter{secnumdepth}{-1} 496 | 497 | %% 498 | % Tighten up space between displays (e.g., a figure or table) and make symmetric 499 | 500 | \setlength\abovedisplayskip{6pt plus 2pt minus 4pt} 501 | \setlength\belowdisplayskip{6pt plus 2pt minus 4pt} 502 | 503 | %% 504 | % To implement full-width display environments 505 | 506 | \newboolean{@tufte@changepage} 507 | \IfFileExists{changepage.sty}{% 508 | \@tufte@debug@info@noline{Found changepage.sty} 509 | \RequirePackage[strict]{changepage} 510 | \setboolean{@tufte@changepage}{true} 511 | }{% 512 | \@tufte@debug@info@noline{Found chngpage.sty} 513 | \RequirePackage[strict]{chngpage} 514 | \setboolean{@tufte@changepage}{false} 515 | } 516 | 517 | % Write our own aliases for the \checkoddpage and \ifoddpage or \ifcpoddpage commands 518 | \newboolean{@tufte@odd@page} 519 | \setboolean{@tufte@odd@page}{true} 520 | \newcommand*{\@tufte@checkoddpage}{% 521 | \checkoddpage% 522 | \ifthenelse{\boolean{@tufte@changepage}}{% 523 | \ifoddpage% 524 | \setboolean{@tufte@odd@page}{true}% 525 | \else% 526 | \setboolean{@tufte@odd@page}{false}% 527 | \fi% 528 | }{% 529 | \ifcpoddpage% 530 | \setboolean{@tufte@odd@page}{true}% 531 | \else% 532 | \setboolean{@tufte@odd@page}{false}% 533 | \fi% 534 | }% 535 | } 536 | 537 | %% 538 | % Compute lengths used for full-width displays 539 | 540 | \newlength{\@tufte@overhang}% used by the fullwidth environment and the running heads 541 | \newlength{\@tufte@fullwidth} 542 | \newlength{\@tufte@caption@fill} 543 | 544 | \newcommand{\TufteRecalculate}{% 545 | \setlength{\@tufte@overhang}{\marginparwidth} 546 | \addtolength{\@tufte@overhang}{\marginparsep} 547 | 548 | \setlength{\@tufte@fullwidth}{\textwidth} 549 | \addtolength{\@tufte@fullwidth}{\marginparsep} 550 | \addtolength{\@tufte@fullwidth}{\marginparwidth} 551 | 552 | \setlength{\@tufte@caption@fill}{\textwidth} 553 | \addtolength{\@tufte@caption@fill}{\marginparsep} 554 | } 555 | 556 | \AtBeginDocument{\TufteRecalculate} 557 | 558 | %% 559 | % Modified \title, \author, and \date commands. These store the 560 | % (footnote-less) values in \plaintitle, \plainauthor, and \thedate, respectively. 561 | 562 | \newcommand{\plaintitle}{}% plain-text-only title 563 | \newcommand{\plainauthor}{}% plain-text-only author 564 | \newcommand{\plainpublisher}{}% plain-text-only publisher 565 | 566 | \newcommand{\thanklesstitle}{}% full title text minus \thanks{} 567 | \newcommand{\thanklessauthor}{}% full author text minus \thanks{} 568 | \newcommand{\thanklesspublisher}{}% full publisher minus \thanks{} 569 | 570 | \newcommand{\@publisher}{}% full publisher with \thanks{} 571 | \newcommand{\thedate}{\today} 572 | 573 | % TODO Fix it so that \thanks is not spaced out (with `soul') and can be 574 | % used in \maketitle when the `sfsidenotes' option is provided. 575 | \renewcommand{\thanks}[1]{\NoCaseChange{\footnote{#1}}} 576 | 577 | \renewcommand{\title}[2][]{% 578 | \gdef\@title{#2}% 579 | \begingroup% 580 | % TODO store contents of \thanks command 581 | \renewcommand{\thanks}[1]{}% swallow \thanks contents 582 | \protected@xdef\thanklesstitle{#2}% 583 | \endgroup% 584 | \ifthenelse{\isempty{#1}}% 585 | {\renewcommand{\plaintitle}{\thanklesstitle}}% use thankless title 586 | {\renewcommand{\plaintitle}{#1}}% use provided plain-text title 587 | \ifthenelse{\isundefined{\hypersetup}}% 588 | {}% hyperref is not loaded; do nothing 589 | {\hypersetup{pdftitle={\plaintitle}}}% set the PDF metadata title 590 | } 591 | 592 | \let\@author\@empty% suppress default latex.ltx ``no author'' warning 593 | \renewcommand{\author}[2][]{% 594 | \ifthenelse{\isempty{#2}}{}{\gdef\@author{#2}}% 595 | \begingroup% 596 | % TODO store contents of \thanks command 597 | \renewcommand{\thanks}[1]{}% swallow \thanks contents 598 | \protected@xdef\thanklessauthor{#2}% 599 | \endgroup% 600 | \ifthenelse{\isempty{#1}}% 601 | {\renewcommand{\plainauthor}{\thanklessauthor}}% use thankless author 602 | {\renewcommand{\plainauthor}{#1}}% use provided plain-text author 603 | \ifthenelse{\isundefined{\hypersetup}}% 604 | {}% hyperref is not loaded; do nothing 605 | {\hypersetup{pdfauthor={\plainauthor}}}% set the PDF metadata author 606 | } 607 | 608 | \renewcommand{\date}[1]{% 609 | \gdef\@date{#1}% 610 | \begingroup% 611 | % TODO store contents of \thanks command 612 | \renewcommand{\thanks}[1]{}% swallow \thanks contents 613 | \protected@xdef\thedate{#1}% 614 | \endgroup% 615 | } 616 | 617 | %% 618 | % Provides a \publisher command to set the publisher 619 | 620 | \newcommand{\publisher}[2][]{% 621 | \gdef\@publisher{#2}% 622 | \begingroup% 623 | \renewcommand{\thanks}[1]{}% swallow \thanks contents 624 | \protected@xdef\thanklesspublisher{#2}% 625 | \endgroup% 626 | \ifthenelse{\isempty{#1}} 627 | {\renewcommand{\plainpublisher}{\thanklesspublisher}}% use thankless publisher 628 | {\renewcommand{\plainpublisher}{#1}}% use provided plain-text publisher 629 | } 630 | 631 | % TODO: Test \hypersetup{pdfauthor,pdftitle} with DVI and XeTeX 632 | 633 | %% 634 | % Require paralist package for tighter lists 635 | 636 | \RequirePackage{paralist} 637 | 638 | % Add rightmargin to compactenum 639 | 640 | \def\@compactenum@{% 641 | \expandafter\list\csname label\@enumctr\endcsname{% 642 | \usecounter{\@enumctr}% 643 | \rightmargin=2em% added this 644 | \parsep\plparsep 645 | \itemsep\plitemsep 646 | \topsep\pltopsep 647 | \partopsep\plpartopsep 648 | \def\makelabel##1{\hss\llap{##1}}}} 649 | 650 | %% 651 | % Improved letterspacing of small caps and all-caps text. 652 | % 653 | % First, try to use the `microtype' package, if it's available. 654 | % Failing that, try to use the `soul' package, if it's available. 655 | % Failing that, well, I give up. 656 | 657 | \DeclareTextFontCommand{\textsmallcaps}{\scshape} 658 | 659 | \RequirePackage{textcase} % provides \MakeTextUppercase and \MakeTextLowercase 660 | \def\allcapsspacing{\@tufte@warning{Proper spacing of ALL-CAPS letters has not been set up.}} 661 | \def\smallcapsspacing{\@tufte@warning{Proper spacing of small-caps letters has not been set up.}} 662 | \newcommand{\allcaps}[1]{\allcapsspacing{\MakeTextUppercase{#1}}} 663 | \newcommand{\smallcaps}[1]{\smallcapsspacing{\MakeTextLowercase{#1}}} 664 | 665 | % If we're using pdfLaTeX v1.40+, use the letterspace package. 666 | % If we're using pdfLaTex < v1.40, use the soul package. 667 | % If we're using XeLaTeX, use XeLaTeX letterspacing options. 668 | % Otherwise fall back on the soul package. 669 | 670 | \ifthenelse{\boolean{@tufte@pdf}} 671 | {\@tufte@debug@info@noline{ifpdf = true}} 672 | {\@tufte@debug@info@noline{ifpdf = false}} 673 | 674 | \ifthenelse{\boolean{@tufte@xetex}} 675 | {\@tufte@debug@info@noline{ifxetex = true}} 676 | {\@tufte@debug@info@noline{ifxetex = false}} 677 | 678 | % Check pdfLaTeX version 679 | \def\@tufte@pdftexversion{0} 680 | \ifx\normalpdftexversion\@undefined \else 681 | \let\pdftexversion \normalpdftexversion 682 | \let\pdftexrevision\normalpdftexrevision 683 | \let\pdfoutput \normalpdfoutput 684 | \fi 685 | \ifx\pdftexversion\@undefined \else 686 | \ifx\pdftexversion\relax \else 687 | \def\@tufte@pdftexversion{6} 688 | \ifnum\pdftexversion < 140 689 | \def\@tufte@pdftexversion{5} 690 | \fi 691 | \fi 692 | \fi 693 | 694 | \newboolean{@tufte@letterspace@pkg@prereqs} 695 | \setboolean{@tufte@letterspace@pkg@prereqs}{true} 696 | \ifnum\@tufte@pdftexversion<6 697 | \setboolean{@tufte@letterspace@pkg@prereqs}{false} 698 | \fi 699 | 700 | 701 | \newcommand{\@tufte@letterspacing@soul}{% 702 | \RequirePackage{soul}% 703 | \sodef\allcapsspacing{}{0.15em}{0.65em}{0.6em}% 704 | \sodef\smallcapsspacing{}{0.075em}{0.5em}{0.6em}% 705 | \sodef\sotextsc{\scshape}{0.075em}{0.5em}{0.6em}% 706 | \renewcommand{\allcaps}[1]{\allcapsspacing{\MakeTextUppercase{##1}}}% 707 | \renewcommand{\smallcaps}[1]{\smallcapsspacing{\scshape\MakeTextLowercase{##1}}}% 708 | \renewcommand{\textsc}[1]{\sotextsc{##1}}% 709 | } 710 | 711 | \newcommand{\@tufte@letterspacing@letterspace}{% 712 | \@tufte@debug@info@noline{Modern version of pdfTeX detected. Using `letterspace' package}% 713 | \RequirePackage{letterspace}% 714 | % Set up letterspacing (using microtype package) -- requires pdfTeX v1.40+ 715 | \renewcommand{\allcapsspacing}[1]{\textls[200]{##1}}% 716 | \renewcommand{\smallcapsspacing}[1]{\textls[50]{##1}}% 717 | \renewcommand{\allcaps}[1]{\allcapsspacing{\MakeTextUppercase{##1}}}% 718 | \renewcommand{\smallcaps}[1]{\smallcapsspacing{\scshape\MakeTextLowercase{##1}}}% 719 | \renewcommand{\textsc}[1]{\smallcapsspacing{\textsmallcaps{##1}}}% 720 | } 721 | 722 | \ifthenelse{\boolean{@tufte@letterspace}}{% 723 | \ifthenelse{\boolean{@tufte@pdf}\AND\boolean{@tufte@letterspace@pkg@prereqs}\AND\NOT\boolean{@tufte@xetex}}{% 724 | % load letterspace pkg 725 | \IfFileExists{letterspace.sty}{% 726 | \@tufte@letterspacing@letterspace 727 | }{}% 728 | }{}% 729 | % load soul pkg 730 | \@ifpackageloaded{letterspace}{}{% 731 | \IfFileExists{soul.sty}{% 732 | \@tufte@letterspacing@soul 733 | }{% 734 | \@tufte@warning@noline{Couldn't locate `soul' package}% 735 | }% soul not installed... giving up. 736 | }% 737 | }{} 738 | 739 | %\ifthenelse{\boolean{@tufte@letterspace}}{% 740 | %\ifthenelse{\boolean{pdf}}{% 741 | %\ifthenelse{\NOT\boolean{@tufte@letterspace@pkg@prereqs}}{% 742 | %% pdfLaTeX version is too old or not using pdfLaTeX 743 | %\ifthenelse{\boolean{@tufte@xetex}}{% 744 | %% TODO use xetex letterspacing 745 | %\@tufte@debug@info@noline{XeTeX detected. Reverting to `soul' package for letterspacing}% 746 | %\@tufte@loadsoul% 747 | %}{% 748 | %% use `soul' package for letterspacing 749 | %\@tufte@debug@info@noline{Old version of pdfTeX detected. Reverting to `soul' package for letterspacing}% 750 | %\@tufte@loadsoul% 751 | %} 752 | %}{% 753 | %\IfFileExists{letterspace.sty}{% 754 | %\@tufte@debug@info@noline{Modern version of pdfTeX detected. Using `letterspace' package} 755 | %\RequirePackage{letterspace} 756 | %% Set up letterspacing (using microtype package) -- requires pdfTeX v1.40+ 757 | %\renewcommand{\allcapsspacing}[1]{\textls[200]{##1}} 758 | %\renewcommand{\smallcapsspacing}[1]{\textls[50]{##1}} 759 | %\renewcommand{\allcaps}[1]{\textls[200]{\MakeTextUppercase{##1}}} 760 | %\renewcommand{\smallcaps}[1]{\smallcapsspacing{\MakeTextLowercase{##1}}} 761 | %\renewcommand{\textsc}[1]{\smallcapsspacing{\textsmallcaps{##1}}} 762 | %}{% microtype failed, check for soul 763 | %\@tufte@debug@info@noline{Modern version of pdfTeX detected, but `letterspace' package not installed. Reverting to `soul' package for letterspacing} 764 | %\@tufte@loadsoul 765 | %}% 766 | %}% 767 | %}{% 768 | %\@tufte@debug@info@noline{Plain LaTeX detected. Using `soul' package for letterspacing} 769 | %\@tufte@loadsoul 770 | %} 771 | %}{% 772 | %% we're not to load letterspacing, so do nothing 773 | %} 774 | 775 | 776 | %% 777 | % An environment for paragraph-style section 778 | 779 | \providecommand\newthought[1]{% 780 | \tuftebreak 781 | \noindent\textsc{#1}% 782 | } 783 | 784 | %% 785 | % Redefine the display environments (quote, quotation, etc.) 786 | 787 | \renewenvironment{verse} 788 | {\let\\\@centercr 789 | \list{}{\itemsep \z@ 790 | \itemindent -1pc% 791 | \listparindent\itemindent 792 | \rightmargin \leftmargin 793 | \advance\leftmargin 1pc}% 794 | \small% 795 | \item\relax} 796 | {\endlist} 797 | \renewenvironment{quotation} 798 | {\list{}{\listparindent 1pc% 799 | \itemindent \listparindent 800 | \rightmargin \leftmargin 801 | \parsep \z@ \@plus\p@}% 802 | \small% 803 | \item\relax\noindent\ignorespaces} 804 | {\endlist} 805 | \renewenvironment{quote} 806 | {\list{}{\rightmargin\leftmargin}% 807 | \small% 808 | \item\relax} 809 | {\endlist} 810 | 811 | %% 812 | % Italicize description run-in headings (instead of the default bold) 813 | 814 | \renewcommand*\descriptionlabel[1]{\hspace\labelsep\normalfont\em #1} 815 | 816 | 817 | %% 818 | % Used for doublespacing, and other linespacing 819 | 820 | \RequirePackage{setspace} 821 | 822 | %% 823 | % Color 824 | \RequirePackage[dvipsnames,svgnames]{xcolor}% load before bidi 825 | 826 | %% 827 | % Load the bidi package if instructed to do so. This package must be loaded 828 | % prior to our redefining the \footnote and \cite commands. 829 | 830 | \ifthenelse{\boolean{@tufte@loadbidi}}{% 831 | \AtBeginDocument{% 832 | \RequirePackage{bidi} 833 | \@tufte@pkghook@post@bidi% 834 | }% 835 | }{} 836 | 837 | 838 | %% 839 | % A function that removes leading and trailing spaces from the supplied macro. 840 | % Based on code written by Michael Downes (See ``Around the Bend'', #15.) 841 | % Executing \@tufte@trim@spaces\xyzzy will result in the contents of \xyzzy 842 | % being trimmed of leading and trailing white space. 843 | 844 | \catcode`\Q=3 845 | \def\@tufte@trim@spaces#1{% 846 | % Use grouping to emulate a multi-token afterassignment queue 847 | \begingroup% 848 | % Put `\toks 0 {' into the afterassignment queue 849 | \aftergroup\toks\aftergroup0\aftergroup{% 850 | % Apply \trimb to the replacement text of #1, adding a leading 851 | % \noexpand to prevent brace stripping and to serve another purpose 852 | % later. 853 | \expandafter\@tufte@trim@b\expandafter\noexpand#1Q Q}% 854 | % Transfer the trimmed text back into #1. 855 | \edef#1{\the\toks0}% 856 | } 857 | 858 | % \trimb removes a trailing space if present, then calls \@tufte@trim@c to 859 | % clean up any leftover bizarre Qs, and trim a leading space. In 860 | % order for \trimc to work properly we need to put back a Q first. 861 | \def\@tufte@trim@b#1 Q{\@tufte@trim@c#1Q} 862 | 863 | % Execute \vfuzz assignment to remove leading space; the \noexpand 864 | % will now prevent unwanted expansion of a macro or other expandable 865 | % token at the beginning of the trimmed text. The \endgroup will feed 866 | % in the \aftergroup tokens after the \vfuzz assignment is completed. 867 | \def\@tufte@trim@c#1Q#2{\afterassignment\endgroup \vfuzz\the\vfuzz#1} 868 | \catcode`\Q=11 869 | 870 | %% 871 | % Citations should go in the margin as sidenotes 872 | 873 | \ifthenelse{\boolean{@tufte@loadnatbib}}{% 874 | \RequirePackage{natbib}% 875 | \RequirePackage{bibentry}% allows bibitems to be typeset outside thebibliography environment 876 | % Redefine the \BR@b@bibitem command to fix a bug with bibentry+chicago style 877 | \renewcommand\BR@b@bibitem[2][]{% 878 | \ifthenelse{\isempty{#1}}% 879 | {\BR@bibitem{#2}}% 880 | {\BR@bibitem[#1]{#2}}% 881 | \BR@c@bibitem{#2}% 882 | }% 883 | \nobibliography*% pre-loads the bibliography keys 884 | \providecommand{\doi}[1]{\textsc{doi:} #1}% pre-defining this so it may be used before the \bibliography command it issued 885 | }{} 886 | 887 | %% 888 | % Normal \cite behavior 889 | \newcounter{@tufte@num@bibkeys}% 890 | \newcommand{\@tufte@normal@cite}[2][0pt]{% 891 | % Snag the last bibentry in the list for later comparison 892 | \let\@temp@last@bibkey\@empty% 893 | \@for\@temp@bibkey:=#2\do{\let\@temp@last@bibkey\@temp@bibkey}% 894 | \sidenote[][#1]{% 895 | % Loop through all the bibentries, separating them with semicolons and spaces 896 | \normalsize\normalfont\@tufte@citation@font% 897 | \setcounter{@tufte@num@bibkeys}{0}% 898 | \@for\@temp@bibkeyx:=#2\do{% 899 | \ifthenelse{\equal{\@temp@last@bibkey}{\@temp@bibkeyx}}% 900 | {\ifthenelse{\equal{\value{@tufte@num@bibkeys}}{0}}{}{and\ }% 901 | \@tufte@trim@spaces\@temp@bibkeyx% trim spaces around bibkey 902 | \bibentry{\@temp@bibkeyx}}% 903 | {\@tufte@trim@spaces\@temp@bibkeyx% trim spaces around bibkey 904 | \bibentry{\@temp@bibkeyx};\ }% 905 | \stepcounter{@tufte@num@bibkeys}% 906 | }% 907 | }% 908 | } 909 | 910 | 911 | %% 912 | % Macros for holding the list of cite keys until after the \sidenote 913 | 914 | \gdef\@tufte@citations{}% list of cite keys 915 | \newcommand\@tufte@add@citation[1]{\relax% adds a new bibkey to the list of cite keys 916 | \ifx\@tufte@citations\@empty\else 917 | \g@addto@macro\@tufte@citations{,}% separate by commas 918 | \fi 919 | \g@addto@macro\@tufte@citations{#1} 920 | } 921 | 922 | \newcommand{\@tufte@print@citations}[1][0pt]{% puts the citations in a margin note 923 | % Snag the last bibentry in the list for later comparison 924 | \let\@temp@last@bibkey\@empty% 925 | \@for\@temp@bibkey:=\@tufte@citations\do{\let\@temp@last@bibkey\@temp@bibkey}% 926 | \marginpar{% 927 | \hbox{}\vspace*{#1}% 928 | \@tufte@citation@font% 929 | \@tufte@citation@justification% 930 | \@tufte@margin@par% use parindent and parskip settings for marginal text 931 | \vspace*{-1\baselineskip}% 932 | % Loop through all the bibentries, separating them with semicolons and spaces 933 | \setcounter{@tufte@num@bibkeys}{0}% 934 | \@for\@temp@bibkeyx:=\@tufte@citations\do{% 935 | \ifthenelse{\equal{\@temp@last@bibkey}{\@temp@bibkeyx}}% 936 | {\ifthenelse{\equal{\value{@tufte@num@bibkeys}}{0}}{}{and\ }% 937 | \@tufte@trim@spaces\@temp@bibkeyx% trim spaces around bibkey 938 | \bibentry{\@temp@bibkeyx}}% 939 | {\@tufte@trim@spaces\@temp@bibkeyx% trim spaces around bibkey 940 | \bibentry{\@temp@bibkeyx};\ }% 941 | \stepcounter{@tufte@num@bibkeys}% 942 | }% 943 | }% 944 | } 945 | 946 | %% 947 | % \cite behavior when executed within a sidenote 948 | 949 | \newcommand{\@tufte@sidenote@citations}{}% contains list of \cites in sidenote 950 | \newcommand{\@tufte@infootnote@cite}[1]{% 951 | \@tufte@add@citation{#1} 952 | } 953 | 954 | %% 955 | % Set the default \cite style. This is set and reset by the \sidenote command. 956 | 957 | \ifthenelse{\boolean{@tufte@loadnatbib}}{% 958 | \let\cite\@tufte@normal@cite 959 | }{} 960 | 961 | %% 962 | % Transform existing \footnotes into \sidenotes 963 | % Sidenote: ``Where God meant footnotes to go.'' ---Tufte 964 | 965 | \RequirePackage{optparams}% for our new sidenote commands -- provides multiple optional arguments for commands 966 | 967 | \providecommand{\footnotelayout}{\@tufte@sidenote@font\@tufte@sidenote@justification} 968 | \renewcommand{\footnotelayout}{\@tufte@sidenote@font\@tufte@sidenote@justification} 969 | 970 | % Override footmisc's definition to set the sidenote marks (numbers) inside the 971 | % sidenote's text block. 972 | \long\def\@makefntext#1{\@textsuperscript{\@tufte@sidenote@font\tiny\@thefnmark}\,\footnotelayout#1} 973 | 974 | % Set the in-text footnote mark in the same typeface as the body text itself. 975 | \def\@makefnmark{\hbox{\@textsuperscript{\normalfont\footnotesize\@thefnmark}}} 976 | 977 | \providecommand*{\multiplefootnotemarker}{3sp} 978 | \providecommand*{\multfootsep}{,} 979 | 980 | \renewcommand{\@footnotemark}{% 981 | \leavevmode% 982 | \ifhmode% 983 | \edef\@x@sf{\the\spacefactor}% 984 | \@tufte@check@multiple@sidenotes% 985 | \nobreak% 986 | \fi% 987 | \@makefnmark% 988 | \ifhmode\spacefactor\@x@sf\fi% 989 | \relax% 990 | } 991 | 992 | \newcommand{\@tufte@check@multiple@sidenotes}{% 993 | \ifdim\lastkern=\multiplefootnotemarker\relax% 994 | \edef\@x@sf{\the\spacefactor}% 995 | \unkern% 996 | \textsuperscript{\multfootsep}% 997 | \spacefactor\@x@sf\relax% 998 | \fi 999 | } 1000 | 1001 | \renewcommand\@footnotetext[2][0pt]{% 1002 | \marginpar{% 1003 | \hbox{}\vspace*{#1}% 1004 | \def\baselinestretch {\setspace@singlespace}% 1005 | \reset@font\footnotesize% 1006 | \@tufte@margin@par% use parindent and parskip settings for marginal text 1007 | \vspace*{-1\baselineskip}\noindent% 1008 | \protected@edef\@currentlabel{% 1009 | \csname p@footnote\endcsname\@thefnmark% 1010 | }% 1011 | \color@begingroup% 1012 | \@makefntext{% 1013 | \ignorespaces#2% 1014 | }% 1015 | \color@endgroup% 1016 | }% 1017 | }% 1018 | 1019 | % Ensure this is run after the bidi package has been loaded 1020 | \def\@tufte@pkghook@post@bidi{}% 1021 | \g@addto@macro{\@tufte@pkghook@post@bidi}{% 1022 | \renewcommand\@footnotetext[2][0pt]{% 1023 | \marginpar{% 1024 | \hbox{}\vspace*{#1}% 1025 | \def\baselinestretch {\setspace@singlespace}% 1026 | \if@rl@footnote\@rltrue\else\@rlfalse\fi% 1027 | \reset@font\footnotesize% 1028 | \@tufte@margin@par% use parindent and parskip settings for marginal text 1029 | \vspace*{-1\baselineskip}\noindent% 1030 | \protected@edef\@currentlabel{% 1031 | \csname p@footnote\endcsname\@thefnmark% 1032 | }% 1033 | \color@begingroup% 1034 | \@makefntext{% 1035 | \ignorespaces#2% 1036 | }% 1037 | \color@endgroup% 1038 | }% 1039 | }% 1040 | }% 1041 | 1042 | % 1043 | % Define \sidenote command. Can handle \cite. 1044 | 1045 | \newlength{\@tufte@sidenote@vertical@offset} 1046 | \setlength{\@tufte@sidenote@vertical@offset}{0pt} 1047 | 1048 | % #1 = footnote num, #2 = vertical offset, #3 = footnote text 1049 | \long\def\@tufte@sidenote[#1][#2]#3{% 1050 | \ifthenelse{\boolean{@tufte@loadnatbib}}{% 1051 | \let\cite\@tufte@infootnote@cite% use the in-sidenote \cite command 1052 | }{}% 1053 | \gdef\@tufte@citations{}% clear out any old citations 1054 | \ifthenelse{\NOT\isempty{#2}}{% 1055 | \gsetlength{\@tufte@sidenote@vertical@offset}{#2}% 1056 | }{% 1057 | \gsetlength{\@tufte@sidenote@vertical@offset}{0pt}% 1058 | }% 1059 | \ifthenelse{\isempty{#1}}{% 1060 | % no specific footnote number provided 1061 | \stepcounter\@mpfn% 1062 | \protected@xdef\@thefnmark{\thempfn}% 1063 | \@footnotemark\@footnotetext[\@tufte@sidenote@vertical@offset]{#3}% 1064 | }{% 1065 | % specific footnote number provided 1066 | \begingroup% 1067 | \csname c@\@mpfn\endcsname #1\relax% 1068 | \unrestored@protected@xdef\@thefnmark{\thempfn}% 1069 | \endgroup% 1070 | \@footnotemark\@footnotetext[\@tufte@sidenote@vertical@offset]{#3}% 1071 | }% 1072 | \@tufte@print@citations% print any citations 1073 | \ifthenelse{\boolean{@tufte@loadnatbib}}{% 1074 | \let\cite\@tufte@normal@cite% go back to using normal in-text \cite command 1075 | }{}% 1076 | \unskip\ignorespaces% remove extra white space 1077 | \kern-\multiplefootnotemarker% remove \kern left behind by sidenote 1078 | \kern\multiplefootnotemarker\relax% add new \kern here to replace the one we yanked 1079 | } 1080 | 1081 | \newcommand{\sidenote}{\optparams{\@tufte@sidenote}{[][0pt]}} 1082 | \renewcommand{\footnote}{\optparams{\@tufte@sidenote}{[][0pt]}} 1083 | 1084 | %% 1085 | % Sidenote without the footnote mark 1086 | 1087 | \newcommand\marginnote[2][0pt]{% 1088 | \ifthenelse{\boolean{@tufte@loadnatbib}}{% 1089 | \let\cite\@tufte@infootnote@cite% use the in-sidenote \cite command 1090 | }{}% 1091 | \gdef\@tufte@citations{}% clear out any old citations 1092 | \marginpar{\hbox{}\vspace*{#1}\@tufte@marginnote@font\@tufte@marginnote@justification\@tufte@margin@par\vspace*{-1\baselineskip}\noindent #2}% 1093 | \@tufte@print@citations% print any citations 1094 | \ifthenelse{\boolean{@tufte@loadnatbib}}{% 1095 | \let\cite\@tufte@normal@cite% go back to using normal in-text \cite command 1096 | }{}% 1097 | } 1098 | 1099 | 1100 | %% 1101 | % The placeins package provides the \FloatBarrier command. This forces 1102 | % LaTeX to place all of the floats before proceeding. We'll use this to 1103 | % keep the float (figure and table) numbers in sequence. 1104 | \RequirePackage{placeins} 1105 | 1106 | %% 1107 | % Margin float environment 1108 | 1109 | \newsavebox{\@tufte@margin@floatbox} 1110 | \newenvironment{@tufte@margin@float}[2][-1.2ex]% 1111 | {\FloatBarrier% process all floats before this point so the figure/table numbers stay in order. 1112 | \begin{lrbox}{\@tufte@margin@floatbox}% 1113 | \begin{minipage}{\marginparwidth}% 1114 | \@tufte@caption@font% 1115 | \def\@captype{#2}% 1116 | \hbox{}\vspace*{#1}% 1117 | \@tufte@caption@justification% 1118 | \@tufte@margin@par% 1119 | \noindent% 1120 | } 1121 | {\end{minipage}% 1122 | \end{lrbox}% 1123 | \marginpar{\usebox{\@tufte@margin@floatbox}}% 1124 | } 1125 | 1126 | 1127 | %% 1128 | % Margin figure environment 1129 | 1130 | \newenvironment{marginfigure}[1][-1.2ex]% 1131 | {\begin{@tufte@margin@float}[#1]{figure}} 1132 | {\end{@tufte@margin@float}} 1133 | 1134 | 1135 | %% 1136 | % Margin table environment 1137 | 1138 | \newenvironment{margintable}[1][-1.2ex]% 1139 | {\begin{@tufte@margin@float}[#1]{table}} 1140 | {\end{@tufte@margin@float}} 1141 | 1142 | 1143 | %% 1144 | % Auto-detects the proper text alignment based on the various class options 1145 | 1146 | \newcommand*{\@tufte@justification@autodetect}{% 1147 | \ifthenelse{\boolean{@tufte@justified}}% 1148 | {\justifying}% 1149 | {\RaggedRight}% 1150 | } 1151 | 1152 | %% 1153 | % Forces the outer edge of the caption to be set ragged. 1154 | % Therefore, on verso pages it's ragged left, and on recto pages it's ragged right. 1155 | 1156 | \newcommand*{\@tufte@justification@caption@outer}{% 1157 | \ifthenelse{\boolean{@tufte@float@recto}}% 1158 | {\RaggedRight}% 1159 | {\RaggedLeft}% 1160 | } 1161 | 1162 | \newcommand*{\@tufte@justification@outer}{% 1163 | \@tufte@checkoddpage% 1164 | \ifthenelse{\boolean{@tufte@odd@page}}% 1165 | {\RaggedRight}% 1166 | {\RaggedLeft}% 1167 | } 1168 | 1169 | 1170 | 1171 | %% 1172 | % A collection of macros to be used with the new Tufte-style float environments. 1173 | % \setfloatalignment forces the caption placement to be treated as top, bottom, etc. 1174 | % \forcerectofloat forces the float to be treated as if it were appearing on a recto page. 1175 | % \forceversofloat does the same, but for verso pages. 1176 | 1177 | \newcommand{\@tufte@float@debug@info}{}% contains debug info generated as the float is processed 1178 | \newcommand{\@tufte@float@debug}[1]{% adds debug info to the queue for output 1179 | \ifthenelse{\equal{\@tufte@float@debug@info}{}}% 1180 | {\def\@tufte@float@debug@info{#1}}% 1181 | {\g@addto@macro\@tufte@float@debug@info{\MessageBreak#1}}% 1182 | } 1183 | 1184 | \newcommand{\floatalignment}{x}% holds the current float alignment (t, b, h, p) 1185 | \newcommand{\setfloatalignment}[1]{\global\def\floatalignment{#1}\@tufte@float@debug{Forcing position: [#1]}}% manually sets the float alignment 1186 | \newboolean{@tufte@float@recto} 1187 | \newcommand{\forcerectofloat}{\gsetboolean{@tufte@float@recto}{true}\@tufte@float@debug{Forcing page: [recto]}} 1188 | \newcommand{\forceversofloat}{\gsetboolean{@tufte@float@recto}{false}\@tufte@float@debug{Forcing page: [verso]}} 1189 | 1190 | % Boxes to temporarily store our float and caption 1191 | \newsavebox{\@tufte@figure@box} 1192 | \newsavebox{\@tufte@caption@box} 1193 | 1194 | % Save original LaTeX float environment 1195 | \let\@tufte@orig@float\@float 1196 | \let\@tufte@orig@endfloat\end@float 1197 | 1198 | % New length for tweaking float captions 1199 | \newlength{\@tufte@caption@vertical@offset} 1200 | \setlength{\@tufte@caption@vertical@offset}{0pt} 1201 | 1202 | % Store the caption and label contents 1203 | \newcommand{\@tufte@stored@shortcaption}{} 1204 | \newcommand{\@tufte@stored@caption}{} 1205 | \newcommand{\@tufte@stored@label}{} 1206 | 1207 | \long\def\@tufte@caption[#1][#2]#3{% 1208 | \ifthenelse{\isempty{#1}}% 1209 | {\gdef\@tufte@stored@shortcaption{#3}}% 1210 | {\gdef\@tufte@stored@shortcaption{#1}}% 1211 | \gsetlength{\@tufte@caption@vertical@offset}{-#2}% we want a positive offset to lower captions 1212 | \gdef\@tufte@stored@caption{#3}% 1213 | } 1214 | 1215 | \newcommand{\@tufte@label}[1]{% 1216 | \gdef\@tufte@stored@label{#1}% 1217 | } 1218 | 1219 | \newcommand{\@tufte@fps}{} 1220 | 1221 | \newboolean{@tufte@float@star} 1222 | \newlength{\@tufte@float@contents@width} 1223 | 1224 | %% 1225 | % Define a float environment to place the captions in the margin space 1226 | 1227 | \newenvironment{@tufte@float}[3][htbp]% 1228 | {% begin @tufte@float 1229 | % Should this float be full-width or just text-width? 1230 | \ifthenelse{\equal{#3}{star}}% 1231 | {\gsetboolean{@tufte@float@star}{true}}% 1232 | {\gsetboolean{@tufte@float@star}{false}}% 1233 | % Check page side (recto/verso) and store detected value -- can be overriden in environment contents 1234 | \@tufte@checkoddpage% 1235 | \ifthenelse{\boolean{@tufte@odd@page}}% 1236 | {\gsetboolean{@tufte@float@recto}{true}\@tufte@float@debug{Detected page: [recto/odd]}}% 1237 | {\gsetboolean{@tufte@float@recto}{false}\@tufte@float@debug{Detected page: [verso/even]}}% 1238 | % If the float placement specifier is 'b' and only 'b', then bottom-align the mini-pages, otherwise top-align them. 1239 | \renewcommand{\@tufte@fps}{#1}% 1240 | \@tufte@float@debug{Allowed positions: [#1]}% 1241 | \ifthenelse{\equal{#1}{b}\OR\equal{#1}{B}}% 1242 | {\renewcommand{\floatalignment}{b}\@tufte@float@debug{Presumed position: [bottom]}}% 1243 | {\renewcommand{\floatalignment}{t}\@tufte@float@debug{Presumed position: [top]}}% 1244 | % Capture the contents of the \caption and \label commands to use later 1245 | \global\let\@tufte@orig@caption\caption% 1246 | \global\let\@tufte@orig@label\label% 1247 | \renewcommand{\caption}{\optparams{\@tufte@caption}{[][0pt]}}% 1248 | \renewcommand{\label}[1]{\@tufte@label{##1}}% 1249 | % Handle subfigure package compatibility 1250 | \ifthenelse{\boolean{@tufte@packages@subfigure}}{% 1251 | % don't move the label while inside a \subfigure or \subtable command 1252 | \global\let\label\@tufte@orig@label% 1253 | }{}% subfigure package is not loaded 1254 | \@tufte@orig@float{#2}[#1]% 1255 | \ifthenelse{\boolean{@tufte@float@star}}% 1256 | {\setlength{\@tufte@float@contents@width}{\@tufte@fullwidth}}% 1257 | {\setlength{\@tufte@float@contents@width}{\textwidth}}% 1258 | \begin{lrbox}{\@tufte@figure@box}% 1259 | \begin{minipage}[\floatalignment]{\@tufte@float@contents@width}\hbox{}% 1260 | }{% end @tufte@float 1261 | \par\hbox{}\vspace{-\baselineskip}\ifthenelse{\prevdepth>0}{\vspace{-\prevdepth}}{}% align baselines of boxes 1262 | \end{minipage}% 1263 | \end{lrbox}% 1264 | % build the caption box 1265 | \begin{lrbox}{\@tufte@caption@box}% 1266 | \begin{minipage}[\floatalignment]{\marginparwidth}\hbox{}% 1267 | \ifthenelse{\NOT\equal{\@tufte@stored@caption}{}}{\@tufte@orig@caption[\@tufte@stored@shortcaption]{\@tufte@stored@caption}}{}% 1268 | \ifthenelse{\NOT\equal{\@tufte@stored@label}{}}{\@tufte@orig@label{\@tufte@stored@label}}{}% 1269 | \par\vspace{-\prevdepth}%% TODO: DOUBLE-CHECK FOR SAFETY 1270 | \end{minipage}% 1271 | \end{lrbox}% 1272 | % now typeset the stored boxes 1273 | \begin{fullwidth}% 1274 | \begin{minipage}[\floatalignment]{\linewidth}% 1275 | \ifthenelse{\boolean{@tufte@float@star}}% 1276 | {\@tufte@float@fullwidth[\@tufte@caption@vertical@offset]{\@tufte@figure@box}{\@tufte@caption@box}}% 1277 | {\@tufte@float@textwidth[\@tufte@caption@vertical@offset]{\@tufte@figure@box}{\@tufte@caption@box}}% 1278 | \end{minipage}% 1279 | \end{fullwidth}% 1280 | \@tufte@orig@endfloat% end original LaTeX float environment 1281 | % output debug info 1282 | \ifthenelse{\boolean{@tufte@debug}}{% 1283 | \typeout{^^J^^J----------- Tufte-LaTeX float information ----------}% 1284 | \ifthenelse{\equal{\@tufte@stored@label}{}}% 1285 | {\typeout{Warning: Float unlabeled!}}% 1286 | {\typeout{Float label: [\@tufte@stored@label]}}% 1287 | \typeout{Page number: [\thepage]}% 1288 | \def\MessageBreak{^^J}% 1289 | \typeout{\@tufte@float@debug@info}% 1290 | \ifthenelse{\boolean{@tufte@symmetric}}% 1291 | {\typeout{Symmetric: [true]}}% 1292 | {\typeout{Symmetric: [false]}}% 1293 | \typeout{----------------------------------------------------^^J^^J}% 1294 | }{}% 1295 | % reset commands and temp boxes and captions 1296 | \gdef\@tufte@float@debug@info{}% 1297 | \let\caption\@tufte@orig@caption% 1298 | \let\label\@tufte@orig@label% 1299 | \begin{lrbox}{\@tufte@figure@box}\hbox{}\end{lrbox}% 1300 | \begin{lrbox}{\@tufte@caption@box}\hbox{}\end{lrbox}% 1301 | \gdef\@tufte@stored@shortcaption{}% 1302 | \gdef\@tufte@stored@caption{}% 1303 | \gdef\@tufte@stored@label{}% 1304 | \gsetlength{\@tufte@caption@vertical@offset}{0pt}% reset caption offset 1305 | } 1306 | 1307 | \newcommand{\@tufte@float@textwidth}[3][0pt]{% 1308 | \ifthenelse{\NOT\boolean{@tufte@symmetric}\OR\boolean{@tufte@float@recto}}{% 1309 | % asymmetric or page is odd, so caption is on the right 1310 | \hbox{% 1311 | \usebox{#2}% 1312 | \hspace{\marginparsep}% 1313 | \smash{\raisebox{#1}{\usebox{#3}}}% 1314 | }% 1315 | \@tufte@float@debug{Caption position: [right]}% 1316 | }{% symmetric pages and page is even, so caption is on the left 1317 | \hbox{% 1318 | \smash{\raisebox{#1}{\usebox{#3}}}% 1319 | \hspace{\marginparsep}% 1320 | \usebox{#2}% 1321 | }% 1322 | \@tufte@float@debug{Caption position: [left]}% 1323 | }% 1324 | } 1325 | 1326 | \newcommand{\@tufte@float@fullwidth}[3][0pt]{% 1327 | \ifthenelse{\equal{\floatalignment}{b}}% 1328 | {% place caption above figure 1329 | \ifthenelse{\NOT\boolean{@tufte@symmetric}\OR\boolean{@tufte@float@recto}}% 1330 | {\hfill\smash{\raisebox{#1}{\usebox{#3}}}\par\usebox{#2}\@tufte@float@debug{Caption position: [above right]}}% caption on the right 1331 | {\smash{\raisebox{#1}{\usebox{#3}}}\hfill\par\usebox{#2}\@tufte@float@debug{Caption position: [above left]}}% caption on the left 1332 | }{% place caption below figure 1333 | \ifthenelse{\NOT\boolean{@tufte@symmetric}\OR\boolean{@tufte@float@recto}}% 1334 | {\usebox{#2}\par\hfill\smash{\raisebox{#1}{\usebox{#3}}}\@tufte@float@debug{Caption position: [below right]}}% caption on the right 1335 | {\usebox{#2}\par\smash{\raisebox{#1}{\usebox{#3}}}\hfill\@tufte@float@debug{Caption position: [below left]}}% caption on the left 1336 | }% 1337 | } 1338 | 1339 | 1340 | %% 1341 | % Redefine the figure environment to place the captions in the margin space 1342 | 1343 | \renewenvironment{figure}[1][htbp]% 1344 | {\ifvmode\else\unskip\fi\begin{@tufte@float}[#1]{figure}{}} 1345 | {\end{@tufte@float}} 1346 | 1347 | 1348 | %% 1349 | % Redefine the table environment to place the captions in the margin space 1350 | 1351 | \renewenvironment{table}[1][htbp] 1352 | {\ifvmode\else\unskip\fi\begin{@tufte@float}[#1]{table}{}} 1353 | {\end{@tufte@float}} 1354 | 1355 | 1356 | %% 1357 | % Full-width figure 1358 | 1359 | \renewenvironment{figure*}[1][htbp]% 1360 | {\ifvmode\else\unskip\fi\begin{@tufte@float}[#1]{figure}{star}} 1361 | {\end{@tufte@float}} 1362 | 1363 | 1364 | %% 1365 | % Full-width table 1366 | 1367 | \renewenvironment{table*}[1][htbp]% 1368 | {\ifvmode\else\unskip\fi\begin{@tufte@float}[#1]{table}{star}} 1369 | {\end{@tufte@float}} 1370 | 1371 | 1372 | %% 1373 | % Full-page-width area 1374 | 1375 | \newenvironment{fullwidth} 1376 | {\ifthenelse{\boolean{@tufte@symmetric}}% 1377 | {\ifthenelse{\boolean{@tufte@changepage}}{\begin{adjustwidth*}{}{-\@tufte@overhang}}{\begin{adjustwidth}[]{}{-\@tufte@overhang}}}% 1378 | {\begin{adjustwidth}{}{-\@tufte@overhang}}% 1379 | }% 1380 | {\ifthenelse{\boolean{@tufte@symmetric}}% 1381 | {\ifthenelse{\boolean{@tufte@changepage}}{\end{adjustwidth*}}{\end{adjustwidth}}}% 1382 | {\end{adjustwidth}}% 1383 | } 1384 | 1385 | %% 1386 | % Format the captions in a style similar to the sidenotes 1387 | 1388 | \long\def\@caption#1[#2]#3{% 1389 | \par% 1390 | \addcontentsline{\csname ext@#1\endcsname}{#1}% 1391 | {\protect\numberline{\csname the#1\endcsname}{\ignorespaces #2}}% 1392 | \begingroup% 1393 | \@parboxrestore% 1394 | \if@minipage% 1395 | \@setminipage% 1396 | \fi% 1397 | \@tufte@caption@font\@tufte@caption@justification% 1398 | \noindent\csname fnum@#1\endcsname: \ignorespaces#3\par% 1399 | %\@makecaption{\csname fnum@#1\endcsname}{\ignorespaces #3}\par 1400 | \endgroup} 1401 | 1402 | %% 1403 | % If we're NOT using XeLaTeX and the `nofonts' class option was NOT provided, 1404 | % we should load the Palatino, Helvetica, and Bera Mono fonts (if they are 1405 | % installed.) 1406 | 1407 | \ifthenelse{\boolean{@tufte@loadfonts}\AND\NOT\boolean{@tufte@xetex}\AND\NOT\boolean{@tufte@luatex}}{% 1408 | \IfFileExists{mathpazo.sty}{\RequirePackage[osf,sc]{mathpazo}}{} 1409 | \IfFileExists{helvet.sty}{\RequirePackage[scaled=0.90]{helvet}}{} 1410 | \IfFileExists{beramono.sty}{\RequirePackage[scaled=0.85]{beramono}}{} 1411 | \RequirePackage[T1]{fontenc} 1412 | \RequirePackage{textcomp} 1413 | }{} 1414 | 1415 | 1416 | %% 1417 | % Turns newlines into spaces. Based on code from the `titlesec' package. 1418 | 1419 | \DeclareRobustCommand{\@tufte@newlinetospace}{% 1420 | \@ifstar{\@tufte@newlinetospace@i}{\@tufte@newlinetospace@i}% 1421 | } 1422 | 1423 | \def\@tufte@newlinetospace@i{% 1424 | \ifdim\lastskip>\z@\else\space\fi 1425 | \ignorespaces% 1426 | } 1427 | 1428 | \DeclareRobustCommand{\newlinetospace}[1]{% 1429 | \let\@tufte@orig@cr\\% save the original meaning of \\ 1430 | \def\\{\@tufte@newlinetospace}% turn \\ and \\* into \space 1431 | \let\newline\\% turn \newline into \space 1432 | #1% 1433 | \let\\\@tufte@orig@cr% revert to original meaning of \\ 1434 | } 1435 | 1436 | 1437 | %% 1438 | % Sets up the running heads and folios. 1439 | 1440 | \RequirePackage{fancyhdr} 1441 | 1442 | % Set the default page style to 'fancy' 1443 | \pagestyle{fancy} 1444 | 1445 | % Set the header/footer width to be the body text block plus the margin 1446 | % note area. 1447 | \AtBeginDocument{% 1448 | \ifthenelse{\boolean{@tufte@symmetric}} 1449 | {\fancyhfoffset[LE,RO]{\@tufte@overhang}} 1450 | {\fancyhfoffset[RE,RO]{\@tufte@overhang}} 1451 | } 1452 | 1453 | % The running heads/feet don't have rules 1454 | \renewcommand{\headrulewidth}{0pt} 1455 | \renewcommand{\footrulewidth}{0pt} 1456 | 1457 | % The 'fancy' page style is the default style for all pages. 1458 | \fancyhf{} % clear header and footer fields 1459 | \ifthenelse{\boolean{@tufte@twoside}} 1460 | {\fancyhead[LE]{\thepage\quad\smallcaps{\newlinetospace{\plainauthor}}}% 1461 | \fancyhead[RO]{\smallcaps{\newlinetospace{\plaintitle}}\quad\thepage}} 1462 | {\fancyhead[RE,RO]{\smallcaps{\newlinetospace{\plaintitle}}\quad\thepage}} 1463 | 1464 | 1465 | % The `plain' page style is used on chapter opening pages. 1466 | % In Tufte's /Beautiful Evidence/ he never puts page numbers at the 1467 | % bottom of pages -- the folios are unexpressed. 1468 | \fancypagestyle{plain}{ 1469 | \fancyhf{} % clear header and footer fields 1470 | % Uncomment the following five lines of code if you want the opening page 1471 | % of the chapter to express the folio in the lower outside corner. 1472 | %\ifthenelse{\boolean{@tufte@twoside}} 1473 | % {\fancyfoot[LE,RO]{\thepage}} 1474 | % {\fancyfoot[RE,RO]{\thepage}} 1475 | } 1476 | 1477 | % The `empty' page style suppresses all headers and footers. 1478 | % It's used on title pages and `intentionally blank' pages. 1479 | \fancypagestyle{empty}{ 1480 | \fancyhf{} % clear header and footer fields 1481 | } 1482 | 1483 | 1484 | %% 1485 | % Set raggedright and paragraph indentation for document 1486 | 1487 | \AtBeginDocument{\@tufte@justification} 1488 | 1489 | 1490 | %% 1491 | % Prints the list of class options and their states. 1492 | 1493 | \newcommand{\typeoutbool}[2]{% 1494 | \ifthenelse{\boolean{#2}} 1495 | {\typeout{\space\space#1: true}} 1496 | {\typeout{\space\space#1: false}} 1497 | } 1498 | 1499 | \newcommand{\typeoutstr}[2]{% 1500 | \typeout{\space\space#1: #2} 1501 | } 1502 | 1503 | \newcommand{\PrintTufteSettings}{% 1504 | \typeout{-------------------- Tufte-LaTeX settings ----------} 1505 | \typeout{Class: \@tufte@pkgname} 1506 | \typeout{} 1507 | \typeout{Class options:} 1508 | \typeoutbool{a4paper}{@tufte@afourpaper} 1509 | \typeoutbool{b5paper}{@tufte@bfivepaper} 1510 | \typeoutbool{load fonts}{@tufte@loadfonts} 1511 | \typeoutbool{fully-justified}{@tufte@justified} 1512 | \typeoutbool{letterspacing}{@tufte@letterspace} 1513 | \typeoutbool{sans-serif sidenotes}{@tufte@sfsidenotes} 1514 | \typeoutbool{symmetric margins}{@tufte@symmetric} 1515 | \typeoutbool{titlepage}{@tufte@titlepage} 1516 | \typeoutbool{twoside}{@tufte@twoside} 1517 | \typeoutbool{debug}{@tufte@debug} 1518 | \typeout{} 1519 | \typeout{Internal variables:} 1520 | \typeoutbool{[twoside]}{@twoside} 1521 | \typeoutbool{pdflatex}{@tufte@pdf} 1522 | \typeoutbool{xelatex}{@tufte@xetex} 1523 | \typeout{----------------------------------------------------} 1524 | } 1525 | 1526 | %% 1527 | % Amount of space to skip before \newthought or after title block 1528 | 1529 | \newskip\tufteskipamount 1530 | \tufteskipamount=1.0\baselineskip plus 0.5ex minus 0.2ex 1531 | 1532 | \newcommand{\tuftebreak}{\par\ifdim\lastskip<\tufteskipamount 1533 | \removelastskip\penalty-100\tufteskip\fi} 1534 | 1535 | \newcommand{\tufteskip}{\vspace\tufteskipamount} 1536 | 1537 | 1538 | %% 1539 | % Produces a full title page 1540 | 1541 | \newcommand{\maketitlepage}[0]{% 1542 | \cleardoublepage% 1543 | {% 1544 | \sffamily% 1545 | \begin{fullwidth}% 1546 | \fontsize{18}{20}\selectfont\par\noindent\textcolor{darkgray}{\allcaps{\thanklessauthor}}% 1547 | \vspace{11.5pc}% 1548 | \fontsize{36}{40}\selectfont\par\noindent\textcolor{darkgray}{\allcaps{\thanklesstitle}}% 1549 | \vfill% 1550 | \fontsize{14}{16}\selectfont\par\noindent\allcaps{\thanklesspublisher}% 1551 | \end{fullwidth}% 1552 | } 1553 | \thispagestyle{empty}% 1554 | \clearpage% 1555 | } 1556 | 1557 | %% 1558 | % Title block 1559 | 1560 | \renewcommand{\maketitle}{% 1561 | \newpage 1562 | \global\@topnum\z@% prevent floats from being placed at the top of the page 1563 | \begingroup 1564 | \setlength{\parindent}{0pt}% 1565 | \setlength{\parskip}{4pt}% 1566 | \let\@@title\@empty 1567 | \let\@@author\@empty 1568 | \let\@@date\@empty 1569 | \ifthenelse{\boolean{@tufte@sfsidenotes}}{% 1570 | \gdef\@@title{\sffamily\LARGE\allcaps{\@title}\par}% 1571 | \gdef\@@author{\sffamily\Large\allcaps{\@author}\par}% 1572 | \gdef\@@date{\sffamily\Large\allcaps{\@date}\par}% 1573 | }{% 1574 | \gdef\@@title{\LARGE\itshape\@title\par}% 1575 | \gdef\@@author{\Large\itshape\@author\par}% 1576 | \gdef\@@date{\Large\itshape\@date\par}% 1577 | }% 1578 | \@@title 1579 | \@@author 1580 | \@@date 1581 | \endgroup 1582 | \thispagestyle{plain}% suppress the running head 1583 | \tuftebreak% add some space before the text begins 1584 | \@afterindentfalse\@afterheading% suppress indentation of the next paragraph 1585 | } 1586 | 1587 | 1588 | %% 1589 | % Title page (if the `titlepage' option was passed to the tufte-handout 1590 | % class.) 1591 | 1592 | \ifthenelse{\boolean{@tufte@titlepage}} 1593 | {\renewcommand{\maketitle}{\maketitlepage}} 1594 | {} 1595 | 1596 | %% 1597 | % When \cleardoublepage is called, produce a blank (empty) page -- i.e., 1598 | % without headers and footers 1599 | \def\cleardoublepage{\clearpage\if@twoside\ifodd\c@page\else 1600 | \hbox{} 1601 | %\vspace*{\fill} 1602 | %\begin{center} 1603 | % This page intentionally contains only this sentence. 1604 | %\end{center} 1605 | %\vspace{\fill} 1606 | \thispagestyle{empty} 1607 | \newpage 1608 | \if@twocolumn\hbox{}\newpage\fi\fi\fi} 1609 | 1610 | %% 1611 | % Make Tuftian-style section headings and TOC formatting 1612 | 1613 | \titleformat{\chapter}% 1614 | [display]% shape 1615 | {\relax\ifthenelse{\NOT\boolean{@tufte@symmetric}}{\begin{fullwidth}}{}}% format applied to label+text 1616 | {\itshape\huge\thechapter}% label 1617 | {0pt}% horizontal separation between label and title body 1618 | {\huge\rmfamily\itshape}% before the title body 1619 | [\ifthenelse{\NOT\boolean{@tufte@symmetric}}{\end{fullwidth}}{}]% after the title body 1620 | 1621 | \titleformat{\section}% 1622 | [hang]% shape 1623 | {\normalfont\Large\itshape}% format applied to label+text 1624 | {\thesection}% label 1625 | {1em}% horizontal separation between label and title body 1626 | {}% before the title body 1627 | []% after the title body 1628 | 1629 | \titleformat{\subsection}% 1630 | [hang]% shape 1631 | {\normalfont\large\itshape}% format applied to label+text 1632 | {\thesubsection}% label 1633 | {1em}% horizontal separation between label and title body 1634 | {}% before the title body 1635 | []% after the title body 1636 | 1637 | \titleformat{\paragraph}% 1638 | [runin]% shape 1639 | {\normalfont\itshape}% format applied to label+text 1640 | {\theparagraph}% label 1641 | {1em}% horizontal separation between label and title body 1642 | {}% before the title body 1643 | []% after the title body 1644 | 1645 | \titlespacing*{\chapter}{0pt}{50pt}{40pt} 1646 | \titlespacing*{\section}{0pt}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex} 1647 | \titlespacing*{\subsection}{0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus.2ex} 1648 | 1649 | % Subsubsection and following section headings shouldn't be used. 1650 | % See Bringhurst's _The Elements of Typography_, section 4.2.2. 1651 | \renewcommand\subsubsection{% 1652 | \@tufte@error{\string\subsubsection is undefined by this class. 1653 | See Robert Bringhurst's _The Elements of 1654 | Typographic Style_, section 4.2.2. 1655 | \string\subsubsection was used} 1656 | {From Bringhurst's _The Elements of Typographic Style_, section 4.2.2: Use as 1657 | many levels of headings as you need, no more and no fewer. Also see the many 1658 | related threads on Ask E.T. at http://www.edwardtufte.com/.} 1659 | } 1660 | 1661 | \renewcommand\subparagraph{% 1662 | \@tufte@error{\string\subparagraph is undefined by this class.% 1663 | See Robert Bringhurst's _The Elements of 1664 | Typographic Style_, section 4.2.2. 1665 | \string\subparagraph was used} 1666 | {From Bringhurst's _The Elements of Typographic Style_, section 4.2.2: Use as 1667 | many levels of headings as you need, no more and no fewer. Also see the many 1668 | related threads on Ask E.T. at http://www.edwardtufte.com/.} 1669 | } 1670 | 1671 | 1672 | % Formatting for main TOC (printed in front matter) 1673 | % {section} [left] {above} {before w/label} {before w/o label} {filler + page} [after] 1674 | \ifthenelse{\boolean{@tufte@toc}}{% 1675 | \titlecontents{part}% FIXME 1676 | [0em] % distance from left margin 1677 | {\vspace{1.5\baselineskip}\begin{fullwidth}\LARGE\rmfamily\itshape} % above (global formatting of entry) 1678 | {\contentslabel{2em}} % before w/label (label = ``II'') 1679 | {} % before w/o label 1680 | {\rmfamily\upshape\qquad\thecontentspage} % filler + page (leaders and page num) 1681 | [\end{fullwidth}] % after 1682 | \titlecontents{chapter}% 1683 | [0em] % distance from left margin 1684 | {\vspace{1.5\baselineskip}\begin{fullwidth}\LARGE\rmfamily\itshape} % above (global formatting of entry) 1685 | {\hspace*{0em}\contentslabel{2em}} % before w/label (label = ``2'') 1686 | {\hspace*{0em}} % before w/o label 1687 | {\rmfamily\upshape\qquad\thecontentspage} % filler + page (leaders and page num) 1688 | [\end{fullwidth}] % after 1689 | \titlecontents{section}% FIXME 1690 | [0em] % distance from left margin 1691 | {\vspace{0\baselineskip}\begin{fullwidth}\Large\rmfamily\itshape} % above (global formatting of entry) 1692 | {\hspace*{2em}\contentslabel{2em}} % before w/label (label = ``2.6'') 1693 | {\hspace*{2em}} % before w/o label 1694 | {\rmfamily\upshape\qquad\thecontentspage} % filler + page (leaders and page num) 1695 | [\end{fullwidth}] % after 1696 | \titlecontents{subsection}% FIXME 1697 | [0em] % distance from left margin 1698 | {\vspace{0\baselineskip}\begin{fullwidth}\large\rmfamily\itshape} % above (global formatting of entry) 1699 | {\hspace*{4em}\contentslabel{4em}} % before w/label (label = ``2.6.1'') 1700 | {\hspace*{4em}} % before w/o label 1701 | {\rmfamily\upshape\qquad\thecontentspage} % filler + page (leaders and page num) 1702 | [\end{fullwidth}] % after 1703 | \titlecontents{paragraph}% FIXME 1704 | [0em] % distance from left margin 1705 | {\vspace{0\baselineskip}\begin{fullwidth}\normalsize\rmfamily\itshape} % above (global formatting of entry) 1706 | {\hspace*{6em}\contentslabel{2em}} % before w/label (label = ``2.6.0.0.1'') 1707 | {\hspace*{6em}} % before w/o label 1708 | {\rmfamily\upshape\qquad\thecontentspage} % filler + page (leaders and page num) 1709 | [\end{fullwidth}] % after 1710 | }{} 1711 | 1712 | %% 1713 | % Format lists of figures/tables 1714 | 1715 | \renewcommand\listoffigures{% 1716 | \ifthenelse{\equal{\@tufte@class}{book}}% 1717 | {\chapter*{\listfigurename}}% 1718 | {\section*{\listfigurename}}% 1719 | % \begin{fullwidth}% 1720 | \@starttoc{lof}% 1721 | % \end{fullwidth}% 1722 | } 1723 | 1724 | \renewcommand\listoftables{% 1725 | \ifthenelse{\equal{\@tufte@class}{book}}% 1726 | {\chapter*{\listtablename}}% 1727 | {\section*{\listtablename}}% 1728 | % \begin{fullwidth}% 1729 | \@starttoc{lot}% 1730 | % \end{fullwidth}% 1731 | } 1732 | 1733 | \newcommand{\@tufte@lof@line}[2]{% 1734 | % #1 is the figure/table number and its caption text 1735 | % #2 is the page number on which the figure/table appears 1736 | \leftskip 0.0em 1737 | \rightskip 0em 1738 | \parfillskip 0em plus 1fil 1739 | \parindent 0.0em 1740 | \@afterindenttrue 1741 | \interlinepenalty\@M 1742 | \leavevmode 1743 | \@tempdima 2.0em 1744 | \advance\leftskip\@tempdima 1745 | \null\nobreak\hskip -\leftskip 1746 | {#1}\nobreak\qquad\nobreak#2% 1747 | \par% 1748 | } 1749 | 1750 | \renewcommand*\l@figure{\@tufte@lof@line} 1751 | \let\l@table\l@figure 1752 | 1753 | 1754 | %% 1755 | % A handy command to disable hyphenation for short bits of text. 1756 | % Borrowed from Peter Wilson's `hyphenat' package. 1757 | 1758 | \AtBeginDocument{% 1759 | \@ifpackageloaded{hyphenat}{}{% 1760 | \newlanguage\langwohyphens% define a language without hyphenation rules 1761 | \providecommand{\nohyphens}[1]{{\language\langwohyphens #1}}% used for short bits of text 1762 | \providecommand{\nohyphenation}{\language\langwohyphens}% can be used inside environments for longer text 1763 | }% 1764 | } 1765 | 1766 | %% 1767 | % Redefine \bibsection to not mark the running heads. 1768 | % (Code modified from natbib.sty.) 1769 | 1770 | \ifthenelse{\boolean{@tufte@loadnatbib}}{% 1771 | \@ifundefined{chapter}{% 1772 | \renewcommand\bibsection{\section*{\refname}}% 1773 | }{% 1774 | \@ifundefined{NAT@sectionbib}{% 1775 | \renewcommand\bibsection{\chapter{\bibname}}% 1776 | }{% 1777 | \renewcommand\bibsection{\section*{\bibname}}% 1778 | }% 1779 | }% 1780 | } 1781 | 1782 | %% 1783 | % An index environment to mimic Tufte's indexes 1784 | 1785 | \RequirePackage{multicol} 1786 | \renewenvironment{theindex}{% 1787 | \ifthenelse{\equal{\@tufte@class}{book}}% 1788 | {\chapter{\indexname}}% 1789 | {\section*{\indexname}}% 1790 | \begin{fullwidth}% 1791 | \small% 1792 | \parskip0pt% 1793 | \parindent0pt% 1794 | \let\item\@idxitem% 1795 | \begin{multicols}{3}% 1796 | }{% 1797 | \end{multicols}% 1798 | \end{fullwidth}% 1799 | } 1800 | \renewcommand\@idxitem{\par\hangindent 2em} 1801 | \renewcommand\subitem{\par\hangindent 3em\hspace*{1em}} 1802 | \renewcommand\subsubitem{\par\hangindent 4em\hspace*{2em}} 1803 | \renewcommand\indexspace{\par\addvspace{1.0\baselineskip plus 0.5ex minus 0.2ex}\relax}% 1804 | \newcommand{\lettergroup}[1]{}% swallow the letter heading in the index 1805 | 1806 | 1807 | %% 1808 | % A couple commands to increase the number of floats you can use at a time. 1809 | 1810 | \def\morefloats{% provides a total of 52 floats 1811 | \ifthenelse{\isundefined{\bx@S}}{% 1812 | \@tufte@debug@info@noline{Adding 34 more float slots.} 1813 | \newinsert\bx@S 1814 | \newinsert\bx@T 1815 | \newinsert\bx@U 1816 | \newinsert\bx@V 1817 | \newinsert\bx@W 1818 | \newinsert\bx@X 1819 | \newinsert\bx@Y 1820 | \newinsert\bx@Z 1821 | \newinsert\bx@a 1822 | \newinsert\bx@b 1823 | \newinsert\bx@c 1824 | \newinsert\bx@d 1825 | \newinsert\bx@e 1826 | \newinsert\bx@f 1827 | \newinsert\bx@g 1828 | \newinsert\bx@h 1829 | \newinsert\bx@i 1830 | \newinsert\bx@j 1831 | \newinsert\bx@k 1832 | \newinsert\bx@l 1833 | \newinsert\bx@m 1834 | \newinsert\bx@n 1835 | \newinsert\bx@o 1836 | \newinsert\bx@p 1837 | \newinsert\bx@q 1838 | \newinsert\bx@r 1839 | \newinsert\bx@s 1840 | \newinsert\bx@t 1841 | \newinsert\bx@u 1842 | \newinsert\bx@v 1843 | \newinsert\bx@w 1844 | \newinsert\bx@x 1845 | \newinsert\bx@y 1846 | \newinsert\bx@z 1847 | \gdef\@freelist{\@elt\bx@A\@elt\bx@B\@elt\bx@C\@elt\bx@D\@elt\bx@E 1848 | \@elt\bx@F\@elt\bx@G\@elt\bx@H\@elt\bx@I\@elt\bx@J 1849 | \@elt\bx@K\@elt\bx@L\@elt\bx@M\@elt\bx@N 1850 | \@elt\bx@O\@elt\bx@P\@elt\bx@Q\@elt\bx@R 1851 | \@elt\bx@S\@elt\bx@T\@elt\bx@U\@elt\bx@V 1852 | \@elt\bx@W\@elt\bx@X\@elt\bx@Y\@elt\bx@Z 1853 | \@elt\bx@a\@elt\bx@b\@elt\bx@c\@elt\bx@d\@elt\bx@e 1854 | \@elt\bx@f\@elt\bx@g\@elt\bx@h\@elt\bx@i\@elt\bx@j 1855 | \@elt\bx@k\@elt\bx@l\@elt\bx@m\@elt\bx@n 1856 | \@elt\bx@o\@elt\bx@p\@elt\bx@q\@elt\bx@r 1857 | \@elt\bx@s\@elt\bx@t\@elt\bx@u\@elt\bx@v 1858 | \@elt\bx@w\@elt\bx@x\@elt\bx@y\@elt\bx@z}% 1859 | }{% we've already added another 34 floats, so we'll add 26 more, but that's it! 1860 | \ifthenelse{\isundefined{\bx@AA}}{% 1861 | \@tufte@debug@info@noline{Adding 26 more float slots.} 1862 | \newinsert\bx@AA 1863 | \newinsert\bx@BB 1864 | \newinsert\bx@CC 1865 | \newinsert\bx@DD 1866 | \newinsert\bx@EE 1867 | \newinsert\bx@FF 1868 | \newinsert\bx@GG 1869 | \newinsert\bx@HH 1870 | \newinsert\bx@II 1871 | \newinsert\bx@JJ 1872 | \newinsert\bx@KK 1873 | \newinsert\bx@LL 1874 | \newinsert\bx@MM 1875 | \newinsert\bx@NN 1876 | \newinsert\bx@OO 1877 | \newinsert\bx@PP 1878 | \newinsert\bx@QQ 1879 | \newinsert\bx@RR 1880 | \newinsert\bx@SS 1881 | \newinsert\bx@TT 1882 | \newinsert\bx@UU 1883 | \newinsert\bx@VV 1884 | \newinsert\bx@WW 1885 | \newinsert\bx@XX 1886 | \newinsert\bx@YY 1887 | \newinsert\bx@ZZ 1888 | \gdef\@freelist{\@elt\bx@A\@elt\bx@B\@elt\bx@C\@elt\bx@D\@elt\bx@E 1889 | \@elt\bx@F\@elt\bx@G\@elt\bx@H\@elt\bx@I\@elt\bx@J 1890 | \@elt\bx@K\@elt\bx@L\@elt\bx@M\@elt\bx@N 1891 | \@elt\bx@O\@elt\bx@P\@elt\bx@Q\@elt\bx@R 1892 | \@elt\bx@S\@elt\bx@T\@elt\bx@U\@elt\bx@V 1893 | \@elt\bx@W\@elt\bx@X\@elt\bx@Y\@elt\bx@Z 1894 | \@elt\bx@a\@elt\bx@b\@elt\bx@c\@elt\bx@d\@elt\bx@e 1895 | \@elt\bx@f\@elt\bx@g\@elt\bx@h\@elt\bx@i\@elt\bx@j 1896 | \@elt\bx@k\@elt\bx@l\@elt\bx@m\@elt\bx@n 1897 | \@elt\bx@o\@elt\bx@p\@elt\bx@q\@elt\bx@r 1898 | \@elt\bx@s\@elt\bx@t\@elt\bx@u\@elt\bx@v 1899 | \@elt\bx@w\@elt\bx@x\@elt\bx@y\@elt\bx@z 1900 | \@elt\bx@AA\@elt\bx@BB\@elt\bx@CC\@elt\bx@DD\@elt\bx@EE 1901 | \@elt\bx@FF\@elt\bx@GG\@elt\bx@HH\@elt\bx@II\@elt\bx@JJ 1902 | \@elt\bx@KK\@elt\bx@LL\@elt\bx@MM\@elt\bx@NN 1903 | \@elt\bx@OO\@elt\bx@PP\@elt\bx@QQ\@elt\bx@RR 1904 | \@elt\bx@SS\@elt\bx@TT\@elt\bx@UU\@elt\bx@VV 1905 | \@elt\bx@WW\@elt\bx@XX\@elt\bx@YY\@elt\bx@ZZ}% 1906 | }{% 1907 | \@tufte@error{You may only call \string\morefloats\space twice. See the Tufte-LaTeX documentation for other workarounds} 1908 | {There are already 78 float slots allocated. Try using \string\FloatBarrier\space or \string\clearpage\space to place some floats before creating more.} 1909 | }% 1910 | }% 1911 | } 1912 | 1913 | 1914 | %% 1915 | % Detect if the subfigure package has been loaded 1916 | 1917 | \newboolean{@tufte@packages@subfigure} 1918 | \setboolean{@tufte@packages@subfigure}{false} 1919 | \AtBeginDocument{% 1920 | \@ifpackageloaded{subfigure} 1921 | {\gsetboolean{@tufte@packages@subfigure}{true}} 1922 | {\gsetboolean{@tufte@packages@subfigure}{false}}% 1923 | } 1924 | 1925 | 1926 | %% 1927 | % Detect of the float package has been loaded 1928 | 1929 | \AtBeginDocument{% 1930 | \@ifpackageloaded{float}{% 1931 | % Save the redefined float environment (instead of the LaTeX float environment) 1932 | \let\@tufte@orig@float\@float 1933 | \let\@tufte@orig@endfloat\end@float 1934 | 1935 | % Define Tuftian float styles (with the caption in the margin) 1936 | \newcommand{\floatc@tufteplain}[2]{% 1937 | \begin{lrbox}{\@tufte@caption@box}% 1938 | \begin{minipage}[\floatalignment]{\marginparwidth}\hbox{}% 1939 | \@tufte@caption@font{\@fs@cfont #1:} #2\par% 1940 | \end{minipage}% 1941 | \end{lrbox}% 1942 | \smash{\hspace{\@tufte@caption@fill}\usebox{\@tufte@caption@box}}% 1943 | } 1944 | \newcommand{\fs@tufteplain}{% 1945 | \def\@fs@cfont{\@tufte@caption@font}% 1946 | \let\@fs@capt\floatc@tufteplain% 1947 | \def\@fs@pre{}% 1948 | \def\@fs@post{}% 1949 | \def\@fs@mid{}% 1950 | \let\@fs@iftopcapt\iftrue% 1951 | } 1952 | \let\fs@tufteplaintop=\fs@tufteplain 1953 | \let\floatc@tufteplaintop=\floatc@tufteplain 1954 | \newcommand\floatc@tufteruled[2]{% 1955 | {\@fs@cfont #1} #2\par% 1956 | } 1957 | \newcommand\fs@tufteruled{% 1958 | \def\@fs@cfont{\@tufte@caption@font}% 1959 | \let\@fs@capt\floatc@tufteplain% 1960 | \def\@fs@pre{\hrule height.8pt depth0pt width\textwidth \kern2pt}% 1961 | \def\@fs@post{\kern2pt\hrule width\textwidth\relax}% 1962 | \def\@fs@mid{}% 1963 | \let\@fs@iftopcapt\iftrue% 1964 | } 1965 | \newcommand\fs@tufteboxed{% 1966 | \def\@fs@cfont{}% 1967 | \let\@fs@capt\floatc@tufteplain% 1968 | \def\@fs@pre{% 1969 | \setbox\@currbox\vbox{\hbadness10000 1970 | \moveleft3.4pt\vbox{\advance\hsize by6.8pt 1971 | \hrule \hbox to\hsize{\vrule\kern3pt 1972 | \vbox{\kern3pt\box\@currbox\kern3pt}\kern3pt\vrule}\hrule}} 1973 | }% 1974 | \def\@fs@mid{\kern2pt}% 1975 | \def\@fs@post{}% 1976 | \let\@fs@iftopcapt\iftrue% 1977 | } 1978 | }{% 1979 | % Nothing to do 1980 | } 1981 | } 1982 | 1983 | \AtBeginDocument{% 1984 | \@ifpackageloaded{algorithm}{% 1985 | % Set the float style to the Tuftian version 1986 | \ifthenelse{\equal{\ALG@floatstyle}{plain}\OR\equal{\ALG@floatstyle}{ruled}\OR\equal{\ALG@floatstyle}{boxed}}{% 1987 | \@tufte@info@noline{Switching algorithm float style from \ALG@floatstyle\space to tufte\ALG@floatstyle}% 1988 | \floatstyle{tufte\ALG@floatstyle}% 1989 | \restylefloat{algorithm}% 1990 | }{}% 1991 | }{% 1992 | % Nothing to do 1993 | } 1994 | } 1995 | 1996 | 1997 | %% 1998 | % For compatibility with the subfig package, we'll set captions=false so that 1999 | % it doesn't load the caption package (which modifies our own caption 2000 | % formatting). 2001 | 2002 | \PassOptionsToPackage{caption=false}{subfig} 2003 | 2004 | 2005 | %% 2006 | % If debugging is enabled, print the Tufte-LaTeX options and the list of 2007 | % files. 2008 | 2009 | \ifthenelse{\boolean{@tufte@debug}} 2010 | {\PrintTufteSettings\listfiles} 2011 | {} 2012 | 2013 | 2014 | %% 2015 | % If there is a `tufte-common-local.tex' file, load it up. 2016 | 2017 | \IfFileExists{tufte-common-local.tex} 2018 | {\input{tufte-common-local.tex}% 2019 | \@tufte@info@noline{Loading tufte-common-local.tex}} 2020 | {} 2021 | 2022 | 2023 | %% 2024 | % End of file 2025 | \endinput 2026 | 2027 | -------------------------------------------------------------------------------- /tufte-handout.cls: -------------------------------------------------------------------------------- 1 | \NeedsTeXFormat{LaTeX2e}[1994/06/01] 2 | 3 | \ProvidesClass{tufte-handout}[2015/06/21 v3.5.2 Tufte-handout class] 4 | 5 | %% 6 | % Declare we're tufte-handout 7 | \newcommand{\@tufte@class}{article}% the base LaTeX class (defaults to the article/handout style) 8 | \newcommand{\@tufte@pkgname}{tufte-handout}% the name of the package (defaults to tufte-handout) 9 | 10 | %% 11 | % Load the common style elements 12 | \input{tufte-common.def} 13 | 14 | 15 | %% 16 | % Set up any handout-specific stuff now 17 | 18 | %% 19 | % Abstract 20 | 21 | % TODO The abstract should be printed on its own page of the `titlepage' 22 | % option was specified. 23 | \renewenvironment{abstract} 24 | {\begin{quotation}\if@tufte@sfsidenotes\begin{sffamily}\fi} 25 | {\if@tufte@sfsidenotes\end{sffamily}\fi\end{quotation}} 26 | 27 | 28 | %% 29 | % If there is a `tufte-handout-local.tex' file, load it. 30 | 31 | \IfFileExists{tufte-handout-local.tex}{% 32 | \input{tufte-handout-local}% 33 | \@tufte@info@noline{Loading tufte-handout-local.tex}% 34 | }{} 35 | 36 | 37 | %% 38 | % End of file 39 | \endinput 40 | -------------------------------------------------------------------------------- /tufte.bst: -------------------------------------------------------------------------------- 1 | %% 2 | %% This is file `tufte.bst', 3 | %% generated with the docstrip utility. 4 | %% 5 | %% The original source files were: 6 | %% 7 | %% merlin.mbs (with options: `seq-no,vonx,ed-au,nmlm,x2,m1,yr-com,xmth,tit-qq,qx,atit-u,jxper,trtit-b,volp-com,jwdpg,pp-last,num-xser,pre-pub,edpar,edby,blk-com,pp,ed,abr,ord,url,url-blk,nfss') 8 | %% ---------------------------------------- 9 | %% *** tufte handout bibliography style *** 10 | %% 11 | %% Copyright 1994-2002 Patrick W Daly 12 | % =============================================================== 13 | % IMPORTANT NOTICE: 14 | % This bibliographic style (bst) file has been generated from one or 15 | % more master bibliographic style (mbs) files, listed above. 16 | % 17 | % This generated file can be redistributed and/or modified under the terms 18 | % of the LaTeX Project Public License Distributed from CTAN 19 | % archives in directory macros/latex/base/lppl.txt; either 20 | % version 1 of the License, or any later version. 21 | % =============================================================== 22 | % Name and version information of the main mbs file: 23 | % \ProvidesFile{merlin.mbs}[2002/10/21 4.05 (PWD, AO, DPC)] 24 | % For use with BibTeX version 0.99a or later 25 | %------------------------------------------------------------------- 26 | % This bibliography style file is intended for texts in ENGLISH 27 | % This is a numerical citation style, and as such is standard LaTeX. 28 | % It requires no extra package to interface to the main text. 29 | % The form of the \bibitem entries is 30 | % \bibitem{key}... 31 | % Usage of \cite is as follows: 32 | % \cite{key} ==>> [#] 33 | % \cite[chap. 2]{key} ==>> [#, chap. 2] 34 | % where # is a number determined by the ordering in the reference list. 35 | % The order in the reference list is that by which the works were originally 36 | % cited in the text, or that in the database. 37 | %--------------------------------------------------------------------- 38 | 39 | ENTRY 40 | { address 41 | author 42 | booktitle 43 | chapter 44 | edition 45 | editor 46 | howpublished 47 | institution 48 | journal 49 | key 50 | month 51 | note 52 | number 53 | organization 54 | pages 55 | publisher 56 | school 57 | series 58 | title 59 | type 60 | url 61 | volume 62 | year 63 | } 64 | {} 65 | { label } 66 | INTEGERS { output.state before.all mid.sentence after.sentence after.block } 67 | FUNCTION {init.state.consts} 68 | { #0 'before.all := 69 | #1 'mid.sentence := 70 | #2 'after.sentence := 71 | #3 'after.block := 72 | } 73 | STRINGS { s t} 74 | FUNCTION {output.nonnull} 75 | { 's := 76 | output.state mid.sentence = 77 | { ", " * write$ } 78 | { output.state after.block = 79 | { add.period$ write$ 80 | newline$ 81 | "\newblock " write$ 82 | } 83 | { output.state before.all = 84 | 'write$ 85 | { add.period$ " " * write$ } 86 | if$ 87 | } 88 | if$ 89 | mid.sentence 'output.state := 90 | } 91 | if$ 92 | s 93 | } 94 | FUNCTION {output} 95 | { duplicate$ empty$ 96 | 'pop$ 97 | 'output.nonnull 98 | if$ 99 | } 100 | FUNCTION {output.check} 101 | { 't := 102 | duplicate$ empty$ 103 | { pop$ "empty " t * " in " * cite$ * warning$ } 104 | 'output.nonnull 105 | if$ 106 | } 107 | FUNCTION {fin.entry} 108 | { add.period$ 109 | write$ 110 | newline$ 111 | } 112 | 113 | FUNCTION {new.block} 114 | { output.state before.all = 115 | 'skip$ 116 | { after.block 'output.state := } 117 | if$ 118 | } 119 | FUNCTION {new.sentence} 120 | { output.state after.block = 121 | 'skip$ 122 | { output.state before.all = 123 | 'skip$ 124 | { after.sentence 'output.state := } 125 | if$ 126 | } 127 | if$ 128 | } 129 | FUNCTION {add.blank} 130 | { " " * before.all 'output.state := 131 | } 132 | 133 | FUNCTION {date.block} 134 | { 135 | skip$ 136 | } 137 | 138 | FUNCTION {not} 139 | { { #0 } 140 | { #1 } 141 | if$ 142 | } 143 | FUNCTION {and} 144 | { 'skip$ 145 | { pop$ #0 } 146 | if$ 147 | } 148 | FUNCTION {or} 149 | { { pop$ #1 } 150 | 'skip$ 151 | if$ 152 | } 153 | FUNCTION {non.stop} 154 | { duplicate$ 155 | "}" * add.period$ 156 | #-1 #1 substring$ "." = 157 | } 158 | 159 | STRINGS {z} 160 | FUNCTION {remove.dots} 161 | { 'z := 162 | "" 163 | { z empty$ not } 164 | { z #1 #1 substring$ 165 | z #2 global.max$ substring$ 'z := 166 | duplicate$ "." = 'pop$ 167 | { * } 168 | if$ 169 | } 170 | while$ 171 | } 172 | FUNCTION {new.block.checka} 173 | { empty$ 174 | 'skip$ 175 | 'new.block 176 | if$ 177 | } 178 | FUNCTION {new.block.checkb} 179 | { empty$ 180 | swap$ empty$ 181 | and 182 | 'skip$ 183 | 'new.block 184 | if$ 185 | } 186 | FUNCTION {new.sentence.checka} 187 | { empty$ 188 | 'skip$ 189 | 'new.sentence 190 | if$ 191 | } 192 | FUNCTION {new.sentence.checkb} 193 | { empty$ 194 | swap$ empty$ 195 | and 196 | 'skip$ 197 | 'new.sentence 198 | if$ 199 | } 200 | FUNCTION {field.or.null} 201 | { duplicate$ empty$ 202 | { pop$ "" } 203 | 'skip$ 204 | if$ 205 | } 206 | FUNCTION {emphasize} 207 | { duplicate$ empty$ 208 | { pop$ "" } 209 | { "\emph{" swap$ * "}" * } 210 | if$ 211 | } 212 | FUNCTION {tie.or.space.prefix} 213 | { duplicate$ text.length$ #3 < 214 | { "~" } 215 | { " " } 216 | if$ 217 | swap$ 218 | } 219 | 220 | FUNCTION {capitalize} 221 | { "u" change.case$ "t" change.case$ } 222 | 223 | FUNCTION {space.word} 224 | { " " swap$ * " " * } 225 | % Here are the language-specific definitions for explicit words. 226 | % Each function has a name bbl.xxx where xxx is the English word. 227 | % The language selected here is ENGLISH 228 | FUNCTION {bbl.and} 229 | { "and"} 230 | 231 | FUNCTION {bbl.etal} 232 | { "et~al." } 233 | 234 | FUNCTION {bbl.editors} 235 | { "eds." } 236 | 237 | FUNCTION {bbl.editor} 238 | { "ed." } 239 | 240 | FUNCTION {bbl.edby} 241 | { "edited by" } 242 | 243 | FUNCTION {bbl.edition} 244 | { "edn." } 245 | 246 | FUNCTION {bbl.volume} 247 | { "vol." } 248 | 249 | FUNCTION {bbl.of} 250 | { "of" } 251 | 252 | FUNCTION {bbl.number} 253 | { "no." } 254 | 255 | FUNCTION {bbl.nr} 256 | { "no." } 257 | 258 | FUNCTION {bbl.in} 259 | { "in" } 260 | 261 | FUNCTION {bbl.pages} 262 | { "pp." } 263 | 264 | FUNCTION {bbl.page} 265 | { "p." } 266 | 267 | FUNCTION {bbl.chapter} 268 | { "chap." } 269 | 270 | FUNCTION {bbl.techrep} 271 | { "Tech. Rep." } 272 | 273 | FUNCTION {bbl.mthesis} 274 | { "Master's thesis" } 275 | 276 | FUNCTION {bbl.phdthesis} 277 | { "Ph.D. thesis" } 278 | 279 | FUNCTION {bbl.first} 280 | { "1st" } 281 | 282 | FUNCTION {bbl.second} 283 | { "2nd" } 284 | 285 | FUNCTION {bbl.third} 286 | { "3rd" } 287 | 288 | FUNCTION {bbl.fourth} 289 | { "4th" } 290 | 291 | FUNCTION {bbl.fifth} 292 | { "5th" } 293 | 294 | FUNCTION {bbl.st} 295 | { "st" } 296 | 297 | FUNCTION {bbl.nd} 298 | { "nd" } 299 | 300 | FUNCTION {bbl.rd} 301 | { "rd" } 302 | 303 | FUNCTION {bbl.th} 304 | { "th" } 305 | 306 | MACRO {jan} {"Jan."} 307 | 308 | MACRO {feb} {"Feb."} 309 | 310 | MACRO {mar} {"Mar."} 311 | 312 | MACRO {apr} {"Apr."} 313 | 314 | MACRO {may} {"May"} 315 | 316 | MACRO {jun} {"Jun."} 317 | 318 | MACRO {jul} {"Jul."} 319 | 320 | MACRO {aug} {"Aug."} 321 | 322 | MACRO {sep} {"Sep."} 323 | 324 | MACRO {oct} {"Oct."} 325 | 326 | MACRO {nov} {"Nov."} 327 | 328 | MACRO {dec} {"Dec."} 329 | 330 | FUNCTION {eng.ord} 331 | { duplicate$ "1" swap$ * 332 | #-2 #1 substring$ "1" = 333 | { bbl.th * } 334 | { duplicate$ #-1 #1 substring$ 335 | duplicate$ "1" = 336 | { pop$ bbl.st * } 337 | { duplicate$ "2" = 338 | { pop$ bbl.nd * } 339 | { "3" = 340 | { bbl.rd * } 341 | { bbl.th * } 342 | if$ 343 | } 344 | if$ 345 | } 346 | if$ 347 | } 348 | if$ 349 | } 350 | 351 | MACRO {acmcs} {"ACM Computing Surveys"} 352 | 353 | MACRO {acta} {"Acta Informatica"} 354 | 355 | MACRO {cacm} {"Communications of the ACM"} 356 | 357 | MACRO {ibmjrd} {"IBM Journal of Research and Development"} 358 | 359 | MACRO {ibmsj} {"IBM Systems Journal"} 360 | 361 | MACRO {ieeese} {"IEEE Transactions on Software Engineering"} 362 | 363 | MACRO {ieeetc} {"IEEE Transactions on Computers"} 364 | 365 | MACRO {ieeetcad} 366 | {"IEEE Transactions on Computer-Aided Design of Integrated Circuits"} 367 | 368 | MACRO {ipl} {"Information Processing Letters"} 369 | 370 | MACRO {jacm} {"Journal of the ACM"} 371 | 372 | MACRO {jcss} {"Journal of Computer and System Sciences"} 373 | 374 | MACRO {scp} {"Science of Computer Programming"} 375 | 376 | MACRO {sicomp} {"SIAM Journal on Computing"} 377 | 378 | MACRO {tocs} {"ACM Transactions on Computer Systems"} 379 | 380 | MACRO {tods} {"ACM Transactions on Database Systems"} 381 | 382 | MACRO {tog} {"ACM Transactions on Graphics"} 383 | 384 | MACRO {toms} {"ACM Transactions on Mathematical Software"} 385 | 386 | MACRO {toois} {"ACM Transactions on Office Information Systems"} 387 | 388 | MACRO {toplas} {"ACM Transactions on Programming Languages and Systems"} 389 | 390 | MACRO {tcs} {"Theoretical Computer Science"} 391 | FUNCTION {bibinfo.check} 392 | { swap$ 393 | duplicate$ missing$ 394 | { 395 | pop$ pop$ 396 | "" 397 | } 398 | { duplicate$ empty$ 399 | { 400 | swap$ pop$ 401 | } 402 | { swap$ 403 | pop$ 404 | } 405 | if$ 406 | } 407 | if$ 408 | } 409 | FUNCTION {bibinfo.warn} 410 | { swap$ 411 | duplicate$ missing$ 412 | { 413 | swap$ "missing " swap$ * " in " * cite$ * warning$ pop$ 414 | "" 415 | } 416 | { duplicate$ empty$ 417 | { 418 | swap$ "empty " swap$ * " in " * cite$ * warning$ 419 | } 420 | { swap$ 421 | pop$ 422 | } 423 | if$ 424 | } 425 | if$ 426 | } 427 | FUNCTION {format.url} 428 | { url empty$ 429 | { "" } 430 | { "\urlprefix\url{" url * "}" * } 431 | if$ 432 | } 433 | 434 | STRINGS { bibinfo} 435 | INTEGERS { nameptr namesleft numnames } 436 | 437 | FUNCTION {format.names} 438 | { 'bibinfo := 439 | duplicate$ empty$ 'skip$ { 440 | 's := 441 | "" 't := 442 | #1 'nameptr := 443 | s num.names$ 'numnames := 444 | numnames 'namesleft := 445 | { namesleft #0 > } 446 | { s nameptr 447 | "{ff~}{vv~}{ll}{, jj}" 448 | format.name$ 449 | bibinfo bibinfo.check 450 | 't := 451 | nameptr #1 > 452 | { 453 | nameptr #1 454 | #1 + = 455 | numnames #2 456 | > and 457 | { "others" 't := 458 | #1 'namesleft := } 459 | 'skip$ 460 | if$ 461 | namesleft #1 > 462 | { ", " * t * } 463 | { 464 | numnames #2 > 465 | { "," * } 466 | 'skip$ 467 | if$ 468 | s nameptr "{ll}" format.name$ duplicate$ "others" = 469 | { 't := } 470 | { pop$ } 471 | if$ 472 | t "others" = 473 | { 474 | " " * bbl.etal * 475 | } 476 | { 477 | bbl.and 478 | space.word * t * 479 | } 480 | if$ 481 | } 482 | if$ 483 | } 484 | 't 485 | if$ 486 | nameptr #1 + 'nameptr := 487 | namesleft #1 - 'namesleft := 488 | } 489 | while$ 490 | } if$ 491 | } 492 | FUNCTION {format.names.ed} 493 | { 494 | format.names 495 | } 496 | FUNCTION {format.authors} 497 | { author "author" format.names 498 | } 499 | FUNCTION {get.bbl.editor} 500 | { editor num.names$ #1 > 'bbl.editors 'bbl.editor if$ } 501 | 502 | FUNCTION {format.editors} 503 | { editor "editor" format.names duplicate$ empty$ 'skip$ 504 | { 505 | " " * 506 | get.bbl.editor 507 | "(" swap$ * ")" * 508 | * 509 | } 510 | if$ 511 | } 512 | FUNCTION {format.note} 513 | { 514 | note empty$ 515 | { "" } 516 | { note #1 #1 substring$ 517 | duplicate$ "{" = 518 | 'skip$ 519 | { output.state mid.sentence = 520 | { "l" } 521 | { "u" } 522 | if$ 523 | change.case$ 524 | } 525 | if$ 526 | note #2 global.max$ substring$ * "note" bibinfo.check 527 | } 528 | if$ 529 | } 530 | 531 | FUNCTION {format.title} 532 | { title 533 | "title" bibinfo.check 534 | duplicate$ empty$ 'skip$ 535 | { 536 | "\enquote{" swap$ * 537 | "}, " * 538 | } 539 | if$ 540 | } 541 | FUNCTION {end.quote.title} 542 | { title empty$ 543 | 'skip$ 544 | { before.all 'output.state := } 545 | if$ 546 | } 547 | FUNCTION {output.bibitem} 548 | { newline$ 549 | "\bibitem{" write$ 550 | cite$ write$ 551 | "}" write$ 552 | newline$ 553 | "" 554 | before.all 'output.state := 555 | } 556 | 557 | FUNCTION {n.dashify} 558 | { 559 | 't := 560 | "" 561 | { t empty$ not } 562 | { t #1 #1 substring$ "-" = 563 | { t #1 #2 substring$ "--" = not 564 | { "--" * 565 | t #2 global.max$ substring$ 't := 566 | } 567 | { { t #1 #1 substring$ "-" = } 568 | { "-" * 569 | t #2 global.max$ substring$ 't := 570 | } 571 | while$ 572 | } 573 | if$ 574 | } 575 | { t #1 #1 substring$ * 576 | t #2 global.max$ substring$ 't := 577 | } 578 | if$ 579 | } 580 | while$ 581 | } 582 | 583 | FUNCTION {word.in} 584 | { bbl.in 585 | " " * } 586 | 587 | FUNCTION {format.date} 588 | { 589 | "" 590 | duplicate$ empty$ 591 | year "year" bibinfo.check duplicate$ empty$ 592 | { swap$ 'skip$ 593 | { "there's a month but no year in " cite$ * warning$ } 594 | if$ 595 | * 596 | } 597 | { swap$ 'skip$ 598 | { 599 | swap$ 600 | " " * swap$ 601 | } 602 | if$ 603 | * 604 | } 605 | if$ 606 | duplicate$ empty$ 607 | 'skip$ 608 | { 609 | before.all 'output.state := 610 | ", " swap$ * 611 | } 612 | if$ 613 | } 614 | FUNCTION {format.btitle} 615 | { title "title" bibinfo.check 616 | duplicate$ empty$ 'skip$ 617 | { 618 | emphasize 619 | } 620 | if$ 621 | } 622 | FUNCTION {either.or.check} 623 | { empty$ 624 | 'pop$ 625 | { "can't use both " swap$ * " fields in " * cite$ * warning$ } 626 | if$ 627 | } 628 | FUNCTION {format.bvolume} 629 | { volume empty$ 630 | { "" } 631 | { bbl.volume volume tie.or.space.prefix 632 | "volume" bibinfo.check * * 633 | series "series" bibinfo.check 634 | duplicate$ empty$ 'pop$ 635 | { swap$ bbl.of space.word * swap$ 636 | emphasize * } 637 | if$ 638 | "volume and number" number either.or.check 639 | } 640 | if$ 641 | } 642 | FUNCTION {format.number.series} 643 | { volume empty$ 644 | { number empty$ 645 | { series field.or.null } 646 | { series empty$ 647 | { number "number" bibinfo.check } 648 | { output.state mid.sentence = 649 | { bbl.number } 650 | { bbl.number capitalize } 651 | if$ 652 | number tie.or.space.prefix "number" bibinfo.check * * 653 | bbl.in space.word * 654 | series "series" bibinfo.check * 655 | } 656 | if$ 657 | } 658 | if$ 659 | } 660 | { "" } 661 | if$ 662 | } 663 | FUNCTION {is.num} 664 | { chr.to.int$ 665 | duplicate$ "0" chr.to.int$ < not 666 | swap$ "9" chr.to.int$ > not and 667 | } 668 | 669 | FUNCTION {extract.num} 670 | { duplicate$ 't := 671 | "" 's := 672 | { t empty$ not } 673 | { t #1 #1 substring$ 674 | t #2 global.max$ substring$ 't := 675 | duplicate$ is.num 676 | { s swap$ * 's := } 677 | { pop$ "" 't := } 678 | if$ 679 | } 680 | while$ 681 | s empty$ 682 | 'skip$ 683 | { pop$ s } 684 | if$ 685 | } 686 | 687 | FUNCTION {convert.edition} 688 | { extract.num "l" change.case$ 's := 689 | s "first" = s "1" = or 690 | { bbl.first 't := } 691 | { s "second" = s "2" = or 692 | { bbl.second 't := } 693 | { s "third" = s "3" = or 694 | { bbl.third 't := } 695 | { s "fourth" = s "4" = or 696 | { bbl.fourth 't := } 697 | { s "fifth" = s "5" = or 698 | { bbl.fifth 't := } 699 | { s #1 #1 substring$ is.num 700 | { s eng.ord 't := } 701 | { edition 't := } 702 | if$ 703 | } 704 | if$ 705 | } 706 | if$ 707 | } 708 | if$ 709 | } 710 | if$ 711 | } 712 | if$ 713 | t 714 | } 715 | 716 | FUNCTION {format.edition} 717 | { edition duplicate$ empty$ 'skip$ 718 | { 719 | convert.edition 720 | output.state mid.sentence = 721 | { "l" } 722 | { "t" } 723 | if$ change.case$ 724 | "edition" bibinfo.check 725 | " " * bbl.edition * 726 | } 727 | if$ 728 | } 729 | INTEGERS { multiresult } 730 | FUNCTION {multi.page.check} 731 | { 't := 732 | #0 'multiresult := 733 | { multiresult not 734 | t empty$ not 735 | and 736 | } 737 | { t #1 #1 substring$ 738 | duplicate$ "-" = 739 | swap$ duplicate$ "," = 740 | swap$ "+" = 741 | or or 742 | { #1 'multiresult := } 743 | { t #2 global.max$ substring$ 't := } 744 | if$ 745 | } 746 | while$ 747 | multiresult 748 | } 749 | FUNCTION {format.pages} 750 | { pages duplicate$ empty$ 'skip$ 751 | { duplicate$ multi.page.check 752 | { 753 | bbl.pages swap$ 754 | n.dashify 755 | } 756 | { 757 | bbl.page swap$ 758 | } 759 | if$ 760 | tie.or.space.prefix 761 | "pages" bibinfo.check 762 | * * 763 | } 764 | if$ 765 | } 766 | FUNCTION {format.journal.pages} 767 | { pages duplicate$ empty$ 'pop$ 768 | { swap$ duplicate$ empty$ 769 | { pop$ pop$ format.pages } 770 | { 771 | ", " * 772 | swap$ 773 | n.dashify 774 | pages multi.page.check 775 | 'bbl.pages 776 | 'bbl.page 777 | if$ 778 | swap$ tie.or.space.prefix 779 | "pages" bibinfo.check 780 | * * 781 | * 782 | } 783 | if$ 784 | } 785 | if$ 786 | } 787 | FUNCTION {format.vol.num.pages} 788 | { volume field.or.null 789 | duplicate$ empty$ 'skip$ 790 | { 791 | "volume" bibinfo.check 792 | } 793 | if$ 794 | number "number" bibinfo.check duplicate$ empty$ 'skip$ 795 | { 796 | swap$ duplicate$ empty$ 797 | { "there's a number but no volume in " cite$ * warning$ } 798 | 'skip$ 799 | if$ 800 | swap$ 801 | "(" swap$ * ")" * 802 | } 803 | if$ * 804 | } 805 | 806 | FUNCTION {format.chapter.pages} 807 | { chapter empty$ 808 | { "" } 809 | { type empty$ 810 | { bbl.chapter } 811 | { type "l" change.case$ 812 | "type" bibinfo.check 813 | } 814 | if$ 815 | chapter tie.or.space.prefix 816 | "chapter" bibinfo.check 817 | * * 818 | } 819 | if$ 820 | } 821 | 822 | FUNCTION {format.booktitle} 823 | { 824 | booktitle "booktitle" bibinfo.check 825 | emphasize 826 | } 827 | FUNCTION {format.in.ed.booktitle} 828 | { format.booktitle duplicate$ empty$ 'skip$ 829 | { 830 | editor "editor" format.names.ed duplicate$ empty$ 'pop$ 831 | { 832 | bbl.edby 833 | " " * swap$ * 834 | swap$ 835 | "," * 836 | " " * swap$ 837 | * } 838 | if$ 839 | word.in swap$ * 840 | } 841 | if$ 842 | } 843 | FUNCTION {empty.misc.check} 844 | { author empty$ title empty$ howpublished empty$ 845 | month empty$ year empty$ note empty$ 846 | and and and and and 847 | { "all relevant fields are empty in " cite$ * warning$ } 848 | 'skip$ 849 | if$ 850 | } 851 | FUNCTION {format.thesis.type} 852 | { type duplicate$ empty$ 853 | 'pop$ 854 | { swap$ pop$ 855 | "t" change.case$ "type" bibinfo.check 856 | } 857 | if$ 858 | } 859 | FUNCTION {format.tr.number} 860 | { number "number" bibinfo.check 861 | type duplicate$ empty$ 862 | { pop$ bbl.techrep } 863 | 'skip$ 864 | if$ 865 | "type" bibinfo.check 866 | swap$ duplicate$ empty$ 867 | { pop$ "t" change.case$ } 868 | { tie.or.space.prefix * * } 869 | if$ 870 | } 871 | FUNCTION {format.article.crossref} 872 | { 873 | key duplicate$ empty$ 874 | { pop$ 875 | journal duplicate$ empty$ 876 | { "need key or journal for " cite$ * " to crossref " * crossref * warning$ } 877 | { "journal" bibinfo.check emphasize word.in swap$ * } 878 | if$ 879 | } 880 | { word.in swap$ * " " *} 881 | if$ 882 | " \cite{" * crossref * "}" * 883 | } 884 | FUNCTION {format.crossref.editor} 885 | { editor #1 "{vv~}{ll}" format.name$ 886 | "editor" bibinfo.check 887 | editor num.names$ duplicate$ 888 | #2 > 889 | { pop$ 890 | "editor" bibinfo.check 891 | " " * bbl.etal 892 | * 893 | } 894 | { #2 < 895 | 'skip$ 896 | { editor #2 "{ff }{vv }{ll}{ jj}" format.name$ "others" = 897 | { 898 | "editor" bibinfo.check 899 | " " * bbl.etal 900 | * 901 | } 902 | { 903 | bbl.and space.word 904 | * editor #2 "{vv~}{ll}" format.name$ 905 | "editor" bibinfo.check 906 | * 907 | } 908 | if$ 909 | } 910 | if$ 911 | } 912 | if$ 913 | } 914 | FUNCTION {format.book.crossref} 915 | { volume duplicate$ empty$ 916 | { "empty volume in " cite$ * "'s crossref of " * crossref * warning$ 917 | pop$ word.in 918 | } 919 | { bbl.volume 920 | swap$ tie.or.space.prefix "volume" bibinfo.check * * bbl.of space.word * 921 | } 922 | if$ 923 | editor empty$ 924 | editor field.or.null author field.or.null = 925 | or 926 | { key empty$ 927 | { series empty$ 928 | { "need editor, key, or series for " cite$ * " to crossref " * 929 | crossref * warning$ 930 | "" * 931 | } 932 | { series emphasize * } 933 | if$ 934 | } 935 | { key * } 936 | if$ 937 | } 938 | { format.crossref.editor * } 939 | if$ 940 | " \cite{" * crossref * "}" * 941 | } 942 | FUNCTION {format.incoll.inproc.crossref} 943 | { 944 | editor empty$ 945 | editor field.or.null author field.or.null = 946 | or 947 | { key empty$ 948 | { format.booktitle duplicate$ empty$ 949 | { "need editor, key, or booktitle for " cite$ * " to crossref " * 950 | crossref * warning$ 951 | } 952 | { word.in swap$ * } 953 | if$ 954 | } 955 | { word.in key * " " *} 956 | if$ 957 | } 958 | { word.in format.crossref.editor * " " *} 959 | if$ 960 | " \cite{" * crossref * "}" * 961 | } 962 | FUNCTION {format.org.or.pub} 963 | { 't := 964 | "" 965 | address empty$ t empty$ and 966 | 'skip$ 967 | { 968 | t empty$ 969 | { address "address" bibinfo.check * 970 | } 971 | { t * 972 | address empty$ 973 | 'skip$ 974 | { ", " * address "address" bibinfo.check * } 975 | if$ 976 | } 977 | if$ 978 | } 979 | if$ 980 | } 981 | FUNCTION {format.publisher.address} 982 | { publisher "publisher" bibinfo.warn format.org.or.pub 983 | } 984 | 985 | FUNCTION {format.organization.address} 986 | { organization "organization" bibinfo.check format.org.or.pub 987 | } 988 | 989 | FUNCTION {article} 990 | { output.bibitem 991 | format.authors "author" output.check 992 | format.title "title" output.check 993 | end.quote.title 994 | crossref missing$ 995 | { 996 | journal 997 | remove.dots 998 | "journal" bibinfo.check 999 | emphasize 1000 | "journal" output.check 1001 | format.vol.num.pages output 1002 | format.date "year" output.check 1003 | } 1004 | { format.article.crossref output.nonnull 1005 | } 1006 | if$ 1007 | format.journal.pages 1008 | format.url output 1009 | format.note output 1010 | fin.entry 1011 | } 1012 | FUNCTION {book} 1013 | { output.bibitem 1014 | author empty$ 1015 | { format.editors "author and editor" output.check 1016 | } 1017 | { format.authors output.nonnull 1018 | crossref missing$ 1019 | { "author and editor" editor either.or.check } 1020 | 'skip$ 1021 | if$ 1022 | } 1023 | if$ 1024 | format.btitle "title" output.check 1025 | crossref missing$ 1026 | { format.bvolume output 1027 | format.number.series output 1028 | format.publisher.address output 1029 | } 1030 | { 1031 | format.book.crossref output.nonnull 1032 | } 1033 | if$ 1034 | format.edition output 1035 | format.date "year" output.check 1036 | format.url output 1037 | format.note output 1038 | fin.entry 1039 | } 1040 | FUNCTION {booklet} 1041 | { output.bibitem 1042 | format.authors output 1043 | format.title "title" output.check 1044 | end.quote.title 1045 | howpublished "howpublished" bibinfo.check output 1046 | address "address" bibinfo.check output 1047 | format.date output 1048 | format.url output 1049 | format.note output 1050 | fin.entry 1051 | } 1052 | 1053 | FUNCTION {inbook} 1054 | { output.bibitem 1055 | author empty$ 1056 | { format.editors "author and editor" output.check 1057 | } 1058 | { format.authors output.nonnull 1059 | crossref missing$ 1060 | { "author and editor" editor either.or.check } 1061 | 'skip$ 1062 | if$ 1063 | } 1064 | if$ 1065 | format.btitle "title" output.check 1066 | crossref missing$ 1067 | { 1068 | format.publisher.address output 1069 | format.bvolume output 1070 | format.chapter.pages "chapter and pages" output.check 1071 | format.number.series output 1072 | } 1073 | { 1074 | format.chapter.pages "chapter and pages" output.check 1075 | format.book.crossref output.nonnull 1076 | } 1077 | if$ 1078 | format.edition output 1079 | format.date "year" output.check 1080 | format.pages "pages" output.check 1081 | format.url output 1082 | format.note output 1083 | fin.entry 1084 | } 1085 | 1086 | FUNCTION {incollection} 1087 | { output.bibitem 1088 | format.authors "author" output.check 1089 | format.title "title" output.check 1090 | end.quote.title 1091 | crossref missing$ 1092 | { format.in.ed.booktitle "booktitle" output.check 1093 | format.publisher.address output 1094 | format.bvolume output 1095 | format.number.series output 1096 | format.chapter.pages output 1097 | format.edition output 1098 | format.date "year" output.check 1099 | } 1100 | { format.incoll.inproc.crossref output.nonnull 1101 | format.chapter.pages output 1102 | } 1103 | if$ 1104 | format.pages "pages" output.check 1105 | format.url output 1106 | format.note output 1107 | fin.entry 1108 | } 1109 | FUNCTION {inproceedings} 1110 | { output.bibitem 1111 | format.authors "author" output.check 1112 | format.title "title" output.check 1113 | end.quote.title 1114 | crossref missing$ 1115 | { format.in.ed.booktitle "booktitle" output.check 1116 | publisher empty$ 1117 | { format.organization.address output } 1118 | { organization "organization" bibinfo.check output 1119 | format.publisher.address output 1120 | } 1121 | if$ 1122 | format.date "year" output.check 1123 | format.bvolume output 1124 | format.number.series output 1125 | } 1126 | { format.incoll.inproc.crossref output.nonnull 1127 | } 1128 | if$ 1129 | format.pages "pages" output.check 1130 | format.url output 1131 | format.note output 1132 | fin.entry 1133 | } 1134 | FUNCTION {conference} { inproceedings } 1135 | FUNCTION {manual} 1136 | { output.bibitem 1137 | author empty$ 1138 | { organization "organization" bibinfo.check 1139 | duplicate$ empty$ 'pop$ 1140 | { output 1141 | address "address" bibinfo.check output 1142 | } 1143 | if$ 1144 | } 1145 | { format.authors output.nonnull } 1146 | if$ 1147 | format.btitle "title" output.check 1148 | author empty$ 1149 | { organization empty$ 1150 | { 1151 | address "address" bibinfo.check output 1152 | } 1153 | 'skip$ 1154 | if$ 1155 | } 1156 | { 1157 | organization "organization" bibinfo.check output 1158 | address "address" bibinfo.check output 1159 | } 1160 | if$ 1161 | format.edition output 1162 | format.date output 1163 | format.url output 1164 | format.note output 1165 | fin.entry 1166 | } 1167 | 1168 | FUNCTION {mastersthesis} 1169 | { output.bibitem 1170 | format.authors "author" output.check 1171 | format.btitle 1172 | "title" output.check 1173 | bbl.mthesis format.thesis.type output.nonnull 1174 | school "school" bibinfo.warn output 1175 | address "address" bibinfo.check output 1176 | format.date "year" output.check 1177 | format.url output 1178 | format.note output 1179 | fin.entry 1180 | } 1181 | 1182 | FUNCTION {misc} 1183 | { output.bibitem 1184 | format.authors output 1185 | format.title output 1186 | end.quote.title 1187 | howpublished "howpublished" bibinfo.check output 1188 | format.date output 1189 | format.url output 1190 | format.note output 1191 | fin.entry 1192 | empty.misc.check 1193 | } 1194 | FUNCTION {phdthesis} 1195 | { output.bibitem 1196 | format.authors "author" output.check 1197 | format.btitle 1198 | "title" output.check 1199 | bbl.phdthesis format.thesis.type output.nonnull 1200 | school "school" bibinfo.warn output 1201 | address "address" bibinfo.check output 1202 | format.date "year" output.check 1203 | format.url output 1204 | format.note output 1205 | fin.entry 1206 | } 1207 | 1208 | FUNCTION {proceedings} 1209 | { output.bibitem 1210 | editor empty$ 1211 | { organization "organization" bibinfo.check output 1212 | } 1213 | { format.editors output.nonnull } 1214 | if$ 1215 | format.btitle "title" output.check 1216 | format.bvolume output 1217 | format.number.series output 1218 | editor empty$ 1219 | { publisher empty$ 1220 | 'skip$ 1221 | { 1222 | format.publisher.address output 1223 | } 1224 | if$ 1225 | } 1226 | { publisher empty$ 1227 | { 1228 | format.organization.address output } 1229 | { 1230 | organization "organization" bibinfo.check output 1231 | format.publisher.address output 1232 | } 1233 | if$ 1234 | } 1235 | if$ 1236 | format.date "year" output.check 1237 | format.url output 1238 | format.note output 1239 | fin.entry 1240 | } 1241 | 1242 | FUNCTION {techreport} 1243 | { output.bibitem 1244 | format.authors "author" output.check 1245 | format.btitle 1246 | "title" output.check 1247 | format.tr.number output.nonnull 1248 | institution "institution" bibinfo.warn output 1249 | address "address" bibinfo.check output 1250 | format.date "year" output.check 1251 | format.url output 1252 | format.note output 1253 | fin.entry 1254 | } 1255 | 1256 | FUNCTION {unpublished} 1257 | { output.bibitem 1258 | format.authors "author" output.check 1259 | format.title "title" output.check 1260 | end.quote.title 1261 | format.date output 1262 | format.url output 1263 | format.note "note" output.check 1264 | fin.entry 1265 | } 1266 | 1267 | FUNCTION {default.type} { misc } 1268 | READ 1269 | STRINGS { longest.label } 1270 | INTEGERS { number.label longest.label.width } 1271 | FUNCTION {initialize.longest.label} 1272 | { "" 'longest.label := 1273 | #1 'number.label := 1274 | #0 'longest.label.width := 1275 | } 1276 | FUNCTION {longest.label.pass} 1277 | { number.label int.to.str$ 'label := 1278 | number.label #1 + 'number.label := 1279 | label width$ longest.label.width > 1280 | { label 'longest.label := 1281 | label width$ 'longest.label.width := 1282 | } 1283 | 'skip$ 1284 | if$ 1285 | } 1286 | EXECUTE {initialize.longest.label} 1287 | ITERATE {longest.label.pass} 1288 | FUNCTION {begin.bib} 1289 | { preamble$ empty$ 1290 | 'skip$ 1291 | { preamble$ write$ newline$ } 1292 | if$ 1293 | "\begin{thebibliography}{" longest.label * "}" * 1294 | write$ newline$ 1295 | "\newcommand{\enquote}[1]{``#1''}" 1296 | write$ newline$ 1297 | "\expandafter\ifx\csname url\endcsname\relax" 1298 | write$ newline$ 1299 | " \def\url#1{\texttt{#1}}\fi" 1300 | write$ newline$ 1301 | "\expandafter\ifx\csname urlprefix\endcsname\relax\def\urlprefix{URL }\fi" 1302 | write$ newline$ 1303 | } 1304 | EXECUTE {begin.bib} 1305 | EXECUTE {init.state.consts} 1306 | ITERATE {call.type$} 1307 | FUNCTION {end.bib} 1308 | { newline$ 1309 | "\end{thebibliography}" write$ newline$ 1310 | } 1311 | EXECUTE {end.bib} 1312 | %% End of customized bst file 1313 | %% 1314 | %% End of file `tufte.bst'. 1315 | --------------------------------------------------------------------------------