25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

457 satır
13KB

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