summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/tufte-latex
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /macros/latex/contrib/tufte-latex
Initial commit
Diffstat (limited to 'macros/latex/contrib/tufte-latex')
-rw-r--r--macros/latex/contrib/tufte-latex/History.txt100
-rw-r--r--macros/latex/contrib/tufte-latex/Manifest.txt27
l---------macros/latex/contrib/tufte-latex/README1
-rw-r--r--macros/latex/contrib/tufte-latex/README.txt101
-rw-r--r--macros/latex/contrib/tufte-latex/graphics/be-contents.pdfbin0 -> 18313 bytes
-rw-r--r--macros/latex/contrib/tufte-latex/graphics/be-title.pdfbin0 -> 5353 bytes
-rw-r--r--macros/latex/contrib/tufte-latex/graphics/ei-contents.pdfbin0 -> 19296 bytes
-rw-r--r--macros/latex/contrib/tufte-latex/graphics/ei-title.pdfbin0 -> 13141 bytes
-rw-r--r--macros/latex/contrib/tufte-latex/graphics/helix.asy25
-rw-r--r--macros/latex/contrib/tufte-latex/graphics/helix.pdfbin0 -> 9436 bytes
-rw-r--r--macros/latex/contrib/tufte-latex/graphics/hilbertcurves.pdfbin0 -> 29629 bytes
-rw-r--r--macros/latex/contrib/tufte-latex/graphics/nasa_vision_sm.pngbin0 -> 47420 bytes
-rw-r--r--macros/latex/contrib/tufte-latex/graphics/satir_graph.pngbin0 -> 9305 bytes
-rw-r--r--macros/latex/contrib/tufte-latex/graphics/sine.asy16
-rw-r--r--macros/latex/contrib/tufte-latex/graphics/sine.pdfbin0 -> 6069 bytes
-rw-r--r--macros/latex/contrib/tufte-latex/graphics/vdqi-contents.pdfbin0 -> 23153 bytes
-rw-r--r--macros/latex/contrib/tufte-latex/graphics/vdqi-title.pdfbin0 -> 20938 bytes
-rw-r--r--macros/latex/contrib/tufte-latex/graphics/ve-contents.pdfbin0 -> 19362 bytes
-rw-r--r--macros/latex/contrib/tufte-latex/graphics/ve-title.pdfbin0 -> 18304 bytes
-rw-r--r--macros/latex/contrib/tufte-latex/sample-book.pdfbin0 -> 283577 bytes
-rw-r--r--macros/latex/contrib/tufte-latex/sample-book.tex1178
-rw-r--r--macros/latex/contrib/tufte-latex/sample-handout.bib65
-rw-r--r--macros/latex/contrib/tufte-latex/sample-handout.pdfbin0 -> 114216 bytes
-rw-r--r--macros/latex/contrib/tufte-latex/sample-handout.tex291
-rw-r--r--macros/latex/contrib/tufte-latex/tufte-book.cls80
-rw-r--r--macros/latex/contrib/tufte-latex/tufte-common.def2026
-rw-r--r--macros/latex/contrib/tufte-latex/tufte-handout.cls39
-rw-r--r--macros/latex/contrib/tufte-latex/tufte.bst1314
28 files changed, 5263 insertions, 0 deletions
diff --git a/macros/latex/contrib/tufte-latex/History.txt b/macros/latex/contrib/tufte-latex/History.txt
new file mode 100644
index 0000000000..581d1ed40f
--- /dev/null
+++ b/macros/latex/contrib/tufte-latex/History.txt
@@ -0,0 +1,100 @@
+== 3.5.2 - 2015/06/21
+
+* A variety of bug fixes and small improvements.
+
+== 3.5.1 - 2010/03/28
+
+* Added bibliography style that didn't make it into the intial release.
+
+== 3.5.0 - 2009/12/11
+
+* Added a [nohyper] document class option that suppresses loading of the
+ hyperref package.
+* Added three commands to modify the positioning of the captions.
+* Now automatically recalculates the lengths in case you've modified the page
+ size or margins.
+* Added a B5 paper size.
+* The justification of sidenotes, margin notes, captions, and citations can be
+ set individually now.
+* The font and style of sidenotes, margin notes, captions, and citations can
+ now be set individually.
+* The \caption command now accepts an optional vertical offset argument.
+* Added the \morefloats command that works in the same way the morefloats
+ package does.
+* Fixed a number of bugs.
+
+== 3.0.0 - 2009/05/17
+
+* Created a Tufte-book document class.
+* Added optional offset parameter to sienotes, cite, etc. so their vertical
+ position can be adjusted manually.
+* Added support for the `bidi' package with XeLateX.
+* Adjusted font sizes and spacing to more closely reflect those used in
+ Tufte's books.
+* Captions are now typeset in the margin as in Tufte's books.
+
+== 2.0.1 - 2008/11/16
+
+* Now works with footmisc version > 5.4.
+
+== 2.0.0 - 2008/06/06
+
+* Added `sfsidenotes' option to set the sidenotes and captions in the sans
+ serif font.
+* Use the Palatino fonts if they're installed.
+* Created `marginfig' and `margintab' environments.
+* Added running heads.
+* Fixed the alignment of sidenote numbers.
+* Added \section and \subsection headings.
+* Uses the Bera Mono fonts if they're installed.
+* Added `symmetric' option to produce outside-margin sidenotes in two-sided
+ spreads.
+* Added `justified' option to set the text fully justified.
+* Rewrote sample-handout to illustrate the tufte-handout usage and serve as an
+ example of its features.
+
+== 1.2.3 - 2008/02/11
+
+* To remove References section from sample-handout.
+* Updated README.txt
+
+== 1.2.2 - 2008/02/09
+
+* Use footmisc package to set \footnotes as sidenotes
+* Use natbib package to set bibliography entries as sidenotes
+
+== 1.2.1 - 2007/10/21
+
+* To assure existing \footnotes become \sidenotes
+
+== 1.2.0 - 2007/10/20
+
+* Enhancements
+ * Added a4paper option (Kevin Godby)
+ * Have \margin{note,figure,table} use \@tufteh@marginfont
+* Bug fix
+ * \@tufteh@overhang typo in figure*, table*, and fullwidth environments (Kevin Godby)
+
+== 1.1.0 - 2007/10/18
+
+* To add some missing environments and commands:
+ * sidenote
+ * marginnote (no mark)
+ * marginfigure/table
+ * text-width figure/table (figure/table)
+ * page-width figure/table (figure*/table*)
+ * page-width environment (for custom minipage displays)
+* To namespace raggedright
+* To add margin font hook
+
+== 1.0.1 - 2007/09/24
+
+* To correct README instructions.
+
+== 1.0.0 - 2007/09/24
+
+* First public release
+
+== 0.1.0 - 2004/02/04
+
+* Birthday!
diff --git a/macros/latex/contrib/tufte-latex/Manifest.txt b/macros/latex/contrib/tufte-latex/Manifest.txt
new file mode 100644
index 0000000000..f553f65fd9
--- /dev/null
+++ b/macros/latex/contrib/tufte-latex/Manifest.txt
@@ -0,0 +1,27 @@
+History.txt
+Manifest.txt
+README.txt
+graphics/nasa_vision_sm.png
+graphics/satir_graph.png
+graphics/helix.asy
+graphics/sine.asy
+graphics/hilbertcurves.pdf
+graphics/helix.pdf
+graphics/sine.pdf
+graphics/be-contents.pdf
+graphics/be-title.pdf
+graphics/ei-contents.pdf
+graphics/ei-title.pdf
+graphics/vdqi-contents.pdf
+graphics/vdqi-title.pdf
+graphics/ve-contents.pdf
+graphics/ve-title.pdf
+sample-book.pdf
+sample-book.tex
+sample-handout.bib
+sample-handout.pdf
+sample-handout.tex
+tufte-book.cls
+tufte-common.def
+tufte-handout.cls
+tufte.bst
diff --git a/macros/latex/contrib/tufte-latex/README b/macros/latex/contrib/tufte-latex/README
new file mode 120000
index 0000000000..c3ca07460a
--- /dev/null
+++ b/macros/latex/contrib/tufte-latex/README
@@ -0,0 +1 @@
+README.txt \ No newline at end of file
diff --git a/macros/latex/contrib/tufte-latex/README.txt b/macros/latex/contrib/tufte-latex/README.txt
new file mode 100644
index 0000000000..57b8ba4fa3
--- /dev/null
+++ b/macros/latex/contrib/tufte-latex/README.txt
@@ -0,0 +1,101 @@
+Hi,
+
+Welcome to the beginnings of Tufte LaTeX package to help you
+produce Tufte-style handouts, reports, and notes.
+
+== Quick Start
+
+Try typesetting sample-handout.tex with the following sequence
+of commands,
+
+ pdflatex sample-handout
+ bibtex sample-handout
+ pdflatex sample-handout
+ pdflatex sample-handout
+
+The result should look like sample-handout.pdf.
+
+The sample book can be compiled with the following:
+
+ pdflatex sample-book
+ bibtex sample-book
+ texindy --language english sample-book.idx
+ # or makeindex sample-book.idx
+ pdflatex sample-book
+ pdflatex sample-book
+ pdflatex sample-book
+
+== Troubleshooting
+
+If you encounter errors of the form,
+
+ ! LaTeX Error: File `paralist.sty' not found.
+
+you will need to obtain missing packages from CTAN <http://ctan.org>.
+For package installation instructions and answers to many other
+questions, see the UK TeX FAQ,
+
+ http://www.tex.ac.uk/cgi-bin/texfaq2html?introduction=yes
+
+or search the news:comp.text.tex group via,
+
+ http://groups.google.com/group/comp.text.tex
+
+The following packages are required:
+
+ * chngpage or changepage
+ * fancyhdr
+ * fontenc
+ * geometry
+ * hyperref
+ * natbib and bibentry
+ * optparams
+ * paralist
+ * placeins
+ * ragged2e
+ * setspace
+ * textcase
+ * textcomp
+ * titlesec
+ * titletoc
+ * xcolor
+ * xifthen
+
+The following packages are optional and will be automatically used if installed:
+
+ * beramono
+ * helvet
+ * ifpdf
+ * ifxetex
+ * letterspace (in the microtype package)
+ * mathpazo
+ * soul
+
+== Bugs/Features/Support
+
+For kudos, feature requests, patches, or support requests that you
+feel are /particular/ to this Tufte-LaTeX package, i.e., not a general
+LaTeX issue, please use this project's issue tracker available at
+
+ http://tufte-latex.googlecode.com
+
+== Contributing
+
+Patches are most welcome via the issue tracker! Submit a series of
+high quality patches, and you'll find yourself a developer on this project.
+
+== License
+
+Copyright 2007-2010 by Kevin Godby, Bil Kleb, and Bill Wood.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
diff --git a/macros/latex/contrib/tufte-latex/graphics/be-contents.pdf b/macros/latex/contrib/tufte-latex/graphics/be-contents.pdf
new file mode 100644
index 0000000000..2f0ff0a3a9
--- /dev/null
+++ b/macros/latex/contrib/tufte-latex/graphics/be-contents.pdf
Binary files differ
diff --git a/macros/latex/contrib/tufte-latex/graphics/be-title.pdf b/macros/latex/contrib/tufte-latex/graphics/be-title.pdf
new file mode 100644
index 0000000000..c7ee88e66a
--- /dev/null
+++ b/macros/latex/contrib/tufte-latex/graphics/be-title.pdf
Binary files differ
diff --git a/macros/latex/contrib/tufte-latex/graphics/ei-contents.pdf b/macros/latex/contrib/tufte-latex/graphics/ei-contents.pdf
new file mode 100644
index 0000000000..56fdb0e2b1
--- /dev/null
+++ b/macros/latex/contrib/tufte-latex/graphics/ei-contents.pdf
Binary files differ
diff --git a/macros/latex/contrib/tufte-latex/graphics/ei-title.pdf b/macros/latex/contrib/tufte-latex/graphics/ei-title.pdf
new file mode 100644
index 0000000000..61d0f5b27d
--- /dev/null
+++ b/macros/latex/contrib/tufte-latex/graphics/ei-title.pdf
Binary files differ
diff --git a/macros/latex/contrib/tufte-latex/graphics/helix.asy b/macros/latex/contrib/tufte-latex/graphics/helix.asy
new file mode 100644
index 0000000000..3d2ce8c9dc
--- /dev/null
+++ b/macros/latex/contrib/tufte-latex/graphics/helix.asy
@@ -0,0 +1,25 @@
+import graph3;
+
+size(0,200);
+
+usepackage("palatino");
+usepackage("mathpazo");
+
+currentprojection=orthographic(4,6,3);
+
+real x(real t) {return cos(2pi*t);}
+real y(real t) {return sin(2pi*t);}
+real z(real t) {return t;}
+
+defaultpen(overwrite(SuppressQuiet));
+
+path3 p=graph(x,y,z,0,2.7,operator ..);
+bbox3 b=autolimits(min(p),max(p));
+aspect(b,1,1,1);
+
+xaxis(rotate(X)*"$x$",all=true,b,red,RightTicks(rotate(X)*Label,2,2));
+yaxis(rotate(Y)*"$y$",all=true,b,red,RightTicks(rotate(Y)*Label,2,2));
+zaxis("$z$",all=true,b,red,RightTicks);
+
+draw(p,Arrow);
+
diff --git a/macros/latex/contrib/tufte-latex/graphics/helix.pdf b/macros/latex/contrib/tufte-latex/graphics/helix.pdf
new file mode 100644
index 0000000000..b0b9116a04
--- /dev/null
+++ b/macros/latex/contrib/tufte-latex/graphics/helix.pdf
Binary files differ
diff --git a/macros/latex/contrib/tufte-latex/graphics/hilbertcurves.pdf b/macros/latex/contrib/tufte-latex/graphics/hilbertcurves.pdf
new file mode 100644
index 0000000000..737c921bef
--- /dev/null
+++ b/macros/latex/contrib/tufte-latex/graphics/hilbertcurves.pdf
Binary files differ
diff --git a/macros/latex/contrib/tufte-latex/graphics/nasa_vision_sm.png b/macros/latex/contrib/tufte-latex/graphics/nasa_vision_sm.png
new file mode 100644
index 0000000000..2f1c324e67
--- /dev/null
+++ b/macros/latex/contrib/tufte-latex/graphics/nasa_vision_sm.png
Binary files differ
diff --git a/macros/latex/contrib/tufte-latex/graphics/satir_graph.png b/macros/latex/contrib/tufte-latex/graphics/satir_graph.png
new file mode 100644
index 0000000000..d9509bc791
--- /dev/null
+++ b/macros/latex/contrib/tufte-latex/graphics/satir_graph.png
Binary files differ
diff --git a/macros/latex/contrib/tufte-latex/graphics/sine.asy b/macros/latex/contrib/tufte-latex/graphics/sine.asy
new file mode 100644
index 0000000000..6904735a10
--- /dev/null
+++ b/macros/latex/contrib/tufte-latex/graphics/sine.asy
@@ -0,0 +1,16 @@
+import graph;
+
+usepackage("palatino");
+usepackage("mathpazo");
+
+size(7inches,3inches);
+scale(true);
+
+real f(real x) { return sin(x); }
+pair F(real x) { return (x, f(x)); }
+
+xaxis("$x$");
+yaxis("$y$");
+
+draw(graph(f,-10.,10,operator ..), red);
+
diff --git a/macros/latex/contrib/tufte-latex/graphics/sine.pdf b/macros/latex/contrib/tufte-latex/graphics/sine.pdf
new file mode 100644
index 0000000000..94331fabb7
--- /dev/null
+++ b/macros/latex/contrib/tufte-latex/graphics/sine.pdf
Binary files differ
diff --git a/macros/latex/contrib/tufte-latex/graphics/vdqi-contents.pdf b/macros/latex/contrib/tufte-latex/graphics/vdqi-contents.pdf
new file mode 100644
index 0000000000..10ffa390cb
--- /dev/null
+++ b/macros/latex/contrib/tufte-latex/graphics/vdqi-contents.pdf
Binary files differ
diff --git a/macros/latex/contrib/tufte-latex/graphics/vdqi-title.pdf b/macros/latex/contrib/tufte-latex/graphics/vdqi-title.pdf
new file mode 100644
index 0000000000..c48a4dec33
--- /dev/null
+++ b/macros/latex/contrib/tufte-latex/graphics/vdqi-title.pdf
Binary files differ
diff --git a/macros/latex/contrib/tufte-latex/graphics/ve-contents.pdf b/macros/latex/contrib/tufte-latex/graphics/ve-contents.pdf
new file mode 100644
index 0000000000..61a78cdde5
--- /dev/null
+++ b/macros/latex/contrib/tufte-latex/graphics/ve-contents.pdf
Binary files differ
diff --git a/macros/latex/contrib/tufte-latex/graphics/ve-title.pdf b/macros/latex/contrib/tufte-latex/graphics/ve-title.pdf
new file mode 100644
index 0000000000..bb2ed48c44
--- /dev/null
+++ b/macros/latex/contrib/tufte-latex/graphics/ve-title.pdf
Binary files differ
diff --git a/macros/latex/contrib/tufte-latex/sample-book.pdf b/macros/latex/contrib/tufte-latex/sample-book.pdf
new file mode 100644
index 0000000000..2249efca23
--- /dev/null
+++ b/macros/latex/contrib/tufte-latex/sample-book.pdf
Binary files differ
diff --git a/macros/latex/contrib/tufte-latex/sample-book.tex b/macros/latex/contrib/tufte-latex/sample-book.tex
new file mode 100644
index 0000000000..f364575e91
--- /dev/null
+++ b/macros/latex/contrib/tufte-latex/sample-book.tex
@@ -0,0 +1,1178 @@
+\documentclass{tufte-book}
+
+\hypersetup{colorlinks}% uncomment this line if you prefer colored hyperlinks (e.g., for onscreen viewing)
+
+%%
+% Book metadata
+\title{A Tufte-Style Book\thanks{Thanks to Edward R.~Tufte for his inspiration.}}
+\author[The Tufte-LaTeX Developers]{The Tufte-LaTeX\ Developers}
+\publisher{Publisher of This Book}
+
+%%
+% If they're installed, use Bergamo and Chantilly from www.fontsite.com.
+% They're clones of Bembo and Gill Sans, respectively.
+%\IfFileExists{bergamo.sty}{\usepackage[osf]{bergamo}}{}% Bembo
+%\IfFileExists{chantill.sty}{\usepackage{chantill}}{}% Gill Sans
+
+%\usepackage{microtype}
+
+%%
+% Just some sample text
+\usepackage{lipsum}
+
+%%
+% For nicely typeset tabular material
+\usepackage{booktabs}
+
+%%
+% For graphics / images
+\usepackage{graphicx}
+\setkeys{Gin}{width=\linewidth,totalheight=\textheight,keepaspectratio}
+\graphicspath{{graphics/}}
+
+% The fancyvrb package lets us customize the formatting of verbatim
+% environments. We use a slightly smaller font.
+\usepackage{fancyvrb}
+\fvset{fontsize=\normalsize}
+
+%%
+% Prints argument within hanging parentheses (i.e., parentheses that take
+% up no horizontal space). Useful in tabular environments.
+\newcommand{\hangp}[1]{\makebox[0pt][r]{(}#1\makebox[0pt][l]{)}}
+
+%%
+% Prints an asterisk that takes up no horizontal space.
+% Useful in tabular environments.
+\newcommand{\hangstar}{\makebox[0pt][l]{*}}
+
+%%
+% Prints a trailing space in a smart way.
+\usepackage{xspace}
+
+%%
+% Some shortcuts for Tufte's book titles. The lowercase commands will
+% produce the initials of the book title in italics. The all-caps commands
+% will print out the full title of the book in italics.
+\newcommand{\vdqi}{\textit{VDQI}\xspace}
+\newcommand{\ei}{\textit{EI}\xspace}
+\newcommand{\ve}{\textit{VE}\xspace}
+\newcommand{\be}{\textit{BE}\xspace}
+\newcommand{\VDQI}{\textit{The Visual Display of Quantitative Information}\xspace}
+\newcommand{\EI}{\textit{Envisioning Information}\xspace}
+\newcommand{\VE}{\textit{Visual Explanations}\xspace}
+\newcommand{\BE}{\textit{Beautiful Evidence}\xspace}
+
+\newcommand{\TL}{Tufte-\LaTeX\xspace}
+
+% Prints the month name (e.g., January) and the year (e.g., 2008)
+\newcommand{\monthyear}{%
+ \ifcase\month\or January\or February\or March\or April\or May\or June\or
+ July\or August\or September\or October\or November\or
+ December\fi\space\number\year
+}
+
+
+% Prints an epigraph and speaker in sans serif, all-caps type.
+\newcommand{\openepigraph}[2]{%
+ %\sffamily\fontsize{14}{16}\selectfont
+ \begin{fullwidth}
+ \sffamily\large
+ \begin{doublespace}
+ \noindent\allcaps{#1}\\% epigraph
+ \noindent\allcaps{#2}% author
+ \end{doublespace}
+ \end{fullwidth}
+}
+
+% Inserts a blank page
+\newcommand{\blankpage}{\newpage\hbox{}\thispagestyle{empty}\newpage}
+
+\usepackage{units}
+
+% Typesets the font size, leading, and measure in the form of 10/12x26 pc.
+\newcommand{\measure}[3]{#1/#2$\times$\unit[#3]{pc}}
+
+% Macros for typesetting the documentation
+\newcommand{\hlred}[1]{\textcolor{Maroon}{#1}}% prints in red
+\newcommand{\hangleft}[1]{\makebox[0pt][r]{#1}}
+\newcommand{\hairsp}{\hspace{1pt}}% hair space
+\newcommand{\hquad}{\hskip0.5em\relax}% half quad space
+\newcommand{\TODO}{\textcolor{red}{\bf TODO!}\xspace}
+\newcommand{\ie}{\textit{i.\hairsp{}e.}\xspace}
+\newcommand{\eg}{\textit{e.\hairsp{}g.}\xspace}
+\newcommand{\na}{\quad--}% used in tables for N/A cells
+\providecommand{\XeLaTeX}{X\lower.5ex\hbox{\kern-0.15em\reflectbox{E}}\kern-0.1em\LaTeX}
+\newcommand{\tXeLaTeX}{\XeLaTeX\index{XeLaTeX@\protect\XeLaTeX}}
+% \index{\texttt{\textbackslash xyz}@\hangleft{\texttt{\textbackslash}}\texttt{xyz}}
+\newcommand{\tuftebs}{\symbol{'134}}% a backslash in tt type in OT1/T1
+\newcommand{\doccmdnoindex}[2][]{\texttt{\tuftebs#2}}% command name -- adds backslash automatically (and doesn't add cmd to the index)
+\newcommand{\doccmddef}[2][]{%
+ \hlred{\texttt{\tuftebs#2}}\label{cmd:#2}%
+ \ifthenelse{\isempty{#1}}%
+ {% add the command to the index
+ \index{#2 command@\protect\hangleft{\texttt{\tuftebs}}\texttt{#2}}% command name
+ }%
+ {% add the command and package to the index
+ \index{#2 command@\protect\hangleft{\texttt{\tuftebs}}\texttt{#2} (\texttt{#1} package)}% command name
+ \index{#1 package@\texttt{#1} package}\index{packages!#1@\texttt{#1}}% package name
+ }%
+}% command name -- adds backslash automatically
+\newcommand{\doccmd}[2][]{%
+ \texttt{\tuftebs#2}%
+ \ifthenelse{\isempty{#1}}%
+ {% add the command to the index
+ \index{#2 command@\protect\hangleft{\texttt{\tuftebs}}\texttt{#2}}% command name
+ }%
+ {% add the command and package to the index
+ \index{#2 command@\protect\hangleft{\texttt{\tuftebs}}\texttt{#2} (\texttt{#1} package)}% command name
+ \index{#1 package@\texttt{#1} package}\index{packages!#1@\texttt{#1}}% package name
+ }%
+}% command name -- adds backslash automatically
+\newcommand{\docopt}[1]{\ensuremath{\langle}\textrm{\textit{#1}}\ensuremath{\rangle}}% optional command argument
+\newcommand{\docarg}[1]{\textrm{\textit{#1}}}% (required) command argument
+\newenvironment{docspec}{\begin{quotation}\ttfamily\parskip0pt\parindent0pt\ignorespaces}{\end{quotation}}% command specification environment
+\newcommand{\docenv}[1]{\texttt{#1}\index{#1 environment@\texttt{#1} environment}\index{environments!#1@\texttt{#1}}}% environment name
+\newcommand{\docenvdef}[1]{\hlred{\texttt{#1}}\label{env:#1}\index{#1 environment@\texttt{#1} environment}\index{environments!#1@\texttt{#1}}}% environment name
+\newcommand{\docpkg}[1]{\texttt{#1}\index{#1 package@\texttt{#1} package}\index{packages!#1@\texttt{#1}}}% package name
+\newcommand{\doccls}[1]{\texttt{#1}}% document class name
+\newcommand{\docclsopt}[1]{\texttt{#1}\index{#1 class option@\texttt{#1} class option}\index{class options!#1@\texttt{#1}}}% document class option name
+\newcommand{\docclsoptdef}[1]{\hlred{\texttt{#1}}\label{clsopt:#1}\index{#1 class option@\texttt{#1} class option}\index{class options!#1@\texttt{#1}}}% document class option name defined
+\newcommand{\docmsg}[2]{\bigskip\begin{fullwidth}\noindent\ttfamily#1\end{fullwidth}\medskip\par\noindent#2}
+\newcommand{\docfilehook}[2]{\texttt{#1}\index{file hooks!#2}\index{#1@\texttt{#1}}}
+\newcommand{\doccounter}[1]{\texttt{#1}\index{#1 counter@\texttt{#1} counter}}
+
+% Generates the index
+\usepackage{makeidx}
+\makeindex
+
+\begin{document}
+
+% Front matter
+\frontmatter
+
+% r.1 blank page
+\blankpage
+
+% v.2 epigraphs
+\newpage\thispagestyle{empty}
+\openepigraph{%
+The public is more familiar with bad design than good design.
+It is, in effect, conditioned to prefer bad design,
+because that is what it lives with.
+The new becomes threatening, the old reassuring.
+}{Paul Rand%, {\itshape Design, Form, and Chaos}
+}
+\vfill
+\openepigraph{%
+A designer knows that he has achieved perfection
+not when there is nothing left to add,
+but when there is nothing left to take away.
+}{Antoine de Saint-Exup\'{e}ry}
+\vfill
+\openepigraph{%
+\ldots the designer of a new system must not only be the implementor and the first
+large-scale user; the designer should also write the first user manual\ldots
+If I had not participated fully in all these activities,
+literally hundreds of improvements would never have been made,
+because I would never have thought of them or perceived
+why they were important.
+}{Donald E. Knuth}
+
+
+% r.3 full title page
+\maketitle
+
+
+% v.4 copyright page
+\newpage
+\begin{fullwidth}
+~\vfill
+\thispagestyle{empty}
+\setlength{\parindent}{0pt}
+\setlength{\parskip}{\baselineskip}
+Copyright \copyright\ \the\year\ \thanklessauthor
+
+\par\smallcaps{Published by \thanklesspublisher}
+
+\par\smallcaps{tufte-latex.googlecode.com}
+
+\par Licensed under the Apache License, Version 2.0 (the ``License''); you may not
+use this file except in compliance with the License. You may obtain a copy
+of the License at \url{http://www.apache.org/licenses/LICENSE-2.0}. Unless
+required by applicable law or agreed to in writing, software distributed
+under the License is distributed on an \smallcaps{``AS IS'' BASIS, WITHOUT
+WARRANTIES OR CONDITIONS OF ANY KIND}, either express or implied. See the
+License for the specific language governing permissions and limitations
+under the License.\index{license}
+
+\par\textit{First printing, \monthyear}
+\end{fullwidth}
+
+% r.5 contents
+\tableofcontents
+
+\listoffigures
+
+\listoftables
+
+% r.7 dedication
+\cleardoublepage
+~\vfill
+\begin{doublespace}
+\noindent\fontsize{18}{22}\selectfont\itshape
+\nohyphenation
+Dedicated to those who appreciate \LaTeX{}
+and the work of \mbox{Edward R.~Tufte}
+and \mbox{Donald E.~Knuth}.
+\end{doublespace}
+\vfill
+\vfill
+
+
+% r.9 introduction
+\cleardoublepage
+\chapter*{Introduction}
+
+This sample book discusses the design of Edward Tufte's
+books\cite{Tufte2001,Tufte1990,Tufte1997,Tufte2006}
+and the use of the \doccls{tufte-book} and \doccls{tufte-handout} document classes.
+
+
+%%
+% Start the main matter (normal chapters)
+\mainmatter
+
+
+\chapter{The Design of Tufte's Books}
+\label{ch:tufte-design}
+
+
+\newthought{The pages} of a book are usually divided into three major
+sections: the front matter (also called preliminary matter or prelim), the
+main matter (the core text of the book), and the back matter (or end
+matter).
+
+\newthought{The front matter} of a book refers to all of the material that
+comes before the main text. The following table from shows a list of
+material that appears in the front matter of \VDQI, \EI, \VE, and \BE
+along with its page number. Page numbers that appear in parentheses refer
+to folios that do not have a printed page number (but they are still
+counted in the page number sequence).
+
+\bigskip
+\begin{minipage}{\textwidth}
+\begin{center}
+\begin{tabular}{lcccc}
+\toprule
+ & \multicolumn{4}{c}{Books} \\
+\cmidrule(l){2-5}
+Page content & \vdqi & \ei & \ve & \be \\
+\midrule
+Blank half title page & \hangp{1} & \hangp{1} & \hangp{1} & \hangp{1} \\
+Frontispiece\footnotemark{}
+ & \hangp{2} & \hangp{2} & \hangp{2} & \hangp{2} \\
+Full title page & \hangp{3} & \hangp{3} & \hangp{3} & \hangp{3} \\
+Copyright page & \hangp{4} & \hangp{4} & \hangp{4} & \hangp{4} \\
+Contents & \hangp{5} & \hangp{5} & \hangp{5} & \hangp{5} \\
+%Blank & -- & \hangp{6} & \hangp{6} & \hangp{6} \\
+Dedication & \hangp{6} & \hangp{7} & \hangp{7} & 7 \\
+%Blank & -- & \hangp{8} & -- & \hangp{8} \\
+Epigraph & -- & -- & \hangp{8} & -- \\
+Introduction & \hangp{7} & \hangp{9} & \hangp{9} & 9 \\
+\bottomrule
+\end{tabular}
+\end{center}
+\end{minipage}
+\vspace{-7\baselineskip}\footnotetext{The contents of this page vary from book to book. In
+ \vdqi this page is blank; in \ei and \ve this page holds a frontispiece;
+ and in \be this page contains three epigraphs.}
+\vspace{7\baselineskip}
+
+\bigskip
+The design of the front matter in Tufte's books varies slightly from the
+traditional design of front matter. First, the pages in front matter are
+traditionally numbered with lowercase roman numerals (\eg, i, ii, iii,
+iv,~\ldots). Second, the front matter page numbering sequence is usually
+separate from the main matter page numbering. That is, the page numbers
+restart at 1 when the main matter begins. In contrast, Tufte has
+enumerated his pages with arabic numerals that share the same page counting
+sequence as the main matter.
+
+There are also some variations in design across Tufte's four books. The
+page opposite the full title page (labeled ``frontispiece'' in the above
+table) has different content in each of the books. In \VDQI, this page is
+blank; in \EI and \VE, this page holds a frontispiece; and in \BE, this
+page contains three epigraphs.
+
+The dedication appears on page~6 in \vdqi (opposite the introduction), and
+is placed on its own spread in the other books. In \ve, an epigraph shares
+the spread with the opening page of the introduction.
+
+None of the page numbers (folios) of the front matter are expressed except in
+\be, where the folios start to appear on the dedication page.
+
+\newthought{The full title page} of each of the books varies slightly in
+design. In all the books, the author's name appears at the top of the
+page, the title it set just above the center line, and the publisher is
+printed along the bottom margin. Some of the differences are outlined in
+the following table.
+
+\bigskip
+\begin{center}
+\footnotesize
+\begin{tabular}{lllll}
+\toprule
+Feature & \vdqi & \ei & \ve & \be \\
+\midrule
+Author & & & & \\
+\quad Typeface & serif & serif & serif & sans serif \\
+\quad Style & italics & italics & italics & upright, caps \\
+\quad Size & 24 pt & 20 pt & 20 pt & 20 pt \\
+\addlinespace
+Title & & & & \\
+\quad Typeface & serif & serif & serif & sans serif \\
+\quad Style & upright & italics & upright & upright, caps \\
+\quad Size & 36 pt & 48 pt & 48 pt & 36 pt \\
+\addlinespace
+Subtitle & & & & \\
+\quad Typeface & \na & \na & serif & \na \\
+\quad Style & \na & \na & upright & \na \\
+\quad Size & \na & \na & 20 pt & \na \\
+\addlinespace
+Edition & & & & \\
+\quad Typeface & sans serif & \na & \na & \na \\
+\quad Style & upright, caps & \na & \na & \na \\
+\quad Size & 14 pt & \na & \na & \na \\
+\addlinespace
+Publisher & & & & \\
+\quad Typeface & serif & serif & serif & sans serif \\
+\quad Style & italics & italics & italics & upright, caps \\
+\quad Size & 14 pt & 14 pt & 14 pt & 14 pt \\
+\bottomrule
+\end{tabular}
+\end{center}
+
+\begin{figure*}[p]
+\fbox{\includegraphics[width=0.45\linewidth]{graphics/vdqi-title.pdf}}
+\hfill
+\fbox{\includegraphics[width=0.45\linewidth]{graphics/ei-title.pdf}}
+\\\vspace{\baselineskip}
+\fbox{\includegraphics[width=0.45\linewidth]{graphics/ve-title.pdf}}
+\hfill
+\fbox{\includegraphics[width=0.45\linewidth]{graphics/be-title.pdf}}
+\end{figure*}
+
+\newthought{The tables of contents} in Tufte's books give us our first
+glimpse of the structure of the main matter. \VDQI is split into two
+parts, each containing some number of chapters. His other three books only
+contain chapters---they're not broken into parts.
+
+\begin{figure*}[p]\index{table of contents}
+\fbox{\includegraphics[width=0.45\linewidth]{graphics/vdqi-contents.pdf}}
+\hfill
+\fbox{\includegraphics[width=0.45\linewidth]{graphics/ei-contents.pdf}}
+\\\vspace{\baselineskip}
+\fbox{\includegraphics[width=0.45\linewidth]{graphics/ve-contents.pdf}}
+\hfill
+\fbox{\includegraphics[width=0.45\linewidth]{graphics/be-contents.pdf}}
+\end{figure*}
+
+
+\section{Typefaces}\label{sec:typefaces1}\index{typefaces}
+\index{fonts|see{typefaces}}
+
+Tufte's books primarily use two typefaces: Bembo and Gill Sans. Bembo is used
+for the headings and body text, while Gill Sans is used for the title page and
+opening epigraphs in \BE.
+
+Since neither Bembo nor Gill Sans are available in default \LaTeX{}
+installations, the \TL document classes default to using Palatino and
+Helvetica, respectively. In addition, the Bera Mono typeface is used for
+\texttt{monospaced} type.
+
+The following font sizes are defined by the \TL classes:
+
+\begin{table}[h]\index{typefaces!sizes}
+ \footnotesize%
+ \begin{center}
+ \begin{tabular}{lccl}
+ \toprule
+ \LaTeX{} size & Font size & Leading & Used for \\
+ \midrule
+ \verb+\tiny+ & 5 & 6 & sidenote numbers \\
+ \verb+\scriptsize+ & 7 & 8 & \na \\
+ \verb+\footnotesize+ & 8 & 10 & sidenotes, captions \\
+ \verb+\small+ & 9 & 12 & quote, quotation, and verse environments \\
+ \verb+\normalsize+ & 10 & 14 & body text \\
+ \verb+\large+ & 11 & 15 & \textsc{b}-heads \\
+ \verb+\Large+ & 12 & 16 & \textsc{a}-heads, \textsc{toc} entries, author, date \\
+ \verb+\LARGE+ & 14 & 18 & handout title \\
+ \verb+\huge+ & 20 & 30 & chapter heads \\
+ \verb+\Huge+ & 24 & 36 & part titles \\
+ \bottomrule
+ \end{tabular}
+ \end{center}
+ \caption{A list of \LaTeX{} font sizes as defined by the \TL document classes.}
+ \label{tab:font-sizes}
+\end{table}
+
+\section{Headings}\label{sec:headings1}\index{headings}
+
+Tufte's books include the following heading levels: parts,
+chapters,\sidenote{Parts and chapters are defined for the \texttt{tufte-book}
+class only.} sections, subsections, and paragraphs. Not defined by default
+are: sub-subsections and subparagraphs.
+
+\begin{table}[h]
+ \begin{center}
+ \footnotesize%
+ \begin{tabular}{lcr}
+ \toprule
+ Heading & Style & Size \\
+ \midrule
+ Part & roman & \measure{24}{36}{40} \\
+ Chapter & italic & \measure{20}{30}{40} \\
+ Section & italic & \measure{12}{16}{26} \\
+ Subsection & italic & \measure{11}{15}{26} \\
+ Paragraph & italic & 10/14 \\
+ \bottomrule
+ \end{tabular}
+ \end{center}
+ \caption{Heading styles used in \BE.}
+ \label{tab:heading-styles}
+\end{table}
+
+\paragraph{Paragraph} Paragraph headings (as shown here) are introduced by
+italicized text and separated from the main paragraph by a bit of space.
+
+\section{Environments}
+
+The following characteristics define the various environments:
+
+
+\begin{table}[h]
+ \begin{center}
+ \footnotesize%
+ \begin{tabular}{lcl}
+ \toprule
+ Environment & Font size & Notes \\
+ \midrule
+ Body text & \measure{10}{14}{26} & \\
+ Block quote & \measure{9}{12}{24} & Block indent (left and right) by \unit[1]{pc} \\
+ Sidenotes & \measure{8}{10}{12} & Sidenote number is set inline, followed by word space \\
+ Captions & \measure{8}{10}{12} & \\
+ \bottomrule
+ \end{tabular}
+ \end{center}
+ \caption{Environment styles used in \BE.}
+ \label{tab:environment-styles}
+\end{table}
+
+
+\chapter[On the Use of the tufte-book Document Class]{On the Use of the \texttt{tufte-book} Document Class}
+\label{ch:tufte-book}
+
+The \TL document classes define a style similar to the
+style Edward Tufte uses in his books and handouts. Tufte's style is known
+for its extensive use of sidenotes, tight integration of graphics with
+text, and well-set typography. This document aims to be at once a
+demonstration of the features of the \TL document classes
+and a style guide to their use.
+
+\section{Page Layout}\label{sec:page-layout}
+\subsection{Headings}\label{sec:headings}\index{headings}
+This style provides \textsc{a}- and \textsc{b}-heads (that is,
+\Verb|\section| and \Verb|\subsection|), demonstrated above.
+
+If you need more than two levels of section headings, you'll have to define
+them yourself at the moment; there are no pre-defined styles for anything below
+a \Verb|\subsection|. As Bringhurst points out in \textit{The Elements of
+Typographic Style},\cite{Bringhurst2005} you should ``use as many levels of
+headings as you need: no more, and no fewer.''
+
+The \TL classes will emit an error if you try to use
+\linebreak\Verb|\subsubsection| and smaller headings.
+
+% let's start a new thought -- a new section
+\newthought{In his later books},\cite{Tufte2006} Tufte
+starts each section with a bit of vertical space, a non-indented paragraph,
+and sets the first few words of the sentence in \textsc{small caps}. To
+accomplish this using this style, use the \doccmddef{newthought} command:
+\begin{docspec}
+ \doccmd{newthought}\{In his later books\}, Tufte starts\ldots
+\end{docspec}
+
+
+\section{Sidenotes}\label{sec:sidenotes}
+One of the most prominent and distinctive features of this style is the
+extensive use of sidenotes. There is a wide margin to provide ample room
+for sidenotes and small figures. Any \doccmd{footnote}s will automatically
+be converted to sidenotes.\footnote{This is a sidenote that was entered
+using the \texttt{\textbackslash footnote} command.} If you'd like to place ancillary
+information in the margin without the sidenote mark (the superscript
+number), you can use the \doccmd{marginnote} command.\marginnote{This is a
+margin note. Notice that there isn't a number preceding the note, and
+there is no number in the main text where this note was written.}
+
+The specification of the \doccmddef{sidenote} command is:
+\begin{docspec}
+ \doccmd{sidenote}[\docopt{number}][\docopt{offset}]\{\docarg{Sidenote text.}\}
+\end{docspec}
+
+Both the \docopt{number} and \docopt{offset} arguments are optional. If you
+provide a \docopt{number} argument, then that number will be used as the
+sidenote number. It will change of the number of the current sidenote only and
+will not affect the numbering sequence of subsequent sidenotes.
+
+Sometimes a sidenote may run over the top of other text or graphics in the
+margin space. If this happens, you can adjust the vertical position of the
+sidenote by providing a dimension in the \docopt{offset} argument. Some
+examples of valid dimensions are:
+\begin{docspec}
+ \ttfamily 1.0in \qquad 2.54cm \qquad 254mm \qquad 6\Verb|\baselineskip|
+\end{docspec}
+If the dimension is positive it will push the sidenote down the page; if the
+dimension is negative, it will move the sidenote up the page.
+
+While both the \docopt{number} and \docopt{offset} arguments are optional, they
+must be provided in order. To adjust the vertical position of the sidenote
+while leaving the sidenote number alone, use the following syntax:
+\begin{docspec}
+ \doccmd{sidenote}[][\docopt{offset}]\{\docarg{Sidenote text.}\}
+\end{docspec}
+The empty brackets tell the \Verb|\sidenote| command to use the default
+sidenote number.
+
+If you \emph{only} want to change the sidenote number, however, you may
+completely omit the \docopt{offset} argument:
+\begin{docspec}
+ \doccmd{sidenote}[\docopt{number}]\{\docarg{Sidenote text.}\}
+\end{docspec}
+
+The \doccmddef{marginnote} command has a similar \docarg{offset} argument:
+\begin{docspec}
+ \doccmd{marginnote}[\docopt{offset}]\{\docarg{Margin note text.}\}
+\end{docspec}
+
+\section{References}
+References are placed alongside their citations as sidenotes,
+as well. This can be accomplished using the normal \doccmddef{cite}
+command.\sidenote{The first paragraph of this document includes a citation.}
+
+The complete list of references may also be printed automatically by using
+the \doccmddef{bibliography} command. (See the end of this document for an
+example.) If you do not want to print a bibliography at the end of your
+document, use the \doccmddef{nobibliography} command in its place.
+
+To enter multiple citations at one location,\cite[-3\baselineskip]{Tufte2006,Tufte1990} you can
+provide a list of keys separated by commas and the same optional vertical
+offset argument: \Verb|\cite{Tufte2006,Tufte1990}|.
+\begin{docspec}
+ \doccmd{cite}[\docopt{offset}]\{\docarg{bibkey1,bibkey2,\ldots}\}
+\end{docspec}
+
+\section{Figures and Tables}\label{sec:figures-and-tables}
+Images and graphics play an integral role in Tufte's work.
+In addition to the standard \docenvdef{figure} and \docenvdef{tabular} environments,
+this style provides special figure and table environments for full-width
+floats.
+
+Full page--width figures and tables may be placed in \docenvdef{figure*} or
+\docenvdef{table*} environments. To place figures or tables in the margin,
+use the \docenvdef{marginfigure} or \docenvdef{margintable} environments as follows
+(see figure~\ref{fig:marginfig}):
+
+\begin{marginfigure}%
+ \includegraphics[width=\linewidth]{helix}
+ \caption{This is a margin figure. The helix is defined by
+ $x = \cos(2\pi z)$, $y = \sin(2\pi z)$, and $z = [0, 2.7]$. The figure was
+ drawn using Asymptote (\url{http://asymptote.sf.net/}).}
+ \label{fig:marginfig}
+\end{marginfigure}
+
+\begin{docspec}
+\textbackslash begin\{marginfigure\}\\
+ \qquad\textbackslash includegraphics\{helix\}\\
+ \qquad\textbackslash caption\{This is a margin figure.\}\\
+ \qquad\textbackslash label\{fig:marginfig\}\\
+\textbackslash end\{marginfigure\}\\
+\end{docspec}
+
+The \docenv{marginfigure} and \docenv{margintable} environments accept an optional parameter \docopt{offset} that adjusts the vertical position of the figure or table. See the ``\nameref{sec:sidenotes}'' section above for examples. The specifications are:
+\begin{docspec}
+ \textbackslash{begin\{marginfigure\}[\docopt{offset}]}\\
+ \qquad\ldots\\
+ \textbackslash{end\{marginfigure\}}\\
+ \mbox{}\\
+ \textbackslash{begin\{margintable\}[\docopt{offset}]}\\
+ \qquad\ldots\\
+ \textbackslash{end\{margintable\}}\\
+\end{docspec}
+
+Figure~\ref{fig:fullfig} is an example of the \docenv{figure*}
+environment and figure~\ref{fig:textfig} is an example of the normal
+\docenv{figure} environment.
+
+\begin{figure*}[h]
+ \includegraphics[width=\linewidth]{sine.pdf}%
+ \caption{This graph shows $y = \sin x$ from about $x = [-10, 10]$.
+ \emph{Notice that this figure takes up the full page width.}}%
+ \label{fig:fullfig}%
+\end{figure*}
+
+\begin{figure}
+ \includegraphics{hilbertcurves.pdf}
+% \checkparity This is an \pageparity\ page.%
+ \caption[Hilbert curves of various degrees $n$.][6pt]{Hilbert curves of various degrees $n$. \emph{Notice that this figure only takes up the main textblock width.}}
+ \label{fig:textfig}
+ %\zsavepos{pos:textfig}
+\end{figure}
+
+As with sidenotes and marginnotes, a caption may sometimes require vertical
+adjustment. The \doccmddef{caption} command now takes a second optional
+argument that enables you to do this by providing a dimension \docopt{offset}.
+You may specify the caption in any one of the following forms:
+\begin{docspec}
+ \doccmd{caption}\{\docarg{long caption}\}\\
+ \doccmd{caption}[\docarg{short caption}]\{\docarg{long caption}\}\\
+ \doccmd{caption}[][\docopt{offset}]\{\docarg{long caption}\}\\
+ \doccmd{caption}[\docarg{short caption}][\docopt{offset}]%
+ \{\docarg{long caption}\}
+\end{docspec}
+A positive \docopt{offset} will push the caption down the page. The short
+caption, if provided, is what appears in the list of figures/tables, otherwise
+the ``long'' caption appears there. Note that although the arguments
+\docopt{short caption} and \docopt{offset} are both optional, they must be
+provided in order. Thus, to specify an \docopt{offset} without specifying a
+\docopt{short caption}, you must include the first set of empty brackets
+\Verb|[]|, which tell \doccmd{caption} to use the default ``long'' caption. As
+an example, the caption to figure~\ref{fig:textfig} above was given in the form
+\begin{docspec}
+ \doccmd{caption}[Hilbert curves...][6pt]\{Hilbert curves...\}
+\end{docspec}
+
+Table~\ref{tab:normaltab} shows table created with the \docpkg{booktabs}
+package. Notice the lack of vertical rules---they serve only to clutter
+the table's data.
+
+\begin{table}[ht]
+ \centering
+ \fontfamily{ppl}\selectfont
+ \begin{tabular}{ll}
+ \toprule
+ Margin & Length \\
+ \midrule
+ Paper width & \unit[8\nicefrac{1}{2}]{inches} \\
+ Paper height & \unit[11]{inches} \\
+ Textblock width & \unit[6\nicefrac{1}{2}]{inches} \\
+ Textblock/sidenote gutter & \unit[\nicefrac{3}{8}]{inches} \\
+ Sidenote width & \unit[2]{inches} \\
+ \bottomrule
+ \end{tabular}
+ \caption{Here are the dimensions of the various margins used in the Tufte-handout class.}
+ \label{tab:normaltab}
+ %\zsavepos{pos:normaltab}
+\end{table}
+
+\newthought{Occasionally} \LaTeX{} will generate an error message:\label{err:too-many-floats}
+\begin{docspec}
+ Error: Too many unprocessed floats
+\end{docspec}
+\LaTeX{} tries to place floats in the best position on the page. Until it's
+finished composing the page, however, it won't know where those positions are.
+If you have a lot of floats on a page (including sidenotes, margin notes,
+figures, tables, etc.), \LaTeX{} may run out of ``slots'' to keep track of them
+and will generate the above error.
+
+\LaTeX{} initially allocates 18 slots for storing floats. To work around this
+limitation, the \TL document classes provide a \doccmddef{morefloats} command
+that will reserve more slots.
+
+The first time \doccmd{morefloats} is called, it allocates an additional 34
+slots. The second time \doccmd{morefloats} is called, it allocates another 26
+slots.
+
+The \doccmd{morefloats} command may only be used two times. Calling it a
+third time will generate an error message. (This is because we can't safely
+allocate many more floats or \LaTeX{} will run out of memory.)
+
+If, after using the \doccmd{morefloats} command twice, you continue to get the
+\texttt{Too many unprocessed floats} error, there are a couple things you can
+do.
+
+The \doccmddef{FloatBarrier} command will immediately process all the floats
+before typesetting more material. Since \doccmd{FloatBarrier} will start a new
+paragraph, you should place this command at the beginning or end of a
+paragraph.
+
+The \doccmddef{clearpage} command will also process the floats before
+continuing, but instead of starting a new paragraph, it will start a new page.
+
+You can also try moving your floats around a bit: move a figure or table to the
+next page or reduce the number of sidenotes. (Each sidenote actually uses
+\emph{two} slots.)
+
+After the floats have placed, \LaTeX{} will mark those slots as unused so they
+are available for the next page to be composed.
+
+\section{Captions}
+You may notice that the captions are sometimes misaligned.
+Due to the way \LaTeX's float mechanism works, we can't know for sure where it
+decided to put a float. Therefore, the \TL document classes provide commands to
+override the caption position.
+
+\paragraph{Vertical alignment} To override the vertical alignment, use the
+\doccmd{setfloatalignment} command inside the float environment. For
+example:
+
+\begin{fullwidth}
+\begin{docspec}
+ \textbackslash begin\{figure\}[btp]\\
+ \qquad \textbackslash includegraphics\{sinewave\}\\
+ \qquad \textbackslash caption\{This is an example of a sine wave.\}\\
+ \qquad \textbackslash label\{fig:sinewave\}\\
+ \qquad \hlred{\textbackslash setfloatalignment\{b\}\% forces caption to be bottom-aligned}\\
+ \textbackslash end\{figure\}
+\end{docspec}
+\end{fullwidth}
+
+\noindent The syntax of the \doccmddef{setfloatalignment} command is:
+
+\begin{docspec}
+ \doccmd{setfloatalignment}\{\docopt{pos}\}
+\end{docspec}
+
+\noindent where \docopt{pos} can be either \texttt{b} for bottom-aligned
+captions, or \texttt{t} for top-aligned captions.
+
+\paragraph{Horizontal alignment}\label{par:overriding-horizontal}
+To override the horizontal alignment, use either the \doccmd{forceversofloat}
+or the \doccmd{forcerectofloat} command inside of the float environment. For
+example:
+
+\begin{fullwidth}
+\begin{docspec}
+ \textbackslash begin\{figure\}[btp]\\
+ \qquad \textbackslash includegraphics\{sinewave\}\\
+ \qquad \textbackslash caption\{This is an example of a sine wave.\}\\
+ \qquad \textbackslash label\{fig:sinewave\}\\
+ \qquad \hlred{\textbackslash forceversofloat\% forces caption to be set to the left of the float}\\
+ \textbackslash end\{figure\}
+\end{docspec}
+\end{fullwidth}
+
+The \doccmddef{forceversofloat} command causes the algorithm to assume the
+float has been placed on a verso page---that is, a page on the left side of a
+two-page spread. Conversely, the \doccmddef{forcerectofloat} command causes
+the algorithm to assume the float has been placed on a recto page---that is, a
+page on the right side of a two-page spread.
+
+
+\section{Full-width text blocks}
+
+In addition to the new float types, there is a \docenvdef{fullwidth}
+environment that stretches across the main text block and the sidenotes
+area.
+
+\begin{Verbatim}
+\begin{fullwidth}
+Lorem ipsum dolor sit amet...
+\end{fullwidth}
+\end{Verbatim}
+
+\begin{fullwidth}
+\small\itshape\lipsum[1]
+\end{fullwidth}
+
+\section{Typography}\label{sec:typography}
+
+\subsection{Typefaces}\label{sec:typefaces}\index{typefaces}
+If the Palatino, \textsf{Helvetica}, and \texttt{Bera Mono} typefaces are installed, this style
+will use them automatically. Otherwise, we'll fall back on the Computer Modern
+typefaces.
+
+\subsection{Letterspacing}\label{sec:letterspacing}
+This document class includes two new commands and some improvements on
+existing commands for letterspacing.
+
+When setting strings of \allcaps{ALL CAPS} or \smallcaps{small caps}, the
+letter\-spacing---that is, the spacing between the letters---should be
+increased slightly.\cite{Bringhurst2005} The \doccmddef{allcaps} command has proper letterspacing for
+strings of \allcaps{FULL CAPITAL LETTERS}, and the \doccmddef{smallcaps} command
+has letterspacing for \smallcaps{small capital letters}. These commands
+will also automatically convert the case of the text to upper- or
+lowercase, respectively.
+
+The \doccmddef{textsc} command has also been redefined to include
+letterspacing. The case of the \doccmd{textsc} argument is left as is,
+however. This allows one to use both uppercase and lowercase letters:
+\textsc{The Initial Letters Of The Words In This Sentence Are Capitalized.}
+
+
+
+\section{Document Class Options}\label{sec:options}
+
+\index{class options|(}
+The \doccls{tufte-book} class is based on the \LaTeX\ \doccls{book}
+document class. Therefore, you can pass any of the typical book
+options. There are a few options that are specific to the
+\doccls{tufte-book} document class, however.
+
+The \docclsoptdef{a4paper} option will set the paper size to \smallcaps{A4} instead of
+the default \smallcaps{US} letter size.
+
+The \docclsoptdef{sfsidenotes} option will set the sidenotes and title block in a
+\textsf{sans serif} typeface instead of the default roman.
+
+The \docclsoptdef{twoside} option will modify the running heads so that the page
+number is printed on the outside edge (as opposed to always printing the page
+number on the right-side edge in \docclsoptdef{oneside} mode).
+
+The \docclsoptdef{symmetric} option typesets the sidenotes on the outside edge of
+the page. This is how books are traditionally printed, but is contrary to
+Tufte's book design which sets the sidenotes on the right side of the page.
+This option implicitly sets the \docclsopt{twoside} option.
+
+The \docclsoptdef{justified} option sets all the text fully justified (flush left
+and right). The default is to set the text ragged right.
+The body text of Tufte's books are set ragged right. This prevents
+needless hyphenation and makes it easier to read the text in the slightly
+narrower column.
+
+The \docclsoptdef{bidi} option loads the \docpkg{bidi} package which is used with
+\tXeLaTeX\ to typeset bi-directional text. Since the \docpkg{bidi}
+package needs to be loaded before the sidenotes and cite commands are defined,
+it can't be loaded in the document preamble.
+
+The \docclsoptdef{debug} option causes the \TL classes to output debug
+information to the log file which is useful in troubleshooting bugs. It will
+also cause the graphics to be replaced by outlines.
+
+The \docclsoptdef{nofonts} option prevents the \TL classes from
+automatically loading the Palatino and Helvetica typefaces. You should use
+this option if you wish to load your own fonts. If you're using \tXeLaTeX, this
+option is implied (\ie, the Palatino and Helvetica fonts aren't loaded if you
+use \tXeLaTeX).
+
+The \docclsoptdef{nols} option inhibits the letterspacing code. The \TL\
+classes try to load the appropriate letterspacing package (either pdf\TeX's
+\docpkg{letterspace} package or the \docpkg{soul} package). If you're using
+\tXeLaTeX\ with \docpkg{fontenc}, however, you should configure your own
+letterspacing.
+
+The \docclsoptdef{notitlepage} option causes \doccmd{maketitle} to generate a title
+block instead of a title page. The \doccls{book} class defaults to a title
+page and the \doccls{handout} class defaults to the title block. There is an
+analogous \docclsoptdef{titlepage} option that forces \doccmd{maketitle} to
+generate a full title page instead of the title block.
+
+The \docclsoptdef{notoc} option suppresses \TL's custom table of contents
+(\textsc{toc}) design. The current \textsc{toc} design only shows unnumbered
+chapter titles; it doesn't show sections or subsections. The \docclsopt{notoc}
+option will revert to \LaTeX's \textsc{toc} design.
+
+The \docclsoptdef{nohyper} option prevents the \docpkg{hyperref} package from
+being loaded. The default is to load the \docpkg{hyperref} package and use the
+\doccmd{title} and \doccmd{author} contents as metadata for the generated
+\textsc{pdf}.
+
+\index{class options|)}
+
+
+
+\chapter[Customizing Tufte-LaTeX]{Customizing \TL}
+\label{ch:customizing}
+
+The \TL document classes are designed to closely emulate Tufte's book
+design by default. However, each document is different and you may encounter
+situations where the default settings are insufficient. This chapter explores
+many of the ways you can adjust the \TL document classes to better fit
+your needs.
+
+\section{File Hooks}
+\label{sec:filehooks}
+
+\index{file hooks|(}
+If you create many documents using the \TL classes, it's easier to
+store your customizations in a separate file instead of copying them into the
+preamble of each document. The \TL classes provide three file hooks:
+\docfilehook{tufte-common-local.tex}{common}, \docfilehook{tufte-book-local.tex}{book}, and
+\docfilehook{tufte-handout-local.tex}{handout}.\sloppy
+
+\begin{description}
+ \item[\docfilehook{tufte-common-local.tex}{common}]
+ If this file exists, it will be loaded by all of the \TL document
+ classes just prior to any document-class-specific code. If your
+ customizations or code should be included in both the book and handout
+ classes, use this file hook.
+ \item[\docfilehook{tufte-book-local.tex}{book}]
+ If this file exists, it will be loaded after all of the common and
+ book-specific code has been read. If your customizations apply only to the
+ book class, use this file hook.
+ \item[\docfilehook{tufte-common-handout.tex}{handout}]
+ If this file exists, it will be loaded after all of the common and
+ handout-specific code has been read. If your customizations apply only to
+ the handout class, use this file hook.
+\end{description}
+
+\index{file hooks|)}
+
+\section{Numbered Section Headings}
+\label{sec:numbered-sections}
+\index{headings!numbered}
+
+While Tufte dispenses with numbered headings in his books, if you require them,
+they can be anabled by changing the value of the \doccounter{secnumdepth}
+counter. From the table below, select the heading level at which numbering
+should stop and set the \doccounter{secnumdepth} counter to that value. For
+example, if you want parts and chapters numbered, but don't want numbering for
+sections or subsections, use the command:
+\begin{docspec}
+ \doccmd{setcounter}\{secnumdepth\}\{0\}
+\end{docspec}
+
+The default \doccounter{secnumdepth} for the \TL document classes is $-1$.
+
+\begin{table}
+ \footnotesize
+ \begin{center}
+ \begin{tabular}{lr}
+ \toprule
+ Heading level & Value \\
+ \midrule
+ Part (in \doccls{tufte-book}) & $-1$ \\
+ Part (in \doccls{tufte-handout}) & $0$ \\
+ Chapter (only in \doccls{tufte-book}) & $0$ \\
+ Section & $1$ \\
+ Subsection & $2$ \\
+ Subsubsection & $3$ \\
+ Paragraph & $4$ \\
+ Subparagraph & $5$ \\
+ \bottomrule
+ \end{tabular}
+ \end{center}
+ \caption{Heading levels used with the \texttt{secnumdepth} counter.}
+\end{table}
+
+\section{Changing the Paper Size}
+\label{sec:paper-size}
+
+The \TL classes currently only provide three paper sizes: \textsc{a4},
+\textsc{b5}, and \textsc{us} letter. To specify a different paper size (and/or
+margins), use the \doccmd[geometry]{geometry} command in the preamble of your
+document (or one of the file hooks). The full documentation of the
+\doccmd{geometry} command may be found in the \docpkg{geometry} package
+documentation.\cite{pkg-geometry}
+
+
+\section{Customizing Marginal Material}
+\label{sec:marginal-material}
+
+Marginal material includes sidenotes, citations, margin notes, and captions.
+Normally, the justification of the marginal material follows the justification
+of the body text. If you specify the \docclsopt{justified} document class
+option, all of the margin material will be fully justified as well. If you
+don't specify the \docclsopt{justified} option, then the marginal material will
+be set ragged right.
+
+You can set the justification of the marginal material separately from the body
+text using the following document class options: \docclsopt{sidenote},
+\docclsopt{marginnote}, \docclsopt{caption}, \docclsopt{citation}, and
+\docclsopt{marginals}. Each option refers to its obviously corresponding
+marginal material type. The \docclsopt{marginals} option simultaneously sets
+the justification on all four marginal material types.
+
+Each of the document class options takes one of five justification types:
+\begin{description}
+ \item[\docclsopt{justified}] Fully justifies the text (sets it flush left and
+ right).
+ \item[\docclsopt{raggedleft}] Sets the text ragged left, regardless of which
+ page it falls on.
+ \item[\docclsopt{raggedright}] Sets the text ragged right, regardless of
+ which page it falls on.
+ \item[\doccls{raggedouter}] Sets the text ragged left if it falls on the
+ left-hand (verso) page of the spread and otherwise sets it ragged right.
+ This is useful in conjunction with the \docclsopt{symmetric} document class
+ option.
+ \item[\docclsopt{auto}] If the \docclsopt{justified} document class option
+ was specified, then set the text fully justified; otherwise the text is set
+ ragged right. This is the default justification option if one is not
+ explicitly specified.
+\end{description}
+
+\noindent For example,
+\begin{docspec}
+ \doccmdnoindex{documentclass}[symmetric,justified,marginals=raggedouter]\{tufte-book\}
+\end{docspec}
+will set the body text of the document to be fully justified and all of the
+margin material (sidenotes, margin notes, captions, and citations) to be flush
+against the body text with ragged outer edges.
+
+\newthought{The font and style} of the marginal material may also be modified using the following commands:
+
+\begin{docspec}
+ \doccmd{setsidenotefont}\{\docopt{font commands}\}\\
+ \doccmd{setcaptionfont}\{\docopt{font commands}\}\\
+ \doccmd{setmarginnotefont}\{\docopt{font commands}\}\\
+ \doccmd{setcitationfont}\{\docopt{font commands}\}
+\end{docspec}
+
+The \doccmddef{setsidenotefont} sets the font and style for sidenotes, the
+\doccmddef{setcaptionfont} for captions, the \doccmddef{setmarginnotefont} for
+margin notes, and the \doccmddef{setcitationfont} for citations. The
+\docopt{font commands} can contain font size changes (e.g.,
+\doccmdnoindex{footnotesize}, \doccmdnoindex{Huge}, etc.), font style changes (e.g.,
+\doccmdnoindex{sffamily}, \doccmdnoindex{ttfamily}, \doccmdnoindex{itshape}, etc.), color changes (e.g.,
+\doccmdnoindex{color}\texttt{\{blue\}}), and many other adjustments.
+
+If, for example, you wanted the captions to be set in italic sans serif, you could use:
+\begin{docspec}
+ \doccmd{setcaptionfont}\{\doccmdnoindex{itshape}\doccmdnoindex{sffamily}\}
+\end{docspec}
+
+\chapter{Compatibility Issues}
+\label{ch:compatibility}
+
+When switching an existing document from one document class to a \TL document class, a few changes to the document may have to be made.
+
+\section{Converting from \doccls{article} to \doccls{tufte-handout}}
+
+The following \doccls{article} class options are unsupported: \docclsopt{10pt}, \docclsopt{11pt}, \docclsopt{12pt}, \docclsopt{a5paper}, \docclsopt{b5paper}, \docclsopt{executivepaper}, \docclsopt{legalpaper}, \docclsopt{landscape}, \docclsopt{onecolumn}, and \doccls{twocolumn}.
+
+The following headings are not supported: \doccmd{subsubsection} and \doccmd{subparagraph}.
+
+\section{Converting from \doccls{book} to \doccls{tufte-book}}
+
+The following \doccls{report} class options are unsupported: \docclsopt{10pt}, \docclsopt{11pt}, \docclsopt{12pt}, \docclsopt{a5paper}, \docclsopt{b5paper}, \docclsopt{executivepaper}, \docclsopt{legalpaper}, \docclsopt{landscape}, \docclsopt{onecolumn}, and \doccls{twocolumn}.
+
+The following headings are not supported: \doccmd{subsubsection} and \doccmd{subparagraph}.
+
+
+
+\chapter{Troubleshooting and Support}
+\label{ch:troubleshooting}
+
+\section{\TL Website}\label{sec:website}
+The website for the \TL packages is located at
+\url{http://code.google.com/p/tufte-latex/}. On our website, you'll find
+links to our \smallcaps{svn} repository, mailing lists, bug tracker, and documentation.
+
+\section{\TL Mailing Lists}\label{sec:mailing-lists}
+There are two mailing lists for the \TL project:
+
+\paragraph{Discussion list}
+The \texttt{tufte-latex} discussion list is for asking questions, getting
+assistance with problems, and help with troubleshooting. Release announcements
+are also posted to this list. You can subscribe to the \texttt{tufte-latex}
+discussion list at \url{http://groups.google.com/group/tufte-latex}.
+
+\paragraph{Commits list}
+The \texttt{tufte-latex-commits} list is a read-only mailing list. A message
+is sent to the list any time the \TL code has been updated. If you'd like to
+keep up with the latest code developments, you may subscribe to this list. You
+can subscribe to the \texttt{tufte-latex-commits} mailing list at
+\url{http://groups.google.com/group/tufte-latex-commits}.
+
+\section{Getting Help}\label{sec:getting-help}
+If you've encountered a problem with one of the \TL document classes, have a
+question, or would like to report a bug, please send an email to our
+mailing list or visit our website.
+
+To help us troubleshoot the problem more quickly, please try to compile your
+document using the \docclsopt{debug} class option and send the generated
+\texttt{.log} file to the mailing list with a brief description of the problem.
+
+
+
+\section{Errors, Warnings, and Informational Messages}\label{sec:tl-messages}
+The following is a list of all of the errors, warnings, and other messages generated by the \TL classes and a brief description of their meanings.
+\index{error messages}\index{warning messages}\index{debug messages}
+
+% Errors
+\docmsg{Error: \doccmd{subparagraph} is undefined by this class.}{%
+The \doccmd{subparagraph} command is not defined in the \TL document classes.
+If you'd like to use the \doccmd{subparagraph} command, you'll need to redefine
+it yourself. See the ``Headings'' section on page~\pageref{sec:headings} for a
+description of the heading styles available in the \TL document classes.}
+
+\docmsg{Error: \doccmd{subsubsection} is undefined by this class.}{%
+The \doccmd{subsubsection} command is not defined in the \TL document classes.
+If you'd like to use the \doccmd{subsubsection} command, you'll need to
+redefine it yourself. See the ``Headings'' section on
+page~\pageref{sec:headings} for a description of the heading styles available
+in the \TL document classes.}
+
+\docmsg{Error: You may only call \doccmd{morefloats} twice. See the\par\noindent\ \ \ \ \ \ \ \ Tufte-LaTeX documentation for other workarounds.}{%
+\LaTeX{} allocates 18 slots for storing floats. The first time
+\doccmd{morefloats} is called, it allocates an additional 34 slots. The second
+time \doccmd{morefloats} is called, it allocates another 26 slots.
+
+The \doccmd{morefloats} command may only be called two times. Calling it a
+third time will generate this error message. See
+page~\pageref{err:too-many-floats} for more information.}
+
+% Warnings
+\docmsg{Warning: Option `\docopt{class option}' is not supported -{}- ignoring option.}{%
+This warning appears when you've tried to use \docopt{class option} with a \TL
+document class, but \docopt{class option} isn't supported by the \TL document
+class. In this situation, \docopt{class option} is ignored.}
+
+% Info / Debug messages
+\docmsg{Info: The `\docclsopt{symmetric}' option implies `\docclsopt{twoside}'}{%
+You specified the \docclsopt{symmetric} document class option. This option automatically forces the \docclsopt{twoside} option as well. See page~\pageref{clsopt:symmetric} for more information on the \docclsopt{symmetric} class option.}
+
+
+\section{Package Dependencies}\label{sec:dependencies}
+The following is a list of packages that the \TL document
+classes rely upon. Packages marked with an asterisk are optional.
+\begin{multicols}{2}
+\begin{itemize}
+ \item xifthen
+ \item ifpdf*
+ \item ifxetex*
+ \item hyperref
+ \item geometry
+ \item ragged2e
+ \item chngpage \emph{or} changepage
+ \item paralist
+ \item textcase
+ \item soul*
+ \item letterspace*
+ \item setspace
+ \item natbib \emph{and} bibentry
+ \item optparams
+ \item placeins
+ \item mathpazo*
+ \item helvet*
+ \item fontenc
+ \item beramono*
+ \item fancyhdr
+ \item xcolor
+ \item textcomp
+ \item titlesec
+ \item titletoc
+\end{itemize}
+\end{multicols}
+
+
+
+
+%%
+% The back matter contains appendices, bibliographies, indices, glossaries, etc.
+
+
+
+
+
+
+
+\backmatter
+
+\bibliography{sample-handout}
+\bibliographystyle{plainnat}
+
+
+\printindex
+
+\end{document}
+
diff --git a/macros/latex/contrib/tufte-latex/sample-handout.bib b/macros/latex/contrib/tufte-latex/sample-handout.bib
new file mode 100644
index 0000000000..a46a71f763
--- /dev/null
+++ b/macros/latex/contrib/tufte-latex/sample-handout.bib
@@ -0,0 +1,65 @@
+@BOOK{Tufte2006,
+ author = {Edward R. Tufte},
+ title = {Beautiful Evidence},
+ year = {2006},
+ publisher = {Graphics Press, {LLC}},
+ month = {May},
+ edition = {First},
+ place = {Cheshire, Connecticut},
+ isbn = {0-9613921-7-7}
+}
+
+@BOOK{Tufte2001,
+ author = {Edward R. Tufte},
+ title = {The Visual Display of Quantitative Information},
+ publisher = {Graphics Press},
+ year = {2001},
+ address = {Cheshire, Connecticut},
+ isbn = {0-9613921-4-2}
+}
+
+@BOOK{Tufte1990,
+ author = {Edward R. Tufte},
+ title = {Envisioning Information},
+ publisher = {Graphics Press},
+ year = {1990},
+ address = {Cheshire, Connecticut},
+ isbn = {0-9613921-1-8}
+}
+
+@BOOK{Tufte1997,
+ author = {Edward R. Tufte},
+ title = {Visual Explanations},
+ publisher = {Graphics Press},
+ year = {1997},
+ address = {Cheshire, Connecticut},
+ isbn = {0-9613921-2-6}
+}
+
+@BOOK{Bringhurst2005,
+ author = {Robert Bringhurst},
+ title = {The Elements of Typography},
+ publisher = {Hartley \& Marks},
+ year = {2005},
+ edition = {3.1},
+ isbn = {0-88179-205-5}
+}
+
+@BOOK{Mittelbach2004,
+ author = {Frank Mittelbach and Michel Goossens},
+ title = {The \LaTeX\ Companion},
+ publisher = {Addison--Wesley},
+ year = {2004},
+ edition = {Second},
+ isbn = {0-201-36299-6}
+}
+
+@MISC{pkg-geometry,
+ author = {Hideo Umeki},
+ title = {The \texttt{geometry} package},
+ year = {2008},
+ month = dec,
+ howpublished = {\url{http://ctan.org/pkg/geometry}}
+}
+
+
diff --git a/macros/latex/contrib/tufte-latex/sample-handout.pdf b/macros/latex/contrib/tufte-latex/sample-handout.pdf
new file mode 100644
index 0000000000..f212b25a0a
--- /dev/null
+++ b/macros/latex/contrib/tufte-latex/sample-handout.pdf
Binary files differ
diff --git a/macros/latex/contrib/tufte-latex/sample-handout.tex b/macros/latex/contrib/tufte-latex/sample-handout.tex
new file mode 100644
index 0000000000..33528c74d2
--- /dev/null
+++ b/macros/latex/contrib/tufte-latex/sample-handout.tex
@@ -0,0 +1,291 @@
+\documentclass{tufte-handout}
+
+\title{An Example of the Usage of the Tufte-Handout Style\thanks{Inspired by Edward~R. Tufte!}}
+
+\author[The Tufte-LaTeX Developers]{The Tufte-\LaTeX\ Developers}
+
+%\date{28 March 2010} % without \date command, current date is supplied
+
+%\geometry{showframe} % display margins for debugging page layout
+
+\usepackage{graphicx} % allow embedded images
+ \setkeys{Gin}{width=\linewidth,totalheight=\textheight,keepaspectratio}
+ \graphicspath{{graphics/}} % set of paths to search for images
+\usepackage{amsmath} % extended mathematics
+\usepackage{booktabs} % book-quality tables
+\usepackage{units} % non-stacked fractions and better unit spacing
+\usepackage{multicol} % multiple column layout facilities
+\usepackage{lipsum} % filler text
+\usepackage{fancyvrb} % extended verbatim environments
+ \fvset{fontsize=\normalsize}% default font size for fancy-verbatim environments
+
+% Standardize command font styles and environments
+\newcommand{\doccmd}[1]{\texttt{\textbackslash#1}}% command name -- adds backslash automatically
+\newcommand{\docopt}[1]{\ensuremath{\langle}\textrm{\textit{#1}}\ensuremath{\rangle}}% optional command argument
+\newcommand{\docarg}[1]{\textrm{\textit{#1}}}% (required) command argument
+\newcommand{\docenv}[1]{\textsf{#1}}% environment name
+\newcommand{\docpkg}[1]{\texttt{#1}}% package name
+\newcommand{\doccls}[1]{\texttt{#1}}% document class name
+\newcommand{\docclsopt}[1]{\texttt{#1}}% document class option name
+\newenvironment{docspec}{\begin{quote}\noindent}{\end{quote}}% command specification environment
+
+\begin{document}
+
+\maketitle% this prints the handout title, author, and date
+
+\begin{abstract}
+\noindent
+This document describes the Tufte handout \LaTeX\ document style.
+It also provides examples and comments on the style's use.
+Only a brief overview is presented here;
+for a complete reference, see the sample book.
+\end{abstract}
+
+%\printclassoptions
+
+The Tufte-\LaTeX\ document classes define a style similar to the
+style Edward Tufte uses in his books and handouts. Tufte's style is known
+for its extensive use of sidenotes, tight integration of graphics with
+text, and well-set typography. This document aims to be at once a
+demonstration of the features of the Tufte-\LaTeX\ document classes
+and a style guide to their use.
+
+\section{Page Layout}\label{sec:page-layout}
+\subsection{Headings}\label{sec:headings}
+This style provides \textsc{a}- and \textsc{b}-heads (that is,
+\Verb|\section| and \Verb|\subsection|), demonstrated above.
+
+The Tufte-\LaTeX\ classes will emit an error if you try to use
+\linebreak\Verb|\subsubsection| and smaller headings.
+
+% let's start a new thought -- a new section
+\newthought{In his later books},\cite{Tufte2006} Tufte
+starts each section with a bit of vertical space, a non-indented paragraph,
+and sets the first few words of the sentence in \textsc{small caps}. To
+accomplish this using this style, use the \Verb|\newthought| command:
+\begin{docspec}
+ \doccmd{newthought\{In his later books\}, Tufte starts\ldots}
+\end{docspec}
+
+\subsection{Sidenotes}\label{sec:sidenotes}
+One of the most prominent and distinctive features of this style is the
+extensive use of sidenotes. There is a wide margin to provide ample room
+for sidenotes and small figures. Any \Verb|\footnote|s will automatically
+be converted to sidenotes.\footnote{This is a sidenote that was entered
+using the \texttt{\textbackslash footnote} command.} If you'd like to place ancillary
+information in the margin without the sidenote mark (the superscript
+number), you can use the \Verb|\marginnote| command.\marginnote{This is a
+margin note. Notice that there isn't a number preceding the note, and
+there is no number in the main text where this note was written.}
+
+The specification of the \Verb|\sidenote| command is:
+\begin{docspec}
+ \doccmd{sidenote[\docopt{number}][\docopt{offset}]\{\docarg{Sidenote text.}\}}
+\end{docspec}
+
+Both the \docopt{number} and \docopt{offset} arguments are optional. If you
+provide a \docopt{number} argument, then that number will be used as the
+sidenote number. It will change of the number of the current sidenote only and
+will not affect the numbering sequence of subsequent sidenotes.
+
+Sometimes a sidenote may run over the top of other text or graphics in the
+margin space. If this happens, you can adjust the vertical position of the
+sidenote by providing a dimension in the \docopt{offset} argument. Some
+examples of valid dimensions are:
+\begin{docspec}
+ \ttfamily 1.0in \qquad 2.54cm \qquad 254mm \qquad 6\Verb|\baselineskip|
+\end{docspec}
+If the dimension is positive it will push the sidenote down the page; if the
+dimension is negative, it will move the sidenote up the page.
+
+While both the \docopt{number} and \docopt{offset} arguments are optional, they
+must be provided in order. To adjust the vertical position of the sidenote
+while leaving the sidenote number alone, use the following syntax:
+\begin{docspec}
+ \doccmd{sidenote[][\docopt{offset}]\{\docarg{Sidenote text.}\}}
+\end{docspec}
+The empty brackets tell the \Verb|\sidenote| command to use the default
+sidenote number.
+
+If you \emph{only} want to change the sidenote number, however, you may
+completely omit the \docopt{offset} argument:
+\begin{docspec}
+ \doccmd{sidenote[\docopt{number}]\{\docarg{Sidenote text.}\}}
+\end{docspec}
+
+The \Verb|\marginnote| command has a similar \docarg{offset} argument:
+\begin{docspec}
+ \doccmd{marginnote[\docopt{offset}]\{\docarg{Margin note text.}\}}
+\end{docspec}
+
+\subsection{References}
+References are placed alongside their citations as sidenotes,
+as well. This can be accomplished using the normal \Verb|\cite|
+command.\sidenote{The first paragraph of this document includes a citation.}
+
+The complete list of references may also be printed automatically by using
+the \Verb|\bibliography| command. (See the end of this document for an
+example.) If you do not want to print a bibliography at the end of your
+document, use the \Verb|\nobibliography| command in its place.
+
+To enter multiple citations at one location,\cite{Tufte2006,Tufte1990} you can
+provide a list of keys separated by commas and the same optional vertical
+offset argument: \Verb|\cite{Tufte2006,Tufte1990}|.
+\begin{docspec}
+ \doccmd{cite[\docopt{offset}]\{\docarg{bibkey1,bibkey2,\ldots}\}}
+\end{docspec}
+
+\section{Figures and Tables}\label{sec:figures-and-tables}
+Images and graphics play an integral role in Tufte's work.
+In addition to the standard \docenv{figure} and \docenv{tabular} environments,
+this style provides special figure and table environments for full-width
+floats.
+
+Full page--width figures and tables may be placed in \docenv{figure*} or
+\docenv{table*} environments. To place figures or tables in the margin,
+use the \docenv{marginfigure} or \docenv{margintable} environments as follows
+(see figure~\ref{fig:marginfig}):
+
+\begin{marginfigure}%
+ \includegraphics[width=\linewidth]{helix}
+ \caption{This is a margin figure. The helix is defined by
+ $x = \cos(2\pi z)$, $y = \sin(2\pi z)$, and $z = [0, 2.7]$. The figure was
+ drawn using Asymptote (\url{http://asymptote.sf.net/}).}
+ \label{fig:marginfig}
+\end{marginfigure}
+\begin{Verbatim}
+\begin{marginfigure}
+ \includegraphics{helix}
+ \caption{This is a margin figure.}
+\end{marginfigure}
+\end{Verbatim}
+
+The \docenv{marginfigure} and \docenv{margintable} environments accept an optional parameter \docopt{offset} that adjusts the vertical position of the figure or table. See the ``\nameref{sec:sidenotes}'' section above for examples. The specifications are:
+\begin{docspec}
+ \doccmd{begin\{marginfigure\}[\docopt{offset}]}\\
+ \qquad\ldots\\
+ \doccmd{end\{marginfigure\}}\\
+ \mbox{}\\
+ \doccmd{begin\{margintable\}[\docopt{offset}]}\\
+ \qquad\ldots\\
+ \doccmd{end\{margintable\}}\\
+\end{docspec}
+
+Figure~\ref{fig:fullfig} is an example of the \Verb|figure*|
+environment and figure~\ref{fig:textfig} is an example of the normal
+\Verb|figure| environment.
+
+\begin{figure*}[h]
+ \includegraphics[width=\linewidth]{sine.pdf}%
+ \caption{This graph shows $y = \sin x$ from about $x = [-10, 10]$.
+ \emph{Notice that this figure takes up the full page width.}}%
+ \label{fig:fullfig}%
+\end{figure*}
+
+\begin{figure}
+ \includegraphics{hilbertcurves.pdf}
+% \checkparity This is an \pageparity\ page.%
+ \caption{Hilbert curves of various degrees $n$.
+ \emph{Notice that this figure only takes up the main textblock width.}}
+ \label{fig:textfig}
+ %\zsavepos{pos:textfig}
+ \setfloatalignment{b}
+\end{figure}
+
+Table~\ref{tab:normaltab} shows table created with the \docpkg{booktabs}
+package. Notice the lack of vertical rules---they serve only to clutter
+the table's data.
+
+\begin{table}[ht]
+ \centering
+ \fontfamily{ppl}\selectfont
+ \begin{tabular}{ll}
+ \toprule
+ Margin & Length \\
+ \midrule
+ Paper width & \unit[8\nicefrac{1}{2}]{inches} \\
+ Paper height & \unit[11]{inches} \\
+ Textblock width & \unit[6\nicefrac{1}{2}]{inches} \\
+ Textblock/sidenote gutter & \unit[\nicefrac{3}{8}]{inches} \\
+ Sidenote width & \unit[2]{inches} \\
+ \bottomrule
+ \end{tabular}
+ \caption{Here are the dimensions of the various margins used in the Tufte-handout class.}
+ \label{tab:normaltab}
+ %\zsavepos{pos:normaltab}
+\end{table}
+
+\section{Full-width text blocks}
+
+In addition to the new float types, there is a \docenv{fullwidth}
+environment that stretches across the main text block and the sidenotes
+area.
+
+\begin{Verbatim}
+\begin{fullwidth}
+Lorem ipsum dolor sit amet...
+\end{fullwidth}
+\end{Verbatim}
+
+\begin{fullwidth}
+\small\itshape\lipsum[1]
+\end{fullwidth}
+
+\section{Typography}\label{sec:typography}
+
+\subsection{Typefaces}\label{sec:typefaces}
+If the Palatino, \textsf{Helvetica}, and \texttt{Bera Mono} typefaces are installed, this style
+will use them automatically. Otherwise, we'll fall back on the Computer Modern
+typefaces.
+
+\subsection{Letterspacing}\label{sec:letterspacing}
+This document class includes two new commands and some improvements on
+existing commands for letterspacing.
+
+When setting strings of \allcaps{ALL CAPS} or \smallcaps{small caps}, the
+letter\-spacing---that is, the spacing between the letters---should be
+increased slightly.\cite{Bringhurst2005} The \Verb|\allcaps| command has proper letterspacing for
+strings of \allcaps{FULL CAPITAL LETTERS}, and the \Verb|\smallcaps| command
+has letterspacing for \smallcaps{small capital letters}. These commands
+will also automatically convert the case of the text to upper- or
+lowercase, respectively.
+
+The \Verb|\textsc| command has also been redefined to include
+letterspacing. The case of the \Verb|\textsc| argument is left as is,
+however. This allows one to use both uppercase and lowercase letters:
+\textsc{The Initial Letters Of The Words In This Sentence Are Capitalized.}
+
+
+
+\section{Installation}\label{sec:installation}
+To install the Tufte-\LaTeX\ classes, simply drop the
+following files into the same directory as your \texttt{.tex}
+file:
+\begin{quote}
+ \ttfamily
+ tufte-book.cls\\
+ tufte-common.def\\
+ tufte-handout.cls\\
+ tufte.bst
+\end{quote}
+
+% TODO add instructions for installing it globally
+
+
+
+\section{More Documentation}\label{sec:more-doc}
+For more documentation on the Tufte-\LaTeX{} document classes (including commands not
+mentioned in this handout), please see the sample book.
+
+\section{Support}\label{sec:support}
+
+The website for the Tufte-\LaTeX\ packages is located at
+\url{http://code.google.com/p/tufte-latex/}. On our website, you'll find
+links to our \smallcaps{svn} repository, mailing lists, bug tracker, and documentation.
+
+\bibliography{sample-handout}
+\bibliographystyle{plainnat}
+
+
+
+\end{document}
diff --git a/macros/latex/contrib/tufte-latex/tufte-book.cls b/macros/latex/contrib/tufte-latex/tufte-book.cls
new file mode 100644
index 0000000000..3ef580c732
--- /dev/null
+++ b/macros/latex/contrib/tufte-latex/tufte-book.cls
@@ -0,0 +1,80 @@
+\NeedsTeXFormat{LaTeX2e}[1994/06/01]
+
+\ProvidesClass{tufte-book}[2015/06/21 v3.5.2 Tufte-book class]
+
+%%
+% Declare we're tufte-book
+\newcommand{\@tufte@class}{book}% the base LaTeX class (defaults to the article/handout style)
+\newcommand{\@tufte@pkgname}{tufte-book}% the name of the package (defaults to tufte-handout)
+
+%%
+% Load the common style elements
+\input{tufte-common.def}
+
+
+%%
+% Set up any book-specific stuff now
+
+%%
+% The front matter in Tufte's /Beautiful Evidence/ contains everything up
+% to the opening page of Chapter 1. The running heads, when they appear,
+% contain only the (arabic) page number in the outside corner.
+%\newif\if@mainmatter \@mainmattertrue
+\renewcommand\frontmatter{%
+ \cleardoublepage%
+ \@mainmatterfalse%
+ \pagenumbering{arabic}%
+ %\pagestyle{plain}%
+ \fancyhf{}%
+ \ifthenelse{\boolean{@tufte@twoside}}%
+ {\fancyhead[LE,RO]{\thepage}}%
+ {\fancyhead[RE,RO]{\thepage}}%
+}
+
+
+%%
+% The main matter in Tufte's /Beautiful Evidence/ doesn't restart the page
+% numbering---it continues where it left off in the front matter.
+\renewcommand\mainmatter{%
+ \cleardoublepage%
+ \@mainmattertrue%
+ \fancyhf{}%
+ \ifthenelse{\boolean{@tufte@twoside}}%
+ {% two-side
+ \renewcommand{\chaptermark}[1]{\markboth{##1}{}}%
+ \fancyhead[LE]{\thepage\quad\smallcaps{\newlinetospace{\plaintitle}}}% book title
+ \fancyhead[RO]{\smallcaps{\newlinetospace{\leftmark}}\quad\thepage}% chapter title
+ }%
+ {% one-side
+ \fancyhead[RE,RO]{\smallcaps{\newlinetospace{\plaintitle}}\quad\thepage}% book title
+ }%
+}
+
+
+%%
+% The back matter contains appendices, indices, glossaries, endnotes,
+% biliographies, list of contributors, illustration credits, etc.
+\renewcommand\backmatter{%
+ \if@openright%
+ \cleardoublepage%
+ \else%
+ \clearpage%
+ \fi%
+ \@mainmatterfalse%
+}
+
+%%
+% Only show the chapter titles in the table of contents
+\setcounter{tocdepth}{0}
+
+%%
+% If there is a `tufte-book-local.sty' file, load it.
+
+\IfFileExists{tufte-book-local.tex}{%
+ \@tufte@info@noline{Loading tufte-book-local.tex}%
+ \input{tufte-book-local}%
+}{}
+
+%%
+% End of file
+\endinput
diff --git a/macros/latex/contrib/tufte-latex/tufte-common.def b/macros/latex/contrib/tufte-latex/tufte-common.def
new file mode 100644
index 0000000000..e3f2005087
--- /dev/null
+++ b/macros/latex/contrib/tufte-latex/tufte-common.def
@@ -0,0 +1,2026 @@
+%%
+%% This file contains the code that is common to the Tufte-LaTeX document classes.
+%%
+
+\ProvidesFile{tufte-common.def}[2015/06/21 v3.5.2 Common code for the Tufte-LaTeX styles]
+
+%%
+% The `xkeyval' package simplifies the user interface for the document class options
+\RequirePackage{xkeyval}
+
+%%
+% We use the `xifthen' package to handle our package option switches
+\RequirePackage{xifthen}
+
+%%
+% Define some shortcut macros for error/warning/info logging.
+\RequirePackage{hardwrap}
+\GenerateClassLogMacros[@tufte]{\@tufte@pkgname}
+\newcommand{\@tufte@debug@info}[1]{\ifthenelse{\boolean{@tufte@debug}}{\@tufte@info{#1}}{}}
+\newcommand{\@tufte@debug@info@noline}[1]{\ifthenelse{\boolean{@tufte@debug}}{\@tufte@info@noline{#1}}{}}
+
+%%
+% `debug' option -- provides more information in the .log file for use in
+% troubleshooting problems
+\newboolean{@tufte@debug}
+\DeclareOptionX[tufte]<common>{debug}{\setboolean{@tufte@debug}{true}}
+
+%%
+% `nofonts' option -- doesn't load any fonts
+% `fonts' option -- tries to load fonts
+\newboolean{@tufte@loadfonts}\setboolean{@tufte@loadfonts}{true}
+\DeclareOptionX[tufte]<common>{fonts}{\setboolean{@tufte@loadfonts}{true}}
+\DeclareOptionX[tufte]<common>{nofonts}{\setboolean{@tufte@loadfonts}{false}}
+
+%%
+% `nols' option -- doesn't configure letterspacing
+% `ls' option -- configures letterspacing
+\newboolean{@tufte@letterspace}\setboolean{@tufte@letterspace}{true}
+\DeclareOptionX[tufte]<common>{ls}{\setboolean{@tufte@letterspace}{true}}
+\DeclareOptionX[tufte]<common>{nols}{\setboolean{@tufte@letterspace}{false}}
+
+%%
+% `nobib' option -- doesn't load natbib or adjust the \cite command
+\newboolean{@tufte@loadnatbib}\setboolean{@tufte@loadnatbib}{true}
+\DeclareOptionX[tufte]<common>{nobib}{\setboolean{@tufte@loadnatbib}{false}}
+
+%%
+% `titlepage' option -- creates a full title page with \maketitle
+
+\newboolean{@tufte@titlepage}
+\DeclareOptionX[tufte]<common>{titlepage}{\setboolean{@tufte@titlepage}{true}}
+\DeclareOptionX[tufte]<common>{notitlepage}{\setboolean{@tufte@titlepage}{false}}
+
+%%
+% `a4paper' option
+
+\newboolean{@tufte@afourpaper}
+\DeclareOptionX[tufte]<common>{a4paper}{\setboolean{@tufte@afourpaper}{true}}
+
+%%
+% `b5paper' option
+
+\newboolean{@tufte@bfivepaper}
+\DeclareOptionX[tufte]<common>{b5paper}{\setboolean{@tufte@bfivepaper}{true}}
+
+%%
+% `sfsidenotes' option -- typesets sidenotes in sans serif typeface
+
+\newboolean{@tufte@sfsidenotes}
+\DeclareOptionX[tufte]<common>{sfsidenotes}{\setboolean{@tufte@sfsidenotes}{true}}
+
+%%
+% `symmetric' option -- puts marginpar space to the outside edge of the page
+% Note: this option forces the twoside option (see the .cls files)
+
+\newboolean{@tufte@symmetric}
+\DeclareOptionX[tufte]<common>{symmetric}{
+ \setboolean{@tufte@symmetric}{true}
+ \@tufte@info@noline{The `symmetric' option implies `twoside'}
+ \ExecuteOptionsX[tufte]<common>{twoside}
+}
+
+%%
+% `twoside' option -- alternates running heads
+
+\newboolean{@tufte@twoside}
+\DeclareOptionX[tufte]<common>{twoside}{%
+ \setboolean{@tufte@twoside}{true}
+ \@tufte@info@noline{Passing the `twoside' option to the `\@tufte@class' class}
+ \PassOptionsToClass{twoside}{\@tufte@class}
+}
+
+%%
+% `notoc' option -- suppresses the Tufte-style table of contents
+
+\newboolean{@tufte@toc}
+\setboolean{@tufte@toc}{true}
+\DeclareOptionX[tufte]<common>{notoc}{\setboolean{@tufte@toc}{false}}
+\DeclareOptionX[tufte]<common>{toc}{\setboolean{@tufte@toc}{true}}
+
+%%
+% `justified' option -- uses fully justified text (flush left and flush
+% right) instead of ragged right.
+
+\newboolean{@tufte@justified}
+\DeclareOptionX[tufte]<common>{justified}{\setboolean{@tufte@justified}{true}}
+
+%%
+% `bidi' option -- loads the bidi package for bi-directional text
+
+\newboolean{@tufte@loadbidi}
+\DeclareOptionX[tufte]<common>{bidi}{\setboolean{@tufte@loadbidi}{true}}
+\DeclareOptionX[tufte]<common>{nobidi}{\setboolean{@tufte@loadbidi}{false}}
+
+%%
+% `nohyper' option -- suppresses loading of the hyperref package
+
+\newboolean{@tufte@loadhyper}
+\setboolean{@tufte@loadhyper}{true}
+\DeclareOptionX[tufte]<common>{hyper}{\setboolean{@tufte@loadhyper}{true}}
+\DeclareOptionX[tufte]<common>{nohyper}{\setboolean{@tufte@loadhyper}{false}}
+
+%%
+% `sidenote', `marginnote', `caption', `citation', `marginals' options
+% Each allows one of {justified,raggedleft,raggedright,raggedouter,auto}.
+
+\newcommand*{\@tufte@sidenote@justification}{\@tufte@justification@autodetect}
+\define@choicekey*+[tufte]{common}{sidenote}[\@tufte@kvtext\@tufte@kvnum]{justified,raggedleft,raggedright,raggedouter,auto}[auto]{%
+ \ifcase\@tufte@kvnum\relax
+ \renewcommand*{\@tufte@sidenote@justification}{\justifying}% justified
+ \or
+ \renewcommand*{\@tufte@sidenote@justification}{\RaggedLeft}% ragged left
+ \or
+ \renewcommand*{\@tufte@sidenote@justification}{\RaggedRight}% ragged right
+ \or
+ \renewcommand*{\@tufte@sidenote@justification}{\@tufte@justification@outer}% ragged outer (flush right on verso pages, flush left on recto pages)
+ \or
+ \renewcommand*{\@tufte@sidenote@justification}{\@tufte@justification@autodetect}% autodetects best justification mode based on all class options
+ \fi
+}{%
+ \@tufte@warning@noline{Invalid option `#1' for sidenote key. Must be one of: justified, raggedleft, raggedright, raggedouter, auto}
+ \renewcommand*{\@tufte@sidenote@justification}{\@tufte@justification@autodetect}% autodetects best justification mode based on all class options
+}
+
+\newcommand*{\@tufte@marginnote@justification}{\@tufte@justification@autodetect}
+\define@choicekey*+[tufte]{common}{marginnote}[\@tufte@kvtext\@tufte@kvnum]{justified,raggedleft,raggedright,raggedouter,auto}[auto]{%
+ \ifcase\@tufte@kvnum\relax
+ \renewcommand*{\@tufte@marginnote@justification}{\justifying}% justified
+ \or
+ \renewcommand*{\@tufte@marginnote@justification}{\RaggedLeft}% ragged left
+ \or
+ \renewcommand*{\@tufte@marginnote@justification}{\RaggedRight}% ragged right
+ \or
+ \renewcommand*{\@tufte@marginnote@justification}{\@tufte@justification@outer}% ragged outer (flush right on verso pages, flush left on recto pages)
+ \or
+ \renewcommand*{\@tufte@marginnote@justification}{\@tufte@justification@autodetect}% autodetects best justification mode based on all class options
+ \fi
+}{%
+ \@tufte@warning@noline{Invalid option `#1' for marginnote key. Must be one of: justified, raggedleft, raggedright, raggedouter, auto}
+ \renewcommand*{\@tufte@marginnote@justification}{\@tufte@justification@autodetect}% autodetects best justification mode based on all class options
+}
+
+\newcommand*{\@tufte@caption@justification}{\@tufte@justification@autodetect}
+\define@choicekey*+[tufte]{common}{caption}[\@tufte@kvtext\@tufte@kvnum]{justified,raggedleft,raggedright,raggedouter,auto}[auto]{%
+ \ifcase\@tufte@kvnum\relax
+ \renewcommand*{\@tufte@caption@justification}{\justifying}% justified
+ \or
+ \renewcommand*{\@tufte@caption@justification}{\RaggedLeft}% ragged left
+ \or
+ \renewcommand*{\@tufte@caption@justification}{\RaggedRight}% ragged right
+ \or
+ \renewcommand*{\@tufte@caption@justification}{\@tufte@justification@caption@outer}% ragged outer (flush right on verso pages, flush left on recto pages)
+ \or
+ \renewcommand*{\@tufte@caption@justification}{\@tufte@justification@autodetect}% autodetects best justification mode based on all class options
+ \fi
+}{%
+ \@tufte@warning@noline{Invalid option `#1' for caption key. Must be one of: justified, raggedleft, raggedright, raggedouter, auto}
+ \renewcommand*{\@tufte@caption@justification}{\@tufte@justification@autodetect}% autodetects best justification mode based on all class options
+}
+
+\newcommand*{\@tufte@citation@justification}{\@tufte@justification@autodetect}
+\define@choicekey*+[tufte]{common}{citation}[\@tufte@kvtext\@tufte@kvnum]{justified,raggedleft,raggedright,raggedouter,auto}[auto]{%
+ \ifcase\@tufte@kvnum\relax
+ \renewcommand*{\@tufte@citation@justification}{\justifying}% justified
+ \or
+ \renewcommand*{\@tufte@citation@justification}{\RaggedLeft}% ragged left
+ \or
+ \renewcommand*{\@tufte@citation@justification}{\RaggedRight}% ragged right
+ \or
+ \renewcommand*{\@tufte@citation@justification}{\@tufte@justification@outer}% ragged outer (flush right on verso pages, flush left on recto pages)
+ \or
+ \renewcommand*{\@tufte@citation@justification}{\@tufte@justification@autodetect}% autodetects best justification mode based on all class options
+ \fi
+}{%
+ \@tufte@warning@noline{Invalid option `#1' for citation key. Must be one of: justified, raggedleft, raggedright, raggedouter, auto}
+ \renewcommand*{\@tufte@citation@justification}{\@tufte@justification@autodetect}% autodetects best justification mode based on all class options
+}
+
+% The ``marginals'' key simultaneously sets the same justification for all marginal material
+\define@choicekey*+[tufte]{common}{marginals}[\@tufte@kvtext\@tufte@kvnum]{justified,raggedleft,raggedright,raggedouter,auto}[auto]{%
+ \ifcase\@tufte@kvnum\relax
+ \ExecuteOptionsX[tufte]<common>{citation=justified,sidenote=justified,caption=justified,marginnote=justified}% justified
+ \or
+ \ExecuteOptionsX[tufte]<common>{citation=raggedleft,sidenote=raggedleft,caption=raggedleft,marginnote=raggedleft}% ragged left
+ \or
+ \ExecuteOptionsX[tufte]<common>{citation=raggedright,sidenote=raggedright,caption=raggedright,marginnote=raggedright}% ragged right
+ \or
+ \ExecuteOptionsX[tufte]<common>{citation=raggedouter,sidenote=raggedouter,caption=raggedouter,marginnote=raggedouter}% ragged outer (flush right on verso pages, flush left on recto pages)
+ \or
+ \ExecuteOptionsX[tufte]<common>{citation=auto,sidenote=auto,caption=auto,marginnote=auto}% autodetects best justification mode based on all class options
+ \fi
+}{%
+ \@tufte@warning@noline{Invalid option `#1' for marginals key. Must be one of: justified, raggedleft, raggedright, raggedouter, auto}
+ \ExecuteOptionsX[tufte]<common>{citation=auto,sidenote=auto,caption=auto,marginnote=auto}% autodetects best justification mode based on all class options
+}
+
+
+%%
+% Unsupported options
+
+\newcommand{\@tufte@unsupported@option}[1]{\@tufte@warning@noline{Option `#1' is not supported -- ignoring option}\OptionNotUsed}
+
+\DeclareOptionX[tufte]<common>{10pt}{\@tufte@unsupported@option{\CurrentOption}}
+\DeclareOptionX[tufte]<common>{11pt}{\@tufte@unsupported@option{\CurrentOption}}
+\DeclareOptionX[tufte]<common>{12pt}{\@tufte@unsupported@option{\CurrentOption}}
+\DeclareOptionX[tufte]<common>{a5paper}{\@tufte@unsupported@option{\CurrentOption}}
+\DeclareOptionX[tufte]<common>{executivepaper}{\@tufte@unsupported@option{\CurrentOption}}
+\DeclareOptionX[tufte]<common>{legalpaper}{\@tufte@unsupported@option{\CurrentOption}}
+\DeclareOptionX[tufte]<common>{landscape}{\@tufte@unsupported@option{\CurrentOption}}
+\DeclareOptionX[tufte]<common>{onecolumn}{\@tufte@unsupported@option{\CurrentOption}}
+\DeclareOptionX[tufte]<common>{twocolumn}{\@tufte@unsupported@option{\CurrentOption}}
+
+%%
+% Default `book' and `handout' options
+
+\ifthenelse{\equal{\@tufte@pkgname}{tufte-book}}
+ {\ExecuteOptionsX[tufte]<common>{titlepage}}
+ {\ExecuteOptionsX[tufte]<common>{notitlepage}}
+
+
+\DeclareOptionX*{%
+ \@tufte@info@noline{Passing \CurrentOption\space to the `\@tufte@class' class.}%
+ \PassOptionsToClass{\CurrentOption}{\@tufte@class}%
+}
+\ProcessOptionsX*[tufte]<common>\relax
+
+%%
+% Load the appropriate base class
+\@tufte@info@noline{Loading the base class `\@tufte@class'}
+\LoadClass{\@tufte@class}
+
+%%
+% Detect whether we're in two-side mode or not. (Used to set up running
+% heads later.)
+
+\ifthenelse{\boolean{@twoside}}
+ {\setboolean{@tufte@twoside}{true}}
+ {}
+
+
+
+%%
+% Detect if we're using pdfLaTeX
+
+\newboolean{@tufte@pdf}
+\IfFileExists{ifpdf.sty}{%
+ \RequirePackage{ifpdf}
+ \ifthenelse{\boolean{pdf}}
+ {\setboolean{@tufte@pdf}{true}}
+ {\setboolean{@tufte@pdf}{false}}
+}{% assume we're not using pdfTex?
+ \setboolean{@tufte@pdf}{false}
+}
+
+%%
+% Detect if we're using XeLaTeX
+
+\newboolean{@tufte@xetex}
+\IfFileExists{ifxetex.sty}{%
+ \RequirePackage{ifxetex}
+ \ifthenelse{\boolean{xetex}}
+ {\setboolean{@tufte@xetex}{true}}
+ {\setboolean{@tufte@xetex}{false}}
+}{% not using xelatex
+ \setboolean{@tufte@xetex}{false}
+}
+
+\ifthenelse{\boolean{@tufte@xetex}}{%
+ \RequirePackage{xltxtra}% xltxtra loads xunicode and fontspec; must be loaded before bidi
+}{}
+
+%%
+% Detect if we're using LuaTeX
+
+\newboolean{@tufte@luatex}
+\IfFileExists{ifluatex.sty}{%
+ \RequirePackage{ifluatex}
+ \ifthenelse{\boolean{luatex}}
+ {\setboolean{@tufte@luatex}{true}}
+ {\setboolean{@tufte@luatex}{false}}
+}{% not using luatex
+ \setboolean{@tufte@luatex}{false}
+}
+
+\ifthenelse{\boolean{@tufte@luatex}}{%
+ \RequirePackage{fontspec}
+ \RequirePackage[osf,sc]{mathpazo}
+ \setmainfont[Renderer=Basic, Numbers=OldStyle, Scale = 1.0]{TeX Gyre Pagella}
+ \setsansfont[Renderer=Basic, Scale=0.90]{TeX Gyre Heros}
+ \setmonofont[Renderer=Basic]{TeX Gyre Cursor}
+}{}
+
+%%
+% Globally sets the length
+
+\newcommand*{\gsetlength}[2]{%
+ \setlength{#1}{#2}%
+ \global#1=#1\relax%
+}
+
+%%
+% Globally sets a boolean
+
+\newcommand*{\gsetboolean}[2]{% based on code from ifthen pkg
+ \lowercase{\def\@tempa{#2}}%
+ \@ifundefined{@tempswa\@tempa}%
+ {\PackageError{ifthen}{You can only set a boolean to `true' or `false'}\@ehc}%
+ {\@ifundefined{#1\@tempa}%
+ {\PackageError{ifthen}{Boolean #1 undefined}\@ehc}%
+ {\global\csname#1\@tempa\endcsname}%
+ }%
+}
+
+%%
+% The titlesec and titletoc packages are used to change the style of the
+% section headings. These packages should be loaded before the hyperref
+% package.
+
+\RequirePackage{titlesec,titletoc}
+
+%%%
+%% Loads the hyperref package and sets some default options.
+
+\newcommand{\TufteLoadHyperref}{%
+ \ifthenelse{\boolean{@tufte@xetex}}
+ {\RequirePackage[unicode,hyperfootnotes=false,xetex]{hyperref}}
+ {\RequirePackage[unicode,hyperfootnotes=false]{hyperref}}
+ \hypersetup{%
+ pdfborder = {0 0 0},
+ bookmarksdepth = section,
+ citecolor = DarkGreen,
+ linkcolor = DarkBlue,
+ urlcolor = DarkGreen,
+ }%
+}
+
+%%%
+%% Load the `hyperref' package.
+
+\ifthenelse{\boolean{@tufte@loadhyper}}{%
+ \TufteLoadHyperref%
+}{% hyperfootnotes override our modifications to the \footnote* and \@footnote* commands.
+ \PassOptionsToPackage{hyperfootnotes=false}{hyperref}
+}
+
+%%
+% Set the font sizes and baselines to match Tufte's books
+\renewcommand\normalsize{%
+ \@setfontsize\normalsize\@xpt{14}%
+ \abovedisplayskip 10\p@ \@plus2\p@ \@minus5\p@
+ \abovedisplayshortskip \z@ \@plus3\p@
+ \belowdisplayshortskip 6\p@ \@plus3\p@ \@minus3\p@
+ \belowdisplayskip \abovedisplayskip
+ \let\@listi\@listI}
+\normalbaselineskip=14pt
+\normalsize
+\renewcommand\small{%
+ \@setfontsize\small\@ixpt{12}%
+ \abovedisplayskip 8.5\p@ \@plus3\p@ \@minus4\p@
+ \abovedisplayshortskip \z@ \@plus2\p@
+ \belowdisplayshortskip 4\p@ \@plus2\p@ \@minus2\p@
+ \def\@listi{\leftmargin\leftmargini
+ \topsep 4\p@ \@plus2\p@ \@minus2\p@
+ \parsep 2\p@ \@plus\p@ \@minus\p@
+ \itemsep \parsep}%
+ \belowdisplayskip \abovedisplayskip
+}
+\renewcommand\footnotesize{%
+ \@setfontsize\footnotesize\@viiipt{10}%
+ \abovedisplayskip 6\p@ \@plus2\p@ \@minus4\p@
+ \abovedisplayshortskip \z@ \@plus\p@
+ \belowdisplayshortskip 3\p@ \@plus\p@ \@minus2\p@
+ \def\@listi{\leftmargin\leftmargini
+ \topsep 3\p@ \@plus\p@ \@minus\p@
+ \parsep 2\p@ \@plus\p@ \@minus\p@
+ \itemsep \parsep}%
+ \belowdisplayskip \abovedisplayskip
+}
+\renewcommand\scriptsize{\@setfontsize\scriptsize\@viipt\@viiipt}
+\renewcommand\tiny{\@setfontsize\tiny\@vpt\@vipt}
+\renewcommand\large{\@setfontsize\large\@xipt{15}}
+\renewcommand\Large{\@setfontsize\Large\@xiipt{16}}
+\renewcommand\LARGE{\@setfontsize\LARGE\@xivpt{18}}
+\renewcommand\huge{\@setfontsize\huge\@xxpt{30}}
+\renewcommand\Huge{\@setfontsize\Huge{24}{36}}
+
+\setlength\leftmargini {1pc}
+\setlength\leftmarginii {1pc}
+\setlength\leftmarginiii {1pc}
+\setlength\leftmarginiv {1pc}
+\setlength\leftmarginv {1pc}
+\setlength\leftmarginvi {1pc}
+\setlength\labelsep {.5pc}
+\setlength\labelwidth {\leftmargini}
+\addtolength\labelwidth{-\labelsep}
+
+%%
+% \RaggedRight allows hyphenation
+
+\setlength{\parindent}{1.0pc}%
+\setlength{\parskip}{0pt}%
+\RequirePackage{ragged2e}
+\setlength{\RaggedRightRightskip}{\z@ plus 0.08\hsize}
+
+% Paragraph indentation and separation for normal text
+\newcommand{\@tufte@reset@par}{%
+ \setlength{\RaggedRightParindent}{1.0pc}%
+ \setlength{\JustifyingParindent}{1.0pc}%
+ \setlength{\parindent}{1pc}%
+ \setlength{\parskip}{0pt}%
+}
+\@tufte@reset@par
+
+% Paragraph indentation and separation for marginal text
+\newcommand{\@tufte@margin@par}{%
+ \setlength{\RaggedRightParindent}{0.5pc}%
+ \setlength{\JustifyingParindent}{0.5pc}%
+ \setlength{\parindent}{0.5pc}%
+ \setlength{\parskip}{0pt}%
+}
+
+
+%%
+% Set page layout geometry
+
+\RequirePackage[letterpaper,left=1in,top=1in,headsep=2\baselineskip,textwidth=26pc,marginparsep=2pc,marginparwidth=12pc,textheight=44\baselineskip,headheight=\baselineskip]{geometry}
+
+\ifthenelse{\boolean{@tufte@afourpaper}}
+ {\geometry{a4paper,left=24.8mm,top=27.4mm,headsep=2\baselineskip,textwidth=107mm,marginparsep=8.2mm,marginparwidth=49.4mm,textheight=49\baselineskip,headheight=\baselineskip}}
+ {}
+
+\ifthenelse{\boolean{@tufte@bfivepaper}}
+ {\geometry{paperwidth=176mm,paperheight=250mm,left=14.66mm,top=13.88mm,textwidth=102.66mm,marginparsep=7.33mm,marginparwidth=36.66mm,textheight=38\baselineskip,includehead}}
+ {}
+
+\ifthenelse{\boolean{@tufte@symmetric}}
+ {}
+ {\geometry{asymmetric}}% forces internal LaTeX `twoside'
+
+
+%%
+% Separation marginpars by a line's worth of space.
+
+\setlength\marginparpush{10pt}
+
+%%
+% Font for margin items
+
+\ifthenelse{\boolean{@tufte@sfsidenotes}}
+ {\newcommand{\@tufte@marginfont}{\normalfont\footnotesize\sffamily}}
+ {\newcommand{\@tufte@marginfont}{\normalfont\footnotesize}}
+
+\newcommand*{\@tufte@sidenote@font}{\@tufte@marginfont}
+\newcommand*{\@tufte@caption@font}{\@tufte@marginfont}
+\newcommand*{\@tufte@marginnote@font}{\@tufte@marginfont}
+\newcommand*{\@tufte@citation@font}{\@tufte@marginfont}
+
+\newcommand*{\setsidenotefont}[1]{\renewcommand*{\@tufte@sidenote@font}{#1}}
+\newcommand*{\setcaptionfont}[1]{\renewcommand*{\@tufte@caption@font}{#1}}
+\newcommand*{\setmarginnotefont}[1]{\renewcommand*{\@tufte@marginnote@font}{#1}}
+\newcommand*{\setcitationfont}[1]{\renewcommand*{\@tufte@citation@font}{#1}}
+
+%%
+% Set the justification baesed on the `justified' class option
+
+\newcommand{\@tufte@justification}{%
+ \ifthenelse{\boolean{@tufte@justified}}%
+ {\justifying}%
+ {\RaggedRight}%
+}
+
+%%
+% Turn off section numbering
+
+\setcounter{secnumdepth}{-1}
+
+%%
+% Tighten up space between displays (e.g., a figure or table) and make symmetric
+
+\setlength\abovedisplayskip{6pt plus 2pt minus 4pt}
+\setlength\belowdisplayskip{6pt plus 2pt minus 4pt}
+
+%%
+% To implement full-width display environments
+
+\newboolean{@tufte@changepage}
+\IfFileExists{changepage.sty}{%
+ \@tufte@debug@info@noline{Found changepage.sty}
+ \RequirePackage[strict]{changepage}
+ \setboolean{@tufte@changepage}{true}
+}{%
+ \@tufte@debug@info@noline{Found chngpage.sty}
+ \RequirePackage[strict]{chngpage}
+ \setboolean{@tufte@changepage}{false}
+}
+
+% Write our own aliases for the \checkoddpage and \ifoddpage or \ifcpoddpage commands
+\newboolean{@tufte@odd@page}
+\setboolean{@tufte@odd@page}{true}
+\newcommand*{\@tufte@checkoddpage}{%
+ \checkoddpage%
+ \ifthenelse{\boolean{@tufte@changepage}}{%
+ \ifoddpage%
+ \setboolean{@tufte@odd@page}{true}%
+ \else%
+ \setboolean{@tufte@odd@page}{false}%
+ \fi%
+ }{%
+ \ifcpoddpage%
+ \setboolean{@tufte@odd@page}{true}%
+ \else%
+ \setboolean{@tufte@odd@page}{false}%
+ \fi%
+ }%
+}
+
+%%
+% Compute lengths used for full-width displays
+
+\newlength{\@tufte@overhang}% used by the fullwidth environment and the running heads
+\newlength{\@tufte@fullwidth}
+\newlength{\@tufte@caption@fill}
+
+\newcommand{\TufteRecalculate}{%
+ \setlength{\@tufte@overhang}{\marginparwidth}
+ \addtolength{\@tufte@overhang}{\marginparsep}
+
+ \setlength{\@tufte@fullwidth}{\textwidth}
+ \addtolength{\@tufte@fullwidth}{\marginparsep}
+ \addtolength{\@tufte@fullwidth}{\marginparwidth}
+
+ \setlength{\@tufte@caption@fill}{\textwidth}
+ \addtolength{\@tufte@caption@fill}{\marginparsep}
+}
+
+\AtBeginDocument{\TufteRecalculate}
+
+%%
+% Modified \title, \author, and \date commands. These store the
+% (footnote-less) values in \plaintitle, \plainauthor, and \thedate, respectively.
+
+\newcommand{\plaintitle}{}% plain-text-only title
+\newcommand{\plainauthor}{}% plain-text-only author
+\newcommand{\plainpublisher}{}% plain-text-only publisher
+
+\newcommand{\thanklesstitle}{}% full title text minus \thanks{}
+\newcommand{\thanklessauthor}{}% full author text minus \thanks{}
+\newcommand{\thanklesspublisher}{}% full publisher minus \thanks{}
+
+\newcommand{\@publisher}{}% full publisher with \thanks{}
+\newcommand{\thedate}{\today}
+
+% TODO Fix it so that \thanks is not spaced out (with `soul') and can be
+% used in \maketitle when the `sfsidenotes' option is provided.
+\renewcommand{\thanks}[1]{\NoCaseChange{\footnote{#1}}}
+
+\renewcommand{\title}[2][]{%
+ \gdef\@title{#2}%
+ \begingroup%
+ % TODO store contents of \thanks command
+ \renewcommand{\thanks}[1]{}% swallow \thanks contents
+ \protected@xdef\thanklesstitle{#2}%
+ \endgroup%
+ \ifthenelse{\isempty{#1}}%
+ {\renewcommand{\plaintitle}{\thanklesstitle}}% use thankless title
+ {\renewcommand{\plaintitle}{#1}}% use provided plain-text title
+ \ifthenelse{\isundefined{\hypersetup}}%
+ {}% hyperref is not loaded; do nothing
+ {\hypersetup{pdftitle={\plaintitle}}}% set the PDF metadata title
+}
+
+\let\@author\@empty% suppress default latex.ltx ``no author'' warning
+\renewcommand{\author}[2][]{%
+ \ifthenelse{\isempty{#2}}{}{\gdef\@author{#2}}%
+ \begingroup%
+ % TODO store contents of \thanks command
+ \renewcommand{\thanks}[1]{}% swallow \thanks contents
+ \protected@xdef\thanklessauthor{#2}%
+ \endgroup%
+ \ifthenelse{\isempty{#1}}%
+ {\renewcommand{\plainauthor}{\thanklessauthor}}% use thankless author
+ {\renewcommand{\plainauthor}{#1}}% use provided plain-text author
+ \ifthenelse{\isundefined{\hypersetup}}%
+ {}% hyperref is not loaded; do nothing
+ {\hypersetup{pdfauthor={\plainauthor}}}% set the PDF metadata author
+}
+
+\renewcommand{\date}[1]{%
+ \gdef\@date{#1}%
+ \begingroup%
+ % TODO store contents of \thanks command
+ \renewcommand{\thanks}[1]{}% swallow \thanks contents
+ \protected@xdef\thedate{#1}%
+ \endgroup%
+}
+
+%%
+% Provides a \publisher command to set the publisher
+
+\newcommand{\publisher}[2][]{%
+ \gdef\@publisher{#2}%
+ \begingroup%
+ \renewcommand{\thanks}[1]{}% swallow \thanks contents
+ \protected@xdef\thanklesspublisher{#2}%
+ \endgroup%
+ \ifthenelse{\isempty{#1}}
+ {\renewcommand{\plainpublisher}{\thanklesspublisher}}% use thankless publisher
+ {\renewcommand{\plainpublisher}{#1}}% use provided plain-text publisher
+}
+
+% TODO: Test \hypersetup{pdfauthor,pdftitle} with DVI and XeTeX
+
+%%
+% Require paralist package for tighter lists
+
+\RequirePackage{paralist}
+
+% Add rightmargin to compactenum
+
+\def\@compactenum@{%
+ \expandafter\list\csname label\@enumctr\endcsname{%
+ \usecounter{\@enumctr}%
+ \rightmargin=2em% added this
+ \parsep\plparsep
+ \itemsep\plitemsep
+ \topsep\pltopsep
+ \partopsep\plpartopsep
+ \def\makelabel##1{\hss\llap{##1}}}}
+
+%%
+% Improved letterspacing of small caps and all-caps text.
+%
+% First, try to use the `microtype' package, if it's available.
+% Failing that, try to use the `soul' package, if it's available.
+% Failing that, well, I give up.
+
+\DeclareTextFontCommand{\textsmallcaps}{\scshape}
+
+\RequirePackage{textcase} % provides \MakeTextUppercase and \MakeTextLowercase
+\def\allcapsspacing{\@tufte@warning{Proper spacing of ALL-CAPS letters has not been set up.}}
+\def\smallcapsspacing{\@tufte@warning{Proper spacing of small-caps letters has not been set up.}}
+\newcommand{\allcaps}[1]{\allcapsspacing{\MakeTextUppercase{#1}}}
+\newcommand{\smallcaps}[1]{\smallcapsspacing{\MakeTextLowercase{#1}}}
+
+% If we're using pdfLaTeX v1.40+, use the letterspace package.
+% If we're using pdfLaTex < v1.40, use the soul package.
+% If we're using XeLaTeX, use XeLaTeX letterspacing options.
+% Otherwise fall back on the soul package.
+
+\ifthenelse{\boolean{@tufte@pdf}}
+ {\@tufte@debug@info@noline{ifpdf = true}}
+ {\@tufte@debug@info@noline{ifpdf = false}}
+
+\ifthenelse{\boolean{@tufte@xetex}}
+ {\@tufte@debug@info@noline{ifxetex = true}}
+ {\@tufte@debug@info@noline{ifxetex = false}}
+
+% Check pdfLaTeX version
+\def\@tufte@pdftexversion{0}
+\ifx\normalpdftexversion\@undefined \else
+ \let\pdftexversion \normalpdftexversion
+ \let\pdftexrevision\normalpdftexrevision
+ \let\pdfoutput \normalpdfoutput
+\fi
+\ifx\pdftexversion\@undefined \else
+ \ifx\pdftexversion\relax \else
+ \def\@tufte@pdftexversion{6}
+ \ifnum\pdftexversion < 140
+ \def\@tufte@pdftexversion{5}
+ \fi
+ \fi
+\fi
+
+\newboolean{@tufte@letterspace@pkg@prereqs}
+\setboolean{@tufte@letterspace@pkg@prereqs}{true}
+\ifnum\@tufte@pdftexversion<6
+ \setboolean{@tufte@letterspace@pkg@prereqs}{false}
+\fi
+
+
+\newcommand{\@tufte@letterspacing@soul}{%
+ \RequirePackage{soul}%
+ \sodef\allcapsspacing{}{0.15em}{0.65em}{0.6em}%
+ \sodef\smallcapsspacing{}{0.075em}{0.5em}{0.6em}%
+ \sodef\sotextsc{\scshape}{0.075em}{0.5em}{0.6em}%
+ \renewcommand{\allcaps}[1]{\allcapsspacing{\MakeTextUppercase{##1}}}%
+ \renewcommand{\smallcaps}[1]{\smallcapsspacing{\scshape\MakeTextLowercase{##1}}}%
+ \renewcommand{\textsc}[1]{\sotextsc{##1}}%
+}
+
+\newcommand{\@tufte@letterspacing@letterspace}{%
+ \@tufte@debug@info@noline{Modern version of pdfTeX detected. Using `letterspace' package}%
+ \RequirePackage{letterspace}%
+ % Set up letterspacing (using microtype package) -- requires pdfTeX v1.40+
+ \renewcommand{\allcapsspacing}[1]{\textls[200]{##1}}%
+ \renewcommand{\smallcapsspacing}[1]{\textls[50]{##1}}%
+ \renewcommand{\allcaps}[1]{\allcapsspacing{\MakeTextUppercase{##1}}}%
+ \renewcommand{\smallcaps}[1]{\smallcapsspacing{\scshape\MakeTextLowercase{##1}}}%
+ \renewcommand{\textsc}[1]{\smallcapsspacing{\textsmallcaps{##1}}}%
+}
+
+\ifthenelse{\boolean{@tufte@letterspace}}{%
+ \ifthenelse{\boolean{@tufte@pdf}\AND\boolean{@tufte@letterspace@pkg@prereqs}\AND\NOT\boolean{@tufte@xetex}}{%
+ % load letterspace pkg
+ \IfFileExists{letterspace.sty}{%
+ \@tufte@letterspacing@letterspace
+ }{}%
+ }{}%
+ % load soul pkg
+ \@ifpackageloaded{letterspace}{}{%
+ \IfFileExists{soul.sty}{%
+ \@tufte@letterspacing@soul
+ }{%
+ \@tufte@warning@noline{Couldn't locate `soul' package}%
+ }% soul not installed... giving up.
+ }%
+}{}
+
+%\ifthenelse{\boolean{@tufte@letterspace}}{%
+ %\ifthenelse{\boolean{pdf}}{%
+ %\ifthenelse{\NOT\boolean{@tufte@letterspace@pkg@prereqs}}{%
+ %% pdfLaTeX version is too old or not using pdfLaTeX
+ %\ifthenelse{\boolean{@tufte@xetex}}{%
+ %% TODO use xetex letterspacing
+ %\@tufte@debug@info@noline{XeTeX detected. Reverting to `soul' package for letterspacing}%
+ %\@tufte@loadsoul%
+ %}{%
+ %% use `soul' package for letterspacing
+ %\@tufte@debug@info@noline{Old version of pdfTeX detected. Reverting to `soul' package for letterspacing}%
+ %\@tufte@loadsoul%
+ %}
+ %}{%
+ %\IfFileExists{letterspace.sty}{%
+ %\@tufte@debug@info@noline{Modern version of pdfTeX detected. Using `letterspace' package}
+ %\RequirePackage{letterspace}
+ %% Set up letterspacing (using microtype package) -- requires pdfTeX v1.40+
+ %\renewcommand{\allcapsspacing}[1]{\textls[200]{##1}}
+ %\renewcommand{\smallcapsspacing}[1]{\textls[50]{##1}}
+ %\renewcommand{\allcaps}[1]{\textls[200]{\MakeTextUppercase{##1}}}
+ %\renewcommand{\smallcaps}[1]{\smallcapsspacing{\MakeTextLowercase{##1}}}
+ %\renewcommand{\textsc}[1]{\smallcapsspacing{\textsmallcaps{##1}}}
+ %}{% microtype failed, check for soul
+ %\@tufte@debug@info@noline{Modern version of pdfTeX detected, but `letterspace' package not installed. Reverting to `soul' package for letterspacing}
+ %\@tufte@loadsoul
+ %}%
+ %}%
+ %}{%
+ %\@tufte@debug@info@noline{Plain LaTeX detected. Using `soul' package for letterspacing}
+ %\@tufte@loadsoul
+ %}
+%}{%
+%% we're not to load letterspacing, so do nothing
+%}
+
+
+%%
+% An environment for paragraph-style section
+
+\providecommand\newthought[1]{%
+ \tuftebreak
+ \noindent\textsc{#1}%
+}
+
+%%
+% Redefine the display environments (quote, quotation, etc.)
+
+\renewenvironment{verse}
+ {\let\\\@centercr
+ \list{}{\itemsep \z@
+ \itemindent -1pc%
+ \listparindent\itemindent
+ \rightmargin \leftmargin
+ \advance\leftmargin 1pc}%
+ \small%
+ \item\relax}
+ {\endlist}
+\renewenvironment{quotation}
+ {\list{}{\listparindent 1pc%
+ \itemindent \listparindent
+ \rightmargin \leftmargin
+ \parsep \z@ \@plus\p@}%
+ \small%
+ \item\relax\noindent\ignorespaces}
+ {\endlist}
+\renewenvironment{quote}
+ {\list{}{\rightmargin\leftmargin}%
+ \small%
+ \item\relax}
+ {\endlist}
+
+%%
+% Italicize description run-in headings (instead of the default bold)
+
+\renewcommand*\descriptionlabel[1]{\hspace\labelsep\normalfont\em #1}
+
+
+%%
+% Used for doublespacing, and other linespacing
+
+\RequirePackage{setspace}
+
+%%
+% Color
+\RequirePackage[usenames,dvipsnames,svgnames]{xcolor}% load before bidi
+
+%%
+% Load the bidi package if instructed to do so. This package must be loaded
+% prior to our redefining the \footnote and \cite commands.
+
+\ifthenelse{\boolean{@tufte@loadbidi}}{%
+ \AtBeginDocument{%
+ \RequirePackage{bidi}
+ \@tufte@pkghook@post@bidi%
+ }%
+}{}
+
+
+%%
+% A function that removes leading and trailling spaces from the supplied macro.
+% Based on code written by Michael Downes (See ``Around the Bend'', #15.)
+% Executing \@tufte@trim@spaces\xyzzy will result in the contents of \xyzzy
+% being trimmed of leading and trailing white space.
+
+\catcode`\Q=3
+\def\@tufte@trim@spaces#1{%
+ % Use grouping to emulate a multi-token afterassignment queue
+ \begingroup%
+ % Put `\toks 0 {' into the afterassignment queue
+ \aftergroup\toks\aftergroup0\aftergroup{%
+ % Apply \trimb to the replacement text of #1, adding a leading
+ % \noexpand to prevent brace stripping and to serve another purpose
+ % later.
+ \expandafter\@tufte@trim@b\expandafter\noexpand#1Q Q}%
+ % Transfer the trimmed text back into #1.
+ \edef#1{\the\toks0}%
+}
+
+% \trimb removes a trailing space if present, then calls \@tufte@trim@c to
+% clean up any leftover bizarre Qs, and trim a leading space. In
+% order for \trimc to work properly we need to put back a Q first.
+\def\@tufte@trim@b#1 Q{\@tufte@trim@c#1Q}
+
+% Execute \vfuzz assignment to remove leading space; the \noexpand
+% will now prevent unwanted expansion of a macro or other expandable
+% token at the beginning of the trimmed text. The \endgroup will feed
+% in the \aftergroup tokens after the \vfuzz assignment is completed.
+\def\@tufte@trim@c#1Q#2{\afterassignment\endgroup \vfuzz\the\vfuzz#1}
+\catcode`\Q=11
+
+%%
+% Citations should go in the margin as sidenotes
+
+\ifthenelse{\boolean{@tufte@loadnatbib}}{%
+ \RequirePackage{natbib}%
+ \RequirePackage{bibentry}% allows bibitems to be typeset outside thebibliography environment
+ % Redefine the \BR@b@bibitem command to fix a bug with bibentry+chicago style
+ \renewcommand\BR@b@bibitem[2][]{%
+ \ifthenelse{\isempty{#1}}%
+ {\BR@bibitem{#2}}%
+ {\BR@bibitem[#1]{#2}}%
+ \BR@c@bibitem{#2}%
+ }%
+ \nobibliography*% pre-loads the bibliography keys
+ \providecommand{\doi}[1]{\textsc{doi:} #1}% pre-defining this so it may be used before the \bibliography command it issued
+}{}
+
+%%
+% Normal \cite behavior
+\newcounter{@tufte@num@bibkeys}%
+\newcommand{\@tufte@normal@cite}[2][0pt]{%
+ % Snag the last bibentry in the list for later comparison
+ \let\@temp@last@bibkey\@empty%
+ \@for\@temp@bibkey:=#2\do{\let\@temp@last@bibkey\@temp@bibkey}%
+ \sidenote[][#1]{%
+ % Loop through all the bibentries, separating them with semicolons and spaces
+ \normalsize\normalfont\@tufte@citation@font%
+ \setcounter{@tufte@num@bibkeys}{0}%
+ \@for\@temp@bibkeyx:=#2\do{%
+ \ifthenelse{\equal{\@temp@last@bibkey}{\@temp@bibkeyx}}%
+ {\ifthenelse{\equal{\value{@tufte@num@bibkeys}}{0}}{}{and\ }%
+ \@tufte@trim@spaces\@temp@bibkeyx% trim spaces around bibkey
+ \bibentry{\@temp@bibkeyx}}%
+ {\@tufte@trim@spaces\@temp@bibkeyx% trim spaces around bibkey
+ \bibentry{\@temp@bibkeyx};\ }%
+ \stepcounter{@tufte@num@bibkeys}%
+ }%
+ }%
+}
+
+
+%%
+% Macros for holding the list of cite keys until after the \sidenote
+
+\gdef\@tufte@citations{}% list of cite keys
+\newcommand\@tufte@add@citation[1]{\relax% adds a new bibkey to the list of cite keys
+ \ifx\@tufte@citations\@empty\else
+ \g@addto@macro\@tufte@citations{,}% separate by commas
+ \fi
+ \g@addto@macro\@tufte@citations{#1}
+}
+
+\newcommand{\@tufte@print@citations}[1][0pt]{% puts the citations in a margin note
+ % Snag the last bibentry in the list for later comparison
+ \let\@temp@last@bibkey\@empty%
+ \@for\@temp@bibkey:=\@tufte@citations\do{\let\@temp@last@bibkey\@temp@bibkey}%
+ \marginpar{%
+ \hbox{}\vspace*{#1}%
+ \@tufte@citation@font%
+ \@tufte@citation@justification%
+ \@tufte@margin@par% use parindent and parskip settings for marginal text
+ \vspace*{-1\baselineskip}%
+ % Loop through all the bibentries, separating them with semicolons and spaces
+ \setcounter{@tufte@num@bibkeys}{0}%
+ \@for\@temp@bibkeyx:=\@tufte@citations\do{%
+ \ifthenelse{\equal{\@temp@last@bibkey}{\@temp@bibkeyx}}%
+ {\ifthenelse{\equal{\value{@tufte@num@bibkeys}}{0}}{}{and\ }%
+ \@tufte@trim@spaces\@temp@bibkeyx% trim spaces around bibkey
+ \bibentry{\@temp@bibkeyx}}%
+ {\@tufte@trim@spaces\@temp@bibkeyx% trim spaces around bibkey
+ \bibentry{\@temp@bibkeyx};\ }%
+ \stepcounter{@tufte@num@bibkeys}%
+ }%
+ }%
+}
+
+%%
+% \cite behavior when executed within a sidenote
+
+\newcommand{\@tufte@sidenote@citations}{}% contains list of \cites in sidenote
+\newcommand{\@tufte@infootnote@cite}[1]{%
+ \@tufte@add@citation{#1}
+}
+
+%%
+% Set the default \cite style. This is set and reset by the \sidenote command.
+
+\ifthenelse{\boolean{@tufte@loadnatbib}}{%
+ \let\cite\@tufte@normal@cite
+}{}
+
+%%
+% Transform existing \footnotes into \sidenotes
+% Sidenote: ``Where God meant footnotes to go.'' ---Tufte
+
+\RequirePackage{optparams}% for our new sidenote commands -- provides multiple optional arguments for commands
+
+\providecommand{\footnotelayout}{\@tufte@sidenote@font\@tufte@sidenote@justification}
+\renewcommand{\footnotelayout}{\@tufte@sidenote@font\@tufte@sidenote@justification}
+
+% Override footmisc's definition to set the sidenote marks (numbers) inside the
+% sidenote's text block.
+\long\def\@makefntext#1{\@textsuperscript{\@tufte@sidenote@font\tiny\@thefnmark}\,\footnotelayout#1}
+
+% Set the in-text footnote mark in the same typeface as the body text itself.
+\def\@makefnmark{\hbox{\@textsuperscript{\normalfont\footnotesize\@thefnmark}}}
+
+\providecommand*{\multiplefootnotemarker}{3sp}
+\providecommand*{\multfootsep}{,}
+
+\renewcommand{\@footnotemark}{%
+ \leavevmode%
+ \ifhmode%
+ \edef\@x@sf{\the\spacefactor}%
+ \@tufte@check@multiple@sidenotes%
+ \nobreak%
+ \fi%
+ \@makefnmark%
+ \ifhmode\spacefactor\@x@sf\fi%
+ \relax%
+}
+
+\newcommand{\@tufte@check@multiple@sidenotes}{%
+ \ifdim\lastkern=\multiplefootnotemarker\relax%
+ \edef\@x@sf{\the\spacefactor}%
+ \unkern%
+ \textsuperscript{\multfootsep}%
+ \spacefactor\@x@sf\relax%
+ \fi
+}
+
+\renewcommand\@footnotetext[2][0pt]{%
+ \marginpar{%
+ \hbox{}\vspace*{#1}%
+ \def\baselinestretch {\setspace@singlespace}%
+ \reset@font\footnotesize%
+ \@tufte@margin@par% use parindent and parskip settings for marginal text
+ \vspace*{-1\baselineskip}\noindent%
+ \protected@edef\@currentlabel{%
+ \csname p@footnote\endcsname\@thefnmark%
+ }%
+ \color@begingroup%
+ \@makefntext{%
+ \ignorespaces#2%
+ }%
+ \color@endgroup%
+ }%
+}%
+
+% Ensure this is run after the bidi package has been loaded
+\def\@tufte@pkghook@post@bidi{}%
+\g@addto@macro{\@tufte@pkghook@post@bidi}{%
+ \renewcommand\@footnotetext[2][0pt]{%
+ \marginpar{%
+ \hbox{}\vspace*{#1}%
+ \def\baselinestretch {\setspace@singlespace}%
+ \if@rl@footnote\@rltrue\else\@rlfalse\fi%
+ \reset@font\footnotesize%
+ \@tufte@margin@par% use parindent and parskip settings for marginal text
+ \vspace*{-1\baselineskip}\noindent%
+ \protected@edef\@currentlabel{%
+ \csname p@footnote\endcsname\@thefnmark%
+ }%
+ \color@begingroup%
+ \@makefntext{%
+ \ignorespaces#2%
+ }%
+ \color@endgroup%
+ }%
+ }%
+}%
+
+%
+% Define \sidenote command. Can handle \cite.
+
+\newlength{\@tufte@sidenote@vertical@offset}
+\setlength{\@tufte@sidenote@vertical@offset}{0pt}
+
+% #1 = footnote num, #2 = vertical offset, #3 = footnote text
+\long\def\@tufte@sidenote[#1][#2]#3{%
+ \ifthenelse{\boolean{@tufte@loadnatbib}}{%
+ \let\cite\@tufte@infootnote@cite% use the in-sidenote \cite command
+ }{}%
+ \gdef\@tufte@citations{}% clear out any old citations
+ \ifthenelse{\NOT\isempty{#2}}{%
+ \gsetlength{\@tufte@sidenote@vertical@offset}{#2}%
+ }{%
+ \gsetlength{\@tufte@sidenote@vertical@offset}{0pt}%
+ }%
+ \ifthenelse{\isempty{#1}}{%
+ % no specific footnote number provided
+ \stepcounter\@mpfn%
+ \protected@xdef\@thefnmark{\thempfn}%
+ \@footnotemark\@footnotetext[\@tufte@sidenote@vertical@offset]{#3}%
+ }{%
+ % specific footnote number provided
+ \begingroup%
+ \csname c@\@mpfn\endcsname #1\relax%
+ \unrestored@protected@xdef\@thefnmark{\thempfn}%
+ \endgroup%
+ \@footnotemark\@footnotetext[\@tufte@sidenote@vertical@offset]{#3}%
+ }%
+ \@tufte@print@citations% print any citations
+ \ifthenelse{\boolean{@tufte@loadnatbib}}{%
+ \let\cite\@tufte@normal@cite% go back to using normal in-text \cite command
+ }{}%
+ \unskip\ignorespaces% remove extra white space
+ \kern-\multiplefootnotemarker% remove \kern left behind by sidenote
+ \kern\multiplefootnotemarker\relax% add new \kern here to replace the one we yanked
+}
+
+\newcommand{\sidenote}{\optparams{\@tufte@sidenote}{[][0pt]}}
+\renewcommand{\footnote}{\optparams{\@tufte@sidenote}{[][0pt]}}
+
+%%
+% Sidenote without the footnote mark
+
+\newcommand\marginnote[2][0pt]{%
+ \ifthenelse{\boolean{@tufte@loadnatbib}}{%
+ \let\cite\@tufte@infootnote@cite% use the in-sidenote \cite command
+ }{}%
+ \gdef\@tufte@citations{}% clear out any old citations
+ \marginpar{\hbox{}\vspace*{#1}\@tufte@marginnote@font\@tufte@marginnote@justification\@tufte@margin@par\vspace*{-1\baselineskip}\noindent #2}%
+ \@tufte@print@citations% print any citations
+ \ifthenelse{\boolean{@tufte@loadnatbib}}{%
+ \let\cite\@tufte@normal@cite% go back to using normal in-text \cite command
+ }{}%
+}
+
+
+%%
+% The placeins package provides the \FloatBarrier command. This forces
+% LaTeX to place all of the floats before proceeding. We'll use this to
+% keep the float (figure and table) numbers in sequence.
+\RequirePackage{placeins}
+
+%%
+% Margin float environment
+
+\newsavebox{\@tufte@margin@floatbox}
+\newenvironment{@tufte@margin@float}[2][-1.2ex]%
+ {\FloatBarrier% process all floats before this point so the figure/table numbers stay in order.
+ \begin{lrbox}{\@tufte@margin@floatbox}%
+ \begin{minipage}{\marginparwidth}%
+ \@tufte@caption@font%
+ \def\@captype{#2}%
+ \hbox{}\vspace*{#1}%
+ \@tufte@caption@justification%
+ \@tufte@margin@par%
+ \noindent%
+ }
+ {\end{minipage}%
+ \end{lrbox}%
+ \marginpar{\usebox{\@tufte@margin@floatbox}}%
+ }
+
+
+%%
+% Margin figure environment
+
+\newenvironment{marginfigure}[1][-1.2ex]%
+ {\begin{@tufte@margin@float}[#1]{figure}}
+ {\end{@tufte@margin@float}}
+
+
+%%
+% Margin table environment
+
+\newenvironment{margintable}[1][-1.2ex]%
+ {\begin{@tufte@margin@float}[#1]{table}}
+ {\end{@tufte@margin@float}}
+
+
+%%
+% Auto-detects the proper text alignment based on the various class options
+
+\newcommand*{\@tufte@justification@autodetect}{%
+ \ifthenelse{\boolean{@tufte@justified}}%
+ {\justifying}%
+ {\RaggedRight}%
+}
+
+%%
+% Forces the outer edge of the caption to be set ragged.
+% Therefore, on verso pages it's ragged left, and on recto pages it's ragged right.
+
+\newcommand*{\@tufte@justification@caption@outer}{%
+ \ifthenelse{\boolean{@tufte@float@recto}}%
+ {\RaggedRight}%
+ {\RaggedLeft}%
+}
+
+\newcommand*{\@tufte@justification@outer}{%
+ \@tufte@checkoddpage%
+ \ifthenelse{\boolean{@tufte@odd@page}}%
+ {\RaggedRight}%
+ {\RaggedLeft}%
+}
+
+
+
+%%
+% A collection of macros to be used with the new Tufte-style float environments.
+% \setfloatalignment forces the caption placement to be treated as top, bottom, etc.
+% \forcerectofloat forces the float to be treated as if it were appearing on a recto page.
+% \forceversofloat does the same, but for verso pages.
+
+\newcommand{\@tufte@float@debug@info}{}% contains debug info generated as the float is processed
+\newcommand{\@tufte@float@debug}[1]{% adds debug info to the queue for output
+ \ifthenelse{\equal{\@tufte@float@debug@info}{}}%
+ {\def\@tufte@float@debug@info{#1}}%
+ {\g@addto@macro\@tufte@float@debug@info{\MessageBreak#1}}%
+}
+
+\newcommand{\floatalignment}{x}% holds the current float alignment (t, b, h, p)
+\newcommand{\setfloatalignment}[1]{\global\def\floatalignment{#1}\@tufte@float@debug{Forcing position: [#1]}}% manually sets the float alignment
+\newboolean{@tufte@float@recto}
+\newcommand{\forcerectofloat}{\gsetboolean{@tufte@float@recto}{true}\@tufte@float@debug{Forcing page: [recto]}}
+\newcommand{\forceversofloat}{\gsetboolean{@tufte@float@recto}{false}\@tufte@float@debug{Forcing page: [verso]}}
+
+% Boxes to temporarily store our float and caption
+\newsavebox{\@tufte@figure@box}
+\newsavebox{\@tufte@caption@box}
+
+% Save original LaTeX float environment
+\let\@tufte@orig@float\@float
+\let\@tufte@orig@endfloat\end@float
+
+% New length for tweaking float captions
+\newlength{\@tufte@caption@vertical@offset}
+\setlength{\@tufte@caption@vertical@offset}{0pt}
+
+% Store the caption and label contents
+\newcommand{\@tufte@stored@shortcaption}{}
+\newcommand{\@tufte@stored@caption}{}
+\newcommand{\@tufte@stored@label}{}
+
+\long\def\@tufte@caption[#1][#2]#3{%
+ \ifthenelse{\isempty{#1}}%
+ {\gdef\@tufte@stored@shortcaption{#3}}%
+ {\gdef\@tufte@stored@shortcaption{#1}}%
+ \gsetlength{\@tufte@caption@vertical@offset}{-#2}% we want a positive offset to lower captions
+ \gdef\@tufte@stored@caption{#3}%
+}
+
+\newcommand{\@tufte@label}[1]{%
+ \gdef\@tufte@stored@label{#1}%
+}
+
+\newcommand{\@tufte@fps}{}
+
+\newboolean{@tufte@float@star}
+\newlength{\@tufte@float@contents@width}
+
+%%
+% Define a float environment to place the captions in the margin space
+
+\newenvironment{@tufte@float}[3][htbp]%
+ {% begin @tufte@float
+ % Should this float be full-width or just text-width?
+ \ifthenelse{\equal{#3}{star}}%
+ {\gsetboolean{@tufte@float@star}{true}}%
+ {\gsetboolean{@tufte@float@star}{false}}%
+ % Check page side (recto/verso) and store detected value -- can be overriden in environment contents
+ \@tufte@checkoddpage%
+ \ifthenelse{\boolean{@tufte@odd@page}}%
+ {\gsetboolean{@tufte@float@recto}{true}\@tufte@float@debug{Detected page: [recto/odd]}}%
+ {\gsetboolean{@tufte@float@recto}{false}\@tufte@float@debug{Detected page: [verso/even]}}%
+ % If the float placement specifier is 'b' and only 'b', then bottom-align the mini-pages, otherwise top-align them.
+ \renewcommand{\@tufte@fps}{#1}%
+ \@tufte@float@debug{Allowed positions: [#1]}%
+ \ifthenelse{\equal{#1}{b}\OR\equal{#1}{B}}%
+ {\renewcommand{\floatalignment}{b}\@tufte@float@debug{Presumed position: [bottom]}}%
+ {\renewcommand{\floatalignment}{t}\@tufte@float@debug{Presumed position: [top]}}%
+ % Capture the contents of the \caption and \label commands to use later
+ \global\let\@tufte@orig@caption\caption%
+ \global\let\@tufte@orig@label\label%
+ \renewcommand{\caption}{\optparams{\@tufte@caption}{[][0pt]}}%
+ \renewcommand{\label}[1]{\@tufte@label{##1}}%
+ % Handle subfigure package compatibility
+ \ifthenelse{\boolean{@tufte@packages@subfigure}}{%
+ % don't move the label while inside a \subfigure or \subtable command
+ \global\let\label\@tufte@orig@label%
+ }{}% subfigure package is not loaded
+ \@tufte@orig@float{#2}[#1]%
+ \ifthenelse{\boolean{@tufte@float@star}}%
+ {\setlength{\@tufte@float@contents@width}{\@tufte@fullwidth}}%
+ {\setlength{\@tufte@float@contents@width}{\textwidth}}%
+ \begin{lrbox}{\@tufte@figure@box}%
+ \begin{minipage}[\floatalignment]{\@tufte@float@contents@width}\hbox{}%
+ }{% end @tufte@float
+ \par\hbox{}\vspace{-\baselineskip}\ifthenelse{\prevdepth>0}{\vspace{-\prevdepth}}{}% align baselines of boxes
+ \end{minipage}%
+ \end{lrbox}%
+ % build the caption box
+ \begin{lrbox}{\@tufte@caption@box}%
+ \begin{minipage}[\floatalignment]{\marginparwidth}\hbox{}%
+ \ifthenelse{\NOT\equal{\@tufte@stored@caption}{}}{\@tufte@orig@caption[\@tufte@stored@shortcaption]{\@tufte@stored@caption}}{}%
+ \ifthenelse{\NOT\equal{\@tufte@stored@label}{}}{\@tufte@orig@label{\@tufte@stored@label}}{}%
+ \par\vspace{-\prevdepth}%% TODO: DOUBLE-CHECK FOR SAFETY
+ \end{minipage}%
+ \end{lrbox}%
+ % now typeset the stored boxes
+ \begin{fullwidth}%
+ \begin{minipage}[\floatalignment]{\linewidth}%
+ \ifthenelse{\boolean{@tufte@float@star}}%
+ {\@tufte@float@fullwidth[\@tufte@caption@vertical@offset]{\@tufte@figure@box}{\@tufte@caption@box}}%
+ {\@tufte@float@textwidth[\@tufte@caption@vertical@offset]{\@tufte@figure@box}{\@tufte@caption@box}}%
+ \end{minipage}%
+ \end{fullwidth}%
+ \@tufte@orig@endfloat% end original LaTeX float environment
+ % output debug info
+ \ifthenelse{\boolean{@tufte@debug}}{%
+ \typeout{^^J^^J----------- Tufte-LaTeX float information ----------}%
+ \ifthenelse{\equal{\@tufte@stored@label}{}}%
+ {\typeout{Warning: Float unlabeled!}}%
+ {\typeout{Float label: [\@tufte@stored@label]}}%
+ \typeout{Page number: [\thepage]}%
+ \def\MessageBreak{^^J}%
+ \typeout{\@tufte@float@debug@info}%
+ \ifthenelse{\boolean{@tufte@symmetric}}%
+ {\typeout{Symmetric: [true]}}%
+ {\typeout{Symmetric: [false]}}%
+ \typeout{----------------------------------------------------^^J^^J}%
+ }{}%
+ % reset commands and temp boxes and captions
+ \gdef\@tufte@float@debug@info{}%
+ \let\caption\@tufte@orig@caption%
+ \let\label\@tufte@orig@label%
+ \begin{lrbox}{\@tufte@figure@box}\hbox{}\end{lrbox}%
+ \begin{lrbox}{\@tufte@caption@box}\hbox{}\end{lrbox}%
+ \gdef\@tufte@stored@shortcaption{}%
+ \gdef\@tufte@stored@caption{}%
+ \gdef\@tufte@stored@label{}%
+ \gsetlength{\@tufte@caption@vertical@offset}{0pt}% reset caption offset
+ }
+
+\newcommand{\@tufte@float@textwidth}[3][0pt]{%
+ \ifthenelse{\NOT\boolean{@tufte@symmetric}\OR\boolean{@tufte@float@recto}}{%
+ % asymmetric or page is odd, so caption is on the right
+ \hbox{%
+ \usebox{#2}%
+ \hspace{\marginparsep}%
+ \smash{\raisebox{#1}{\usebox{#3}}}%
+ }%
+ \@tufte@float@debug{Caption position: [right]}%
+ }{% symmetric pages and page is even, so caption is on the left
+ \hbox{%
+ \smash{\raisebox{#1}{\usebox{#3}}}%
+ \hspace{\marginparsep}%
+ \usebox{#2}%
+ }%
+ \@tufte@float@debug{Caption position: [left]}%
+ }%
+}
+
+\newcommand{\@tufte@float@fullwidth}[3][0pt]{%
+ \ifthenelse{\equal{\floatalignment}{b}}%
+ {% place caption above figure
+ \ifthenelse{\NOT\boolean{@tufte@symmetric}\OR\boolean{@tufte@float@recto}}%
+ {\hfill\smash{\raisebox{#1}{\usebox{#3}}}\par\usebox{#2}\@tufte@float@debug{Caption position: [above right]}}% caption on the right
+ {\smash{\raisebox{#1}{\usebox{#3}}}\hfill\par\usebox{#2}\@tufte@float@debug{Caption position: [above left]}}% caption on the left
+ }{% place caption below figure
+ \ifthenelse{\NOT\boolean{@tufte@symmetric}\OR\boolean{@tufte@float@recto}}%
+ {\usebox{#2}\par\hfill\smash{\raisebox{#1}{\usebox{#3}}}\@tufte@float@debug{Caption position: [below right]}}% caption on the right
+ {\usebox{#2}\par\smash{\raisebox{#1}{\usebox{#3}}}\hfill\@tufte@float@debug{Caption position: [below left]}}% caption on the left
+ }%
+}
+
+
+%%
+% Redefine the figure environment to place the captions in the margin space
+
+\renewenvironment{figure}[1][htbp]%
+ {\ifvmode\else\unskip\fi\begin{@tufte@float}[#1]{figure}{}}
+ {\end{@tufte@float}}
+
+
+%%
+% Redefine the table environment to place the captions in the margin space
+
+\renewenvironment{table}[1][htbp]
+ {\ifvmode\else\unskip\fi\begin{@tufte@float}[#1]{table}{}}
+ {\end{@tufte@float}}
+
+
+%%
+% Full-width figure
+
+\renewenvironment{figure*}[1][htbp]%
+ {\ifvmode\else\unskip\fi\begin{@tufte@float}[#1]{figure}{star}}
+ {\end{@tufte@float}}
+
+
+%%
+% Full-width table
+
+\renewenvironment{table*}[1][htbp]%
+ {\ifvmode\else\unskip\fi\begin{@tufte@float}[#1]{table}{star}}
+ {\end{@tufte@float}}
+
+
+%%
+% Full-page-width area
+
+\newenvironment{fullwidth}
+ {\ifthenelse{\boolean{@tufte@symmetric}}%
+ {\ifthenelse{\boolean{@tufte@changepage}}{\begin{adjustwidth*}{}{-\@tufte@overhang}}{\begin{adjustwidth}[]{}{-\@tufte@overhang}}}%
+ {\begin{adjustwidth}{}{-\@tufte@overhang}}%
+ }%
+ {\ifthenelse{\boolean{@tufte@symmetric}}%
+ {\ifthenelse{\boolean{@tufte@changepage}}{\end{adjustwidth*}}{\end{adjustwidth}}}%
+ {\end{adjustwidth}}%
+ }
+
+%%
+% Format the captions in a style similar to the sidenotes
+
+\long\def\@caption#1[#2]#3{%
+ \par%
+ \addcontentsline{\csname ext@#1\endcsname}{#1}%
+ {\protect\numberline{\csname the#1\endcsname}{\ignorespaces #2}}%
+ \begingroup%
+ \@parboxrestore%
+ \if@minipage%
+ \@setminipage%
+ \fi%
+ \@tufte@caption@font\@tufte@caption@justification%
+ \noindent\csname fnum@#1\endcsname: \ignorespaces#3\par%
+ %\@makecaption{\csname fnum@#1\endcsname}{\ignorespaces #3}\par
+ \endgroup}
+
+%%
+% If we're NOT using XeLaTeX and the `nofonts' class option was NOT provided,
+% we should load the Palatino, Helvetica, and Bera Mono fonts (if they are
+% installed.)
+
+\ifthenelse{\boolean{@tufte@loadfonts}\AND\NOT\boolean{@tufte@xetex}\AND\NOT\boolean{@tufte@luatex}}{%
+ \IfFileExists{mathpazo.sty}{\RequirePackage[osf,sc]{mathpazo}}{}
+ \IfFileExists{helvet.sty}{\RequirePackage[scaled=0.90]{helvet}}{}
+ \IfFileExists{beramono.sty}{\RequirePackage[scaled=0.85]{beramono}}{}
+ \RequirePackage[T1]{fontenc}
+ \RequirePackage{textcomp}
+}{}
+
+
+%%
+% Turns newlines into spaces. Based on code from the `titlesec' package.
+
+\DeclareRobustCommand{\@tufte@newlinetospace}{%
+ \@ifstar{\@tufte@newlinetospace@i}{\@tufte@newlinetospace@i}%
+}
+
+\def\@tufte@newlinetospace@i{%
+ \ifdim\lastskip>\z@\else\space\fi
+ \ignorespaces%
+}
+
+\DeclareRobustCommand{\newlinetospace}[1]{%
+ \let\@tufte@orig@cr\\% save the original meaning of \\
+ \def\\{\@tufte@newlinetospace}% turn \\ and \\* into \space
+ \let\newline\\% turn \newline into \space
+ #1%
+ \let\\\@tufte@orig@cr% revert to original meaning of \\
+}
+
+
+%%
+% Sets up the running heads and folios.
+
+\RequirePackage{fancyhdr}
+
+% Set the default page style to 'fancy'
+\pagestyle{fancy}
+
+% Set the header/footer width to be the body text block plus the margin
+% note area.
+\AtBeginDocument{%
+ \ifthenelse{\boolean{@tufte@symmetric}}
+ {\fancyhfoffset[LE,RO]{\@tufte@overhang}}
+ {\fancyhfoffset[RE,RO]{\@tufte@overhang}}
+}
+
+% The running heads/feet don't have rules
+\renewcommand{\headrulewidth}{0pt}
+\renewcommand{\footrulewidth}{0pt}
+
+% The 'fancy' page style is the default style for all pages.
+\fancyhf{} % clear header and footer fields
+\ifthenelse{\boolean{@tufte@twoside}}
+ {\fancyhead[LE]{\thepage\quad\smallcaps{\newlinetospace{\plainauthor}}}%
+ \fancyhead[RO]{\smallcaps{\newlinetospace{\plaintitle}}\quad\thepage}}
+ {\fancyhead[RE,RO]{\smallcaps{\newlinetospace{\plaintitle}}\quad\thepage}}
+
+
+% The `plain' page style is used on chapter opening pages.
+% In Tufte's /Beautiful Evidence/ he never puts page numbers at the
+% bottom of pages -- the folios are unexpressed.
+\fancypagestyle{plain}{
+ \fancyhf{} % clear header and footer fields
+ % Uncomment the following five lines of code if you want the opening page
+ % of the chapter to express the folio in the lower outside corner.
+ %\ifthenelse{\boolean{@tufte@twoside}}
+ % {\fancyfoot[LE,RO]{\thepage}}
+ % {\fancyfoot[RE,RO]{\thepage}}
+}
+
+% The `empty' page style suppresses all headers and footers.
+% It's used on title pages and `intentionally blank' pages.
+\fancypagestyle{empty}{
+ \fancyhf{} % clear header and footer fields
+}
+
+
+%%
+% Set raggedright and paragraph indentation for document
+
+\AtBeginDocument{\@tufte@justification}
+
+
+%%
+% Prints the list of class options and their states.
+
+\newcommand{\typeoutbool}[2]{%
+ \ifthenelse{\boolean{#2}}
+ {\typeout{\space\space#1: true}}
+ {\typeout{\space\space#1: false}}
+}
+
+\newcommand{\typeoutstr}[2]{%
+ \typeout{\space\space#1: #2}
+}
+
+\newcommand{\PrintTufteSettings}{%
+ \typeout{-------------------- Tufte-LaTeX settings ----------}
+ \typeout{Class: \@tufte@pkgname}
+ \typeout{}
+ \typeout{Class options:}
+ \typeoutbool{a4paper}{@tufte@afourpaper}
+ \typeoutbool{b5paper}{@tufte@bfivepaper}
+ \typeoutbool{load fonts}{@tufte@loadfonts}
+ \typeoutbool{fully-justified}{@tufte@justified}
+ \typeoutbool{letterspacing}{@tufte@letterspace}
+ \typeoutbool{sans-serif sidenotes}{@tufte@sfsidenotes}
+ \typeoutbool{symmetric margins}{@tufte@symmetric}
+ \typeoutbool{titlepage}{@tufte@titlepage}
+ \typeoutbool{twoside}{@tufte@twoside}
+ \typeoutbool{debug}{@tufte@debug}
+ \typeout{}
+ \typeout{Internal variables:}
+ \typeoutbool{[twoside]}{@twoside}
+ \typeoutbool{pdflatex}{@tufte@pdf}
+ \typeoutbool{xelatex}{@tufte@xetex}
+ \typeout{----------------------------------------------------}
+}
+
+%%
+% Amount of space to skip before \newthought or after title block
+
+\newskip\tufteskipamount
+\tufteskipamount=1.0\baselineskip plus 0.5ex minus 0.2ex
+
+\newcommand{\tuftebreak}{\par\ifdim\lastskip<\tufteskipamount
+ \removelastskip\penalty-100\tufteskip\fi}
+
+\newcommand{\tufteskip}{\vspace\tufteskipamount}
+
+
+%%
+% Produces a full title page
+
+\newcommand{\maketitlepage}[0]{%
+ \cleardoublepage%
+ {%
+ \sffamily%
+ \begin{fullwidth}%
+ \fontsize{18}{20}\selectfont\par\noindent\textcolor{darkgray}{\allcaps{\thanklessauthor}}%
+ \vspace{11.5pc}%
+ \fontsize{36}{40}\selectfont\par\noindent\textcolor{darkgray}{\allcaps{\thanklesstitle}}%
+ \vfill%
+ \fontsize{14}{16}\selectfont\par\noindent\allcaps{\thanklesspublisher}%
+ \end{fullwidth}%
+ }
+ \thispagestyle{empty}%
+ \clearpage%
+}
+
+%%
+% Title block
+
+\renewcommand{\maketitle}{%
+ \newpage
+ \global\@topnum\z@% prevent floats from being placed at the top of the page
+ \begingroup
+ \setlength{\parindent}{0pt}%
+ \setlength{\parskip}{4pt}%
+ \let\@@title\@empty
+ \let\@@author\@empty
+ \let\@@date\@empty
+ \ifthenelse{\boolean{@tufte@sfsidenotes}}{%
+ \gdef\@@title{\sffamily\LARGE\allcaps{\@title}\par}%
+ \gdef\@@author{\sffamily\Large\allcaps{\@author}\par}%
+ \gdef\@@date{\sffamily\Large\allcaps{\@date}\par}%
+ }{%
+ \gdef\@@title{\LARGE\itshape\@title\par}%
+ \gdef\@@author{\Large\itshape\@author\par}%
+ \gdef\@@date{\Large\itshape\@date\par}%
+ }%
+ \@@title
+ \@@author
+ \@@date
+ \endgroup
+ \thispagestyle{plain}% suppress the running head
+ \tuftebreak% add some space before the text begins
+ \@afterindentfalse\@afterheading% suppress indentation of the next paragraph
+}
+
+
+%%
+% Title page (if the `titlepage' option was passed to the tufte-handout
+% class.)
+
+\ifthenelse{\boolean{@tufte@titlepage}}
+ {\renewcommand{\maketitle}{\maketitlepage}}
+ {}
+
+%%
+% When \cleardoublepage is called, produce a blank (empty) page -- i.e.,
+% without headers and footers
+\def\cleardoublepage{\clearpage\if@twoside\ifodd\c@page\else
+ \hbox{}
+ %\vspace*{\fill}
+ %\begin{center}
+ % This page intentionally contains only this sentence.
+ %\end{center}
+ %\vspace{\fill}
+ \thispagestyle{empty}
+ \newpage
+ \if@twocolumn\hbox{}\newpage\fi\fi\fi}
+
+%%
+% Make Tuftian-style section headings and TOC formatting
+
+\titleformat{\chapter}%
+ [display]% shape
+ {\relax\ifthenelse{\NOT\boolean{@tufte@symmetric}}{\begin{fullwidth}}{}}% format applied to label+text
+ {\itshape\huge\thechapter}% label
+ {0pt}% horizontal separation between label and title body
+ {\huge\rmfamily\itshape}% before the title body
+ [\ifthenelse{\NOT\boolean{@tufte@symmetric}}{\end{fullwidth}}{}]% after the title body
+
+\titleformat{\section}%
+ [hang]% shape
+ {\normalfont\Large\itshape}% format applied to label+text
+ {\thesection}% label
+ {1em}% horizontal separation between label and title body
+ {}% before the title body
+ []% after the title body
+
+\titleformat{\subsection}%
+ [hang]% shape
+ {\normalfont\large\itshape}% format applied to label+text
+ {\thesubsection}% label
+ {1em}% horizontal separation between label and title body
+ {}% before the title body
+ []% after the title body
+
+\titleformat{\paragraph}%
+ [runin]% shape
+ {\normalfont\itshape}% format applied to label+text
+ {\theparagraph}% label
+ {1em}% horizontal separation between label and title body
+ {}% before the title body
+ []% after the title body
+
+\titlespacing*{\chapter}{0pt}{50pt}{40pt}
+\titlespacing*{\section}{0pt}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex}
+\titlespacing*{\subsection}{0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus.2ex}
+
+% Subsubsection and following section headings shouldn't be used.
+% See Bringhurst's _The Elements of Typography_, section 4.2.2.
+\renewcommand\subsubsection{%
+ \@tufte@error{\string\subsubsection is undefined by this class.
+ See Robert Bringhurst's _The Elements of
+ Typographic Style_, section 4.2.2.
+ \string\subsubsection was used}
+ {From Bringhurst's _The Elements of Typographic Style_, section 4.2.2: Use as
+ many levels of headings as you need, no more and no fewer. Also see the many
+ related threads on Ask E.T. at http://www.edwardtufte.com/.}
+}
+
+\renewcommand\subparagraph{%
+ \@tufte@error{\string\subparagraph is undefined by this class.%
+ See Robert Bringhurst's _The Elements of
+ Typographic Style_, section 4.2.2.
+ \string\subparagraph was used}
+ {From Bringhurst's _The Elements of Typographic Style_, section 4.2.2: Use as
+ many levels of headings as you need, no more and no fewer. Also see the many
+ related threads on Ask E.T. at http://www.edwardtufte.com/.}
+}
+
+
+% Formatting for main TOC (printed in front matter)
+% {section} [left] {above} {before w/label} {before w/o label} {filler + page} [after]
+\ifthenelse{\boolean{@tufte@toc}}{%
+ \titlecontents{part}% FIXME
+ [0em] % distance from left margin
+ {\vspace{1.5\baselineskip}\begin{fullwidth}\LARGE\rmfamily\itshape} % above (global formatting of entry)
+ {\contentslabel{2em}} % before w/label (label = ``II'')
+ {} % before w/o label
+ {\rmfamily\upshape\qquad\thecontentspage} % filler + page (leaders and page num)
+ [\end{fullwidth}] % after
+ \titlecontents{chapter}%
+ [0em] % distance from left margin
+ {\vspace{1.5\baselineskip}\begin{fullwidth}\LARGE\rmfamily\itshape} % above (global formatting of entry)
+ {\hspace*{0em}\contentslabel{2em}} % before w/label (label = ``2'')
+ {\hspace*{0em}} % before w/o label
+ {\rmfamily\upshape\qquad\thecontentspage} % filler + page (leaders and page num)
+ [\end{fullwidth}] % after
+ \titlecontents{section}% FIXME
+ [0em] % distance from left margin
+ {\vspace{0\baselineskip}\begin{fullwidth}\Large\rmfamily\itshape} % above (global formatting of entry)
+ {\hspace*{2em}\contentslabel{2em}} % before w/label (label = ``2.6'')
+ {\hspace*{2em}} % before w/o label
+ {\rmfamily\upshape\qquad\thecontentspage} % filler + page (leaders and page num)
+ [\end{fullwidth}] % after
+ \titlecontents{subsection}% FIXME
+ [0em] % distance from left margin
+ {\vspace{0\baselineskip}\begin{fullwidth}\large\rmfamily\itshape} % above (global formatting of entry)
+ {\hspace*{4em}\contentslabel{4em}} % before w/label (label = ``2.6.1'')
+ {\hspace*{4em}} % before w/o label
+ {\rmfamily\upshape\qquad\thecontentspage} % filler + page (leaders and page num)
+ [\end{fullwidth}] % after
+ \titlecontents{paragraph}% FIXME
+ [0em] % distance from left margin
+ {\vspace{0\baselineskip}\begin{fullwidth}\normalsize\rmfamily\itshape} % above (global formatting of entry)
+ {\hspace*{6em}\contentslabel{2em}} % before w/label (label = ``2.6.0.0.1'')
+ {\hspace*{6em}} % before w/o label
+ {\rmfamily\upshape\qquad\thecontentspage} % filler + page (leaders and page num)
+ [\end{fullwidth}] % after
+}{}
+
+%%
+% Format lists of figures/tables
+
+\renewcommand\listoffigures{%
+ \ifthenelse{\equal{\@tufte@class}{book}}%
+ {\chapter*{\listfigurename}}%
+ {\section*{\listfigurename}}%
+% \begin{fullwidth}%
+ \@starttoc{lof}%
+% \end{fullwidth}%
+}
+
+\renewcommand\listoftables{%
+ \ifthenelse{\equal{\@tufte@class}{book}}%
+ {\chapter*{\listtablename}}%
+ {\section*{\listtablename}}%
+% \begin{fullwidth}%
+ \@starttoc{lot}%
+% \end{fullwidth}%
+}
+
+\newcommand{\@tufte@lof@line}[2]{%
+ % #1 is the figure/table number and its caption text
+ % #2 is the page number on which the figure/table appears
+ \leftskip 0.0em
+ \rightskip 0em
+ \parfillskip 0em plus 1fil
+ \parindent 0.0em
+ \@afterindenttrue
+ \interlinepenalty\@M
+ \leavevmode
+ \@tempdima 2.0em
+ \advance\leftskip\@tempdima
+ \null\nobreak\hskip -\leftskip
+ {#1}\nobreak\qquad\nobreak#2%
+ \par%
+}
+
+\renewcommand*\l@figure{\@tufte@lof@line}
+\let\l@table\l@figure
+
+
+%%
+% A handy command to disable hyphenation for short bits of text.
+% Borrowed from Peter Wilson's `hyphenat' package.
+
+\AtBeginDocument{%
+ \@ifpackageloaded{hyphenat}{}{%
+ \newlanguage\langwohyphens% define a language without hyphenation rules
+ \providecommand{\nohyphens}[1]{{\language\langwohyphens #1}}% used for short bits of text
+ \providecommand{\nohyphenation}{\language\langwohyphens}% can be used inside environments for longer text
+ }%
+}
+
+%%
+% Redefine \bibsection to not mark the running heads.
+% (Code modified from natbib.sty.)
+
+\ifthenelse{\boolean{@tufte@loadnatbib}}{%
+ \@ifundefined{chapter}{%
+ \renewcommand\bibsection{\section*{\refname}}%
+ }{%
+ \@ifundefined{NAT@sectionbib}{%
+ \renewcommand\bibsection{\chapter{\bibname}}%
+ }{%
+ \renewcommand\bibsection{\section*{\bibname}}%
+ }%
+ }%
+}
+
+%%
+% An index environment to mimic Tufte's indexes
+
+\RequirePackage{multicol}
+\renewenvironment{theindex}{%
+ \ifthenelse{\equal{\@tufte@class}{book}}%
+ {\chapter{\indexname}}%
+ {\section*{\indexname}}%
+ \begin{fullwidth}%
+ \small%
+ \parskip0pt%
+ \parindent0pt%
+ \let\item\@idxitem%
+ \begin{multicols}{3}%
+}{%
+ \end{multicols}%
+ \end{fullwidth}%
+}
+\renewcommand\@idxitem{\par\hangindent 2em}
+\renewcommand\subitem{\par\hangindent 3em\hspace*{1em}}
+\renewcommand\subsubitem{\par\hangindent 4em\hspace*{2em}}
+\renewcommand\indexspace{\par\addvspace{1.0\baselineskip plus 0.5ex minus 0.2ex}\relax}%
+\newcommand{\lettergroup}[1]{}% swallow the letter heading in the index
+
+
+%%
+% A couple commands to incresae the number of floats you can use at a time.
+
+\def\morefloats{% provides a total of 52 floats
+ \ifthenelse{\isundefined{\bx@S}}{%
+ \@tufte@debug@info@noline{Adding 34 more float slots.}
+ \newinsert\bx@S
+ \newinsert\bx@T
+ \newinsert\bx@U
+ \newinsert\bx@V
+ \newinsert\bx@W
+ \newinsert\bx@X
+ \newinsert\bx@Y
+ \newinsert\bx@Z
+ \newinsert\bx@a
+ \newinsert\bx@b
+ \newinsert\bx@c
+ \newinsert\bx@d
+ \newinsert\bx@e
+ \newinsert\bx@f
+ \newinsert\bx@g
+ \newinsert\bx@h
+ \newinsert\bx@i
+ \newinsert\bx@j
+ \newinsert\bx@k
+ \newinsert\bx@l
+ \newinsert\bx@m
+ \newinsert\bx@n
+ \newinsert\bx@o
+ \newinsert\bx@p
+ \newinsert\bx@q
+ \newinsert\bx@r
+ \newinsert\bx@s
+ \newinsert\bx@t
+ \newinsert\bx@u
+ \newinsert\bx@v
+ \newinsert\bx@w
+ \newinsert\bx@x
+ \newinsert\bx@y
+ \newinsert\bx@z
+ \gdef\@freelist{\@elt\bx@A\@elt\bx@B\@elt\bx@C\@elt\bx@D\@elt\bx@E
+ \@elt\bx@F\@elt\bx@G\@elt\bx@H\@elt\bx@I\@elt\bx@J
+ \@elt\bx@K\@elt\bx@L\@elt\bx@M\@elt\bx@N
+ \@elt\bx@O\@elt\bx@P\@elt\bx@Q\@elt\bx@R
+ \@elt\bx@S\@elt\bx@T\@elt\bx@U\@elt\bx@V
+ \@elt\bx@W\@elt\bx@X\@elt\bx@Y\@elt\bx@Z
+ \@elt\bx@a\@elt\bx@b\@elt\bx@c\@elt\bx@d\@elt\bx@e
+ \@elt\bx@f\@elt\bx@g\@elt\bx@h\@elt\bx@i\@elt\bx@j
+ \@elt\bx@k\@elt\bx@l\@elt\bx@m\@elt\bx@n
+ \@elt\bx@o\@elt\bx@p\@elt\bx@q\@elt\bx@r
+ \@elt\bx@s\@elt\bx@t\@elt\bx@u\@elt\bx@v
+ \@elt\bx@w\@elt\bx@x\@elt\bx@y\@elt\bx@z}%
+ }{% we've already added another 34 floats, so we'll add 26 more, but that's it!
+ \ifthenelse{\isundefined{\bx@AA}}{%
+ \@tufte@debug@info@noline{Adding 26 more float slots.}
+ \newinsert\bx@AA
+ \newinsert\bx@BB
+ \newinsert\bx@CC
+ \newinsert\bx@DD
+ \newinsert\bx@EE
+ \newinsert\bx@FF
+ \newinsert\bx@GG
+ \newinsert\bx@HH
+ \newinsert\bx@II
+ \newinsert\bx@JJ
+ \newinsert\bx@KK
+ \newinsert\bx@LL
+ \newinsert\bx@MM
+ \newinsert\bx@NN
+ \newinsert\bx@OO
+ \newinsert\bx@PP
+ \newinsert\bx@QQ
+ \newinsert\bx@RR
+ \newinsert\bx@SS
+ \newinsert\bx@TT
+ \newinsert\bx@UU
+ \newinsert\bx@VV
+ \newinsert\bx@WW
+ \newinsert\bx@XX
+ \newinsert\bx@YY
+ \newinsert\bx@ZZ
+ \gdef\@freelist{\@elt\bx@A\@elt\bx@B\@elt\bx@C\@elt\bx@D\@elt\bx@E
+ \@elt\bx@F\@elt\bx@G\@elt\bx@H\@elt\bx@I\@elt\bx@J
+ \@elt\bx@K\@elt\bx@L\@elt\bx@M\@elt\bx@N
+ \@elt\bx@O\@elt\bx@P\@elt\bx@Q\@elt\bx@R
+ \@elt\bx@S\@elt\bx@T\@elt\bx@U\@elt\bx@V
+ \@elt\bx@W\@elt\bx@X\@elt\bx@Y\@elt\bx@Z
+ \@elt\bx@a\@elt\bx@b\@elt\bx@c\@elt\bx@d\@elt\bx@e
+ \@elt\bx@f\@elt\bx@g\@elt\bx@h\@elt\bx@i\@elt\bx@j
+ \@elt\bx@k\@elt\bx@l\@elt\bx@m\@elt\bx@n
+ \@elt\bx@o\@elt\bx@p\@elt\bx@q\@elt\bx@r
+ \@elt\bx@s\@elt\bx@t\@elt\bx@u\@elt\bx@v
+ \@elt\bx@w\@elt\bx@x\@elt\bx@y\@elt\bx@z
+ \@elt\bx@AA\@elt\bx@BB\@elt\bx@CC\@elt\bx@DD\@elt\bx@EE
+ \@elt\bx@FF\@elt\bx@GG\@elt\bx@HH\@elt\bx@II\@elt\bx@JJ
+ \@elt\bx@KK\@elt\bx@LL\@elt\bx@MM\@elt\bx@NN
+ \@elt\bx@OO\@elt\bx@PP\@elt\bx@QQ\@elt\bx@RR
+ \@elt\bx@SS\@elt\bx@TT\@elt\bx@UU\@elt\bx@VV
+ \@elt\bx@WW\@elt\bx@XX\@elt\bx@YY\@elt\bx@ZZ}%
+ }{%
+ \@tufte@error{You may only call \string\morefloats\space twice. See the Tufte-LaTeX documentation for other workarounds}
+ {There are already 78 float slots allocated. Try using \string\FloatBarrier\space or \string\clearpage\space to place some floats before creating more.}
+ }%
+ }%
+}
+
+
+%%
+% Detect if the subfigure package has been loaded
+
+\newboolean{@tufte@packages@subfigure}
+\setboolean{@tufte@packages@subfigure}{false}
+\AtBeginDocument{%
+ \@ifpackageloaded{subfigure}
+ {\gsetboolean{@tufte@packages@subfigure}{true}}
+ {\gsetboolean{@tufte@packages@subfigure}{false}}%
+}
+
+
+%%
+% Detect of the float package has been loaded
+
+\AtBeginDocument{%
+ \@ifpackageloaded{float}{%
+ % Save the redefined float environment (instead of the LaTeX float environment)
+ \let\@tufte@orig@float\@float
+ \let\@tufte@orig@endfloat\end@float
+
+ % Define Tuftian float styles (with the caption in the margin)
+ \newcommand{\floatc@tufteplain}[2]{%
+ \begin{lrbox}{\@tufte@caption@box}%
+ \begin{minipage}[\floatalignment]{\marginparwidth}\hbox{}%
+ \@tufte@caption@font{\@fs@cfont #1:} #2\par%
+ \end{minipage}%
+ \end{lrbox}%
+ \smash{\hspace{\@tufte@caption@fill}\usebox{\@tufte@caption@box}}%
+ }
+ \newcommand{\fs@tufteplain}{%
+ \def\@fs@cfont{\@tufte@caption@font}%
+ \let\@fs@capt\floatc@tufteplain%
+ \def\@fs@pre{}%
+ \def\@fs@post{}%
+ \def\@fs@mid{}%
+ \let\@fs@iftopcapt\iftrue%
+ }
+ \let\fs@tufteplaintop=\fs@tufteplain
+ \let\floatc@tufteplaintop=\floatc@tufteplain
+ \newcommand\floatc@tufteruled[2]{%
+ {\@fs@cfont #1} #2\par%
+ }
+ \newcommand\fs@tufteruled{%
+ \def\@fs@cfont{\@tufte@caption@font}%
+ \let\@fs@capt\floatc@tufteplain%
+ \def\@fs@pre{\hrule height.8pt depth0pt width\textwidth \kern2pt}%
+ \def\@fs@post{\kern2pt\hrule width\textwidth\relax}%
+ \def\@fs@mid{}%
+ \let\@fs@iftopcapt\iftrue%
+ }
+ \newcommand\fs@tufteboxed{%
+ \def\@fs@cfont{}%
+ \let\@fs@capt\floatc@tufteplain%
+ \def\@fs@pre{%
+ \setbox\@currbox\vbox{\hbadness10000
+ \moveleft3.4pt\vbox{\advance\hsize by6.8pt
+ \hrule \hbox to\hsize{\vrule\kern3pt
+ \vbox{\kern3pt\box\@currbox\kern3pt}\kern3pt\vrule}\hrule}}
+ }%
+ \def\@fs@mid{\kern2pt}%
+ \def\@fs@post{}%
+ \let\@fs@iftopcapt\iftrue%
+ }
+ }{%
+ % Nothing to do
+ }
+}
+
+\AtBeginDocument{%
+ \@ifpackageloaded{algorithm}{%
+ % Set the float style to the Tuftian version
+ \ifthenelse{\equal{\ALG@floatstyle}{plain}\OR\equal{\ALG@floatstyle}{ruled}\OR\equal{\ALG@floatstyle}{boxed}}{%
+ \@tufte@info@noline{Switching algorithm float style from \ALG@floatstyle\space to tufte\ALG@floatstyle}%
+ \floatstyle{tufte\ALG@floatstyle}%
+ \restylefloat{algorithm}%
+ }{}%
+ }{%
+ % Nothing to do
+ }
+}
+
+
+%%
+% For compatibility with the subfig package, we'll set captions=false so that
+% it doesn't load the caption package (which modifies our own caption
+% formatting).
+
+\PassOptionsToPackage{caption=false}{subfig}
+
+
+%%
+% If debugging is enabled, print the Tufte-LaTeX options and the list of
+% files.
+
+\ifthenelse{\boolean{@tufte@debug}}
+ {\PrintTufteSettings\listfiles}
+ {}
+
+
+%%
+% If there is a `tufte-common-local.tex' file, load it up.
+
+\IfFileExists{tufte-common-local.tex}
+ {\input{tufte-common-local.tex}%
+ \@tufte@info@noline{Loading tufte-common-local.tex}}
+ {}
+
+
+%%
+% End of file
+\endinput
+
diff --git a/macros/latex/contrib/tufte-latex/tufte-handout.cls b/macros/latex/contrib/tufte-latex/tufte-handout.cls
new file mode 100644
index 0000000000..2ad43c5a69
--- /dev/null
+++ b/macros/latex/contrib/tufte-latex/tufte-handout.cls
@@ -0,0 +1,39 @@
+\NeedsTeXFormat{LaTeX2e}[1994/06/01]
+
+\ProvidesClass{tufte-handout}[2015/06/21 v3.5.2 Tufte-handout class]
+
+%%
+% Declare we're tufte-handout
+\newcommand{\@tufte@class}{article}% the base LaTeX class (defaults to the article/handout style)
+\newcommand{\@tufte@pkgname}{tufte-handout}% the name of the package (defaults to tufte-handout)
+
+%%
+% Load the common style elements
+\input{tufte-common.def}
+
+
+%%
+% Set up any handout-specific stuff now
+
+%%
+% Abstract
+
+% TODO The abstract should be printed on its own page of the `titlepage'
+% option was specified.
+\renewenvironment{abstract}
+ {\begin{quotation}\if@tufte@sfsidenotes\begin{sffamily}\fi}
+ {\if@tufte@sfsidenotes\end{sffamily}\fi\end{quotation}}
+
+
+%%
+% If there is a `tufte-handout-local.tex' file, load it.
+
+\IfFileExists{tufte-handout-local.tex}{%
+ \input{tufte-handout-local}%
+ \@tufte@info@noline{Loading tufte-handout-local.tex}%
+}{}
+
+
+%%
+% End of file
+\endinput
diff --git a/macros/latex/contrib/tufte-latex/tufte.bst b/macros/latex/contrib/tufte-latex/tufte.bst
new file mode 100644
index 0000000000..ee0c26bfcc
--- /dev/null
+++ b/macros/latex/contrib/tufte-latex/tufte.bst
@@ -0,0 +1,1314 @@
+%%
+%% This is file `tufte.bst',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% 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')
+%% ----------------------------------------
+%% *** tufte handout bibliography style ***
+%%
+%% Copyright 1994-2002 Patrick W Daly
+ % ===============================================================
+ % IMPORTANT NOTICE:
+ % This bibliographic style (bst) file has been generated from one or
+ % more master bibliographic style (mbs) files, listed above.
+ %
+ % This generated file can be redistributed and/or modified under the terms
+ % of the LaTeX Project Public License Distributed from CTAN
+ % archives in directory macros/latex/base/lppl.txt; either
+ % version 1 of the License, or any later version.
+ % ===============================================================
+ % Name and version information of the main mbs file:
+ % \ProvidesFile{merlin.mbs}[2002/10/21 4.05 (PWD, AO, DPC)]
+ % For use with BibTeX version 0.99a or later
+ %-------------------------------------------------------------------
+ % This bibliography style file is intended for texts in ENGLISH
+ % This is a numerical citation style, and as such is standard LaTeX.
+ % It requires no extra package to interface to the main text.
+ % The form of the \bibitem entries is
+ % \bibitem{key}...
+ % Usage of \cite is as follows:
+ % \cite{key} ==>> [#]
+ % \cite[chap. 2]{key} ==>> [#, chap. 2]
+ % where # is a number determined by the ordering in the reference list.
+ % The order in the reference list is that by which the works were originally
+ % cited in the text, or that in the database.
+ %---------------------------------------------------------------------
+
+ENTRY
+ { address
+ author
+ booktitle
+ chapter
+ edition
+ editor
+ howpublished
+ institution
+ journal
+ key
+ month
+ note
+ number
+ organization
+ pages
+ publisher
+ school
+ series
+ title
+ type
+ url
+ volume
+ year
+ }
+ {}
+ { label }
+INTEGERS { output.state before.all mid.sentence after.sentence after.block }
+FUNCTION {init.state.consts}
+{ #0 'before.all :=
+ #1 'mid.sentence :=
+ #2 'after.sentence :=
+ #3 'after.block :=
+}
+STRINGS { s t}
+FUNCTION {output.nonnull}
+{ 's :=
+ output.state mid.sentence =
+ { ", " * write$ }
+ { output.state after.block =
+ { add.period$ write$
+ newline$
+ "\newblock " write$
+ }
+ { output.state before.all =
+ 'write$
+ { add.period$ " " * write$ }
+ if$
+ }
+ if$
+ mid.sentence 'output.state :=
+ }
+ if$
+ s
+}
+FUNCTION {output}
+{ duplicate$ empty$
+ 'pop$
+ 'output.nonnull
+ if$
+}
+FUNCTION {output.check}
+{ 't :=
+ duplicate$ empty$
+ { pop$ "empty " t * " in " * cite$ * warning$ }
+ 'output.nonnull
+ if$
+}
+FUNCTION {fin.entry}
+{ add.period$
+ write$
+ newline$
+}
+
+FUNCTION {new.block}
+{ output.state before.all =
+ 'skip$
+ { after.block 'output.state := }
+ if$
+}
+FUNCTION {new.sentence}
+{ output.state after.block =
+ 'skip$
+ { output.state before.all =
+ 'skip$
+ { after.sentence 'output.state := }
+ if$
+ }
+ if$
+}
+FUNCTION {add.blank}
+{ " " * before.all 'output.state :=
+}
+
+FUNCTION {date.block}
+{
+ skip$
+}
+
+FUNCTION {not}
+{ { #0 }
+ { #1 }
+ if$
+}
+FUNCTION {and}
+{ 'skip$
+ { pop$ #0 }
+ if$
+}
+FUNCTION {or}
+{ { pop$ #1 }
+ 'skip$
+ if$
+}
+FUNCTION {non.stop}
+{ duplicate$
+ "}" * add.period$
+ #-1 #1 substring$ "." =
+}
+
+STRINGS {z}
+FUNCTION {remove.dots}
+{ 'z :=
+ ""
+ { z empty$ not }
+ { z #1 #1 substring$
+ z #2 global.max$ substring$ 'z :=
+ duplicate$ "." = 'pop$
+ { * }
+ if$
+ }
+ while$
+}
+FUNCTION {new.block.checka}
+{ empty$
+ 'skip$
+ 'new.block
+ if$
+}
+FUNCTION {new.block.checkb}
+{ empty$
+ swap$ empty$
+ and
+ 'skip$
+ 'new.block
+ if$
+}
+FUNCTION {new.sentence.checka}
+{ empty$
+ 'skip$
+ 'new.sentence
+ if$
+}
+FUNCTION {new.sentence.checkb}
+{ empty$
+ swap$ empty$
+ and
+ 'skip$
+ 'new.sentence
+ if$
+}
+FUNCTION {field.or.null}
+{ duplicate$ empty$
+ { pop$ "" }
+ 'skip$
+ if$
+}
+FUNCTION {emphasize}
+{ duplicate$ empty$
+ { pop$ "" }
+ { "\emph{" swap$ * "}" * }
+ if$
+}
+FUNCTION {tie.or.space.prefix}
+{ duplicate$ text.length$ #3 <
+ { "~" }
+ { " " }
+ if$
+ swap$
+}
+
+FUNCTION {capitalize}
+{ "u" change.case$ "t" change.case$ }
+
+FUNCTION {space.word}
+{ " " swap$ * " " * }
+ % Here are the language-specific definitions for explicit words.
+ % Each function has a name bbl.xxx where xxx is the English word.
+ % The language selected here is ENGLISH
+FUNCTION {bbl.and}
+{ "and"}
+
+FUNCTION {bbl.etal}
+{ "et~al." }
+
+FUNCTION {bbl.editors}
+{ "eds." }
+
+FUNCTION {bbl.editor}
+{ "ed." }
+
+FUNCTION {bbl.edby}
+{ "edited by" }
+
+FUNCTION {bbl.edition}
+{ "edn." }
+
+FUNCTION {bbl.volume}
+{ "vol." }
+
+FUNCTION {bbl.of}
+{ "of" }
+
+FUNCTION {bbl.number}
+{ "no." }
+
+FUNCTION {bbl.nr}
+{ "no." }
+
+FUNCTION {bbl.in}
+{ "in" }
+
+FUNCTION {bbl.pages}
+{ "pp." }
+
+FUNCTION {bbl.page}
+{ "p." }
+
+FUNCTION {bbl.chapter}
+{ "chap." }
+
+FUNCTION {bbl.techrep}
+{ "Tech. Rep." }
+
+FUNCTION {bbl.mthesis}
+{ "Master's thesis" }
+
+FUNCTION {bbl.phdthesis}
+{ "Ph.D. thesis" }
+
+FUNCTION {bbl.first}
+{ "1st" }
+
+FUNCTION {bbl.second}
+{ "2nd" }
+
+FUNCTION {bbl.third}
+{ "3rd" }
+
+FUNCTION {bbl.fourth}
+{ "4th" }
+
+FUNCTION {bbl.fifth}
+{ "5th" }
+
+FUNCTION {bbl.st}
+{ "st" }
+
+FUNCTION {bbl.nd}
+{ "nd" }
+
+FUNCTION {bbl.rd}
+{ "rd" }
+
+FUNCTION {bbl.th}
+{ "th" }
+
+MACRO {jan} {"Jan."}
+
+MACRO {feb} {"Feb."}
+
+MACRO {mar} {"Mar."}
+
+MACRO {apr} {"Apr."}
+
+MACRO {may} {"May"}
+
+MACRO {jun} {"Jun."}
+
+MACRO {jul} {"Jul."}
+
+MACRO {aug} {"Aug."}
+
+MACRO {sep} {"Sep."}
+
+MACRO {oct} {"Oct."}
+
+MACRO {nov} {"Nov."}
+
+MACRO {dec} {"Dec."}
+
+FUNCTION {eng.ord}
+{ duplicate$ "1" swap$ *
+ #-2 #1 substring$ "1" =
+ { bbl.th * }
+ { duplicate$ #-1 #1 substring$
+ duplicate$ "1" =
+ { pop$ bbl.st * }
+ { duplicate$ "2" =
+ { pop$ bbl.nd * }
+ { "3" =
+ { bbl.rd * }
+ { bbl.th * }
+ if$
+ }
+ if$
+ }
+ if$
+ }
+ if$
+}
+
+MACRO {acmcs} {"ACM Computing Surveys"}
+
+MACRO {acta} {"Acta Informatica"}
+
+MACRO {cacm} {"Communications of the ACM"}
+
+MACRO {ibmjrd} {"IBM Journal of Research and Development"}
+
+MACRO {ibmsj} {"IBM Systems Journal"}
+
+MACRO {ieeese} {"IEEE Transactions on Software Engineering"}
+
+MACRO {ieeetc} {"IEEE Transactions on Computers"}
+
+MACRO {ieeetcad}
+ {"IEEE Transactions on Computer-Aided Design of Integrated Circuits"}
+
+MACRO {ipl} {"Information Processing Letters"}
+
+MACRO {jacm} {"Journal of the ACM"}
+
+MACRO {jcss} {"Journal of Computer and System Sciences"}
+
+MACRO {scp} {"Science of Computer Programming"}
+
+MACRO {sicomp} {"SIAM Journal on Computing"}
+
+MACRO {tocs} {"ACM Transactions on Computer Systems"}
+
+MACRO {tods} {"ACM Transactions on Database Systems"}
+
+MACRO {tog} {"ACM Transactions on Graphics"}
+
+MACRO {toms} {"ACM Transactions on Mathematical Software"}
+
+MACRO {toois} {"ACM Transactions on Office Information Systems"}
+
+MACRO {toplas} {"ACM Transactions on Programming Languages and Systems"}
+
+MACRO {tcs} {"Theoretical Computer Science"}
+FUNCTION {bibinfo.check}
+{ swap$
+ duplicate$ missing$
+ {
+ pop$ pop$
+ ""
+ }
+ { duplicate$ empty$
+ {
+ swap$ pop$
+ }
+ { swap$
+ pop$
+ }
+ if$
+ }
+ if$
+}
+FUNCTION {bibinfo.warn}
+{ swap$
+ duplicate$ missing$
+ {
+ swap$ "missing " swap$ * " in " * cite$ * warning$ pop$
+ ""
+ }
+ { duplicate$ empty$
+ {
+ swap$ "empty " swap$ * " in " * cite$ * warning$
+ }
+ { swap$
+ pop$
+ }
+ if$
+ }
+ if$
+}
+FUNCTION {format.url}
+{ url empty$
+ { "" }
+ { "\urlprefix\url{" url * "}" * }
+ if$
+}
+
+STRINGS { bibinfo}
+INTEGERS { nameptr namesleft numnames }
+
+FUNCTION {format.names}
+{ 'bibinfo :=
+ duplicate$ empty$ 'skip$ {
+ 's :=
+ "" 't :=
+ #1 'nameptr :=
+ s num.names$ 'numnames :=
+ numnames 'namesleft :=
+ { namesleft #0 > }
+ { s nameptr
+ "{ff~}{vv~}{ll}{, jj}"
+ format.name$
+ bibinfo bibinfo.check
+ 't :=
+ nameptr #1 >
+ {
+ nameptr #1
+ #1 + =
+ numnames #2
+ > and
+ { "others" 't :=
+ #1 'namesleft := }
+ 'skip$
+ if$
+ namesleft #1 >
+ { ", " * t * }
+ {
+ numnames #2 >
+ { "," * }
+ 'skip$
+ if$
+ s nameptr "{ll}" format.name$ duplicate$ "others" =
+ { 't := }
+ { pop$ }
+ if$
+ t "others" =
+ {
+ " " * bbl.etal *
+ }
+ {
+ bbl.and
+ space.word * t *
+ }
+ if$
+ }
+ if$
+ }
+ 't
+ if$
+ nameptr #1 + 'nameptr :=
+ namesleft #1 - 'namesleft :=
+ }
+ while$
+ } if$
+}
+FUNCTION {format.names.ed}
+{
+ format.names
+}
+FUNCTION {format.authors}
+{ author "author" format.names
+}
+FUNCTION {get.bbl.editor}
+{ editor num.names$ #1 > 'bbl.editors 'bbl.editor if$ }
+
+FUNCTION {format.editors}
+{ editor "editor" format.names duplicate$ empty$ 'skip$
+ {
+ " " *
+ get.bbl.editor
+ "(" swap$ * ")" *
+ *
+ }
+ if$
+}
+FUNCTION {format.note}
+{
+ note empty$
+ { "" }
+ { note #1 #1 substring$
+ duplicate$ "{" =
+ 'skip$
+ { output.state mid.sentence =
+ { "l" }
+ { "u" }
+ if$
+ change.case$
+ }
+ if$
+ note #2 global.max$ substring$ * "note" bibinfo.check
+ }
+ if$
+}
+
+FUNCTION {format.title}
+{ title
+ "title" bibinfo.check
+ duplicate$ empty$ 'skip$
+ {
+ "\enquote{" swap$ *
+ "}, " *
+ }
+ if$
+}
+FUNCTION {end.quote.title}
+{ title empty$
+ 'skip$
+ { before.all 'output.state := }
+ if$
+}
+FUNCTION {output.bibitem}
+{ newline$
+ "\bibitem{" write$
+ cite$ write$
+ "}" write$
+ newline$
+ ""
+ before.all 'output.state :=
+}
+
+FUNCTION {n.dashify}
+{
+ 't :=
+ ""
+ { t empty$ not }
+ { t #1 #1 substring$ "-" =
+ { t #1 #2 substring$ "--" = not
+ { "--" *
+ t #2 global.max$ substring$ 't :=
+ }
+ { { t #1 #1 substring$ "-" = }
+ { "-" *
+ t #2 global.max$ substring$ 't :=
+ }
+ while$
+ }
+ if$
+ }
+ { t #1 #1 substring$ *
+ t #2 global.max$ substring$ 't :=
+ }
+ if$
+ }
+ while$
+}
+
+FUNCTION {word.in}
+{ bbl.in
+ " " * }
+
+FUNCTION {format.date}
+{
+ ""
+ duplicate$ empty$
+ year "year" bibinfo.check duplicate$ empty$
+ { swap$ 'skip$
+ { "there's a month but no year in " cite$ * warning$ }
+ if$
+ *
+ }
+ { swap$ 'skip$
+ {
+ swap$
+ " " * swap$
+ }
+ if$
+ *
+ }
+ if$
+ duplicate$ empty$
+ 'skip$
+ {
+ before.all 'output.state :=
+ ", " swap$ *
+ }
+ if$
+}
+FUNCTION {format.btitle}
+{ title "title" bibinfo.check
+ duplicate$ empty$ 'skip$
+ {
+ emphasize
+ }
+ if$
+}
+FUNCTION {either.or.check}
+{ empty$
+ 'pop$
+ { "can't use both " swap$ * " fields in " * cite$ * warning$ }
+ if$
+}
+FUNCTION {format.bvolume}
+{ volume empty$
+ { "" }
+ { bbl.volume volume tie.or.space.prefix
+ "volume" bibinfo.check * *
+ series "series" bibinfo.check
+ duplicate$ empty$ 'pop$
+ { swap$ bbl.of space.word * swap$
+ emphasize * }
+ if$
+ "volume and number" number either.or.check
+ }
+ if$
+}
+FUNCTION {format.number.series}
+{ volume empty$
+ { number empty$
+ { series field.or.null }
+ { series empty$
+ { number "number" bibinfo.check }
+ { output.state mid.sentence =
+ { bbl.number }
+ { bbl.number capitalize }
+ if$
+ number tie.or.space.prefix "number" bibinfo.check * *
+ bbl.in space.word *
+ series "series" bibinfo.check *
+ }
+ if$
+ }
+ if$
+ }
+ { "" }
+ if$
+}
+FUNCTION {is.num}
+{ chr.to.int$
+ duplicate$ "0" chr.to.int$ < not
+ swap$ "9" chr.to.int$ > not and
+}
+
+FUNCTION {extract.num}
+{ duplicate$ 't :=
+ "" 's :=
+ { t empty$ not }
+ { t #1 #1 substring$
+ t #2 global.max$ substring$ 't :=
+ duplicate$ is.num
+ { s swap$ * 's := }
+ { pop$ "" 't := }
+ if$
+ }
+ while$
+ s empty$
+ 'skip$
+ { pop$ s }
+ if$
+}
+
+FUNCTION {convert.edition}
+{ extract.num "l" change.case$ 's :=
+ s "first" = s "1" = or
+ { bbl.first 't := }
+ { s "second" = s "2" = or
+ { bbl.second 't := }
+ { s "third" = s "3" = or
+ { bbl.third 't := }
+ { s "fourth" = s "4" = or
+ { bbl.fourth 't := }
+ { s "fifth" = s "5" = or
+ { bbl.fifth 't := }
+ { s #1 #1 substring$ is.num
+ { s eng.ord 't := }
+ { edition 't := }
+ if$
+ }
+ if$
+ }
+ if$
+ }
+ if$
+ }
+ if$
+ }
+ if$
+ t
+}
+
+FUNCTION {format.edition}
+{ edition duplicate$ empty$ 'skip$
+ {
+ convert.edition
+ output.state mid.sentence =
+ { "l" }
+ { "t" }
+ if$ change.case$
+ "edition" bibinfo.check
+ " " * bbl.edition *
+ }
+ if$
+}
+INTEGERS { multiresult }
+FUNCTION {multi.page.check}
+{ 't :=
+ #0 'multiresult :=
+ { multiresult not
+ t empty$ not
+ and
+ }
+ { t #1 #1 substring$
+ duplicate$ "-" =
+ swap$ duplicate$ "," =
+ swap$ "+" =
+ or or
+ { #1 'multiresult := }
+ { t #2 global.max$ substring$ 't := }
+ if$
+ }
+ while$
+ multiresult
+}
+FUNCTION {format.pages}
+{ pages duplicate$ empty$ 'skip$
+ { duplicate$ multi.page.check
+ {
+ bbl.pages swap$
+ n.dashify
+ }
+ {
+ bbl.page swap$
+ }
+ if$
+ tie.or.space.prefix
+ "pages" bibinfo.check
+ * *
+ }
+ if$
+}
+FUNCTION {format.journal.pages}
+{ pages duplicate$ empty$ 'pop$
+ { swap$ duplicate$ empty$
+ { pop$ pop$ format.pages }
+ {
+ ", " *
+ swap$
+ n.dashify
+ pages multi.page.check
+ 'bbl.pages
+ 'bbl.page
+ if$
+ swap$ tie.or.space.prefix
+ "pages" bibinfo.check
+ * *
+ *
+ }
+ if$
+ }
+ if$
+}
+FUNCTION {format.vol.num.pages}
+{ volume field.or.null
+ duplicate$ empty$ 'skip$
+ {
+ "volume" bibinfo.check
+ }
+ if$
+ number "number" bibinfo.check duplicate$ empty$ 'skip$
+ {
+ swap$ duplicate$ empty$
+ { "there's a number but no volume in " cite$ * warning$ }
+ 'skip$
+ if$
+ swap$
+ "(" swap$ * ")" *
+ }
+ if$ *
+}
+
+FUNCTION {format.chapter.pages}
+{ chapter empty$
+ { "" }
+ { type empty$
+ { bbl.chapter }
+ { type "l" change.case$
+ "type" bibinfo.check
+ }
+ if$
+ chapter tie.or.space.prefix
+ "chapter" bibinfo.check
+ * *
+ }
+ if$
+}
+
+FUNCTION {format.booktitle}
+{
+ booktitle "booktitle" bibinfo.check
+ emphasize
+}
+FUNCTION {format.in.ed.booktitle}
+{ format.booktitle duplicate$ empty$ 'skip$
+ {
+ editor "editor" format.names.ed duplicate$ empty$ 'pop$
+ {
+ bbl.edby
+ " " * swap$ *
+ swap$
+ "," *
+ " " * swap$
+ * }
+ if$
+ word.in swap$ *
+ }
+ if$
+}
+FUNCTION {empty.misc.check}
+{ author empty$ title empty$ howpublished empty$
+ month empty$ year empty$ note empty$
+ and and and and and
+ { "all relevant fields are empty in " cite$ * warning$ }
+ 'skip$
+ if$
+}
+FUNCTION {format.thesis.type}
+{ type duplicate$ empty$
+ 'pop$
+ { swap$ pop$
+ "t" change.case$ "type" bibinfo.check
+ }
+ if$
+}
+FUNCTION {format.tr.number}
+{ number "number" bibinfo.check
+ type duplicate$ empty$
+ { pop$ bbl.techrep }
+ 'skip$
+ if$
+ "type" bibinfo.check
+ swap$ duplicate$ empty$
+ { pop$ "t" change.case$ }
+ { tie.or.space.prefix * * }
+ if$
+}
+FUNCTION {format.article.crossref}
+{
+ key duplicate$ empty$
+ { pop$
+ journal duplicate$ empty$
+ { "need key or journal for " cite$ * " to crossref " * crossref * warning$ }
+ { "journal" bibinfo.check emphasize word.in swap$ * }
+ if$
+ }
+ { word.in swap$ * " " *}
+ if$
+ " \cite{" * crossref * "}" *
+}
+FUNCTION {format.crossref.editor}
+{ editor #1 "{vv~}{ll}" format.name$
+ "editor" bibinfo.check
+ editor num.names$ duplicate$
+ #2 >
+ { pop$
+ "editor" bibinfo.check
+ " " * bbl.etal
+ *
+ }
+ { #2 <
+ 'skip$
+ { editor #2 "{ff }{vv }{ll}{ jj}" format.name$ "others" =
+ {
+ "editor" bibinfo.check
+ " " * bbl.etal
+ *
+ }
+ {
+ bbl.and space.word
+ * editor #2 "{vv~}{ll}" format.name$
+ "editor" bibinfo.check
+ *
+ }
+ if$
+ }
+ if$
+ }
+ if$
+}
+FUNCTION {format.book.crossref}
+{ volume duplicate$ empty$
+ { "empty volume in " cite$ * "'s crossref of " * crossref * warning$
+ pop$ word.in
+ }
+ { bbl.volume
+ swap$ tie.or.space.prefix "volume" bibinfo.check * * bbl.of space.word *
+ }
+ if$
+ editor empty$
+ editor field.or.null author field.or.null =
+ or
+ { key empty$
+ { series empty$
+ { "need editor, key, or series for " cite$ * " to crossref " *
+ crossref * warning$
+ "" *
+ }
+ { series emphasize * }
+ if$
+ }
+ { key * }
+ if$
+ }
+ { format.crossref.editor * }
+ if$
+ " \cite{" * crossref * "}" *
+}
+FUNCTION {format.incoll.inproc.crossref}
+{
+ editor empty$
+ editor field.or.null author field.or.null =
+ or
+ { key empty$
+ { format.booktitle duplicate$ empty$
+ { "need editor, key, or booktitle for " cite$ * " to crossref " *
+ crossref * warning$
+ }
+ { word.in swap$ * }
+ if$
+ }
+ { word.in key * " " *}
+ if$
+ }
+ { word.in format.crossref.editor * " " *}
+ if$
+ " \cite{" * crossref * "}" *
+}
+FUNCTION {format.org.or.pub}
+{ 't :=
+ ""
+ address empty$ t empty$ and
+ 'skip$
+ {
+ t empty$
+ { address "address" bibinfo.check *
+ }
+ { t *
+ address empty$
+ 'skip$
+ { ", " * address "address" bibinfo.check * }
+ if$
+ }
+ if$
+ }
+ if$
+}
+FUNCTION {format.publisher.address}
+{ publisher "publisher" bibinfo.warn format.org.or.pub
+}
+
+FUNCTION {format.organization.address}
+{ organization "organization" bibinfo.check format.org.or.pub
+}
+
+FUNCTION {article}
+{ output.bibitem
+ format.authors "author" output.check
+ format.title "title" output.check
+ end.quote.title
+ crossref missing$
+ {
+ journal
+ remove.dots
+ "journal" bibinfo.check
+ emphasize
+ "journal" output.check
+ format.vol.num.pages output
+ format.date "year" output.check
+ }
+ { format.article.crossref output.nonnull
+ }
+ if$
+ format.journal.pages
+ format.url output
+ format.note output
+ fin.entry
+}
+FUNCTION {book}
+{ output.bibitem
+ author empty$
+ { format.editors "author and editor" output.check
+ }
+ { format.authors output.nonnull
+ crossref missing$
+ { "author and editor" editor either.or.check }
+ 'skip$
+ if$
+ }
+ if$
+ format.btitle "title" output.check
+ crossref missing$
+ { format.bvolume output
+ format.number.series output
+ format.publisher.address output
+ }
+ {
+ format.book.crossref output.nonnull
+ }
+ if$
+ format.edition output
+ format.date "year" output.check
+ format.url output
+ format.note output
+ fin.entry
+}
+FUNCTION {booklet}
+{ output.bibitem
+ format.authors output
+ format.title "title" output.check
+ end.quote.title
+ howpublished "howpublished" bibinfo.check output
+ address "address" bibinfo.check output
+ format.date output
+ format.url output
+ format.note output
+ fin.entry
+}
+
+FUNCTION {inbook}
+{ output.bibitem
+ author empty$
+ { format.editors "author and editor" output.check
+ }
+ { format.authors output.nonnull
+ crossref missing$
+ { "author and editor" editor either.or.check }
+ 'skip$
+ if$
+ }
+ if$
+ format.btitle "title" output.check
+ crossref missing$
+ {
+ format.publisher.address output
+ format.bvolume output
+ format.chapter.pages "chapter and pages" output.check
+ format.number.series output
+ }
+ {
+ format.chapter.pages "chapter and pages" output.check
+ format.book.crossref output.nonnull
+ }
+ if$
+ format.edition output
+ format.date "year" output.check
+ format.pages "pages" output.check
+ format.url output
+ format.note output
+ fin.entry
+}
+
+FUNCTION {incollection}
+{ output.bibitem
+ format.authors "author" output.check
+ format.title "title" output.check
+ end.quote.title
+ crossref missing$
+ { format.in.ed.booktitle "booktitle" output.check
+ format.publisher.address output
+ format.bvolume output
+ format.number.series output
+ format.chapter.pages output
+ format.edition output
+ format.date "year" output.check
+ }
+ { format.incoll.inproc.crossref output.nonnull
+ format.chapter.pages output
+ }
+ if$
+ format.pages "pages" output.check
+ format.url output
+ format.note output
+ fin.entry
+}
+FUNCTION {inproceedings}
+{ output.bibitem
+ format.authors "author" output.check
+ format.title "title" output.check
+ end.quote.title
+ crossref missing$
+ { format.in.ed.booktitle "booktitle" output.check
+ publisher empty$
+ { format.organization.address output }
+ { organization "organization" bibinfo.check output
+ format.publisher.address output
+ }
+ if$
+ format.date "year" output.check
+ format.bvolume output
+ format.number.series output
+ }
+ { format.incoll.inproc.crossref output.nonnull
+ }
+ if$
+ format.pages "pages" output.check
+ format.url output
+ format.note output
+ fin.entry
+}
+FUNCTION {conference} { inproceedings }
+FUNCTION {manual}
+{ output.bibitem
+ author empty$
+ { organization "organization" bibinfo.check
+ duplicate$ empty$ 'pop$
+ { output
+ address "address" bibinfo.check output
+ }
+ if$
+ }
+ { format.authors output.nonnull }
+ if$
+ format.btitle "title" output.check
+ author empty$
+ { organization empty$
+ {
+ address "address" bibinfo.check output
+ }
+ 'skip$
+ if$
+ }
+ {
+ organization "organization" bibinfo.check output
+ address "address" bibinfo.check output
+ }
+ if$
+ format.edition output
+ format.date output
+ format.url output
+ format.note output
+ fin.entry
+}
+
+FUNCTION {mastersthesis}
+{ output.bibitem
+ format.authors "author" output.check
+ format.btitle
+ "title" output.check
+ bbl.mthesis format.thesis.type output.nonnull
+ school "school" bibinfo.warn output
+ address "address" bibinfo.check output
+ format.date "year" output.check
+ format.url output
+ format.note output
+ fin.entry
+}
+
+FUNCTION {misc}
+{ output.bibitem
+ format.authors output
+ format.title output
+ end.quote.title
+ howpublished "howpublished" bibinfo.check output
+ format.date output
+ format.url output
+ format.note output
+ fin.entry
+ empty.misc.check
+}
+FUNCTION {phdthesis}
+{ output.bibitem
+ format.authors "author" output.check
+ format.btitle
+ "title" output.check
+ bbl.phdthesis format.thesis.type output.nonnull
+ school "school" bibinfo.warn output
+ address "address" bibinfo.check output
+ format.date "year" output.check
+ format.url output
+ format.note output
+ fin.entry
+}
+
+FUNCTION {proceedings}
+{ output.bibitem
+ editor empty$
+ { organization "organization" bibinfo.check output
+ }
+ { format.editors output.nonnull }
+ if$
+ format.btitle "title" output.check
+ format.bvolume output
+ format.number.series output
+ editor empty$
+ { publisher empty$
+ 'skip$
+ {
+ format.publisher.address output
+ }
+ if$
+ }
+ { publisher empty$
+ {
+ format.organization.address output }
+ {
+ organization "organization" bibinfo.check output
+ format.publisher.address output
+ }
+ if$
+ }
+ if$
+ format.date "year" output.check
+ format.url output
+ format.note output
+ fin.entry
+}
+
+FUNCTION {techreport}
+{ output.bibitem
+ format.authors "author" output.check
+ format.btitle
+ "title" output.check
+ format.tr.number output.nonnull
+ institution "institution" bibinfo.warn output
+ address "address" bibinfo.check output
+ format.date "year" output.check
+ format.url output
+ format.note output
+ fin.entry
+}
+
+FUNCTION {unpublished}
+{ output.bibitem
+ format.authors "author" output.check
+ format.title "title" output.check
+ end.quote.title
+ format.date output
+ format.url output
+ format.note "note" output.check
+ fin.entry
+}
+
+FUNCTION {default.type} { misc }
+READ
+STRINGS { longest.label }
+INTEGERS { number.label longest.label.width }
+FUNCTION {initialize.longest.label}
+{ "" 'longest.label :=
+ #1 'number.label :=
+ #0 'longest.label.width :=
+}
+FUNCTION {longest.label.pass}
+{ number.label int.to.str$ 'label :=
+ number.label #1 + 'number.label :=
+ label width$ longest.label.width >
+ { label 'longest.label :=
+ label width$ 'longest.label.width :=
+ }
+ 'skip$
+ if$
+}
+EXECUTE {initialize.longest.label}
+ITERATE {longest.label.pass}
+FUNCTION {begin.bib}
+{ preamble$ empty$
+ 'skip$
+ { preamble$ write$ newline$ }
+ if$
+ "\begin{thebibliography}{" longest.label * "}" *
+ write$ newline$
+ "\newcommand{\enquote}[1]{``#1''}"
+ write$ newline$
+ "\expandafter\ifx\csname url\endcsname\relax"
+ write$ newline$
+ " \def\url#1{\texttt{#1}}\fi"
+ write$ newline$
+ "\expandafter\ifx\csname urlprefix\endcsname\relax\def\urlprefix{URL }\fi"
+ write$ newline$
+}
+EXECUTE {begin.bib}
+EXECUTE {init.state.consts}
+ITERATE {call.type$}
+FUNCTION {end.bib}
+{ newline$
+ "\end{thebibliography}" write$ newline$
+}
+EXECUTE {end.bib}
+%% End of customized bst file
+%%
+%% End of file `tufte.bst'.