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.

249 line
6.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,marginal]{footmisc}
  112. \setlength{\footnotemargin}{0.8em}
  113. \newcommand{\footnotelayout}{\@tufteh@marginfont\@tufteh@raggedright}
  114. \let\sidenote\footnote
  115. % Set the footnote mark (adjacent to the footnote) in the same typeface as the footenote itself.
  116. \def\@makefnmark{\hbox{\@textsuperscript{\@tufteh@marginfont\tiny\@thefnmark}}}
  117. % TODO: Automatically determine the \footnotemargin value based on the width of the footnote mark.
  118. %%
  119. % Sidenote without the footnote mark
  120. \providecommand\marginnote[1]%
  121. {\marginpar{\@tufteh@marginfont\raggedright #1}}
  122. %%
  123. % Citations should go in the margin as well
  124. \RequirePackage{natbib}
  125. \RequirePackage{bibentry} % allows bibitems to be typeset outside thebibliography environment
  126. \nobibliography* % pre-loads the bibliography keys
  127. \renewcommand{\cite}[1]{\sidenote{\bibentry{#1}.}}
  128. \providecommand{\doi}[1]{\textsc{doi:} #1} % pre-defining this so it may be used before the \bibliography command it issued
  129. % TODO: Rewrite \cite so that you can specify multiple bib keys
  130. % at once. For example, \cite{Author01,Author02}
  131. % TODO: Combine sequences of citations so that 2,3,4,6 becomes 2-4,6
  132. % but be careful of hypperref interaction
  133. %%
  134. % Margin figure
  135. \newcommand{\marginfigure}[2]%
  136. [-1.2ex]%
  137. {\marginpar{\@tufteh@marginfont
  138. \def\@captype{figure}
  139. \vspace*{#1}
  140. \@tufteh@raggedright #2}}
  141. % FIXME: if anyone can make this an environment instead -- patch welcome!
  142. %%
  143. % Margin table
  144. \newcommand{\margintable}[2]%
  145. [-1.2ex]%
  146. {\marginpar{\@tufteh@marginfont
  147. \def\@captype{table}
  148. \vspace*{#1}
  149. \@tufteh@raggedright #2}}
  150. % FIXME: if anyone can make this an environment instead -- patch welcome!
  151. %%
  152. % Full-width figure
  153. \renewenvironment{figure*}[1]%
  154. [htbp]%
  155. {\@float{figure}[#1]%
  156. \begin{adjustwidth}{}{-\@tufteh@overhang}%
  157. \begin{minipage}{\linewidth}}%
  158. {\end{minipage}%
  159. \end{adjustwidth}%
  160. \end@float}
  161. %%
  162. % Full-width table
  163. \renewenvironment{table*}[1]
  164. [htbp]%
  165. {\@float{table}[#1]%
  166. \begin{adjustwidth}{}{-\@tufteh@overhang}%
  167. \begin{minipage}{\linewidth}}%
  168. {\end{minipage}%
  169. \end{adjustwidth}%
  170. \end@float}
  171. %%
  172. % Full-page-width area
  173. \newenvironment{fullwidth}
  174. {\begin{adjustwidth}{}{-\@tufteh@overhang}}%
  175. {\end{adjustwidth}}
  176. %%
  177. % Format the captions in a style similar to the sidenotes
  178. % if 'sfsidenotes' option is specified, set the captions in sf, too.
  179. \if@tufteh@sfsidenotes
  180. \RequirePackage[format=default,font={sf,scriptsize},justification=raggedright,singlelinecheck=false]{caption}
  181. \else
  182. \RequirePackage[format=default,font={rm,scriptsize},justification=raggedright,singlelinecheck=false]{caption}
  183. \fi
  184. %%
  185. % Set raggedright and paragraph indentation for document
  186. \AtBeginDocument{\@tufteh@raggedright\setlength\parindent{1em}}
  187. \endinput