選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

tufte-handout.cls 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  1. \NeedsTeXFormat{LaTeX2e}[1994/06/01]
  2. \ProvidesClass{tufte-handout}[2008/05/16 v2.0.0 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. % Detect whether we're in two-side mode or not. (Used to set up running
  17. % heads later.)
  18. \newif\if@tufteh@twoside\let\if@tufteh@twoside\if@twoside
  19. %%
  20. % Set page layout geometry
  21. \if@tufteh@afourpaper
  22. \RequirePackage[a4paper,includemp,width=170mm,marginparsep=10mm,marginparwidth=50mm,asymmetric]{geometry}
  23. \else
  24. \RequirePackage[letterpaper,includemp,width=6.5in,marginparsep=0.375in,marginparwidth=2in,asymmetric]{geometry}
  25. \fi
  26. %%
  27. % Separation marginpars by a line's worth of space.
  28. \setlength\marginparpush{\baselineskip}
  29. %%
  30. % Font for margin items
  31. \if@tufteh@sfsidenotes
  32. \newcommand{\@tufteh@marginfont}{\normalfont\scriptsize\sffamily}
  33. \else
  34. \newcommand{\@tufteh@marginfont}{\normalfont\scriptsize}
  35. \fi
  36. %%
  37. % Modify \raggedright from latex.ltx to allow hyphenation per Donald Arseneau
  38. \def\@tufteh@raggedright{%
  39. \let\\\@centercr\@rightskip\z@ plus 0.08\hsize
  40. \rightskip\@rightskip
  41. \leftskip\z@skip}
  42. %%
  43. % Turn off section numbering
  44. \setcounter{secnumdepth}{-1}
  45. %%
  46. % Tighten up space between displays (e.g., a figure or table) and make symmetric
  47. \setlength\abovedisplayskip{6pt plus 2pt minus 4pt}
  48. \setlength\belowdisplayskip{6pt plus 2pt minus 4pt}
  49. %%
  50. % To implement full-width display environments
  51. \RequirePackage{chngpage}
  52. % Compute length used for full-width displays
  53. \newlength{\@tufteh@overhang}
  54. \setlength{\@tufteh@overhang}{\marginparwidth}
  55. \addtolength{\@tufteh@overhang}{\marginparsep}
  56. %%
  57. % Alter \maketitle from article.cls
  58. \renewcommand\maketitle{\par
  59. \global\let\and\relax
  60. \global\let\thanks\footnote
  61. \begingroup
  62. \newpage
  63. \global\@topnum\z@
  64. \@maketitle
  65. \endgroup
  66. \global\let\thanks\relax
  67. \global\let\maketitle\relax
  68. \global\let\@maketitle\relax
  69. \global\let\@thanks\@empty
  70. %\global\let\@author\@empty
  71. %\global\let\@date\@empty
  72. %\global\let\@title\@empty
  73. \global\let\title\relax
  74. \global\let\author\relax
  75. \global\let\date\relax
  76. }
  77. \def\@maketitle{%
  78. \newpage
  79. \noindent\sffamily\large{\@title}\\
  80. \vskip0.5\baselineskip
  81. \noindent\normalsize{\@author}\\
  82. \vskip0.3\baselineskip
  83. \noindent{\@date}
  84. \thispagestyle{plain}
  85. }
  86. %%
  87. % Abstract
  88. \renewenvironment{abstract}%
  89. {\begin{quotation}
  90. \begin{sffamily}
  91. \begin{small}}%
  92. { \end{small}
  93. \end{sffamily}
  94. \end{quotation}}
  95. %%
  96. % Require paralist package for tighter lists
  97. \RequirePackage{paralist}
  98. % Add rightmargin to compactenum
  99. \def\@compactenum@{%
  100. \expandafter\list\csname label\@enumctr\endcsname{%
  101. \usecounter{\@enumctr}%
  102. \rightmargin=2em% added this
  103. \parsep\plparsep
  104. \itemsep\plitemsep
  105. \topsep\pltopsep
  106. \partopsep\plpartopsep
  107. \def\makelabel##1{\hss\llap{##1}}}}
  108. %%
  109. % Improved letterspacing of small caps and all-caps text.
  110. %
  111. % First, try to use the `microtype' package, if it's available.
  112. % Failing that, try to use the `soul' package, if it's available.
  113. % Failing that, well, I give up.
  114. \RequirePackage{textcase} % provides \MakeTextUppercase and \MakeTextLowercase
  115. \newcommand{\allcaps}[1]{\MakeTextUppercase{#1}}
  116. \newcommand{\smallcaps}[1]{\textsc{\MakeTextLowercase{#1}}}
  117. \newcommand{\smallcapsspacing}[1]{#1}
  118. \IfFileExists{microtype.sty}{%
  119. \RequirePackage[final]{microtype}
  120. % Set up letterspacing (using microtype package) -- requires pdfTeX v1.40+
  121. \renewcommand{\smallcapsspacing}[1]{\textls[50]{##1}}
  122. \renewcommand{\allcaps}[1]{\textls[200]{\MakeTextUppercase{##1}}}
  123. \renewcommand{\smallcaps}[1]{\textsc{\MakeTextLowercase{##1}}}
  124. }{% microtype failed, check for soul
  125. \IfFileExists{soul.sty}{%
  126. \RequirePackage{soul}
  127. \sodef\allcapsspacing{\upshape}{0.15em}{0.65em}{0.6em}
  128. \sodef\smallcapsspacing{\scshape}{0.075em}{0.5em}{0.6em}
  129. \renewcommand{\allcaps}[1]{\allcapsspacing{\MakeTextUppercase{##1}}}
  130. \renewcommand{\smallcaps}[1]{\textsc{\MakeTextLowercase{##1}}}
  131. }{}% neither microtype nor soul are installed... giving up.
  132. }
  133. \DeclareTextFontCommand{\textsmallcaps}{\scshape}
  134. \renewcommand{\textsc}[1]{\textsmallcaps{\smallcapsspacing{#1}}}
  135. %%
  136. % An environment for paragraph-style section
  137. \providecommand\newthought[1]{\vspace{1.8\baselineskip plus 3pt minus 2pt}%
  138. {\noindent\textsc{#1}}}
  139. %%
  140. % Transform existing \footnotes into \sidenotes
  141. % Sidenote: ``Where God meant footnotes to go.'' ---Tufte
  142. \RequirePackage[side,multiple]{footmisc}
  143. \newcommand{\footnotelayout}{\@tufteh@marginfont\@tufteh@raggedright}
  144. % Override footmisc's definition to set the sidenote marks (numbers) inside the
  145. % sidenote's text block.
  146. \long\def\@makefntext#1{\@textsuperscript{\@tufteh@marginfont\tiny\@thefnmark}\,\footnotelayout#1}
  147. % Set the in-text footnote mark in the same typeface as the body text itself.
  148. \def\@makefnmark{\hbox{\@textsuperscript{\normalfont\scriptsize\@thefnmark}}}
  149. \let\sidenote\footnote
  150. %%
  151. % Sidenote without the footnote mark
  152. \providecommand\marginnote[1]%
  153. {\marginpar{\@tufteh@marginfont\raggedright #1}}
  154. %%
  155. % Citations should go in the margin as well
  156. \RequirePackage{natbib}
  157. \RequirePackage{bibentry} % allows bibitems to be typeset outside thebibliography environment
  158. \nobibliography* % pre-loads the bibliography keys
  159. \renewcommand{\cite}[1]{\sidenote{\bibentry{#1}.}}
  160. \providecommand{\doi}[1]{\textsc{doi:} #1} % pre-defining this so it may be used before the \bibliography command it issued
  161. % TODO: Rewrite \cite so that you can specify multiple bib keys
  162. % at once. For example, \cite{Author01,Author02}
  163. % TODO: Combine sequences of citations so that 2,3,4,6 becomes 2-4,6
  164. % but be careful of hyperref interaction
  165. %%
  166. % Make Tuftian-style section headings
  167. % TODO: I'd prefer to use the 'titlesec' package for this formatting, but
  168. % I'll do it old-style for now. --Kevin
  169. \renewcommand\section{\@startsection {section}{1}{\z@}%
  170. {-3.5ex \@plus -1ex \@minus -.2ex}%
  171. {2.3ex \@plus.2ex}%
  172. {\normalfont\large\it}}
  173. \renewcommand\subsection{\@startsection{subsection}{2}{\z@}%
  174. {-3.25ex\@plus -1ex \@minus -.2ex}%
  175. {1.5ex \@plus .2ex}%
  176. {\normalfont\normalsize\it}}
  177. % Subsubsection and following section headings shouldn't be used.
  178. % See Bringhurst's _The Elements of Typography_, section 4.2.2.
  179. \renewcommand\subsubsection{%
  180. \PackageError{tufte-handout}{\noexpand\subsubsection is undefined by this class.%
  181. \MessageBreak See Robert Bringhurst's _The Elements of
  182. \MessageBreak Typographic Style_, section 4.2.2.
  183. \MessageBreak \noexpand\subsubsection was used}
  184. {From Bringhurst's _The Elements of Typographic Style_, section 4.2.2: Use as
  185. \MessageBreak many levels of headings as you need, no more and no fewer. Also see the many
  186. \MessageBreak related threads on Ask E.T. at http://www.edwardtufte.com/.}
  187. }
  188. \renewcommand\paragraph{%
  189. \PackageError{tufte-handout}{\noexpand\paragraph is undefined by this class.%
  190. \MessageBreak See Robert Bringhurst's _The Elements of
  191. \MessageBreak Typographic Style_, section 4.2.2.
  192. \MessageBreak \noexpand\paragraph was used}
  193. {From Bringhurst's _The Elements of Typographic Style_, section 4.2.2: Use as
  194. \MessageBreak many levels of headings as you need, no more and no fewer. Also see the many
  195. \MessageBreak related threads on Ask E.T. at http://www.edwardtufte.com/.}
  196. }
  197. \renewcommand\subparagraph{%
  198. \PackageError{tufte-handout}{\noexpand\subparagraph is undefined by this class.%
  199. \MessageBreak See Robert Bringhurst's _The Elements of
  200. \MessageBreak Typographic Style_, section 4.2.2.
  201. \MessageBreak \noexpand\subparagraph was used}
  202. {From Bringhurst's _The Elements of Typographic Style_, section 4.2.2: Use as
  203. \MessageBreak many levels of headings as you need, no more and no fewer. Also see the many
  204. \MessageBreak related threads on Ask E.T. at http://www.edwardtufte.com/.}
  205. }
  206. %%
  207. % The placeins package provides the \FloatBarrier command. This forces
  208. % LaTeX to place all of the floats before proceeding. We'll use this to
  209. % keep the float (figure and table) numbers in sequence.
  210. \RequirePackage{placeins}
  211. %%
  212. % Margin figure environment
  213. \newsavebox{\@tufteh@marginfigbox}
  214. \newenvironment{marginfigure}[1]
  215. [-1.2ex]
  216. {\FloatBarrier% process all floats before this point so the figure numbers stay in order.
  217. \begin{lrbox}{\@tufteh@marginfigbox}
  218. \begin{minipage}{\marginparwidth}
  219. \@tufteh@marginfont
  220. \def\@captype{figure}
  221. \vspace*{#1}
  222. \@tufteh@raggedright
  223. }
  224. {\end{minipage}%
  225. \end{lrbox}%
  226. \marginpar{\usebox{\@tufteh@marginfigbox}}}
  227. %%
  228. % Margin table environment
  229. \newsavebox{\@tufteh@margintablebox}
  230. \newenvironment{margintable}[1]
  231. [-1.2ex]
  232. {\FloatBarrier% process all floats before this point so the figure numbers stay in order.
  233. \begin{lrbox}{\@tufteh@margintablebox}
  234. \begin{minipage}{\marginparwidth}
  235. \@tufteh@marginfont
  236. \def\@captype{table}
  237. \vspace*{#1}
  238. \@tufteh@raggedright
  239. }
  240. {\end{minipage}%
  241. \end{lrbox}%
  242. \marginpar{\usebox{\@tufteh@margintablebox}}}
  243. %%
  244. % Full-width figure
  245. \renewenvironment{figure*}[1]%
  246. [htbp]%
  247. {\@float{figure}[#1]%
  248. \begin{adjustwidth}{}{-\@tufteh@overhang}%
  249. \begin{minipage}{\linewidth}}%
  250. {\end{minipage}%
  251. \end{adjustwidth}%
  252. \end@float}
  253. %%
  254. % Full-width table
  255. \renewenvironment{table*}[1]
  256. [htbp]%
  257. {\@float{table}[#1]%
  258. \begin{adjustwidth}{}{-\@tufteh@overhang}%
  259. \begin{minipage}{\linewidth}}%
  260. {\end{minipage}%
  261. \end{adjustwidth}%
  262. \end@float}
  263. %%
  264. % Full-page-width area
  265. \newenvironment{fullwidth}
  266. {\begin{adjustwidth}{}{-\@tufteh@overhang}}%
  267. {\end{adjustwidth}}
  268. %%
  269. % Format the captions in a style similar to the sidenotes
  270. % if 'sfsidenotes' option is specified, set the captions in sf, too.
  271. \if@tufteh@sfsidenotes
  272. \RequirePackage[format=default,font={sf,scriptsize},justification=raggedright,singlelinecheck=false]{caption}
  273. \else
  274. \RequirePackage[format=default,font={rm,scriptsize},justification=raggedright,singlelinecheck=false]{caption}
  275. \fi
  276. %%
  277. % If the Palatino typeface (and its math symbol set) are installed, load them.
  278. \IfFileExists{palatino.sty}{%
  279. \RequirePackage{palatino}
  280. \IfFileExists{mathpazo.sty}{\RequirePackage[osf,sc]{mathpazo}}{}
  281. }{} % if the Palatino typefaces aren't found, do nothing.
  282. %%
  283. % Sets up the running heads and folios.
  284. \RequirePackage{fancyhdr}
  285. % Set the header/footer width to be the body text block plus the margin
  286. % note area.
  287. \fancyhfoffset[RE,RO]{\@tufteh@overhang}
  288. % The 'fancy' page style is the default style for all pages.
  289. \fancyhf{} % clear header and footer fields
  290. \if@tufteh@twoside
  291. \fancyhead[LE]{\thepage\quad\smallcaps{\@author}}
  292. \fancyhead[RO]{\smallcaps{\@title}\quad\thepage}
  293. \else
  294. \fancyhead[RE,RO]{\smallcaps{\@title}\quad\thepage}
  295. \fi
  296. \renewcommand{\headrulewidth}{0pt}
  297. \renewcommand{\footrulewidth}{0pt}
  298. % The 'plain' page style is used on chapter opening pages.
  299. \fancypagestyle{plain}{
  300. \fancyhf{} % clear header and footer fields
  301. \if@tufteh@twoside
  302. \fancyfoot[LE,RO]{\thepage}
  303. \else
  304. \fancyfoot[RE,RO]{\thepage}
  305. \fi
  306. }
  307. % The 'empty' page style suppresses all headers and footers.
  308. % It's used on title pages and `intentionally blank' pages.
  309. \fancypagestyle{empty}{
  310. \fancyhf{} % clear header and footer fields
  311. }
  312. % Set the default page style to 'fancy'
  313. \pagestyle{fancy}
  314. %%
  315. % Set raggedright and paragraph indentation for document
  316. \AtBeginDocument{\@tufteh@raggedright\setlength\parindent{1em}}
  317. \endinput