您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

484 行
14KB

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