Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

1659 строки
56KB

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