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

tufte-common.def 57KB

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