You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1318 lines
42KB

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