25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

346 lines
10KB

  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. % Improved letterspacing of small caps and all-caps text.
  106. %
  107. % First, try to use the `microtype' package, if it's available.
  108. % Failing that, try to use the `soul' package, if it's available.
  109. % Failing that, well, I give up.
  110. \RequirePackage{textcase} % provides \MakeTextUppercase and \MakeTextLowercase
  111. \newcommand{\allcaps}[1]{\MakeTextUppercase{#1}}
  112. \newcommand{\smallcaps}[1]{\textsc{\MakeTextLowercase{#1}}}
  113. \newcommand{\smallcapsspacing}[1]{#1}
  114. \IfFileExists{microtype.sty}{%
  115. \RequirePackage[final]{microtype}
  116. % Set up letterspacing (using microtype package) -- requires pdfTeX v1.40+
  117. \renewcommand{\smallcapsspacing}[1]{\textls[50]{##1}}
  118. \renewcommand{\allcaps}[1]{\textls[200]{\MakeTextUppercase{##1}}}
  119. \renewcommand{\smallcaps}[1]{\textsc{\MakeTextLowercase{##1}}}
  120. }{% microtype failed, check for soul
  121. \IfFileExists{soul.sty}{%
  122. \RequirePackage{soul}
  123. \sodef\allcapsspacing{\upshape}{0.15em}{0.65em}{0.6em}
  124. \sodef\smallcapsspacing{\scshape}{0.075em}{0.5em}{0.6em}
  125. \renewcommand{\allcaps}[1]{\allcapsspacing{\MakeTextUppercase{##1}}}
  126. \renewcommand{\smallcaps}[1]{\textsc{\MakeTextLowercase{##1}}}
  127. }{}% neither microtype nor soul are installed... giving up.
  128. }
  129. \DeclareTextFontCommand{\textsmallcaps}{\scshape}
  130. \renewcommand{\textsc}[1]{\textsmallcaps{\smallcapsspacing{#1}}}
  131. %%
  132. % An environment for paragraph-style section
  133. \providecommand\newthought[1]{\vspace{1.8\baselineskip plus 3pt minus 2pt}%
  134. {\noindent\textsc{#1}}}
  135. %%
  136. % Transform existing \footnotes into \sidenotes
  137. % Sidenote: ``Where God meant footnotes to go.'' ---Tufte
  138. \RequirePackage[side,multiple]{footmisc}
  139. \newcommand{\footnotelayout}{\@tufteh@marginfont\@tufteh@raggedright}
  140. % Override footmisc's definition to set the sidenote marks (numbers) inside the
  141. % sidenote's text block.
  142. \long\def\@makefntext#1{\@textsuperscript{\@tufteh@marginfont\tiny\@thefnmark}\,\footnotelayout#1}
  143. % Set the in-text footnote mark in the same typeface as the body text itself.
  144. \def\@makefnmark{\hbox{\@textsuperscript{\normalfont\scriptsize\@thefnmark}}}
  145. \let\sidenote\footnote
  146. %%
  147. % Sidenote without the footnote mark
  148. \providecommand\marginnote[1]%
  149. {\marginpar{\@tufteh@marginfont\raggedright #1}}
  150. %%
  151. % Citations should go in the margin as well
  152. \RequirePackage{natbib}
  153. \RequirePackage{bibentry} % allows bibitems to be typeset outside thebibliography environment
  154. \nobibliography* % pre-loads the bibliography keys
  155. \renewcommand{\cite}[1]{\sidenote{\bibentry{#1}.}}
  156. \providecommand{\doi}[1]{\textsc{doi:} #1} % pre-defining this so it may be used before the \bibliography command it issued
  157. % TODO: Rewrite \cite so that you can specify multiple bib keys
  158. % at once. For example, \cite{Author01,Author02}
  159. % TODO: Combine sequences of citations so that 2,3,4,6 becomes 2-4,6
  160. % but be careful of hyperref interaction
  161. %%
  162. % Make Tuftian-style section headings
  163. % TODO: I'd prefer to use the 'titlesec' package for this formatting, but
  164. % I'll do it old-style for now. --Kevin
  165. \renewcommand\section{\@startsection {section}{1}{\z@}%
  166. {-3.5ex \@plus -1ex \@minus -.2ex}%
  167. {2.3ex \@plus.2ex}%
  168. {\normalfont\large\it}}
  169. \renewcommand\subsection{\@startsection{subsection}{2}{\z@}%
  170. {-3.25ex\@plus -1ex \@minus -.2ex}%
  171. {1.5ex \@plus .2ex}%
  172. {\normalfont\normalsize\it}}
  173. % Subsubsection and following section headings shouldn't be used.
  174. % See Bringhurst's _The Elements of Typography_, section 4.2.2.
  175. \renewcommand\subsubsection{%
  176. \PackageError{tufte-handout}{\noexpand\subsubsection is undefined by this class.%
  177. \MessageBreak See Robert Bringhurst's _The Elements of
  178. \MessageBreak Typographic Style_, section 4.2.2.
  179. \MessageBreak \noexpand\subsubsection was used}
  180. {From Bringhurst's _The Elements of Typographic Style_, section 4.2.2: Use as
  181. \MessageBreak many levels of headings as you need, no more and no fewer. Also see the many
  182. \MessageBreak related threads on Ask E.T. at http://www.edwardtufte.com/.}
  183. }
  184. \renewcommand\paragraph{%
  185. \PackageError{tufte-handout}{\noexpand\paragraph is undefined by this class.%
  186. \MessageBreak See Robert Bringhurst's _The Elements of
  187. \MessageBreak Typographic Style_, section 4.2.2.
  188. \MessageBreak \noexpand\paragraph was used}
  189. {From Bringhurst's _The Elements of Typographic Style_, section 4.2.2: Use as
  190. \MessageBreak many levels of headings as you need, no more and no fewer. Also see the many
  191. \MessageBreak related threads on Ask E.T. at http://www.edwardtufte.com/.}
  192. }
  193. \renewcommand\subparagraph{%
  194. \PackageError{tufte-handout}{\noexpand\subparagraph is undefined by this class.%
  195. \MessageBreak See Robert Bringhurst's _The Elements of
  196. \MessageBreak Typographic Style_, section 4.2.2.
  197. \MessageBreak \noexpand\subparagraph was used}
  198. {From Bringhurst's _The Elements of Typographic Style_, section 4.2.2: Use as
  199. \MessageBreak many levels of headings as you need, no more and no fewer. Also see the many
  200. \MessageBreak related threads on Ask E.T. at http://www.edwardtufte.com/.}
  201. }
  202. %%
  203. % The placeins package provides the \FloatBarrier command. This forces
  204. % LaTeX to place all of the floats before proceeding. We'll use this to
  205. % keep the float (figure and table) numbers in sequence.
  206. \RequirePackage{placeins}
  207. %%
  208. % Margin figure
  209. \newcommand{\marginfigure}[2]%
  210. [-1.2ex]%
  211. {\FloatBarrier% process all floats before this point so the figure numbers stay in order.
  212. \marginpar{\@tufteh@marginfont
  213. \def\@captype{figure}
  214. \vspace*{#1}
  215. \@tufteh@raggedright #2}}
  216. % FIXME: if anyone can make this an environment instead -- patch welcome!
  217. %%
  218. % Margin table
  219. \newcommand{\margintable}[2]%
  220. [-1.2ex]%
  221. {\FloatBarrier% process all floats before this point so the table numbers stay in order.
  222. \marginpar{\@tufteh@marginfont
  223. \def\@captype{table}
  224. \vspace*{#1}
  225. \@tufteh@raggedright #2}}
  226. % FIXME: if anyone can make this an environment instead -- patch welcome!
  227. %%
  228. % Full-width figure
  229. \renewenvironment{figure*}[1]%
  230. [htbp]%
  231. {\@float{figure}[#1]%
  232. \begin{adjustwidth}{}{-\@tufteh@overhang}%
  233. \begin{minipage}{\linewidth}}%
  234. {\end{minipage}%
  235. \end{adjustwidth}%
  236. \end@float}
  237. %%
  238. % Full-width table
  239. \renewenvironment{table*}[1]
  240. [htbp]%
  241. {\@float{table}[#1]%
  242. \begin{adjustwidth}{}{-\@tufteh@overhang}%
  243. \begin{minipage}{\linewidth}}%
  244. {\end{minipage}%
  245. \end{adjustwidth}%
  246. \end@float}
  247. %%
  248. % Full-page-width area
  249. \newenvironment{fullwidth}
  250. {\begin{adjustwidth}{}{-\@tufteh@overhang}}%
  251. {\end{adjustwidth}}
  252. %%
  253. % Format the captions in a style similar to the sidenotes
  254. % if 'sfsidenotes' option is specified, set the captions in sf, too.
  255. \if@tufteh@sfsidenotes
  256. \RequirePackage[format=default,font={sf,scriptsize},justification=raggedright,singlelinecheck=false]{caption}
  257. \else
  258. \RequirePackage[format=default,font={rm,scriptsize},justification=raggedright,singlelinecheck=false]{caption}
  259. \fi
  260. %%
  261. % If the Palatino typeface (and its math symbol set) are installed, load them.
  262. \IfFileExists{palatino.sty}{%
  263. \RequirePackage{palatino}
  264. \IfFileExists{mathpazo.sty}{\RequirePackage[osf,sc]{mathpazo}}{}
  265. }{} % if the Palatino typefaces aren't found, do nothing.
  266. %%
  267. % Set raggedright and paragraph indentation for document
  268. \AtBeginDocument{\@tufteh@raggedright\setlength\parindent{1em}}
  269. \endinput