Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

1652 рядки
56KB

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