You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1630 line
55KB

  1. %\NeedsTeXFormat{LaTeX2e}[1994/06/01]
  2. %\ProvidesPackage{tufte-common}[2009/05/17 v3.0.0 Common code for the Tufte-LaTeX styles]
  3. %%
  4. % The `xkeyval' package simplifies the user interface for the document class options
  5. \RequirePackage{xkeyval}
  6. %%
  7. % We use the `xifthen' package to handle our package option switches
  8. \RequirePackage{xifthen}
  9. %%
  10. % `debug' option -- provides more information in the .log file for use in
  11. % troubleshooting problems
  12. \newboolean{@tufte@debug}
  13. \DeclareOptionX[tufte]<common>{debug}{\setboolean{@tufte@debug}{true}}
  14. %%
  15. % `nofonts' option -- doesn't load any fonts
  16. % `fonts' option -- tries to load fonts
  17. \newboolean{@tufte@loadfonts}\setboolean{@tufte@loadfonts}{true}
  18. \DeclareOptionX[tufte]<common>{fonts}{\setboolean{@tufte@loadfonts}{true}}
  19. \DeclareOptionX[tufte]<common>{nofonts}{\setboolean{@tufte@loadfonts}{false}}
  20. %%
  21. % `nols' option -- doesn't configure letterspacing
  22. % `ls' option -- configures letterspacing
  23. \newboolean{@tufte@letterspace}\setboolean{@tufte@letterspace}{true}
  24. \DeclareOptionX[tufte]<common>{ls}{\setboolean{@tufte@letterspace}{true}}
  25. \DeclareOptionX[tufte]<common>{nols}{\setboolean{@tufte@letterspace}{false}}
  26. %%
  27. % `titlepage' option -- creates a full title page with \maketitle
  28. \newboolean{@tufte@titlepage}
  29. \DeclareOptionX[tufte]<common>{titlepage}{\setboolean{@tufte@titlepage}{true}}
  30. \DeclareOptionX[tufte]<common>{notitlepage}{\setboolean{@tufte@titlepage}{false}}
  31. %%
  32. % `a4paper' option
  33. \newboolean{@tufte@afourpaper}
  34. \DeclareOptionX[tufte]<common>{a4paper}{\setboolean{@tufte@afourpaper}{true}}
  35. %%
  36. % `b4paper' option
  37. \newboolean{@tufte@bfivepaper}
  38. \DeclareOptionX[tufte]<common>{b5paper}{\setboolean{@tufte@bfivepaper}{true}}
  39. %%
  40. % `sfsidenotes' option -- typesets sidenotes in sans serif typeface
  41. \newboolean{@tufte@sfsidenotes}
  42. \DeclareOptionX[tufte]<common>{sfsidenotes}{\setboolean{@tufte@sfsidenotes}{true}}
  43. %%
  44. % `symmetric' option -- puts marginpar space to the outside edge of the page
  45. % Note: this option forces the twoside option (see the .cls files)
  46. \newboolean{@tufte@symmetric}
  47. \DeclareOptionX[tufte]<common>{symmetric}{
  48. \setboolean{@tufte@symmetric}{true}
  49. \ClassInfo{\@tufte@pkgname}{The `symmetric' option implies `twoside'}
  50. \ExecuteOptionsX[tufte]<common>{twoside}
  51. }
  52. %%
  53. % `twoside' option -- alternates running heads
  54. \newboolean{@tufte@twoside}
  55. \DeclareOptionX[tufte]<common>{twoside}{%
  56. \setboolean{@tufte@twoside}{true}
  57. \ClassInfo{\@tufte@pkgname}{Passing the `twoside' option to the `\@tufte@class' class}
  58. \PassOptionsToClass{twoside}{\@tufte@class}
  59. }
  60. %%
  61. % `notoc' option -- suppresses the Tufte-style table of contents
  62. \newboolean{@tufte@toc}
  63. \setboolean{@tufte@toc}{true}
  64. \DeclareOptionX[tufte]<common>{notoc}{\setboolean{@tufte@toc}{false}}
  65. \DeclareOptionX[tufte]<common>{toc}{\setboolean{@tufte@toc}{true}}
  66. %%
  67. % `justified' option -- uses fully justified text (flush left and flush
  68. % right) instead of ragged right.
  69. \newboolean{@tufte@justified}
  70. \DeclareOptionX[tufte]<common>{justified}{\setboolean{@tufte@justified}{true}}
  71. %%
  72. % `bidi' option -- loads the bidi package for bi-directional text
  73. \newboolean{@tufte@loadbidi}
  74. \DeclareOptionX[tufte]<common>{bidi}{\setboolean{@tufte@loadbidi}{true}}
  75. \DeclareOptionX[tufte]<common>{nobidi}{\setboolean{@tufte@loadbidi}{false}}
  76. %%
  77. % `nohyper' option -- suppresses loading of the hyperref package
  78. \newboolean{@tufte@loadhyper}
  79. \setboolean{@tufte@loadhyper}{true}
  80. \DeclareOptionX[tufte]<common>{hyper}{\setboolean{@tufte@loadhyper}{true}}
  81. \DeclareOptionX[tufte]<common>{nohyper}{\setboolean{@tufte@loadhyper}{false}}
  82. %%
  83. % `sidenote', `marginnote', `caption', `citation', `marginals' options
  84. % Each allows one of {justified,raggedleft,raggedright,raggedouter,auto}.
  85. \newcommand*{\@tufte@sidenote@justification}{\@tufte@justification@autodetect}
  86. \define@choicekey*+[tufte]{common}{sidenote}[\@tufte@kvtext\@tufte@kvnum]{justified,raggedleft,raggedright,raggedouter,auto}[auto]{%
  87. \ifcase\@tufte@kvnum\relax
  88. \renewcommand*{\@tufte@sidenote@justification}{\justifying}% justified
  89. \or
  90. \renewcommand*{\@tufte@sidenote@justification}{\RaggedLeft}% ragged left
  91. \or
  92. \renewcommand*{\@tufte@sidenote@justification}{\RaggedRight}% ragged right
  93. \or
  94. \renewcommand*{\@tufte@sidenote@justification}{\@tufte@justification@outer}% ragged outer (flush right on verso pages, flush left on recto pages)
  95. \or
  96. \renewcommand*{\@tufte@sidenote@justification}{\@tufte@justification@autodetect}% autodetects best justification mode based on all class options
  97. \fi
  98. }{%
  99. \PackageWarningNoLine{\@tufte@pkgname}{Invalid option `#1' for sidenote key.\MessageBreak Must be one of: justified, raggedleft,\MessageBreak raggedright, raggedouter, auto}
  100. \renewcommand*{\@tufte@sidenote@justification}{\@tufte@justification@autodetect}% autodetects best justification mode based on all class options
  101. }
  102. \newcommand*{\@tufte@marginnote@justification}{\@tufte@justification@autodetect}
  103. \define@choicekey*+[tufte]{common}{marginnote}[\@tufte@kvtext\@tufte@kvnum]{justified,raggedleft,raggedright,raggedouter,auto}[auto]{%
  104. \ifcase\@tufte@kvnum\relax
  105. \renewcommand*{\@tufte@marginnote@justification}{\justifying}% justified
  106. \or
  107. \renewcommand*{\@tufte@marginnote@justification}{\RaggedLeft}% ragged left
  108. \or
  109. \renewcommand*{\@tufte@marginnote@justification}{\RaggedRight}% ragged right
  110. \or
  111. \renewcommand*{\@tufte@marginnote@justification}{\@tufte@justification@outer}% ragged outer (flush right on verso pages, flush left on recto pages)
  112. \or
  113. \renewcommand*{\@tufte@marginnote@justification}{\@tufte@justification@autodetect}% autodetects best justification mode based on all class options
  114. \fi
  115. }{%
  116. \PackageWarningNoLine{\@tufte@pkgname}{Invalid option `#1' for marginnote key.\MessageBreak Must be one of: justified, raggedleft,\MessageBreak raggedright, raggedouter, auto}
  117. \renewcommand*{\@tufte@marginnote@justification}{\@tufte@justification@autodetect}% autodetects best justification mode based on all class options
  118. }
  119. \newcommand*{\@tufte@caption@justification}{\@tufte@justification@autodetect}
  120. \define@choicekey*+[tufte]{common}{caption}[\@tufte@kvtext\@tufte@kvnum]{justified,raggedleft,raggedright,raggedouter,auto}[auto]{%
  121. \ifcase\@tufte@kvnum\relax
  122. \renewcommand*{\@tufte@caption@justification}{\justifying}% justified
  123. \or
  124. \renewcommand*{\@tufte@caption@justification}{\RaggedLeft}% ragged left
  125. \or
  126. \renewcommand*{\@tufte@caption@justification}{\RaggedRight}% ragged right
  127. \or
  128. \renewcommand*{\@tufte@caption@justification}{\@tufte@justification@caption@outer}% ragged outer (flush right on verso pages, flush left on recto pages)
  129. \or
  130. \renewcommand*{\@tufte@caption@justification}{\@tufte@justification@autodetect}% autodetects best justification mode based on all class options
  131. \fi
  132. }{%
  133. \PackageWarningNoLine{\@tufte@pkgname}{Invalid option `#1' for caption key.\MessageBreak Must be one of: justified, raggedleft,\MessageBreak raggedright, raggedouter, auto}
  134. \renewcommand*{\@tufte@caption@justification}{\@tufte@justification@autodetect}% autodetects best justification mode based on all class options
  135. }
  136. \newcommand*{\@tufte@citation@justification}{\@tufte@justification@autodetect}
  137. \define@choicekey*+[tufte]{common}{citation}[\@tufte@kvtext\@tufte@kvnum]{justified,raggedleft,raggedright,raggedouter,auto}[auto]{%
  138. \ifcase\@tufte@kvnum\relax
  139. \renewcommand*{\@tufte@citation@justification}{\justifying}% justified
  140. \or
  141. \renewcommand*{\@tufte@citation@justification}{\RaggedLeft}% ragged left
  142. \or
  143. \renewcommand*{\@tufte@citation@justification}{\RaggedRight}% ragged right
  144. \or
  145. \renewcommand*{\@tufte@citation@justification}{\@tufte@justification@outer}% ragged outer (flush right on verso pages, flush left on recto pages)
  146. \or
  147. \renewcommand*{\@tufte@citation@justification}{\@tufte@justification@autodetect}% autodetects best justification mode based on all class options
  148. \fi
  149. }{%
  150. \PackageWarningNoLine{\@tufte@pkgname}{Invalid option `#1' for citation key.\MessageBreak Must be one of: justified, raggedleft,\MessageBreak raggedright, raggedouter, auto}
  151. \renewcommand*{\@tufte@citation@justification}{\@tufte@justification@autodetect}% autodetects best justification mode based on all class options
  152. }
  153. % The ``marginals'' key simultaneously sets the same justification for all marginal material
  154. \define@choicekey*+[tufte]{common}{marginals}[\@tufte@kvtext\@tufte@kvnum]{justified,raggedleft,raggedright,raggedouter,auto}[auto]{%
  155. \ifcase\@tufte@kvnum\relax
  156. \ExecuteOptionsX[tufte]<common>{citation=justified,sidenote=justified,caption=justified,marginnote=justified}% justified
  157. \or
  158. \ExecuteOptionsX[tufte]<common>{citation=raggedleft,sidenote=raggedleft,caption=raggedleft,marginnote=raggedleft}% ragged left
  159. \or
  160. \ExecuteOptionsX[tufte]<common>{citation=raggedright,sidenote=raggedright,caption=raggedright,marginnote=raggedright}% ragged right
  161. \or
  162. \ExecuteOptionsX[tufte]<common>{citation=raggedouter,sidenote=raggedouter,caption=raggedouter,marginnote=raggedouter}% ragged outer (flush right on verso pages, flush left on recto pages)
  163. \or
  164. \ExecuteOptionsX[tufte]<common>{citation=auto,sidenote=auto,caption=auto,marginnote=auto}% autodetects best justification mode based on all class options
  165. \fi
  166. }{%
  167. \PackageWarningNoLine{\@tufte@pkgname}{Invalid option `#1' for marginals key.\MessageBreak Must be one of: justified, raggedleft,\MessageBreak raggedright, raggedouter, auto}
  168. \ExecuteOptionsX[tufte]<common>{citation=auto,sidenote=auto,caption=auto,marginnote=auto}% autodetects best justification mode based on all class options
  169. }
  170. %%
  171. % Unsupported options
  172. \newcommand{\@tufte@unsupported@option}[1]{\ClassWarningNoLine{\@tufte@pkgname}{Option `#1' is not supported -- \MessageBreak ignoring option}\OptionNotUsed}
  173. \DeclareOptionX[tufte]<common>{10pt}{\@tufte@unsupported@option{\CurrentOption}}
  174. \DeclareOptionX[tufte]<common>{11pt}{\@tufte@unsupported@option{\CurrentOption}}
  175. \DeclareOptionX[tufte]<common>{12pt}{\@tufte@unsupported@option{\CurrentOption}}
  176. \DeclareOptionX[tufte]<common>{a5paper}{\@tufte@unsupported@option{\CurrentOption}}
  177. \DeclareOptionX[tufte]<common>{executivepaper}{\@tufte@unsupported@option{\CurrentOption}}
  178. \DeclareOptionX[tufte]<common>{legalpaper}{\@tufte@unsupported@option{\CurrentOption}}
  179. \DeclareOptionX[tufte]<common>{landscape}{\@tufte@unsupported@option{\CurrentOption}}
  180. \DeclareOptionX[tufte]<common>{onecolumn}{\@tufte@unsupported@option{\CurrentOption}}
  181. \DeclareOptionX[tufte]<common>{twocolumn}{\@tufte@unsupported@option{\CurrentOption}}
  182. %%
  183. % Default `book' and `handout' options
  184. \ifthenelse{\equal{\@tufte@pkgname}{tufte-book}}
  185. {\ExecuteOptionsX[tufte]<common>{titlepage}}
  186. {\ExecuteOptionsX[tufte]<common>{notitlepage}}
  187. \DeclareOptionX*{%
  188. \ClassInfo{\@tufte@pkgname}{Passing \CurrentOption\space to the `\@tufte@class' class}%
  189. \PassOptionsToClass{\CurrentOption}{\@tufte@class}%
  190. }
  191. \ProcessOptionsX*[tufte]<common>\relax
  192. %%
  193. % Load the appropriate base class
  194. \ClassInfo{\@tufte@pkgname}{Loading the base class `\@tufte@class'}
  195. \LoadClass{\@tufte@class}
  196. %%
  197. % Detect whether we're in two-side mode or not. (Used to set up running
  198. % heads later.)
  199. \ifthenelse{\boolean{@twoside}}
  200. {\setboolean{@tufte@twoside}{true}}
  201. {}
  202. %%
  203. % Detect if we're using pdfLaTeX
  204. \newboolean{@tufte@pdf}
  205. \IfFileExists{ifpdf.sty}{%
  206. \RequirePackage{ifpdf}
  207. \ifthenelse{\boolean{pdf}}
  208. {\setboolean{@tufte@pdf}{true}}
  209. {\setboolean{@tufte@pdf}{false}}
  210. }{% assume we're not using pdfTex?
  211. \setboolean{@tufte@pdf}{false}
  212. }
  213. %%
  214. % Detect if we're using XeLaTeX
  215. \newboolean{@tufte@xetex}
  216. \IfFileExists{ifxetex.sty}{%
  217. \RequirePackage{ifxetex}
  218. \ifthenelse{\boolean{xetex}}
  219. {\setboolean{@tufte@xetex}{true}}
  220. {\setboolean{@tufte@xetex}{false}}
  221. }{% not using xelatex
  222. \setboolean{@tufte@xetex}{false}
  223. }
  224. %%
  225. % Load the `hyperref' package. We will set more options later.
  226. % TODO Set nice defaults for hyperref options
  227. \ifthenelse{\boolean{@tufte@loadhyper}}{%
  228. \ifthenelse{\boolean{@tufte@xetex}}
  229. {\RequirePackage[xetex]{hyperref}}
  230. {\RequirePackage{hyperref}}
  231. \hypersetup{%
  232. pdfborder = {0 0 0},
  233. bookmarksdepth = section,
  234. hyperfootnotes = false,
  235. citecolor = DarkGreen,
  236. linkcolor = DarkBlue,
  237. pagecolor = DarkBlue,
  238. urlcolor = DarkGreen,
  239. }%
  240. }{%
  241. }
  242. %%
  243. % Set the font sizes and baselines to match Tufte's books
  244. \renewcommand\normalsize{%
  245. \@setfontsize\normalsize\@xpt{14}%
  246. \abovedisplayskip 10\p@ \@plus2\p@ \@minus5\p@
  247. \abovedisplayshortskip \z@ \@plus3\p@
  248. \belowdisplayshortskip 6\p@ \@plus3\p@ \@minus3\p@
  249. \belowdisplayskip \abovedisplayskip
  250. \let\@listi\@listI}
  251. \normalbaselineskip=14pt
  252. \normalsize
  253. \renewcommand\small{%
  254. \@setfontsize\small\@ixpt{12}%
  255. \abovedisplayskip 8.5\p@ \@plus3\p@ \@minus4\p@
  256. \abovedisplayshortskip \z@ \@plus2\p@
  257. \belowdisplayshortskip 4\p@ \@plus2\p@ \@minus2\p@
  258. \def\@listi{\leftmargin\leftmargini
  259. \topsep 4\p@ \@plus2\p@ \@minus2\p@
  260. \parsep 2\p@ \@plus\p@ \@minus\p@
  261. \itemsep \parsep}%
  262. \belowdisplayskip \abovedisplayskip
  263. }
  264. \renewcommand\footnotesize{%
  265. \@setfontsize\footnotesize\@viiipt{10}%
  266. \abovedisplayskip 6\p@ \@plus2\p@ \@minus4\p@
  267. \abovedisplayshortskip \z@ \@plus\p@
  268. \belowdisplayshortskip 3\p@ \@plus\p@ \@minus2\p@
  269. \def\@listi{\leftmargin\leftmargini
  270. \topsep 3\p@ \@plus\p@ \@minus\p@
  271. \parsep 2\p@ \@plus\p@ \@minus\p@
  272. \itemsep \parsep}%
  273. \belowdisplayskip \abovedisplayskip
  274. }
  275. \renewcommand\scriptsize{\@setfontsize\scriptsize\@viipt\@viiipt}
  276. \renewcommand\tiny{\@setfontsize\tiny\@vpt\@vipt}
  277. \renewcommand\large{\@setfontsize\large\@xipt{15}}
  278. \renewcommand\Large{\@setfontsize\Large\@xiipt{16}}
  279. \renewcommand\LARGE{\@setfontsize\LARGE\@xivpt{18}}
  280. \renewcommand\huge{\@setfontsize\huge\@xxpt{30}}
  281. \renewcommand\Huge{\@setfontsize\Huge{24}{36}}
  282. \setlength\leftmargini {1pc}
  283. \setlength\leftmarginii {1pc}
  284. \setlength\leftmarginiii {1pc}
  285. \setlength\leftmarginiv {1pc}
  286. \setlength\leftmarginv {1pc}
  287. \setlength\leftmarginvi {1pc}
  288. \setlength\labelsep {.5pc}
  289. \setlength\labelwidth {\leftmargini}
  290. \addtolength\labelwidth{-\labelsep}
  291. %%
  292. % \RaggedRight allows hyphenation
  293. \RequirePackage{ragged2e}
  294. \setlength{\RaggedRightRightskip}{\z@ plus 0.08\hsize}
  295. \setlength{\RaggedRightParindent}{1pc}
  296. % Paragraph indentation and separation for normal text
  297. \newcommand{\@tufte@reset@par}{%
  298. \setlength{\RaggedRightParindent}{1.0pc}%
  299. \setlength{\parindent}{1pc}%
  300. \setlength{\parskip}{0pt}%
  301. }
  302. \@tufte@reset@par
  303. % Paragraph indentation and separation for marginal text
  304. \newcommand{\@tufte@margin@par}{%
  305. \setlength{\RaggedRightParindent}{0.5pc}%
  306. \setlength{\parindent}{0.5pc}%
  307. \setlength{\parskip}{0pt}%
  308. }
  309. %%
  310. % Set page layout geometry
  311. \RequirePackage[letterpaper,left=1in,top=1in,headsep=2\baselineskip,textwidth=26pc,marginparsep=2pc,marginparwidth=12pc,textheight=44\baselineskip,headheight=\baselineskip]{geometry}
  312. \ifthenelse{\boolean{@tufte@afourpaper}}
  313. {\geometry{a4paper,left=24.8mm,top=27.4mm,headsep=2\baselineskip,textwidth=107mm,marginparsep=8.2mm,marginparwidth=49.4mm,textheight=49\baselineskip,headheight=\baselineskip}}
  314. {}
  315. \ifthenelse{\boolean{@tufte@bfivepaper}}
  316. {\geometry{paperwidth=176mm,paperheight=250mm,left=14.66mm,top=13.88mm,textwidth=102.66mm,marginparsep=7.33mm,marginparwidth=36.66mm,textheight=38\baselineskip,includehead}}
  317. {}
  318. \ifthenelse{\boolean{@tufte@symmetric}}
  319. {}
  320. {\geometry{asymmetric}}% forces internal LaTeX `twoside'
  321. %%
  322. % Separation marginpars by a line's worth of space.
  323. \setlength\marginparpush{10pt}
  324. %%
  325. % Font for margin items
  326. \ifthenelse{\boolean{@tufte@sfsidenotes}}
  327. {\newcommand{\@tufte@marginfont}{\normalfont\footnotesize\sffamily}}
  328. {\newcommand{\@tufte@marginfont}{\normalfont\footnotesize}}
  329. %%
  330. % Set the justification baesed on the `justified' class option
  331. \newcommand{\@tufte@justification}{%
  332. \ifthenelse{\boolean{@tufte@justified}}%
  333. {\justifying}%
  334. {\RaggedRight}%
  335. }
  336. %%
  337. % Turn off section numbering
  338. \setcounter{secnumdepth}{-1}
  339. %%
  340. % Tighten up space between displays (e.g., a figure or table) and make symmetric
  341. \setlength\abovedisplayskip{6pt plus 2pt minus 4pt}
  342. \setlength\belowdisplayskip{6pt plus 2pt minus 4pt}
  343. %%
  344. % To implement full-width display environments
  345. \newboolean{@tufte@changepage}
  346. \IfFileExists{changepage.sty}{%
  347. \ClassInfo{\@tufte@pkgname}{Found changepage.sty}
  348. \RequirePackage[strict]{changepage}
  349. \setboolean{@tufte@changepage}{true}
  350. }{%
  351. \ClassInfo{\@tufte@pkgname}{Found chngpage.sty}
  352. \RequirePackage[strict]{chngpage}
  353. \setboolean{@tufte@changepage}{false}
  354. }
  355. % Write our own aliases for the \checkoddpage and \ifoddpage or \ifcpoddpage commands
  356. \newboolean{@tufte@odd@page}
  357. \setboolean{@tufte@odd@page}{true}
  358. \newcommand*{\@tufte@checkoddpage}{%
  359. \checkoddpage%
  360. \ifthenelse{\boolean{@tufte@changepage}}{%
  361. \ifoddpage%
  362. \setboolean{@tufte@odd@page}{true}%
  363. \else%
  364. \setboolean{@tufte@odd@page}{false}%
  365. \fi%
  366. }{%
  367. \ifcpoddpage%
  368. \setboolean{@tufte@odd@page}{true}%
  369. \else%
  370. \setboolean{@tufte@odd@page}{false}%
  371. \fi%
  372. }%
  373. }
  374. %%
  375. % Compute lengths used for full-width displays
  376. \newlength{\@tufte@overhang}% used by the fullwidth environment and the running heads
  377. \newlength{\@tufte@fullwidth}
  378. \newlength{\@tufte@caption@fill}
  379. \newcommand{\TufteRecalculate}{%
  380. \setlength{\@tufte@overhang}{\marginparwidth}
  381. \addtolength{\@tufte@overhang}{\marginparsep}
  382. \setlength{\@tufte@fullwidth}{\textwidth}
  383. \addtolength{\@tufte@fullwidth}{\marginparsep}
  384. \addtolength{\@tufte@fullwidth}{\marginparwidth}
  385. \setlength{\@tufte@caption@fill}{\textwidth}
  386. \addtolength{\@tufte@caption@fill}{\marginparsep}
  387. }
  388. \AtBeginDocument{\TufteRecalculate}
  389. %%
  390. % Modified \title, \author, and \date commands. These store the
  391. % (footnote-less) values in \plaintitle, \plainauthor, and \thedate, respectively.
  392. \newcommand{\plaintitle}{}% plain-text-only title
  393. \newcommand{\plainauthor}{}% plain-text-only author
  394. \newcommand{\plainpublisher}{}% plain-text-only publisher
  395. \newcommand{\thanklesstitle}{}% full title text minus \thanks{}
  396. \newcommand{\thanklessauthor}{}% full author text minus \thanks{}
  397. \newcommand{\thanklesspublisher}{}% full publisher minus \thanks{}
  398. \newcommand{\@publisher}{}% full publisher with \thanks{}
  399. \newcommand{\thedate}{\today}
  400. % TODO Fix it so that \thanks is not spaced out (with `soul') and can be
  401. % used in \maketitle when the `sfsidenotes' option is provided.
  402. \renewcommand{\thanks}[1]{\NoCaseChange{\footnote{#1}}}
  403. \renewcommand{\title}[2][]{%
  404. \gdef\@title{#2}%
  405. \begingroup%
  406. % TODO store contents of \thanks command
  407. \renewcommand{\thanks}[1]{}% swallow \thanks contents
  408. \protected@xdef\thanklesstitle{#2}%
  409. \endgroup%
  410. \ifthenelse{\isempty{#1}}%
  411. {\renewcommand{\plaintitle}{\thanklesstitle}}% use thankless title
  412. {\renewcommand{\plaintitle}{#1}}% use provided plain-text title
  413. \ifthenelse{\boolean{@tufte@loadhyper}}{\hypersetup{pdftitle={\plaintitle}}}{}% set the PDF metadata title
  414. }
  415. \def\@author{}% default author is empty (suppresses LaTeX's ``no author'' warning)
  416. \renewcommand*{\author}[2][]{%
  417. \gdef\@author{#2}%
  418. \begingroup%
  419. % TODO store contents of \thanks command
  420. \renewcommand{\thanks}[1]{}% swallow \thanks contents
  421. \protected@xdef\thanklessauthor{#2}%
  422. \endgroup%
  423. \ifthenelse{\isempty{#1}}
  424. {\renewcommand{\plainauthor}{\thanklessauthor}}% use thankless author
  425. {\renewcommand{\plainauthor}{#1}}% use provided plain-text author
  426. \ifthenelse{\boolean{@tufte@loadhyper}}{\hypersetup{pdfauthor={\plainauthor}}}{}% set the PDF metadata author
  427. }
  428. \renewcommand*{\date}[1]{%
  429. \gdef\@date{#1}%
  430. \begingroup%
  431. % TODO store contents of \thanks command
  432. \renewcommand{\thanks}[1]{}% swallow \thanks contents
  433. \protected@xdef\thedate{#1}%
  434. \endgroup%
  435. }
  436. %%
  437. % Provides a \publisher command to set the publisher
  438. \newcommand{\publisher}[2][]{%
  439. \gdef\@publisher{#2}%
  440. \begingroup%
  441. \renewcommand{\thanks}[1]{}% swallow \thanks contents
  442. \protected@xdef\thanklesspublisher{#2}%
  443. \endgroup%
  444. \ifthenelse{\isempty{#1}}
  445. {\renewcommand{\plainpublisher}{\thanklesspublisher}}% use thankless publisher
  446. {\renewcommand{\plainpublisher}{#1}}% use provided plain-text publisher
  447. }
  448. % TODO: Test \hypersetup{pdfauthor,pdftitle} with DVI and XeTeX
  449. %%
  450. % Require paralist package for tighter lists
  451. \RequirePackage{paralist}
  452. % Add rightmargin to compactenum
  453. \def\@compactenum@{%
  454. \expandafter\list\csname label\@enumctr\endcsname{%
  455. \usecounter{\@enumctr}%
  456. \rightmargin=2em% added this
  457. \parsep\plparsep
  458. \itemsep\plitemsep
  459. \topsep\pltopsep
  460. \partopsep\plpartopsep
  461. \def\makelabel##1{\hss\llap{##1}}}}
  462. %%
  463. % Improved letterspacing of small caps and all-caps text.
  464. %
  465. % First, try to use the `microtype' package, if it's available.
  466. % Failing that, try to use the `soul' package, if it's available.
  467. % Failing that, well, I give up.
  468. \RequirePackage{textcase} % provides \MakeTextUppercase and \MakeTextLowercase
  469. \def\allcapsspacing{\relax}
  470. \def\smallcapsspacing{\relax}
  471. \newcommand{\allcaps}[1]{\MakeTextUppercase{\allcapsspacing{#1}}}
  472. \newcommand{\smallcaps}[1]{\MakeTextLowercase{\textsc{#1}}}
  473. \newcommand{\@tufte@loadsoul}{%
  474. \IfFileExists{soul.sty}{%
  475. \RequirePackage{soul}
  476. \sodef\allcapsspacing{\upshape}{0.15em}{0.65em}{0.6em}
  477. \sodef\smallcapsspacing{\scshape}{0.075em}{0.5em}{0.6em}
  478. }{
  479. \ClassWarningNoLine{\@tufte@pkgname}{Couldn't locate `soul' package.}
  480. }% soul not installed... giving up.
  481. }
  482. % If we're using pdfLaTeX v1.40+, use the letterspace package.
  483. % If we're using pdfLaTex < v1.40, use the soul package.
  484. % If we're using XeLaTeX, use XeLaTeX letterspacing options.
  485. % Otherwise fall back on the soul package.
  486. \ifthenelse{\boolean{@tufte@pdf}}
  487. {\ClassInfo{\@tufte@pkgname}{ifpdf = true}}
  488. {\ClassInfo{\@tufte@pkgname}{ifpdf = false}}
  489. \ifthenelse{\boolean{@tufte@xetex}}
  490. {\ClassInfo{\@tufte@pkgname}{ifxetex = true}}
  491. {\ClassInfo{\@tufte@pkgname}{ifxetex = false}}
  492. % Check pdfLaTeX version
  493. \def\@tufte@pdftexversion{0}
  494. \ifx\normalpdftexversion\@undefined \else
  495. \let\pdftexversion \normalpdftexversion
  496. \let\pdftexrevision\normalpdftexrevision
  497. \let\pdfoutput \normalpdfoutput
  498. \fi
  499. \ifx\pdftexversion\@undefined \else
  500. \ifx\pdftexversion\relax \else
  501. \def\@tufte@pdftexversion{6}
  502. \ifnum\pdftexversion < 140
  503. \def\@tufte@pdftexversion{5}
  504. \fi
  505. \fi
  506. \fi
  507. \ifthenelse{\boolean{@tufte@letterspace}}
  508. {%
  509. \ifnum\@tufte@pdftexversion<6
  510. % pdfLaTeX version is too old or not using pdfLaTeX
  511. \ifthenelse{\boolean{@tufte@xetex}}
  512. {% TODO use xetex letterspacing
  513. \ClassInfo{\@tufte@pkgname}{XeTeX detected. Reverting to `soul' package for letterspacing.}
  514. \@tufte@loadsoul}
  515. {% use `soul' package for letterspacing
  516. \ClassInfo{\@tufte@pkgname}{Old version of pdfTeX detected. Reverting to `soul' package for letterspacing.}
  517. \@tufte@loadsoul}
  518. \else
  519. \IfFileExists{letterspace.sty}{%
  520. \ClassInfo{\@tufte@pkgname}{Modern version of pdfTeX detected. Using `letterspace' package.}
  521. \RequirePackage{letterspace}
  522. % Set up letterspacing (using microtype package) -- requires pdfTeX v1.40+
  523. \renewcommand{\allcapsspacing}[1]{\textls[200]{##1}}
  524. \renewcommand{\smallcapsspacing}[1]{\textls[50]{##1}}
  525. \renewcommand{\allcaps}[1]{\textls[200]{\MakeTextUppercase{##1}}}
  526. \renewcommand{\smallcaps}[1]{\textsc{\MakeTextLowercase{##1}}}
  527. }{% microtype failed, check for soul
  528. \ClassInfo{\@tufte@pkgname}{Modern version of pdfTeX detected, but `letterspace' package not installed. Reverting to `soul' package for letterspacing.}
  529. \@tufte@loadsoul
  530. }
  531. \fi}
  532. {}
  533. \DeclareTextFontCommand{\textsmallcaps}{\scshape}
  534. \renewcommand{\textsc}[1]{\textsmallcaps{\smallcapsspacing{#1}}}
  535. %%
  536. % An environment for paragraph-style section
  537. \providecommand\newthought[1]{%
  538. \addvspace{1.0\baselineskip plus 0.5ex minus 0.2ex}%
  539. \noindent\textsc{#1}%
  540. }
  541. %%
  542. % Redefine the display environments (quote, quotation, etc.)
  543. \renewenvironment{verse}
  544. {\let\\\@centercr
  545. \list{}{\itemsep \z@
  546. \itemindent -1pc%
  547. \listparindent\itemindent
  548. \rightmargin \leftmargin
  549. \advance\leftmargin 1pc}%
  550. \small%
  551. \item\relax}
  552. {\endlist}
  553. \renewenvironment{quotation}
  554. {\list{}{\listparindent 1pc%
  555. \itemindent \listparindent
  556. \rightmargin \leftmargin
  557. \parsep \z@ \@plus\p@}%
  558. \small%
  559. \item\relax\noindent\ignorespaces}
  560. {\endlist}
  561. \renewenvironment{quote}
  562. {\list{}{\rightmargin\leftmargin}%
  563. \small%
  564. \item\relax}
  565. {\endlist}
  566. %%
  567. % Italicize description run-in headings (instead of the default bold)
  568. \renewcommand*\descriptionlabel[1]{\hspace\labelsep\normalfont\em #1}
  569. %%
  570. % Used for doublespacing, and other linespacing
  571. \RequirePackage{setspace}
  572. %%
  573. % Load the bidi package if instructed to do so. This package must be loaded
  574. % prior to our redefining the \footnote and \cite commands.
  575. \ifthenelse{\boolean{@tufte@loadbidi}}{\RequirePackage{bidi}}{}
  576. %%
  577. % A function that removes leading and trailling spaces from the supplied macro.
  578. % Based on code written by Michael Downes (See ``Around the Bend'', #15.)
  579. % Executing \@tufte@trim@spaces\xyzzy will result in the contents of \xyzzy
  580. % being trimmed of leading and trailing white space.
  581. \catcode`\Q=3
  582. \def\@tufte@trim@spaces#1{%
  583. % Use grouping to emulate a multi-token afterassignment queue
  584. \begingroup%
  585. % Put `\toks 0 {' into the afterassignment queue
  586. \aftergroup\toks\aftergroup0\aftergroup{%
  587. % Apply \trimb to the replacement text of #1, adding a leading
  588. % \noexpand to prevent brace stripping and to serve another purpose
  589. % later.
  590. \expandafter\@tufte@trim@b\expandafter\noexpand#1Q Q}%
  591. % Transfer the trimmed text back into #1.
  592. \edef#1{\the\toks0}%
  593. }
  594. % \trimb removes a trailing space if present, then calls \@tufte@trim@c to
  595. % clean up any leftover bizarre Qs, and trim a leading space. In
  596. % order for \trimc to work properly we need to put back a Q first.
  597. \def\@tufte@trim@b#1 Q{\@tufte@trim@c#1Q}
  598. % Execute \vfuzz assignment to remove leading space; the \noexpand
  599. % will now prevent unwanted expansion of a macro or other expandable
  600. % token at the beginning of the trimmed text. The \endgroup will feed
  601. % in the \aftergroup tokens after the \vfuzz assignment is completed.
  602. \def\@tufte@trim@c#1Q#2{\afterassignment\endgroup \vfuzz\the\vfuzz#1}
  603. \catcode`\Q=11
  604. %%
  605. % Citations should go in the margin as sidenotes
  606. \RequirePackage{natbib}
  607. \RequirePackage{bibentry} % allows bibitems to be typeset outside thebibliography environment
  608. % Redefine the \BR@b@bibitem command to fix a bug with bibentry+chicago style
  609. \renewcommand\BR@b@bibitem[2][]{%
  610. \ifthenelse{\isempty{#1}}%
  611. {\BR@bibitem{#2}}%
  612. {\BR@bibitem[#1]{#2}}%
  613. \BR@c@bibitem{#2}%
  614. }
  615. \nobibliography* % pre-loads the bibliography keys
  616. \providecommand{\doi}[1]{\textsc{doi:} #1}% pre-defining this so it may be used before the \bibliography command it issued
  617. %%
  618. % Normal \cite behavior
  619. \newcounter{@tufte@num@bibkeys}%
  620. \newcommand{\@tufte@normal@cite}[2][0pt]{%
  621. % Snag the last bibentry in the list for later comparison
  622. \let\@temp@last@bibkey\@empty%
  623. \@for\@temp@bibkey:=#2\do{\let\@temp@last@bibkey\@temp@bibkey}%
  624. \sidenote[][#1]{%
  625. % Loop through all the bibentries, separating them with semicolons and spaces
  626. \setcounter{@tufte@num@bibkeys}{0}%
  627. \@for\@temp@bibkeyx:=#2\do{%
  628. \ifthenelse{\equal{\@temp@last@bibkey}{\@temp@bibkeyx}}%
  629. {\ifthenelse{\equal{\value{@tufte@num@bibkeys}}{0}}{}{and\ }%
  630. \@tufte@trim@spaces\@temp@bibkeyx% trim spaces around bibkey
  631. \bibentry{\@temp@bibkeyx}}%
  632. {\@tufte@trim@spaces\@temp@bibkeyx% trim spaces around bibkey
  633. \bibentry{\@temp@bibkeyx};\ }%
  634. \stepcounter{@tufte@num@bibkeys}%
  635. }%
  636. }%
  637. }
  638. %%
  639. % Macros for holding the list of cite keys until after the \sidenote
  640. \gdef\@tufte@citations{}% list of cite keys
  641. \newcommand\@tufte@add@citation[1]{\relax% adds a new bibkey to the list of cite keys
  642. \ifx\@tufte@citations\@empty\else
  643. \g@addto@macro\@tufte@citations{,}% separate by commas
  644. \fi
  645. \g@addto@macro\@tufte@citations{#1}
  646. }
  647. \newcommand{\@tufte@print@citations}[1][0pt]{% puts the citations in a margin note
  648. % Snag the last bibentry in the list for later comparison
  649. \let\@temp@last@bibkey\@empty%
  650. \@for\@temp@bibkey:=\@tufte@citations\do{\let\@temp@last@bibkey\@temp@bibkey}%
  651. \marginpar{%
  652. \hbox{}\vspace*{#1}%
  653. \@tufte@marginfont%
  654. \@tufte@citation@justification%
  655. \@tufte@margin@par% use parindent and parskip settings for marginal text
  656. \vspace*{-1\baselineskip}%
  657. % Loop through all the bibentries, separating them with semicolons and spaces
  658. \setcounter{@tufte@num@bibkeys}{0}%
  659. \@for\@temp@bibkeyx:=\@tufte@citations\do{%
  660. \ifthenelse{\equal{\@temp@last@bibkey}{\@temp@bibkeyx}}%
  661. {\ifthenelse{\equal{\value{@tufte@num@bibkeys}}{0}}{}{and\ }%
  662. \@tufte@trim@spaces\@temp@bibkeyx% trim spaces around bibkey
  663. \bibentry{\@temp@bibkeyx}}%
  664. {\@tufte@trim@spaces\@temp@bibkeyx% trim spaces around bibkey
  665. \bibentry{\@temp@bibkeyx};\ }%
  666. \stepcounter{@tufte@num@bibkeys}%
  667. }%
  668. \@tufte@reset@par% use parindent and parskip settings for body text
  669. }%
  670. }
  671. %%
  672. % \cite behavior when executed within a sidenote
  673. \newcommand{\@tufte@sidenote@citations}{}% contains list of \cites in sidenote
  674. \newcommand{\@tufte@infootnote@cite}[1]{%
  675. \@tufte@add@citation{#1}
  676. }
  677. %%
  678. % Set the default \cite style. This is set and reset by the \sidenote command.
  679. \let\cite\@tufte@normal@cite
  680. %%
  681. % Transform existing \footnotes into \sidenotes
  682. % Sidenote: ``Where God meant footnotes to go.'' ---Tufte
  683. \RequirePackage{optparams}% for our new sidenote commands -- provides multiple optional arguments for commands
  684. \providecommand*{\footnotelayout}{\@tufte@marginfont\@tufte@sidenote@justification}
  685. \renewcommand{\footnotelayout}{\@tufte@marginfont\@tufte@sidenote@justification}
  686. % Override footmisc's definition to set the sidenote marks (numbers) inside the
  687. % sidenote's text block.
  688. \long\def\@makefntext#1{\@textsuperscript{\@tufte@marginfont\tiny\@thefnmark}\,\footnotelayout#1}
  689. % Set the in-text footnote mark in the same typeface as the body text itself.
  690. \def\@makefnmark{\hbox{\@textsuperscript{\normalfont\footnotesize\@thefnmark}}}
  691. \providecommand*{\multiplefootnotemarker}{3sp}
  692. \providecommand*{\multfootsep}{,}
  693. \renewcommand*\@footnotemark{%
  694. \leavevmode%
  695. \ifhmode%
  696. \edef\@x@sf{\the\spacefactor}%
  697. \@tufte@check@multiple@sidenotes%
  698. \nobreak%
  699. \fi%
  700. \@makefnmark%
  701. \ifhmode\spacefactor\@x@sf\fi%
  702. \relax%
  703. }
  704. \newcommand{\@tufte@check@multiple@sidenotes}{%
  705. \ifdim\lastkern=\multiplefootnotemarker\relax%
  706. \edef\@x@sf{\the\spacefactor}%
  707. \unkern%
  708. \textsuperscript{\multfootsep}%
  709. \spacefactor\@x@sf\relax%
  710. \fi
  711. }
  712. \renewcommand\@footnotetext[2][0pt]{%
  713. \marginpar{%
  714. \hbox{}\vspace*{#1}%
  715. \def\baselinestretch {\setspace@singlespace}%
  716. \ifthenelse{\boolean{@tufte@loadbidi}}{\if@rl@footnote\@rltrue\else\@rlfalse\fi}{}%
  717. \reset@font\footnotesize%
  718. \@tufte@margin@par% use parindent and parskip settings for marginal text
  719. \vspace*{-1\baselineskip}\noindent%
  720. \protected@edef\@currentlabel{%
  721. \csname p@footnote\endcsname\@thefnmark%
  722. }%
  723. \color@begingroup%
  724. \@makefntext{%
  725. \ignorespaces#2%
  726. }%
  727. \color@endgroup%
  728. }%
  729. \@tufte@reset@par% use parindent and parskip settings for body text
  730. }%
  731. %
  732. % Define \sidenote command. Can handle \cite.
  733. \newcommand{\@tufte@sidenote@vertical@offset}{0pt}
  734. % #1 = footnote num, #2 = vertical offset, #3 = footnote text
  735. \long\def\@tufte@sidenote[#1][#2]#3{%
  736. \let\cite\@tufte@infootnote@cite% use the in-sidenote \cite command
  737. \gdef\@tufte@citations{}% clear out any old citations
  738. \ifthenelse{\NOT\isempty{#2}}{\renewcommand{\@tufte@sidenote@vertical@offset}{#2}}{}%
  739. \ifthenelse{\isempty{#1}}{%
  740. % no specific footnote number provided
  741. \stepcounter\@mpfn%
  742. \protected@xdef\@thefnmark{\thempfn}%
  743. \@footnotemark\@footnotetext[\@tufte@sidenote@vertical@offset]{#3}%
  744. }{%
  745. % specific footnote number provided
  746. \begingroup%
  747. \csname c@\@mpfn\endcsname #1\relax%
  748. \unrestored@protected@xdef\@thefnmark{\thempfn}%
  749. \endgroup%
  750. \@footnotemark\@footnotetext[\@tufte@sidenote@vertical@offset]{#3}%
  751. }%
  752. \@tufte@print@citations% print any citations
  753. \let\cite\@tufte@normal@cite% go back to using normal in-text \cite command
  754. \unskip\ignorespaces% remove extra white space
  755. \kern-\multiplefootnotemarker% remove \kern left behind by sidenote
  756. \kern\multiplefootnotemarker\relax% add new \kern here to replace the one we yanked
  757. }
  758. \newcommand*{\sidenote}{\optparams{\@tufte@sidenote}{[][0pt]}}
  759. \renewcommand*{\footnote}{\optparams{\@tufte@sidenote}{[][0pt]}}
  760. %%
  761. % Sidenote without the footnote mark
  762. \newcommand\marginnote[2][0pt]{%
  763. \let\cite\@tufte@infootnote@cite% use the in-sidenote \cite command
  764. \gdef\@tufte@citations{}% clear out any old citations
  765. \@tufte@margin@par% use parindent and parskip settings for marginal text
  766. \marginpar{\hbox{}\vspace*{#1}\@tufte@marginfont\@tufte@marginnote@justification\vspace*{-1\baselineskip}\noindent #2}%
  767. \@tufte@reset@par% use parindent and parskip settings for body text
  768. \@tufte@print@citations% print any citations
  769. \let\cite\@tufte@normal@cite% go back to using normal in-text \cite command
  770. }
  771. %%
  772. % The placeins package provides the \FloatBarrier command. This forces
  773. % LaTeX to place all of the floats before proceeding. We'll use this to
  774. % keep the float (figure and table) numbers in sequence.
  775. \RequirePackage{placeins}
  776. %%
  777. % Margin float environment
  778. \newsavebox{\@tufte@margin@floatbox}
  779. \newenvironment{@tufte@margin@float}[2][-1.2ex]%
  780. {\FloatBarrier% process all floats before this point so the figure/table numbers stay in order.
  781. \begin{lrbox}{\@tufte@margin@floatbox}%
  782. \begin{minipage}{\marginparwidth}%
  783. \@tufte@marginfont%
  784. \def\@captype{#2}%
  785. \hbox{}\vspace*{#1}%
  786. \@tufte@caption@justification%
  787. \@tufte@margin@par%
  788. \noindent%
  789. }
  790. {\end{minipage}%
  791. \end{lrbox}%
  792. \marginpar{\usebox{\@tufte@margin@floatbox}}%
  793. \@tufte@reset@par%
  794. }
  795. %%
  796. % Margin figure environment
  797. \newenvironment{marginfigure}[1][-1.2ex]%
  798. {\begin{@tufte@margin@float}[#1]{figure}}
  799. {\end{@tufte@margin@float}}
  800. %%
  801. % Margin table environment
  802. \newenvironment{margintable}[1][-1.2ex]%
  803. {\begin{@tufte@margin@float}[#1]{table}}
  804. {\end{@tufte@margin@float}}
  805. %%
  806. % Auto-detects the proper text alignment based on the various class options
  807. \newcommand*{\@tufte@justification@autodetect}{%
  808. \ifthenelse{\boolean{@tufte@justified}}%
  809. {\justifying}%
  810. {\RaggedRight}%
  811. }
  812. %%
  813. % Forces the outer edge of the caption to be set ragged.
  814. % Therefore, on verso pages it's ragged left, and on recto pages it's ragged right.
  815. \newcommand*{\@tufte@justification@caption@outer}{%
  816. \ifthenelse{\boolean{@tufte@float@recto}}%
  817. {\RaggedRight}%
  818. {\RaggedLeft}%
  819. }
  820. \newcommand*{\@tufte@justification@outer}{%
  821. \@tufte@checkoddpage%
  822. \ifthenelse{\boolean{@tufte@odd@page}}%
  823. {\RaggedRight}%
  824. {\RaggedLeft}%
  825. }
  826. %%
  827. % A collection of macros to be used with the new Tufte-style float environments.
  828. % \setfloatalignment forces the caption placement to be treated as top, bottom, etc.
  829. % \forcerectofloat forces the float to be treated as if it were appearing on a recto page.
  830. % \forceversofloat does the same, but for verso pages.
  831. \newcommand{\floatalignment}{x}% holds the current float alignment (t, b, h, p)
  832. \newcommand{\setfloatalignment}[1]{\global\def\floatalignment{#1}}% manually sets the float alignment
  833. \newboolean{@tufte@float@recto}
  834. \newcommand{\forcerectofloat}{\global\@tufte@float@rectotrue}
  835. \newcommand{\forceversofloat}{\global\@tufte@float@rectofalse}
  836. % Boxes to temporarily store our float and caption
  837. \newsavebox{\@tufte@figure@box}
  838. \newsavebox{\@tufte@caption@box}
  839. % Save original LaTeX float environment
  840. \let\@tufte@orig@float\@float
  841. \let\@tufte@orig@endfloat\end@float
  842. % Save original LaTeX \caption and \label commands
  843. \AtBeginDocument{%
  844. \let\@tufte@orig@caption\caption%
  845. \let\@tufte@orig@label\label%
  846. }
  847. % Store the caption and label contents
  848. \newcommand{\@tufte@stored@shortcaption}{}
  849. \newcommand{\@tufte@stored@caption}{}
  850. \newcommand{\@tufte@stored@label}{}
  851. \newcommand{\@tufte@caption}[2][]{%
  852. \ifthenelse{\isempty{#1}}%
  853. {\gdef\@tufte@stored@shortcaption{#2}}%
  854. {\gdef\@tufte@stored@shortcaption{#1}}%
  855. \gdef\@tufte@stored@caption{#2}%
  856. }
  857. \newcommand{\@tufte@label}[1]{%
  858. \gdef\@tufte@stored@label{#1}%
  859. }
  860. \newcommand{\@tufte@fps}{}
  861. \newboolean{@tufte@float@star}
  862. \newlength{\@tufte@float@contents@width}
  863. %%
  864. % Define a float environment to place the captions in the margin space
  865. \newenvironment{@tufte@float}[3][htbp]%
  866. {% begin @tufte@float
  867. % Should this float be full-width or just text-width?
  868. \ifthenelse{\equal{#3}{star}}%
  869. {\setboolean{@tufte@float@star}{true}}%
  870. {\setboolean{@tufte@float@star}{false}}%
  871. % Check page side (recto/verso) and store detected value -- can be overriden in environment contents
  872. \@tufte@checkoddpage%
  873. \ifthenelse{\boolean{@tufte@odd@page}}%
  874. {\global\@tufte@float@rectotrue}%
  875. {\global\@tufte@float@rectofalse}%
  876. % If the float placement specifier is 'b' and only 'b', then bottom-align the mini-pages, otherwise top-align them.
  877. \renewcommand{\@tufte@fps}{#1}%
  878. \ifthenelse{\equal{#1}{b}\OR\equal{#1}{B}}%
  879. {\renewcommand{\floatalignment}{b}}%
  880. {\renewcommand{\floatalignment}{t}}%
  881. % Caption the contents of the \caption and \label commands to use later
  882. \renewcommand{\caption}[2][]{\@tufte@caption[##1]{##2}}%
  883. \renewcommand{\label}[1]{\@tufte@label{##1}}%
  884. \@tufte@orig@float{#2}[#1]%
  885. \ifthenelse{\boolean{@tufte@float@star}}%
  886. {\setlength{\@tufte@float@contents@width}{\@tufte@fullwidth}}%
  887. {\setlength{\@tufte@float@contents@width}{\textwidth}}%
  888. \begin{lrbox}{\@tufte@figure@box}%
  889. \begin{minipage}[\floatalignment]{\@tufte@float@contents@width}\hbox{}%
  890. }{% end @tufte@float
  891. \par\hbox{}\vspace{-\baselineskip}\ifthenelse{\prevdepth>0}{\vspace{-\prevdepth}}{}% align baselines of boxes
  892. \end{minipage}%
  893. \end{lrbox}%
  894. % build the caption box
  895. \begin{lrbox}{\@tufte@caption@box}%
  896. \begin{minipage}[\floatalignment]{\marginparwidth}\hbox{}%
  897. \ifthenelse{\NOT\equal{\@tufte@stored@caption}{}}{\@tufte@orig@caption[\@tufte@stored@shortcaption]{\@tufte@stored@caption}}{}%
  898. \ifthenelse{\NOT\equal{\@tufte@stored@label}{}}{\@tufte@orig@label{\@tufte@stored@label}}{}%
  899. \par\vspace{-\prevdepth}%% TODO: DOUBLE-CHECK FOR SAFETY
  900. \end{minipage}%
  901. \end{lrbox}%
  902. % now typeset the stored boxes
  903. \begin{fullwidth}%
  904. \begin{minipage}[\floatalignment]{\linewidth}%
  905. \ifthenelse{\boolean{@tufte@float@star}}%
  906. {\@tufte@float@fullwidth{\@tufte@figure@box}{\@tufte@caption@box}}%
  907. {\@tufte@float@textwidth{\@tufte@figure@box}{\@tufte@caption@box}}%
  908. \end{minipage}%
  909. \end{fullwidth}%
  910. \@tufte@orig@endfloat%
  911. % reset commands and temp boxes and captions
  912. \let\caption\@tufte@orig@caption%
  913. \let\label\@tufte@orig@label%
  914. \begin{lrbox}{\@tufte@figure@box}\hbox{}\end{lrbox}%
  915. \begin{lrbox}{\@tufte@caption@box}\hbox{}\end{lrbox}%
  916. \gdef\@tufte@stored@shortcaption{}%
  917. \gdef\@tufte@stored@caption{}%
  918. }
  919. \newcommand{\@tufte@float@textwidth}[2]{%
  920. \ifthenelse{\NOT\boolean{@tufte@symmetric}\OR\boolean{@tufte@float@recto}}{%
  921. % asymmetric or page is odd, so caption is on the right
  922. \hbox{%
  923. \usebox{#1}%
  924. \hspace{\marginparsep}%
  925. \smash{\usebox{#2}}%
  926. }%
  927. }{%
  928. % symmetric pages and page is even, so caption is on the left
  929. \hbox{%
  930. \smash{\usebox{#2}}%
  931. \hspace{\marginparsep}%
  932. \usebox{#1}%
  933. }%
  934. }%
  935. }
  936. \newcommand{\@tufte@float@fullwidth}[2]{%
  937. \ifthenelse{\equal{\floatalignment}{b}}%
  938. {% place caption above figure
  939. \ifthenelse{\NOT\boolean{@tufte@symmetric}\OR\boolean{@tufte@float@recto}}%
  940. {\hfill\smash{\usebox{#2}}\par\usebox{#1}}% caption on the right
  941. {\smash{\usebox{#2}\hfill}\par\usebox{#1}}% caption on the left
  942. }%
  943. {% place caption below figure
  944. \ifthenelse{\NOT\boolean{@tufte@symmetric}\OR\boolean{@tufte@float@recto}}%
  945. {\usebox{#1}\par\hfill\smash{\usebox{#2}}}% caption on the right
  946. {\usebox{#1}\par\smash{\usebox{#2}\hfill}}% caption on the left
  947. }%
  948. }
  949. %%
  950. % Redefine the figure environment to place the captions in the margin space
  951. \renewenvironment{figure}[1][htbp]
  952. {\begin{@tufte@float}[#1]{figure}{}}
  953. {\end{@tufte@float}}
  954. %%
  955. % Redefine the table environment to place the captions in the margin space
  956. \renewenvironment{table}[1][htbp]
  957. {\begin{@tufte@float}[#1]{table}{}}
  958. {\end{@tufte@float}}
  959. %%
  960. % Full-width figure
  961. \renewenvironment{figure*}[1][htbp]%
  962. {\begin{@tufte@float}[#1]{figure}{star}}
  963. {\end{@tufte@float}}
  964. %%
  965. % Full-width table
  966. \renewenvironment{table*}[1][htbp]%
  967. {\begin{@tufte@float}[#1]{table}{star}}
  968. {\end{@tufte@float}}
  969. %%
  970. % Full-page-width area
  971. \newenvironment{fullwidth}
  972. {\ifthenelse{\boolean{@tufte@symmetric}}%
  973. {\ifthenelse{\boolean{@tufte@changepage}}{\begin{adjustwidth*}{}{-\@tufte@overhang}}{\begin{adjustwidth}[]{}{-\@tufte@overhang}}}%
  974. {\begin{adjustwidth}{}{-\@tufte@overhang}}%
  975. }%
  976. {\ifthenelse{\boolean{@tufte@symmetric}}%
  977. {\ifthenelse{\boolean{@tufte@changepage}}{\end{adjustwidth*}}{\end{adjustwidth}}}%
  978. {\end{adjustwidth}}%
  979. }
  980. %%
  981. % Format the captions in a style similar to the sidenotes
  982. \long\def\@caption#1[#2]#3{%
  983. \par%
  984. \addcontentsline{\csname ext@#1\endcsname}{#1}%
  985. {\protect\numberline{\csname the#1\endcsname}{\ignorespaces #2}}%
  986. \begingroup%
  987. \@parboxrestore%
  988. \if@minipage%
  989. \@setminipage%
  990. \fi%
  991. \@tufte@marginfont\@tufte@caption@justification%
  992. \noindent\csname fnum@#1\endcsname: \ignorespaces#3\par%
  993. %\@makecaption{\csname fnum@#1\endcsname}{\ignorespaces #3}\par
  994. \endgroup}
  995. %%
  996. % If we're NOT using XeLaTeX and the `nofonts' class option was NOT provided,
  997. % we should load the Palatino, Helvetica, and Bera Mono fonts (if they are
  998. % installed.)
  999. \ifthenelse{\boolean{@tufte@loadfonts}\AND\NOT\boolean{@tufte@xetex}}{%
  1000. \IfFileExists{mathpazo.sty}{\RequirePackage[osf,sc]{mathpazo}}{}
  1001. \IfFileExists{helvet.sty}{\RequirePackage[scaled=0.90]{helvet}}{}
  1002. \IfFileExists{beramono.sty}{\RequirePackage[scaled=0.85]{beramono}}{}
  1003. \RequirePackage[T1]{fontenc}
  1004. \RequirePackage{textcomp}
  1005. }{}
  1006. %%
  1007. % Turns newlines into spaces. Based on code from the `titlesec' package.
  1008. \DeclareRobustCommand{\@tufte@newlinetospace}{%
  1009. \@ifstar{\@tufte@newlinetospace@i}{\@tufte@newlinetospace@i}%
  1010. }
  1011. \def\@tufte@newlinetospace@i{%
  1012. \ifdim\lastskip>\z@\else\space\fi
  1013. \ignorespaces%
  1014. }
  1015. \DeclareRobustCommand{\newlinetospace}[1]{%
  1016. \let\@tufte@orig@cr\\% save the original meaning of \\
  1017. \def\\{\@tufte@newlinetospace}% turn \\ and \\* into \space
  1018. \let\newline\\% turn \newline into \space
  1019. #1%
  1020. \let\\\@tufte@orig@cr% revert to original meaning of \\
  1021. }
  1022. %%
  1023. % Sets up the running heads and folios.
  1024. \RequirePackage{fancyhdr}
  1025. % Set the default page style to 'fancy'
  1026. \pagestyle{fancy}
  1027. % Set the header/footer width to be the body text block plus the margin
  1028. % note area.
  1029. \AtBeginDocument{%
  1030. \ifthenelse{\boolean{@tufte@symmetric}}
  1031. {\fancyhfoffset[LE,RO]{\@tufte@overhang}}
  1032. {\fancyhfoffset[RE,RO]{\@tufte@overhang}}
  1033. }
  1034. % The running heads/feet don't have rules
  1035. \renewcommand{\headrulewidth}{0pt}
  1036. \renewcommand{\footrulewidth}{0pt}
  1037. % The 'fancy' page style is the default style for all pages.
  1038. \fancyhf{} % clear header and footer fields
  1039. \ifthenelse{\boolean{@tufte@twoside}}
  1040. {\fancyhead[LE]{\thepage\quad\smallcaps{\newlinetospace{\plainauthor}}}%
  1041. \fancyhead[RO]{\smallcaps{\newlinetospace{\plaintitle}}\quad\thepage}}
  1042. {\fancyhead[RE,RO]{\smallcaps{\newlinetospace{\plaintitle}}\quad\thepage}}
  1043. % The `plain' page style is used on chapter opening pages.
  1044. % In Tufte's /Beautiful Evidence/ he never puts page numbers at the
  1045. % bottom of pages -- the folios are unexpressed.
  1046. \fancypagestyle{plain}{
  1047. \fancyhf{} % clear header and footer fields
  1048. % Uncomment the following five lines of code if you want the opening page
  1049. % of the chapter to express the folio in the lower outside corner.
  1050. %\ifthenelse{\boolean{@tufte@twoside}}
  1051. % {\fancyfoot[LE,RO]{\thepage}}
  1052. % {\fancyfoot[RE,RO]{\thepage}}
  1053. }
  1054. % The `empty' page style suppresses all headers and footers.
  1055. % It's used on title pages and `intentionally blank' pages.
  1056. \fancypagestyle{empty}{
  1057. \fancyhf{} % clear header and footer fields
  1058. }
  1059. %%
  1060. % Set raggedright and paragraph indentation for document
  1061. \AtBeginDocument{\@tufte@justification}
  1062. %%
  1063. % Prints the list of class options and their states.
  1064. \newcommand{\typeoutbool}[2]{%
  1065. \ifthenelse{\boolean{#2}}
  1066. {\typeout{\space\space#1: true}}
  1067. {\typeout{\space\space#1: false}}
  1068. }
  1069. \newcommand{\typeoutstr}[2]{%
  1070. \typeout{\space\space#1: #2}
  1071. }
  1072. \newcommand{\PrintTufteSettings}{%
  1073. \typeout{-------------------- Tufte-LaTeX settings ----------}
  1074. \typeout{Class: \@tufte@pkgname}
  1075. \typeout{}
  1076. \typeout{Class options:}
  1077. \typeoutbool{a4paper}{@tufte@afourpaper}
  1078. \typeoutbool{b5paper}{@tufte@bfivepaper}
  1079. \typeoutbool{load fonts}{@tufte@loadfonts}
  1080. \typeoutbool{fully-justified}{@tufte@justified}
  1081. \typeoutbool{letterspacing}{@tufte@letterspace}
  1082. \typeoutbool{sans-serif sidenotes}{@tufte@sfsidenotes}
  1083. \typeoutbool{symmetric margins}{@tufte@symmetric}
  1084. \typeoutbool{titlepage}{@tufte@titlepage}
  1085. \typeoutbool{twoside}{@tufte@twoside}
  1086. \typeoutbool{debug}{@tufte@debug}
  1087. \typeout{}
  1088. \typeout{Internal variables:}
  1089. \typeoutbool{[twoside]}{@twoside}
  1090. \typeoutbool{pdflatex}{@tufte@pdf}
  1091. \typeoutbool{xelatex}{@tufte@xetex}
  1092. \typeout{----------------------------------------------------}
  1093. }
  1094. %%
  1095. % Color
  1096. \RequirePackage[usenames,dvipsnames,svgnames]{xcolor}
  1097. %%
  1098. % Produces a full title page
  1099. \newcommand{\maketitlepage}[0]{%
  1100. \cleardoublepage%
  1101. {%
  1102. \sffamily%
  1103. \begin{fullwidth}%
  1104. \fontsize{18}{20}\selectfont\par\noindent\textcolor{darkgray}{\allcaps{\thanklessauthor}}%
  1105. \vspace{11.5pc}%
  1106. \fontsize{36}{40}\selectfont\par\noindent\textcolor{darkgray}{\allcaps{\thanklesstitle}}%
  1107. \vfill%
  1108. \fontsize{14}{16}\selectfont\par\noindent\allcaps{\thanklesspublisher}%
  1109. \end{fullwidth}%
  1110. }
  1111. \thispagestyle{empty}%
  1112. \clearpage%
  1113. }
  1114. %%
  1115. % Title block
  1116. \renewcommand{\maketitle}{%
  1117. \newpage
  1118. \global\@topnum\z@% prevent floats from being placed at the top of the page
  1119. \begingroup
  1120. \setlength{\parindent}{0pt}
  1121. \setlength{\parskip}{4pt}
  1122. \ifthenelse{\boolean{@tufte@sfsidenotes}}
  1123. {\begingroup
  1124. % FIXME fails with \thanks
  1125. \sffamily
  1126. \par{\LARGE\allcaps{\@title}}
  1127. \ifthenelse{\equal{\@author}{}}{}{\par{\Large\allcaps{\@author}}}
  1128. \ifthenelse{\equal{\@date}{}}{}{\par{\Large\allcaps{\@date}}}
  1129. \endgroup}
  1130. {\begingroup
  1131. \par{\LARGE\textit{\@title}}
  1132. \ifthenelse{\equal{\@author}{}}{}{\par{\Large\textit{\@author}}}
  1133. \ifthenelse{\equal{\@date}{}}{}{\par{\Large\textit{\@date}}}
  1134. \endgroup}
  1135. \par
  1136. \endgroup
  1137. \thispagestyle{plain}% suppress the running head
  1138. }
  1139. %%
  1140. % Title page (if the `titlepage' option was passed to the tufte-handout
  1141. % class.)
  1142. \ifthenelse{\boolean{@tufte@titlepage}}
  1143. {\renewcommand{\maketitle}{\maketitlepage}}
  1144. {}
  1145. %%
  1146. % When \cleardoublepage is called, produce a blank (empty) page -- i.e.,
  1147. % without headers and footers
  1148. \def\cleardoublepage{\clearpage\if@twoside\ifodd\c@page\else
  1149. \hbox{}
  1150. %\vspace*{\fill}
  1151. %\begin{center}
  1152. % This page intentionally contains only this sentence.
  1153. %\end{center}
  1154. %\vspace{\fill}
  1155. \thispagestyle{empty}
  1156. \newpage
  1157. \if@twocolumn\hbox{}\newpage\fi\fi\fi}
  1158. %%
  1159. % Make Tuftian-style section headings and TOC formatting
  1160. \RequirePackage{titlesec,titletoc}
  1161. \titleformat{\chapter}%
  1162. [display]% shape
  1163. {\relax\ifthenelse{\NOT\boolean{@tufte@symmetric}}{\begin{fullwidth}}{}}% format applied to label+text
  1164. {\itshape\huge\thechapter}% label
  1165. {0pt}% horizontal separation between label and title body
  1166. {\huge\rmfamily\itshape}% before the title body
  1167. [\ifthenelse{\NOT\boolean{@tufte@symmetric}}{\end{fullwidth}}{}]% after the title body
  1168. \titleformat{\section}%
  1169. [hang]% shape
  1170. {\normalfont\Large\itshape}% format applied to label+text
  1171. {\thesection}% label
  1172. {1em}% horizontal separation between label and title body
  1173. {}% before the title body
  1174. []% after the title body
  1175. \titleformat{\subsection}%
  1176. [hang]% shape
  1177. {\normalfont\large\itshape}% format applied to label+text
  1178. {\thesubsection}% label
  1179. {1em}% horizontal separation between label and title body
  1180. {}% before the title body
  1181. []% after the title body
  1182. \titleformat{\paragraph}%
  1183. [runin]% shape
  1184. {\normalfont\itshape}% format applied to label+text
  1185. {\theparagraph}% label
  1186. {1em}% horizontal separation between label and title body
  1187. {}% before the title body
  1188. []% after the title body
  1189. \titlespacing*{\chapter}{0pt}{50pt}{40pt}
  1190. \titlespacing*{\section}{0pt}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex}
  1191. \titlespacing*{\subsection}{0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus.2ex}
  1192. % Subsubsection and following section headings shouldn't be used.
  1193. % See Bringhurst's _The Elements of Typography_, section 4.2.2.
  1194. \renewcommand\subsubsection{%
  1195. \ClassError{\@tufte@pkgname}{\noexpand\subsubsection is undefined by this class.%
  1196. \MessageBreak See Robert Bringhurst's _The Elements of
  1197. \MessageBreak Typographic Style_, section 4.2.2.
  1198. \MessageBreak \noexpand\subsubsection was used}
  1199. {From Bringhurst's _The Elements of Typographic Style_, section 4.2.2: Use as
  1200. \MessageBreak many levels of headings as you need, no more and no fewer. Also see the many
  1201. \MessageBreak related threads on Ask E.T. at http://www.edwardtufte.com/.}
  1202. }
  1203. \renewcommand\subparagraph{%
  1204. \ClassError{\@tufte@pkgname}{\noexpand\subparagraph is undefined by this class.%
  1205. \MessageBreak See Robert Bringhurst's _The Elements of
  1206. \MessageBreak Typographic Style_, section 4.2.2.
  1207. \MessageBreak \noexpand\subparagraph was used}
  1208. {From Bringhurst's _The Elements of Typographic Style_, section 4.2.2: Use as
  1209. \MessageBreak many levels of headings as you need, no more and no fewer. Also see the many
  1210. \MessageBreak related threads on Ask E.T. at http://www.edwardtufte.com/.}
  1211. }
  1212. % Formatting for main TOC (printed in front matter)
  1213. % {section} [left] {above} {before w/label} {before w/o label} {filler + page} [after]
  1214. \ifthenelse{\boolean{@tufte@toc}}{%
  1215. \titlecontents{part}% FIXME
  1216. [0em] % distance from left margin
  1217. {\vspace{1.5\baselineskip}\begin{fullwidth}\LARGE\rmfamily\itshape} % above (global formatting of entry)
  1218. {\contentslabel{2em}} % before w/label (label = ``II'')
  1219. {} % before w/o label
  1220. {\rmfamily\upshape\qquad\thecontentspage} % filler + page (leaders and page num)
  1221. [\end{fullwidth}] % after
  1222. \titlecontents{chapter}%
  1223. [0em] % distance from left margin
  1224. {\vspace{1.5\baselineskip}\begin{fullwidth}\LARGE\rmfamily\itshape} % above (global formatting of entry)
  1225. {\hspace*{0em}\contentslabel{2em}} % before w/label (label = ``2'')
  1226. {\hspace*{0em}} % before w/o label
  1227. {\rmfamily\upshape\qquad\thecontentspage} % filler + page (leaders and page num)
  1228. [\end{fullwidth}] % after
  1229. \titlecontents{section}% FIXME
  1230. [0em] % distance from left margin
  1231. {\vspace{0\baselineskip}\begin{fullwidth}\Large\rmfamily\itshape} % above (global formatting of entry)
  1232. {\hspace*{2em}\contentslabel{2em}} % before w/label (label = ``2.6'')
  1233. {\hspace*{2em}} % before w/o label
  1234. {\rmfamily\upshape\qquad\thecontentspage} % filler + page (leaders and page num)
  1235. [\end{fullwidth}] % after
  1236. \titlecontents{subsection}% FIXME
  1237. [0em] % distance from left margin
  1238. {\vspace{0\baselineskip}\begin{fullwidth}\large\rmfamily\itshape} % above (global formatting of entry)
  1239. {\hspace*{4em}\contentslabel{4em}} % before w/label (label = ``2.6.1'')
  1240. {\hspace*{4em}} % before w/o label
  1241. {\rmfamily\upshape\qquad\thecontentspage} % filler + page (leaders and page num)
  1242. [\end{fullwidth}] % after
  1243. \titlecontents{paragraph}% FIXME
  1244. [0em] % distance from left margin
  1245. {\vspace{0\baselineskip}\begin{fullwidth}\normalsize\rmfamily\itshape} % above (global formatting of entry)
  1246. {\hspace*{6em}\contentslabel{2em}} % before w/label (label = ``2.6.0.0.1'')
  1247. {\hspace*{6em}} % before w/o label
  1248. {\rmfamily\upshape\qquad\thecontentspage} % filler + page (leaders and page num)
  1249. [\end{fullwidth}] % after
  1250. }{}
  1251. %%
  1252. % Format lists of figures/tables
  1253. \renewcommand\listoffigures{%
  1254. \ifthenelse{\equal{\@tufte@class}{book}}%
  1255. {\chapter*{\listfigurename}}%
  1256. {\section*{\listfigurename}}%
  1257. % \begin{fullwidth}%
  1258. \@starttoc{lof}%
  1259. % \end{fullwidth}%
  1260. }
  1261. \renewcommand\listoftables{%
  1262. \ifthenelse{\equal{\@tufte@class}{book}}%
  1263. {\chapter*{\listtablename}}%
  1264. {\section*{\listtablename}}%
  1265. % \begin{fullwidth}%
  1266. \@starttoc{lot}%
  1267. % \end{fullwidth}%
  1268. }
  1269. \newcommand{\@tufte@lof@line}[2]{%
  1270. % #1 is the figure/table number and its caption text
  1271. % #2 is the page number on which the figure/table appears
  1272. \leftskip 0.0em
  1273. \rightskip 0em
  1274. \parfillskip 0em plus 1fil
  1275. \parindent 0.0em
  1276. \@afterindenttrue
  1277. \interlinepenalty\@M
  1278. \leavevmode
  1279. \@tempdima 2.0em
  1280. \advance\leftskip\@tempdima
  1281. \null\nobreak\hskip -\leftskip
  1282. {#1}\nobreak\qquad\nobreak#2%
  1283. \par%
  1284. }
  1285. \renewcommand*\l@figure{\@tufte@lof@line}
  1286. \let\l@table\l@figure
  1287. %%
  1288. % A handy command to disable hyphenation for short bits of text.
  1289. % Borrowed from Peter Wilson's `hyphenat' package.
  1290. \newlanguage\langwohyphens% define a language without hyphenation rules
  1291. \newcommand{\nohyphens}[1]{{\language\langwohyphens #1}}% used for short bits of text
  1292. \newcommand{\nohyphenation}{\language\langwohyphens}% can be used inside environments for longer text
  1293. %%
  1294. % The bibliography environment
  1295. \setlength\bibindent{1.5em}
  1296. \renewenvironment{thebibliography}[1]
  1297. {%
  1298. \ifthenelse{\equal{\@tufte@class}{book}}%
  1299. {\chapter{\bibname}}%
  1300. {\section*{\refname}}%
  1301. % \@mkboth{\MakeUppercase\bibname}{\MakeUppercase\bibname}%
  1302. \list{\@biblabel{\@arabic\c@enumiv}}%
  1303. {\settowidth\labelwidth{\@biblabel{#1}}%
  1304. \leftmargin\labelwidth
  1305. \advance\leftmargin\labelsep
  1306. \@openbib@code
  1307. \usecounter{enumiv}%
  1308. \let\p@enumiv\@empty
  1309. \renewcommand\theenumiv{\@arabic\c@enumiv}}%
  1310. \sloppy
  1311. \clubpenalty4000
  1312. \@clubpenalty \clubpenalty
  1313. \widowpenalty4000%
  1314. \sfcode`\.\@m%
  1315. }
  1316. {%
  1317. \def\@noitemerr
  1318. {\@latex@warning{Empty `thebibliography' environment}}%
  1319. \endlist%
  1320. }
  1321. \renewcommand\newblock{\hskip .11em\@plus.33em\@minus.07em}
  1322. %%
  1323. % An index environment to mimic Tufte's indexes
  1324. \RequirePackage{multicol}
  1325. \renewenvironment{theindex}
  1326. {\begin{fullwidth}%
  1327. \small%
  1328. \ifthenelse{\equal{\@tufte@class}{book}}%
  1329. {\chapter{\indexname}}%
  1330. {\section*{\indexname}}%
  1331. \parskip0pt%
  1332. \parindent0pt%
  1333. \let\item\@idxitem%
  1334. \begin{multicols}{3}%
  1335. }
  1336. {\end{multicols}%
  1337. \end{fullwidth}%
  1338. }
  1339. \renewcommand\@idxitem{\par\hangindent 2em}
  1340. \renewcommand\subitem{\par\hangindent 3em\hspace*{1em}}
  1341. \renewcommand\subsubitem{\par\hangindent 4em\hspace*{2em}}
  1342. \renewcommand\indexspace{\par\addvspace{1.0\baselineskip plus 0.5ex minus 0.2ex}\relax}%
  1343. \newcommand{\lettergroup}[1]{}% swallow the letter heading in the index
  1344. %%
  1345. % If debugging is enabled, print the Tufte-LaTeX options and the list of
  1346. % files.
  1347. \ifthenelse{\boolean{@tufte@debug}}
  1348. {\PrintTufteSettings\listfiles}
  1349. {}
  1350. %%
  1351. % If there is a `tufte-common-local.tex' file, load it up.
  1352. \IfFileExists{tufte-common-local.tex}
  1353. {\input{tufte-common-local.tex}}
  1354. {}
  1355. %%
  1356. % End of file
  1357. \endinput