25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1704 lines
59KB

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