You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

314 lines
9.1KB

  1. \NeedsTeXFormat{LaTeX2e}[1994/06/01]
  2. \ProvidesClass{tufte-handout}[2008/02/11 v1.2.3 Tufte-handout class]
  3. %%
  4. % a4paper option
  5. \newif\if@tufteh@afourpaper \@tufteh@afourpaperfalse
  6. \DeclareOption{a4paper}{\@tufteh@afourpapertrue}
  7. %%
  8. % sfsidenotes option -- typesets sidenotes in sans serif typeface
  9. \newif\if@tufteh@sfsidenotes \@tufteh@sfsidenotesfalse
  10. \DeclareOption{sfsidenotes}{\@tufteh@sfsidenotestrue}
  11. % FIXME: should probably specify options not supported like Mittelbach's aipproc.cls
  12. \DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}
  13. \ProcessOptions
  14. \LoadClass{article}%
  15. %%
  16. % Set page layout geometry
  17. \if@tufteh@afourpaper
  18. \RequirePackage[a4paper,includemp,width=170mm,marginparsep=10mm,marginparwidth=50mm]{geometry}
  19. \else
  20. \RequirePackage[letterpaper,includemp,width=6.5in,marginparsep=0.375in,marginparwidth=2in]{geometry}
  21. \fi
  22. %%
  23. % Separation marginpars by a line's worth of space.
  24. \setlength\marginparpush{\baselineskip}
  25. %%
  26. % Font for margin items
  27. \if@tufteh@sfsidenotes
  28. \newcommand{\@tufteh@marginfont}{\normalfont\scriptsize\sffamily}
  29. \else
  30. \newcommand{\@tufteh@marginfont}{\normalfont\scriptsize}
  31. \fi
  32. %%
  33. % Modify \raggedright from latex.ltx to allow hyphenation per Donald Arseneau
  34. \def\@tufteh@raggedright{%
  35. \let\\\@centercr\@rightskip\z@ plus 0.08\hsize
  36. \rightskip\@rightskip
  37. \leftskip\z@skip}
  38. %%
  39. % Turn off section numbering
  40. \setcounter{secnumdepth}{-1}
  41. %%
  42. % Tighten up space between displays (e.g., a figure or table) and make symmetric
  43. \setlength\abovedisplayskip{6pt plus 2pt minus 4pt}
  44. \setlength\belowdisplayskip{6pt plus 2pt minus 4pt}
  45. %%
  46. % To implement full-width display environments
  47. \RequirePackage{chngpage}
  48. % Compute length used for full-width displays
  49. \newlength{\@tufteh@overhang}
  50. \setlength{\@tufteh@overhang}{\marginparwidth}
  51. \addtolength{\@tufteh@overhang}{\marginparsep}
  52. %%
  53. % Alter \maketitle from article.cls
  54. \renewcommand\maketitle{\par
  55. \global\let\and\relax
  56. \global\let\thanks\footnote
  57. \begingroup
  58. \newpage
  59. \global\@topnum\z@
  60. \@maketitle
  61. \endgroup
  62. \global\let\thanks\relax
  63. \global\let\maketitle\relax
  64. \global\let\@maketitle\relax
  65. \global\let\@thanks\@empty
  66. \global\let\@author\@empty
  67. \global\let\@date\@empty
  68. \global\let\@title\@empty
  69. \global\let\title\relax
  70. \global\let\author\relax
  71. \global\let\date\relax
  72. }
  73. \def\@maketitle{%
  74. \newpage
  75. \noindent\sffamily\large{\@title}\\
  76. \vskip0.5\baselineskip
  77. \noindent\normalsize{\@author}\\
  78. \vskip0.3\baselineskip
  79. \noindent{\@date}
  80. \thispagestyle{empty}
  81. }
  82. %%
  83. % Abstract
  84. \renewenvironment{abstract}%
  85. {\begin{quotation}
  86. \begin{sffamily}
  87. \begin{small}}%
  88. { \end{small}
  89. \end{sffamily}
  90. \end{quotation}}
  91. %%
  92. % Require paralist package for tighter lists
  93. \RequirePackage{paralist}
  94. % Add rightmargin to compactenum
  95. \def\@compactenum@{%
  96. \expandafter\list\csname label\@enumctr\endcsname{%
  97. \usecounter{\@enumctr}%
  98. \rightmargin=2em% added this
  99. \parsep\plparsep
  100. \itemsep\plitemsep
  101. \topsep\pltopsep
  102. \partopsep\plpartopsep
  103. \def\makelabel##1{\hss\llap{##1}}}}
  104. %%
  105. % An environment for paragraph-style section
  106. \providecommand\newthought[1]{\vspace{1.8\baselineskip plus 3pt minus 2pt}%
  107. {\noindent\scshape #1}}
  108. %%
  109. % Transform existing \footnotes into \sidenotes
  110. % Sidenote: ``Where God meant footnotes to go.'' ---Tufte
  111. \RequirePackage[side,multiple]{footmisc}
  112. \newcommand{\footnotelayout}{\@tufteh@marginfont\@tufteh@raggedright}
  113. % Override footmisc's definition to set the sidenote marks (numbers) inside the
  114. % sidenote's text block.
  115. \long\def\@makefntext#1{\@textsuperscript{\@tufteh@marginfont\tiny\@thefnmark}\,\footnotelayout#1}
  116. % Set the in-text footnote mark in the same typeface as the body text itself.
  117. \def\@makefnmark{\hbox{\@textsuperscript{\normalfont\scriptsize\@thefnmark}}}
  118. \let\sidenote\footnote
  119. %%
  120. % Sidenote without the footnote mark
  121. \providecommand\marginnote[1]%
  122. {\marginpar{\@tufteh@marginfont\raggedright #1}}
  123. %%
  124. % Citations should go in the margin as well
  125. \RequirePackage{natbib}
  126. \RequirePackage{bibentry} % allows bibitems to be typeset outside thebibliography environment
  127. \nobibliography* % pre-loads the bibliography keys
  128. \renewcommand{\cite}[1]{\sidenote{\bibentry{#1}.}}
  129. \providecommand{\doi}[1]{\textsc{doi:} #1} % pre-defining this so it may be used before the \bibliography command it issued
  130. % TODO: Rewrite \cite so that you can specify multiple bib keys
  131. % at once. For example, \cite{Author01,Author02}
  132. % TODO: Combine sequences of citations so that 2,3,4,6 becomes 2-4,6
  133. % but be careful of hyperref interaction
  134. %%
  135. % Make Tuftian-style section headings
  136. % TODO: I'd prefer to use the 'titlesec' package for this formatting, but
  137. % I'll do it old-style for now. --Kevin
  138. \renewcommand\section{\@startsection {section}{1}{\z@}%
  139. {-3.5ex \@plus -1ex \@minus -.2ex}%
  140. {2.3ex \@plus.2ex}%
  141. {\normalfont\large\it}}
  142. \renewcommand\subsection{\@startsection{subsection}{2}{\z@}%
  143. {-3.25ex\@plus -1ex \@minus -.2ex}%
  144. {1.5ex \@plus .2ex}%
  145. {\normalfont\normalsize\it}}
  146. % Subsubsection and following section headings shouldn't be used.
  147. % See Bringhurst's _The Elements of Typography_, section 4.2.2.
  148. \renewcommand\subsubsection{%
  149. \PackageError{tufte-handout}{\noexpand\subsubsection is undefined by this class.%
  150. \MessageBreak See Robert Bringhurst's _The Elements of
  151. \MessageBreak Typographic Style_, section 4.2.2.
  152. \MessageBreak \noexpand\subsubsection was used}
  153. {From Bringhurst's _The Elements of Typographic Style_, section 4.2.2: Use as
  154. \MessageBreak many levels of headings as you need, no more and no fewer. Also see the many
  155. \MessageBreak related threads on Ask E.T. at http://www.edwardtufte.com/.}
  156. }
  157. \renewcommand\paragraph{%
  158. \PackageError{tufte-handout}{\noexpand\paragraph is undefined by this class.%
  159. \MessageBreak See Robert Bringhurst's _The Elements of
  160. \MessageBreak Typographic Style_, section 4.2.2.
  161. \MessageBreak \noexpand\paragraph was used}
  162. {From Bringhurst's _The Elements of Typographic Style_, section 4.2.2: Use as
  163. \MessageBreak many levels of headings as you need, no more and no fewer. Also see the many
  164. \MessageBreak related threads on Ask E.T. at http://www.edwardtufte.com/.}
  165. }
  166. \renewcommand\subparagraph{%
  167. \PackageError{tufte-handout}{\noexpand\subparagraph is undefined by this class.%
  168. \MessageBreak See Robert Bringhurst's _The Elements of
  169. \MessageBreak Typographic Style_, section 4.2.2.
  170. \MessageBreak \noexpand\subparagraph was used}
  171. {From Bringhurst's _The Elements of Typographic Style_, section 4.2.2: Use as
  172. \MessageBreak many levels of headings as you need, no more and no fewer. Also see the many
  173. \MessageBreak related threads on Ask E.T. at http://www.edwardtufte.com/.}
  174. }
  175. %%
  176. % The placeins package provides the \FloatBarrier command. This forces
  177. % LaTeX to place all of the floats before proceeding. We'll use this to
  178. % keep the float (figure and table) numbers in sequence.
  179. \RequirePackage{placeins}
  180. %%
  181. % Margin figure
  182. \newcommand{\marginfigure}[2]%
  183. [-1.2ex]%
  184. {\FloatBarrier% process all floats before this point so the figure numbers stay in order.
  185. \marginpar{\@tufteh@marginfont
  186. \def\@captype{figure}
  187. \vspace*{#1}
  188. \@tufteh@raggedright #2}}
  189. % FIXME: if anyone can make this an environment instead -- patch welcome!
  190. %%
  191. % Margin table
  192. \newcommand{\margintable}[2]%
  193. [-1.2ex]%
  194. {\FloatBarrier% process all floats before this point so the table numbers stay in order.
  195. \marginpar{\@tufteh@marginfont
  196. \def\@captype{table}
  197. \vspace*{#1}
  198. \@tufteh@raggedright #2}}
  199. % FIXME: if anyone can make this an environment instead -- patch welcome!
  200. %%
  201. % Full-width figure
  202. \renewenvironment{figure*}[1]%
  203. [htbp]%
  204. {\@float{figure}[#1]%
  205. \begin{adjustwidth}{}{-\@tufteh@overhang}%
  206. \begin{minipage}{\linewidth}}%
  207. {\end{minipage}%
  208. \end{adjustwidth}%
  209. \end@float}
  210. %%
  211. % Full-width table
  212. \renewenvironment{table*}[1]
  213. [htbp]%
  214. {\@float{table}[#1]%
  215. \begin{adjustwidth}{}{-\@tufteh@overhang}%
  216. \begin{minipage}{\linewidth}}%
  217. {\end{minipage}%
  218. \end{adjustwidth}%
  219. \end@float}
  220. %%
  221. % Full-page-width area
  222. \newenvironment{fullwidth}
  223. {\begin{adjustwidth}{}{-\@tufteh@overhang}}%
  224. {\end{adjustwidth}}
  225. %%
  226. % Format the captions in a style similar to the sidenotes
  227. % if 'sfsidenotes' option is specified, set the captions in sf, too.
  228. \if@tufteh@sfsidenotes
  229. \RequirePackage[format=default,font={sf,scriptsize},justification=raggedright,singlelinecheck=false]{caption}
  230. \else
  231. \RequirePackage[format=default,font={rm,scriptsize},justification=raggedright,singlelinecheck=false]{caption}
  232. \fi
  233. %%
  234. % If the Palatino typeface (and its math symbol set) are installed, load them.
  235. \IfFileExists{palatino.sty}{%
  236. \RequirePackage{palatino}
  237. \IfFileExists{mathpazo.sty}{\RequirePackage[osf,sc]{mathpazo}}{}
  238. }{} % if the Palatino typefaces aren't found, do nothing.
  239. %%
  240. % Set raggedright and paragraph indentation for document
  241. \AtBeginDocument{\@tufteh@raggedright\setlength\parindent{1em}}
  242. \endinput