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

tufte-handout.cls 15KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551
  1. \NeedsTeXFormat{LaTeX2e}[1994/06/01]
  2. \ProvidesClass{tufte-handout}[2008/06/06 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[strict]{chngpage}
  75. %%
  76. % Detect if we're using pdfLaTeX
  77. \IfFileExists{ifpdf.sty}{%
  78. \RequirePackage{ifpdf}
  79. }{% assume we're not using pdfTex?
  80. \newif\ifpdf\pdffalse
  81. }
  82. %%
  83. % Detect if we're using XeLaTeX
  84. \IfFileExists{ifxetex.sty}{%
  85. \RequirePackage{ifxetex}
  86. }{% not using xelatex
  87. \newif\ifxetex\xetexfalse
  88. }
  89. % Compute length used for full-width displays
  90. \newlength{\@tufteh@overhang}
  91. \setlength{\@tufteh@overhang}{\marginparwidth}
  92. \addtolength{\@tufteh@overhang}{\marginparsep}
  93. %%
  94. % Alter \maketitle from article.cls
  95. \renewcommand\maketitle{\par
  96. \global\let\and\relax
  97. \global\let\thanks\footnote
  98. \begingroup
  99. \newpage
  100. \global\@topnum\z@
  101. \@maketitle
  102. \endgroup
  103. \global\let\thanks\relax
  104. \global\let\maketitle\relax
  105. \global\let\@maketitle\relax
  106. \global\let\@thanks\@empty
  107. %\global\let\@author\@empty
  108. %\global\let\@date\@empty
  109. %\global\let\@title\@empty
  110. \global\let\title\relax
  111. \global\let\author\relax
  112. \global\let\date\relax
  113. }
  114. \def\@maketitle{%
  115. \newpage
  116. \noindent\sffamily\large{\allcaps{\@title}}\\
  117. \vskip0.5\baselineskip
  118. \noindent\normalsize{\allcaps{\@author}}\\
  119. \vskip0.3\baselineskip
  120. \noindent{\allcaps{\@date}}
  121. \thispagestyle{plain}
  122. }
  123. %%
  124. % Abstract
  125. \renewenvironment{abstract}%
  126. {\begin{quotation}
  127. \begin{sffamily}
  128. \begin{small}}%
  129. { \end{small}
  130. \end{sffamily}
  131. \end{quotation}}
  132. %%
  133. % Require paralist package for tighter lists
  134. \RequirePackage{paralist}
  135. % Add rightmargin to compactenum
  136. \def\@compactenum@{%
  137. \expandafter\list\csname label\@enumctr\endcsname{%
  138. \usecounter{\@enumctr}%
  139. \rightmargin=2em% added this
  140. \parsep\plparsep
  141. \itemsep\plitemsep
  142. \topsep\pltopsep
  143. \partopsep\plpartopsep
  144. \def\makelabel##1{\hss\llap{##1}}}}
  145. %%
  146. % Improved letterspacing of small caps and all-caps text.
  147. %
  148. % First, try to use the `microtype' package, if it's available.
  149. % Failing that, try to use the `soul' package, if it's available.
  150. % Failing that, well, I give up.
  151. \RequirePackage{textcase} % provides \MakeTextUppercase and \MakeTextLowercase
  152. \def\allcapsspacing{\relax}
  153. \def\smallcapsspacing{\relax}
  154. \newcommand{\allcaps}[1]{\MakeTextUppercase{\allcapsspacing{#1}}}
  155. \newcommand{\smallcaps}[1]{\MakeTextLowercase{\textsc{#1}}}
  156. \newcommand{\@tufteh@loadsoul}{%
  157. \IfFileExists{soul.sty}{%
  158. \RequirePackage{soul}
  159. \sodef\allcapsspacing{\upshape}{0.15em}{0.65em}{0.6em}
  160. \sodef\smallcapsspacing{\scshape}{0.075em}{0.5em}{0.6em}
  161. }{
  162. \PackageWarningNoLine{tufte-handout}{Couldn't locate `soul' package.}
  163. }% soul not installed... giving up.
  164. }
  165. % If we're using pdfLaTeX v1.40+, use the letterspace package.
  166. % If we're using pdfLaTex < v1.40, use the soul package.
  167. % If we're using XeLaTeX, use XeLaTeX letterspacing options.
  168. % Otherwise fall back on the soul package.
  169. \ifpdf\PackageInfo{tufte-handout}{ifpdf = true}
  170. \else\PackageInfo{tufte-handout}{ifpdf = false}
  171. \fi
  172. \ifxetex\PackageInfo{tufte-handout}{ifxetex = true}
  173. \else\PackageInfo{tufte-handout}{ifxetex = false}
  174. \fi
  175. % Check pdfLaTeX version
  176. \def\@tufteh@pdftexversion{0}
  177. \ifx\normalpdftexversion\@undefined \else
  178. \let\pdftexversion \normalpdftexversion
  179. \let\pdftexrevision\normalpdftexrevision
  180. \let\pdfoutput \normalpdfoutput
  181. \fi
  182. \ifx\pdftexversion\@undefined \else
  183. \ifx\pdftexversion\relax \else
  184. \def\@tufteh@pdftexversion{6}
  185. \ifnum\pdftexversion < 140
  186. \def\@tufteh@pdftexversion{5}
  187. \fi
  188. \fi
  189. \fi
  190. \ifnum\@tufteh@pdftexversion<6
  191. % pdfLaTeX version is too old or not using pdfLaTeX
  192. \ifxetex
  193. % TODO use xetex letterspacing
  194. \PackageInfo{tufte-handout}{XeTeX detected. Reverting to `soul' package for letterspacing.}
  195. \@tufteh@loadsoul
  196. \else
  197. \PackageInfo{tufte-handout}{Old version of pdfTeX detected. Reverting to `soul' package for letterspacing.}
  198. \@tufteh@loadsoul
  199. \fi
  200. \else
  201. \IfFileExists{letterspace.sty}{%
  202. \PackageInfo{tufte-handout}{Modern version of pdfTeX detected. Using `letterspace' package.}
  203. \RequirePackage{letterspace}
  204. % Set up letterspacing (using microtype package) -- requires pdfTeX v1.40+
  205. \renewcommand{\smallcapsspacing}[1]{\textls[50]{##1}}
  206. \renewcommand{\allcaps}[1]{\textls[200]{\MakeTextUppercase{##1}}}
  207. \renewcommand{\smallcaps}[1]{\textsc{\MakeTextLowercase{##1}}}
  208. }{% microtype failed, check for soul
  209. \PackageInfo{tufte-handout}{Modern version of pdfTeX detected, but `letterspace' package not installed. Reverting to `soul' package for letterspacing.}
  210. \@tufteh@loadsoul
  211. }
  212. \fi
  213. \DeclareTextFontCommand{\textsmallcaps}{\scshape}
  214. \renewcommand{\textsc}[1]{\textsmallcaps{\smallcapsspacing{#1}}}
  215. %%
  216. % An environment for paragraph-style section
  217. \providecommand\newthought[1]{\vspace{1.8\baselineskip plus 3pt minus 2pt}%
  218. {\noindent\textsc{#1}}}
  219. %%
  220. % Transform existing \footnotes into \sidenotes
  221. % Sidenote: ``Where God meant footnotes to go.'' ---Tufte
  222. \RequirePackage[side,multiple]{footmisc}
  223. \newcommand{\footnotelayout}{\@tufteh@marginfont\@tufteh@justification}
  224. % Override footmisc's definition to set the sidenote marks (numbers) inside the
  225. % sidenote's text block.
  226. \long\def\@makefntext#1{\@textsuperscript{\@tufteh@marginfont\tiny\@thefnmark}\,\footnotelayout#1}
  227. % Set the in-text footnote mark in the same typeface as the body text itself.
  228. \def\@makefnmark{\hbox{\@textsuperscript{\normalfont\scriptsize\@thefnmark}}}
  229. \let\sidenote\footnote
  230. %%
  231. % Sidenote without the footnote mark
  232. \providecommand\marginnote[1]%
  233. {\marginpar{\@tufteh@marginfont\@tufteh@justification #1}}
  234. %%
  235. % Citations should go in the margin as well
  236. \RequirePackage{natbib}
  237. \RequirePackage{bibentry} % allows bibitems to be typeset outside thebibliography environment
  238. \nobibliography* % pre-loads the bibliography keys
  239. \renewcommand{\cite}[1]{\sidenote{\bibentry{#1}.}}
  240. \providecommand{\doi}[1]{\textsc{doi:} #1} % pre-defining this so it may be used before the \bibliography command it issued
  241. % TODO: Rewrite \cite so that you can specify multiple bib keys
  242. % at once. For example, \cite{Author01,Author02}
  243. % TODO: Combine sequences of citations so that 2,3,4,6 becomes 2-4,6
  244. % but be careful of hyperref interaction
  245. %%
  246. % Make Tuftian-style section headings
  247. % TODO: I'd prefer to use the 'titlesec' package for this formatting, but
  248. % I'll do it old-style for now. --Kevin
  249. \renewcommand\section{\@startsection {section}{1}{\z@}%
  250. {-3.5ex \@plus -1ex \@minus -.2ex}%
  251. {2.3ex \@plus.2ex}%
  252. {\normalfont\large\it}}
  253. \renewcommand\subsection{\@startsection{subsection}{2}{\z@}%
  254. {-3.25ex\@plus -1ex \@minus -.2ex}%
  255. {1.5ex \@plus .2ex}%
  256. {\normalfont\normalsize\it}}
  257. % Subsubsection and following section headings shouldn't be used.
  258. % See Bringhurst's _The Elements of Typography_, section 4.2.2.
  259. \renewcommand\subsubsection{%
  260. \PackageError{tufte-handout}{\noexpand\subsubsection is undefined by this class.%
  261. \MessageBreak See Robert Bringhurst's _The Elements of
  262. \MessageBreak Typographic Style_, section 4.2.2.
  263. \MessageBreak \noexpand\subsubsection was used}
  264. {From Bringhurst's _The Elements of Typographic Style_, section 4.2.2: Use as
  265. \MessageBreak many levels of headings as you need, no more and no fewer. Also see the many
  266. \MessageBreak related threads on Ask E.T. at http://www.edwardtufte.com/.}
  267. }
  268. \renewcommand\paragraph{%
  269. \PackageError{tufte-handout}{\noexpand\paragraph is undefined by this class.%
  270. \MessageBreak See Robert Bringhurst's _The Elements of
  271. \MessageBreak Typographic Style_, section 4.2.2.
  272. \MessageBreak \noexpand\paragraph was used}
  273. {From Bringhurst's _The Elements of Typographic Style_, section 4.2.2: Use as
  274. \MessageBreak many levels of headings as you need, no more and no fewer. Also see the many
  275. \MessageBreak related threads on Ask E.T. at http://www.edwardtufte.com/.}
  276. }
  277. \renewcommand\subparagraph{%
  278. \PackageError{tufte-handout}{\noexpand\subparagraph is undefined by this class.%
  279. \MessageBreak See Robert Bringhurst's _The Elements of
  280. \MessageBreak Typographic Style_, section 4.2.2.
  281. \MessageBreak \noexpand\subparagraph was used}
  282. {From Bringhurst's _The Elements of Typographic Style_, section 4.2.2: Use as
  283. \MessageBreak many levels of headings as you need, no more and no fewer. Also see the many
  284. \MessageBreak related threads on Ask E.T. at http://www.edwardtufte.com/.}
  285. }
  286. %%
  287. % The placeins package provides the \FloatBarrier command. This forces
  288. % LaTeX to place all of the floats before proceeding. We'll use this to
  289. % keep the float (figure and table) numbers in sequence.
  290. \RequirePackage{placeins}
  291. %%
  292. % Margin figure environment
  293. \newsavebox{\@tufteh@marginfigbox}
  294. \newenvironment{marginfigure}[1]
  295. [-1.2ex]
  296. {\FloatBarrier% process all floats before this point so the figure numbers stay in order.
  297. \begin{lrbox}{\@tufteh@marginfigbox}
  298. \begin{minipage}{\marginparwidth}
  299. \@tufteh@marginfont
  300. \def\@captype{figure}
  301. \vspace*{#1}
  302. \@tufteh@justification
  303. }
  304. {\end{minipage}%
  305. \end{lrbox}%
  306. \marginpar{\usebox{\@tufteh@marginfigbox}}}
  307. %%
  308. % Margin table environment
  309. \newsavebox{\@tufteh@margintablebox}
  310. \newenvironment{margintable}[1]
  311. [-1.2ex]
  312. {\FloatBarrier% process all floats before this point so the figure numbers stay in order.
  313. \begin{lrbox}{\@tufteh@margintablebox}
  314. \begin{minipage}{\marginparwidth}
  315. \@tufteh@marginfont
  316. \def\@captype{table}
  317. \vspace*{#1}
  318. \@tufteh@justification
  319. }
  320. {\end{minipage}%
  321. \end{lrbox}%
  322. \marginpar{\usebox{\@tufteh@margintablebox}}}
  323. %%
  324. % Full-width figure
  325. \renewenvironment{figure*}[1]%
  326. [htbp]%
  327. {\@float{figure}[#1]%
  328. \if@tufteh@symmetric
  329. \begin{adjustwidth}[]{}{-\@tufteh@overhang}%
  330. \else
  331. \begin{adjustwidth}{}{-\@tufteh@overhang}%
  332. \fi
  333. \begin{minipage}{\linewidth}}%
  334. {\end{minipage}%
  335. \end{adjustwidth}%
  336. \end@float}
  337. %%
  338. % Full-width table
  339. \renewenvironment{table*}[1]
  340. [htbp]%
  341. {\@float{table}[#1]%
  342. \if@tufteh@symmetric
  343. \begin{adjustwidth}[]{}{-\@tufteh@overhang}%
  344. \else
  345. \begin{adjustwidth}{}{-\@tufteh@overhang}%
  346. \fi
  347. \begin{minipage}{\linewidth}}%
  348. {\end{minipage}%
  349. \end{adjustwidth}%
  350. \end@float}
  351. %%
  352. % Full-page-width area
  353. \newenvironment{fullwidth}
  354. {\if@tufteh@symmetric
  355. \begin{adjustwidth}[]{}{-\@tufteh@overhang}%
  356. \else
  357. \begin{adjustwidth}{}{-\@tufteh@overhang}%
  358. \fi
  359. }
  360. {\end{adjustwidth}}
  361. %%
  362. % Format the captions in a style similar to the sidenotes
  363. \RequirePackage[format=default,font={rm,scriptsize},justification=raggedright,singlelinecheck=false]{caption}
  364. % if the `sfsidenotes' option is specified, set the captions in sf, too.
  365. \if@tufteh@sfsidenotes
  366. \captionsetup{font={sf,scriptsize}}
  367. \else
  368. \captionsetup{font={rm,scriptsize}}
  369. \fi
  370. % if the `justified' option is specified, set the captions in flush left
  371. % and flush right
  372. \if@tufteh@justified
  373. \captionsetup{justification=justified}
  374. \else
  375. \captionsetup{justification=raggedright}
  376. \fi
  377. %%
  378. % If the Palatino typeface (and its math symbol set) are installed, load them.
  379. \IfFileExists{palatino.sty}{%
  380. \RequirePackage{palatino}
  381. \IfFileExists{mathpazo.sty}{\RequirePackage[osf,sc]{mathpazo}}{}
  382. }{} % if the Palatino typefaces aren't found, do nothing.
  383. %%
  384. % If the Bera Mono typeface is available, use it.
  385. \IfFileExists{beramono.sty}{%
  386. \RequirePackage[T1]{fontenc}
  387. \RequirePackage[scaled=0.85]{beramono}
  388. }{}
  389. %%
  390. % Sets up the running heads and folios.
  391. \RequirePackage{fancyhdr}
  392. % Set the header/footer width to be the body text block plus the margin
  393. % note area.
  394. \if@tufteh@symmetric
  395. \fancyhfoffset[LE,RO]{\@tufteh@overhang}
  396. \else
  397. \fancyhfoffset[RE,RO]{\@tufteh@overhang}
  398. \fi
  399. % The 'fancy' page style is the default style for all pages.
  400. \fancyhf{} % clear header and footer fields
  401. \if@tufteh@twoside
  402. \fancyhead[LE]{\thepage\quad\smallcaps{\@author}}
  403. \fancyhead[RO]{\smallcaps{\@title}\quad\thepage}
  404. \else
  405. \fancyhead[RE,RO]{\smallcaps{\@title}\quad\thepage}
  406. \fi
  407. \renewcommand{\headrulewidth}{0pt}
  408. \renewcommand{\footrulewidth}{0pt}
  409. % The 'plain' page style is used on chapter opening pages.
  410. \fancypagestyle{plain}{
  411. \fancyhf{} % clear header and footer fields
  412. \if@tufteh@twoside
  413. \fancyfoot[LE,RO]{\thepage}
  414. \else
  415. \fancyfoot[RE,RO]{\thepage}
  416. \fi
  417. }
  418. % The 'empty' page style suppresses all headers and footers.
  419. % It's used on title pages and `intentionally blank' pages.
  420. \fancypagestyle{empty}{
  421. \fancyhf{} % clear header and footer fields
  422. }
  423. % Set the default page style to 'fancy'
  424. \pagestyle{fancy}
  425. %%
  426. % Set raggedright and paragraph indentation for document
  427. \AtBeginDocument{\@tufteh@justification\setlength\parindent{1em}}
  428. %%
  429. % Prints the list of class options and their states.
  430. \newcommand{\printclassoptions}{%
  431. \texttt{symmetric}---\if@tufteh@symmetric true\else false\fi\\
  432. \texttt{a4paper}---\if@tufteh@afourpaper true\else false\fi\\
  433. \texttt{twoside}---\if@tufteh@twoside true\else false\fi\\
  434. \texttt{sfsidenotes}---\if@tufteh@sfsidenotes true\else false\fi\\
  435. \texttt{justified}---\if@tufteh@justified true\else false\fi
  436. }
  437. \endinput