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.

1682 lines
57KB

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