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

1319 рядки
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 \thetitle, \theauthor, and \thedate, respectively.
  247. \newcommand{\thetitle}{}% plain-text-only title
  248. \newcommand{\theauthor}{}% plain-text-only author
  249. \newcommand{\thepublisher}{}% 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{\thetitle}{\thanklesstitle}}% use thankless title
  267. {\renewcommand{\thetitle}{#1}}% use provided plain-text title
  268. \hypersetup{pdftitle={\thetitle}}% 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{\theauthor}{\thanklessauthor}}% use thankless author
  280. {\renewcommand{\theauthor}{#1}}% use provided plain-text author
  281. \hypersetup{pdfauthor={\theauthor}}% 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{\thepublisher}{\thanklesspublisher}}% use thankless publisher
  301. {\renewcommand{\thepublisher}{#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. \def\@tufte@trim@spaces#1{%
  434. % Use grouping to emulate a multi-token afterassignment queue
  435. \begingroup%
  436. % Put `\toks 0 {' into the afterassignment queue
  437. \aftergroup\toks\aftergroup0\aftergroup{%
  438. % Apply \trimb to the replacement text of #1, adding a leading
  439. % \noexpand to prevent brace stripping and to serve another purpose
  440. % later.
  441. \expandafter\@tufte@trim@b\expandafter\noexpand#1Q Q}%
  442. % Transfer the trimmed text back into #1.
  443. \edef#1{\the\toks0}%
  444. }
  445. % \trimb removes a trailing space if present, then calls \@tufte@trim@c to
  446. % clean up any leftover bizarre Qs, and trim a leading space. In
  447. % order for \trimc to work properly we need to put back a Q first.
  448. \def\@tufte@trim@b#1 Q{\@tufte@trim@c#1Q}
  449. % Execute \vfuzz assignment to remove leading space; the \noexpand
  450. % will now prevent unwanted expansion of a macro or other expandable
  451. % token at the beginning of the trimmed text. The \endgroup will feed
  452. % in the \aftergroup tokens after the \vfuzz assignment is completed.
  453. \def\@tufte@trim@c#1Q#2{\afterassignment\endgroup \vfuzz\the\vfuzz#1}
  454. %%
  455. % Citations should go in the margin as sidenotes
  456. \RequirePackage[numbers]{natbib}
  457. \RequirePackage{bibentry} % allows bibitems to be typeset outside thebibliography environment
  458. % Redefine the \BR@b@bibitem command to fix a bug with bibentry+chicago style
  459. \renewcommand\BR@b@bibitem[2][]{%
  460. \ifthenelse{\isempty{#1}}%
  461. {\BR@bibitem{#2}}%
  462. {\BR@bibitem[#1]{#2}}%
  463. \BR@c@bibitem{#2}%
  464. }
  465. \nobibliography* % pre-loads the bibliography keys
  466. \providecommand{\doi}[1]{\textsc{doi:} #1}% pre-defining this so it may be used before the \bibliography command it issued
  467. %%
  468. % Normal \cite behavior
  469. \newcounter{@tufte@num@bibkeys}%
  470. \newcommand{\@tufte@normal@cite}[2][0pt]{%
  471. % Snag the last bibentry in the list for later comparison
  472. \let\@temp@last@bibkey\@empty%
  473. \@for\@temp@bibkey:=#2\do{\let\@temp@last@bibkey\@temp@bibkey}%
  474. \sidenote[][#1]{%
  475. % Loop through all the bibentries, separating them with semicolons and spaces
  476. \setcounter{@tufte@num@bibkeys}{0}%
  477. \@for\@temp@bibkeyx:=#2\do{%
  478. \ifthenelse{\equal{\@temp@last@bibkey}{\@temp@bibkeyx}}%
  479. {\ifthenelse{\equal{\value{@tufte@num@bibkeys}}{0}}{}{and\ }%
  480. \@tufte@trim@spaces\@temp@bibkeyx% trim spaces around bibkey
  481. \bibentry{\@temp@bibkeyx}}%
  482. {\@tufte@trim@spaces\@temp@bibkeyx% trim spaces around bibkey
  483. \bibentry{\@temp@bibkeyx};\ }%
  484. \stepcounter{@tufte@num@bibkeys}%
  485. }%
  486. }%
  487. }
  488. %%
  489. % Macros for holding the list of cite keys until after the \sidenote
  490. \gdef\@tufte@citations{}% list of cite keys
  491. \newcommand\@tufte@add@citation[1]{\relax% adds a new bibkey to the list of cite keys
  492. \ifx\@tufte@citations\@empty\else
  493. \g@addto@macro\@tufte@citations{,}% separate by commas
  494. \fi
  495. \g@addto@macro\@tufte@citations{#1}
  496. }
  497. \newcommand{\@tufte@print@citations}[1][0pt]{% puts the citations in a margin note
  498. % Snag the last bibentry in the list for later comparison
  499. \let\@temp@last@bibkey\@empty%
  500. \@for\@temp@bibkey:=\@tufte@citations\do{\let\@temp@last@bibkey\@temp@bibkey}%
  501. \marginpar{%
  502. \hbox{}\vspace*{#1}%
  503. \@tufte@marginfont%
  504. \@tufte@justification%
  505. \@tufte@margin@par% use parindent and parskip settings for marginal text
  506. \vspace*{-1\baselineskip}%
  507. % Loop through all the bibentries, separating them with semicolons and spaces
  508. \setcounter{@tufte@num@bibkeys}{0}%
  509. \@for\@temp@bibkeyx:=\@tufte@citations\do{%
  510. \ifthenelse{\equal{\@temp@last@bibkey}{\@temp@bibkeyx}}%
  511. {\ifthenelse{\equal{\value{@tufte@num@bibkeys}}{0}}{}{and\ }%
  512. \@tufte@trim@spaces\@temp@bibkeyx% trim spaces around bibkey
  513. \bibentry{\@temp@bibkeyx}}%
  514. {\@tufte@trim@spaces\@temp@bibkeyx% trim spaces around bibkey
  515. \bibentry{\@temp@bibkeyx};\ }%
  516. \stepcounter{@tufte@num@bibkeys}%
  517. }%
  518. \@tufte@reset@par% use parindent and parskip settings for body text
  519. }%
  520. }
  521. %%
  522. % \cite behavior when executed within a sidenote
  523. \newcommand{\@tufte@sidenote@citations}{}% contains list of \cites in sidenote
  524. \newcommand{\@tufte@infootnote@cite}[1]{%
  525. \@tufte@add@citation{#1}
  526. }
  527. %%
  528. % Set the default \cite style. This is set and reset by the \sidenote command.
  529. \let\cite\@tufte@normal@cite
  530. %%
  531. % Transform existing \footnotes into \sidenotes
  532. % Sidenote: ``Where God meant footnotes to go.'' ---Tufte
  533. \RequirePackage{optparams}% for our new sidenote commands -- provides multiple optional arguments for commands
  534. \providecommand*{\footnotelayout}{\@tufte@marginfont\@tufte@justification}
  535. \renewcommand{\footnotelayout}{\@tufte@marginfont\@tufte@justification}
  536. % Override footmisc's definition to set the sidenote marks (numbers) inside the
  537. % sidenote's text block.
  538. \long\def\@makefntext#1{\@textsuperscript{\@tufte@marginfont\tiny\@thefnmark}\,\footnotelayout#1}
  539. % Set the in-text footnote mark in the same typeface as the body text itself.
  540. \def\@makefnmark{\hbox{\@textsuperscript{\normalfont\footnotesize\@thefnmark}}}
  541. \providecommand*{\multiplefootnotemarker}{3sp}
  542. \providecommand*{\multfootsep}{,}
  543. \renewcommand*\@footnotemark{%
  544. \leavevmode%
  545. \ifhmode%
  546. \edef\@x@sf{\the\spacefactor}%
  547. \@tufte@check@multiple@sidenotes%
  548. \nobreak%
  549. \fi%
  550. \@makefnmark%
  551. \ifhmode\spacefactor\@x@sf\fi%
  552. \relax%
  553. }
  554. \newcommand{\@tufte@check@multiple@sidenotes}{%
  555. \ifdim\lastkern=\multiplefootnotemarker\relax%
  556. \edef\@x@sf{\the\spacefactor}%
  557. \unkern%
  558. \textsuperscript{\multfootsep}%
  559. \spacefactor\@x@sf\relax%
  560. \fi
  561. }
  562. \renewcommand\@footnotetext[2][0pt]{%
  563. \marginpar{%
  564. \hbox{}\vspace*{#1}%
  565. \def\baselinestretch {\setspace@singlespace}%
  566. \ifthenelse{\boolean{@tufte@loadbidi}}{\if@rl@footnote\@rltrue\else\@rlfalse\fi}{}%
  567. \reset@font\footnotesize%
  568. \@tufte@margin@par% use parindent and parskip settings for marginal text
  569. \vspace*{-1\baselineskip}\noindent%
  570. \protected@edef\@currentlabel{%
  571. \csname p@footnote\endcsname\@thefnmark%
  572. }%
  573. \color@begingroup%
  574. \@makefntext{%
  575. \ignorespaces#2%
  576. }%
  577. \color@endgroup%
  578. }%
  579. \@tufte@reset@par% use parindent and parskip settings for body text
  580. }%
  581. %
  582. % Define \sidenote command. Can handle \cite.
  583. \newcommand{\@tufte@sidenote@vertical@offset}{0pt}
  584. % #1 = footnote num, #2 = vertical offset, #3 = footnote text
  585. \long\def\@tufte@sidenote[#1][#2]#3{%
  586. \let\cite\@tufte@infootnote@cite% use the in-sidenote \cite command
  587. \gdef\@tufte@citations{}% clear out any old citations
  588. \ifthenelse{\NOT\isempty{#2}}{\renewcommand{\@tufte@sidenote@vertical@offset}{#2}}{}%
  589. \ifthenelse{\isempty{#1}}{%
  590. % no specific footnote number provided
  591. \stepcounter\@mpfn%
  592. \protected@xdef\@thefnmark{\thempfn}%
  593. \@footnotemark\@footnotetext[\@tufte@sidenote@vertical@offset]{#3}%
  594. }{%
  595. % specific footnote number provided
  596. \begingroup%
  597. \csname c@\@mpfn\endcsname #1\relax%
  598. \unrestored@protected@xdef\@thefnmark{\thempfn}%
  599. \endgroup%
  600. \@footnotemark\@footnotetext[\@tufte@sidenote@vertical@offset]{#3}%
  601. }%
  602. \@tufte@print@citations% print any citations
  603. \let\cite\@tufte@normal@cite% go back to using normal in-text \cite command
  604. \unskip\ignorespaces% remove extra white space
  605. \kern-\multiplefootnotemarker% remove \kern left behind by sidenote
  606. \kern\multiplefootnotemarker\relax% add new \kern here to replace the one we yanked
  607. }
  608. \newcommand*{\sidenote}{\optparams{\@tufte@sidenote}{[][0pt]}}
  609. \renewcommand*{\footnote}{\optparams{\@tufte@sidenote}{[][0pt]}}
  610. %%
  611. % Sidenote without the footnote mark
  612. \newcommand\marginnote[2][0pt]{%
  613. \let\cite\@tufte@infootnote@cite% use the in-sidenote \cite command
  614. \gdef\@tufte@citations{}% clear out any old citations
  615. \@tufte@margin@par% use parindent and parskip settings for marginal text
  616. \marginpar{\hbox{}\vspace*{#1}\@tufte@marginfont\@tufte@justification\vspace*{-1\baselineskip}\noindent #2}%
  617. \@tufte@reset@par% use parindent and parskip settings for body text
  618. \@tufte@print@citations% print any citations
  619. \let\cite\@tufte@normal@cite% go back to using normal in-text \cite command
  620. }
  621. %%
  622. % The placeins package provides the \FloatBarrier command. This forces
  623. % LaTeX to place all of the floats before proceeding. We'll use this to
  624. % keep the float (figure and table) numbers in sequence.
  625. \RequirePackage{placeins}
  626. %%
  627. % Margin float environment
  628. \newsavebox{\@tufte@margin@floatbox}
  629. \newenvironment{@tufte@margin@float}[2][-1.2ex]%
  630. {\FloatBarrier% process all floats before this point so the figure/table numbers stay in order.
  631. \begin{lrbox}{\@tufte@margin@floatbox}%
  632. \begin{minipage}{\marginparwidth}%
  633. \@tufte@marginfont%
  634. \def\@captype{#2}%
  635. \hbox{}\vspace*{#1}%
  636. \@tufte@justification%
  637. \@tufte@margin@par%
  638. \noindent%
  639. }
  640. {\end{minipage}%
  641. \end{lrbox}%
  642. \marginpar{\usebox{\@tufte@margin@floatbox}}%
  643. \@tufte@reset@par%
  644. }
  645. %%
  646. % Margin figure environment
  647. \newenvironment{marginfigure}[1][-1.2ex]%
  648. {\begin{@tufte@margin@float}[#1]{figure}}
  649. {\end{@tufte@margin@float}}
  650. %%
  651. % Margin table environment
  652. \newenvironment{margintable}[1][-1.2ex]%
  653. {\begin{@tufte@margin@float}[#1]{table}}
  654. {\end{@tufte@margin@float}}
  655. %%
  656. % A collection of macros to be used with the new Tufte-style float environments
  657. \newcommand{\floatalignment}{x}% holds the current float alignment (t, b, h, p)
  658. \newcommand{\setfloatalignment}[1]{\renewcommand{\floatalignment}{#1}}% manually sets the float alignment
  659. % Boxes to temporarily store our float and caption
  660. \newsavebox{\@tufte@figure@box}
  661. \newsavebox{\@tufte@caption@box}
  662. % Save original LaTeX float environment
  663. \let\@tufte@orig@float\@float
  664. \let\@tufte@orig@endfloat\end@float
  665. % Save original LaTeX \caption and \label commands
  666. \AtBeginDocument{%
  667. \let\@tufte@orig@caption\caption%
  668. \let\@tufte@orig@label\label%
  669. }
  670. % Store the caption and label contents
  671. \newcommand{\@tufte@stored@shortcaption}{}
  672. \newcommand{\@tufte@stored@caption}{}
  673. \newcommand{\@tufte@stored@label}{}
  674. \newcommand{\@tufte@caption}[2][]{%
  675. \ifthenelse{\isempty{#1}}
  676. {\gdef\@tufte@stored@shortcaption{#2}}%
  677. {\gdef\@tufte@stored@shortcaption{#1}}%
  678. \gdef\@tufte@stored@caption{#2}%
  679. }
  680. \newcommand{\@tufte@label}[1]{%
  681. \gdef\@tufte@stored@label{#1}%
  682. }
  683. \newcommand{\@tufte@fps}{}
  684. % TODO make sure new caption and figure code can handle [p] and [h] placements well
  685. % TODO handle the symmetric class option (move caption to other side of verso pages)
  686. %%
  687. % Define a float environment to place the captions in the margin space
  688. \newenvironment{@tufte@float}[2][htbp]
  689. {% If the float placement specifier is 'b' and only 'b', then bottom-align the mini-pages, otherwise top-align them.
  690. \renewcommand{\@tufte@fps}{#1}%
  691. \ifthenelse{\equal{#1}{b}\OR\equal{#1}{B}}%
  692. {\renewcommand{\floatalignment}{b}}%
  693. {\renewcommand{\floatalignment}{t}}%
  694. \renewcommand{\caption}[2][]{\@tufte@caption[##1]{##2}}%
  695. \renewcommand{\label}[1]{\@tufte@label{##1}}%
  696. \@tufte@orig@float{#2}[#1]%
  697. \begin{lrbox}{\@tufte@figure@box}%
  698. \begin{minipage}[\floatalignment]{\textwidth}\hbox{}%
  699. }
  700. {% end @tufte@float
  701. \par\hbox{}\vspace{-\baselineskip}\ifthenelse{\prevdepth>0}{\vspace{-\prevdepth}}{}% align baselines of boxes
  702. \end{minipage}%
  703. \end{lrbox}%
  704. % build the caption box
  705. \begin{lrbox}{\@tufte@caption@box}%
  706. \begin{minipage}[\floatalignment]{\marginparwidth}\hbox{}%
  707. \ifthenelse{\NOT\equal{\@tufte@stored@caption}{}}{\@tufte@orig@caption[\@tufte@stored@shortcaption]{\@tufte@stored@caption}}{}%
  708. \ifthenelse{\NOT\equal{\@tufte@stored@label}{}}{\@tufte@orig@label{\@tufte@stored@label}}{}%
  709. \par\vspace{-\prevdepth}%% TODO: DOUBLE-CHECK FOR SAFETY
  710. \end{minipage}%
  711. \end{lrbox}%
  712. % now typeset the stored boxes
  713. \begin{fullwidth}%
  714. \begin{minipage}[\floatalignment]{\paperwidth}%
  715. \usebox{\@tufte@figure@box}%
  716. \hspace{\marginparsep}%
  717. \smash{\usebox{\@tufte@caption@box}}%
  718. \end{minipage}%
  719. \end{fullwidth}%
  720. \@tufte@orig@endfloat%
  721. % reset commands and temp boxes and captions
  722. \let\caption\@tufte@orig@caption%
  723. \let\label\@tufte@orig@label%
  724. \begin{lrbox}{\@tufte@figure@box}\hbox{}\end{lrbox}
  725. \begin{lrbox}{\@tufte@caption@box}\hbox{}\end{lrbox}
  726. \gdef\@tufte@stored@shortcaption{}
  727. \gdef\@tufte@stored@caption{}
  728. }
  729. %%
  730. % Redefine the figure environment to place the captions in the margin space
  731. \renewenvironment{figure}[1][htbp]
  732. {\begin{@tufte@float}[#1]{figure}}
  733. {\end{@tufte@float}}
  734. %%
  735. % Redefine the table environment to place the captions in the margin space
  736. \renewenvironment{table}[1][htbp]
  737. {\begin{@tufte@float}[#1]{table}}
  738. {\end{@tufte@float}}
  739. %%
  740. % Full-width figures and tables
  741. \newenvironment{@tufte@float@star}[2][htbp]%
  742. {% begin
  743. % If the float placement specifier is 'b' and only 'b', then place the caption above the figure, else place the caption below the figure.
  744. \renewcommand{\@tufte@fps}{#1}%
  745. \ifthenelse{\equal{#1}{b}\OR\equal{#1}{B}}%
  746. {\renewcommand{\floatalignment}{b}}%
  747. {\renewcommand{\floatalignment}{t}}%
  748. \renewcommand{\caption}[2][]{\@tufte@caption[##1]{##2}}%
  749. \renewcommand{\label}[1]{\@tufte@label{##1}}%
  750. \@tufte@orig@float{#2}[#1]%
  751. \begin{lrbox}{\@tufte@figure@box}%
  752. \begin{minipage}[\floatalignment]{\linewidth}\hbox{}%
  753. \begin{fullwidth}
  754. }%
  755. {% end figure*
  756. \par\hbox{}\vspace{-\baselineskip}\ifthenelse{\prevdepth>0}{\vspace{-\prevdepth}}{}% align baselines of boxes
  757. \end{fullwidth}%
  758. \end{minipage}%
  759. \end{lrbox}%
  760. % build the caption box
  761. % TODO use \captionaboveskip and \captionbelowskip for spacing between caption and figure boxes
  762. \begin{lrbox}{\@tufte@caption@box}%
  763. \begin{minipage}[\floatalignment]{\marginparwidth}\hbox{}%
  764. \ifthenelse{\NOT\equal{\@tufte@stored@caption}{}}{\@tufte@orig@caption[\@tufte@stored@shortcaption]{\@tufte@stored@caption}}{}%
  765. \ifthenelse{\NOT\equal{\@tufte@stored@label}{}}{\@tufte@orig@label{\@tufte@stored@label}}{}%
  766. \par\vspace{-\prevdepth}%% TODO: DOUBLE-CHECK FOR SAFETY
  767. \end{minipage}%
  768. \end{lrbox}%
  769. % now typeset the stored boxes
  770. \begin{fullwidth}%
  771. \begin{minipage}[\floatalignment]{\paperwidth}%
  772. \hbox{}%
  773. \ifthenelse{\equal{\floatalignment}{b}}
  774. {% place caption above figure
  775. \hspace{\@tufte@caption@fill}\smash{\usebox{\@tufte@caption@box}}\\
  776. \usebox{\@tufte@figure@box}%
  777. }
  778. {% place caption below figure
  779. \usebox{\@tufte@figure@box}\\
  780. \hspace{\@tufte@caption@fill}\smash{\usebox{\@tufte@caption@box}}%
  781. }
  782. \end{minipage}%
  783. \end{fullwidth}%
  784. \@tufte@orig@endfloat%
  785. % reset commands and temp boxes and captions
  786. \let\caption\@tufte@orig@caption%
  787. \let\label\@tufte@orig@label%
  788. \begin{lrbox}{\@tufte@figure@box}\hbox{}\end{lrbox}
  789. \begin{lrbox}{\@tufte@caption@box}\hbox{}\end{lrbox}
  790. \gdef\@tufte@stored@shortcaption{}
  791. \gdef\@tufte@stored@caption{}
  792. }
  793. %%
  794. % Full-width figure
  795. \renewenvironment{figure*}[1][htbp]%
  796. {\begin{@tufte@float@star}[#1]{figure}}
  797. {\end{@tufte@float@star}}
  798. %%
  799. % Full-width table
  800. \renewenvironment{table*}[1][htbp]%
  801. {\begin{@tufte@float@star}[#1]{table}}
  802. {\end{@tufte@float@star}}
  803. %%
  804. % Full-page-width area
  805. \newenvironment{fullwidth}
  806. {\ifthenelse{\boolean{@tufte@symmetric}}
  807. {\ifthenelse{\boolean{@tufte@changepage}}{\begin{adjustwidth*}{}{-\@tufte@overhang}}{\begin{adjustwidth}[]{}{-\@tufte@overhang}}}
  808. {\begin{adjustwidth}{}{-\@tufte@overhang}}%
  809. }
  810. {\end{adjustwidth}}
  811. %%
  812. % Format the captions in a style similar to the sidenotes
  813. \long\def\@caption#1[#2]#3{%
  814. \par%
  815. \addcontentsline{\csname ext@#1\endcsname}{#1}%
  816. {\protect\numberline{\csname the#1\endcsname}{\ignorespaces #2}}%
  817. \begingroup
  818. \@parboxrestore
  819. \if@minipage
  820. \@setminipage
  821. \fi
  822. \@tufte@marginfont\@tufte@justification%
  823. \noindent\csname fnum@#1\endcsname: \ignorespaces#3\par
  824. %\@makecaption{\csname fnum@#1\endcsname}{\ignorespaces #3}\par
  825. \endgroup}
  826. %%
  827. % If we're NOT using XeLaTeX and the `nofonts' class option was NOT provided,
  828. % we should load the Palatino, Helvetica, and Bera Mono fonts (if they are
  829. % installed.)
  830. \ifthenelse{\boolean{@tufte@loadfonts}\AND\NOT\boolean{@tufte@xetex}}{%
  831. \IfFileExists{mathpazo.sty}{\RequirePackage[osf,sc]{mathpazo}}{}
  832. \IfFileExists{helvet.sty}{\RequirePackage[scaled=0.90]{helvet}}{}
  833. \IfFileExists{beramono.sty}{\RequirePackage[scaled=0.85]{beramono}}{}
  834. \RequirePackage[T1]{fontenc}
  835. \RequirePackage{textcomp}
  836. }{}
  837. %%
  838. % Turns newlines into spaces. Based on code from the `titlesec' package.
  839. \DeclareRobustCommand{\@tufte@newlinetospace}{%
  840. \@ifstar{\@tufte@newlinetospace@i}{\@tufte@newlinetospace@i}%
  841. }
  842. \def\@tufte@newlinetospace@i{%
  843. \ifdim\lastskip>\z@\else\space\fi
  844. \ignorespaces%
  845. }
  846. \DeclareRobustCommand{\newlinetospace}[1]{%
  847. \let\@tufte@orig@cr\\% save the original meaning of \\
  848. \def\\{\@tufte@newlinetospace}% turn \\ and \\* into \space
  849. \let\newline\\% turn \newline into \space
  850. #1%
  851. \let\\\@tufte@orig@cr% revert to original meaning of \\
  852. }
  853. %%
  854. % Sets up the running heads and folios.
  855. \RequirePackage{fancyhdr}
  856. % Set the default page style to 'fancy'
  857. \pagestyle{fancy}
  858. % Set the header/footer width to be the body text block plus the margin
  859. % note area.
  860. \ifthenelse{\boolean{@tufte@symmetric}}
  861. {\fancyhfoffset[LE,RO]{\@tufte@overhang}}
  862. {\fancyhfoffset[RE,RO]{\@tufte@overhang}}
  863. % The running heads/feet don't have rules
  864. \renewcommand{\headrulewidth}{0pt}
  865. \renewcommand{\footrulewidth}{0pt}
  866. % The 'fancy' page style is the default style for all pages.
  867. \fancyhf{} % clear header and footer fields
  868. \ifthenelse{\boolean{@tufte@twoside}}
  869. {\fancyhead[LE]{\thepage\quad\smallcaps{\newlinetospace{\theauthor}}}%
  870. \fancyhead[RO]{\smallcaps{\newlinetospace{\thetitle}}\quad\thepage}}
  871. {\fancyhead[RE,RO]{\smallcaps{\newlinetospace{\thetitle}}\quad\thepage}}
  872. % The `plain' page style is used on chapter opening pages.
  873. % In Tufte's /Beautiful Evidence/ he never puts page numbers at the
  874. % bottom of pages -- the folios are unexpressed.
  875. \fancypagestyle{plain}{
  876. \fancyhf{} % clear header and footer fields
  877. % Uncomment the following five lines of code if you want the opening page
  878. % of the chapter to express the folio in the lower outside corner.
  879. %\ifthenelse{\boolean{@tufte@twoside}}
  880. % {\fancyfoot[LE,RO]{\thepage}}
  881. % {\fancyfoot[RE,RO]{\thepage}}
  882. }
  883. % The `empty' page style suppresses all headers and footers.
  884. % It's used on title pages and `intentionally blank' pages.
  885. \fancypagestyle{empty}{
  886. \fancyhf{} % clear header and footer fields
  887. }
  888. %%
  889. % Set raggedright and paragraph indentation for document
  890. \AtBeginDocument{\@tufte@justification}
  891. %%
  892. % Prints the list of class options and their states.
  893. \newcommand{\typeoutbool}[2]{%
  894. \ifthenelse{\boolean{#2}}
  895. {\typeout{\space\space#1: true}}
  896. {\typeout{\space\space#1: false}}
  897. }
  898. \newcommand{\typeoutstr}[2]{%
  899. \typeout{\space\space#1: #2}
  900. }
  901. \newcommand{\PrintTufteSettings}{%
  902. \typeout{-------------------- Tufte-LaTeX settings ----------}
  903. \typeout{Class: \@tufte@pkgname}
  904. \typeout{}
  905. \typeout{Class options:}
  906. \typeoutbool{a4paper}{@tufte@afourpaper}
  907. \typeoutbool{load fonts}{@tufte@loadfonts}
  908. \typeoutbool{fully-justified}{@tufte@justified}
  909. \typeoutbool{letterspacing}{@tufte@letterspace}
  910. \typeoutbool{sans-serif sidenotes}{@tufte@sfsidenotes}
  911. \typeoutbool{symmetric margins}{@tufte@symmetric}
  912. \typeoutbool{titlepage}{@tufte@titlepage}
  913. \typeoutbool{twoside}{@tufte@twoside}
  914. \typeoutbool{debug}{@tufte@debug}
  915. \typeout{}
  916. \typeout{Internal variables:}
  917. \typeoutbool{[twoside]}{@twoside}
  918. \typeoutbool{pdflatex}{@tufte@pdf}
  919. \typeoutbool{xelatex}{@tufte@xetex}
  920. \typeout{----------------------------------------------------}
  921. }
  922. %%
  923. % Color
  924. \RequirePackage{xcolor}
  925. %%
  926. % Produces a full title page
  927. \newcommand{\maketitlepage}[0]{%
  928. \cleardoublepage%
  929. {%
  930. \sffamily%
  931. \begin{fullwidth}%
  932. \fontsize{18}{20}\selectfont\par\noindent\textcolor{darkgray}{\allcaps{\thanklessauthor}}%
  933. \vspace{11.5pc}%
  934. \fontsize{36}{40}\selectfont\par\noindent\textcolor{darkgray}{\allcaps{\thanklesstitle}}%
  935. \vfill%
  936. \fontsize{14}{16}\selectfont\par\noindent\allcaps{\thanklesspublisher}%
  937. \end{fullwidth}%
  938. }
  939. \thispagestyle{empty}%
  940. \clearpage%
  941. }
  942. %%
  943. % Title block
  944. \renewcommand{\maketitle}{%
  945. \newpage
  946. \global\@topnum\z@% prevent floats from being placed at the top of the page
  947. \begingroup
  948. \setlength{\parindent}{0pt}
  949. \setlength{\parskip}{4pt}
  950. \ifthenelse{\boolean{@tufte@sfsidenotes}}
  951. {\begingroup
  952. % FIXME fails with \thanks
  953. \sffamily
  954. \par{\LARGE\allcaps{\@title}}
  955. \ifthenelse{\equal{\@author}{}}{}{\par{\Large\allcaps{\@author}}}
  956. \ifthenelse{\equal{\@date}{}}{}{\par{\Large\allcaps{\@date}}}
  957. \endgroup}
  958. {\begingroup
  959. \par{\LARGE\textit{\@title}}
  960. \ifthenelse{\equal{\@author}{}}{}{\par{\Large\textit{\@author}}}
  961. \ifthenelse{\equal{\@date}{}}{}{\par{\Large\textit{\@date}}}
  962. \endgroup}
  963. \par
  964. \endgroup
  965. \thispagestyle{plain}% suppress the running head
  966. }
  967. %%
  968. % Title page (if the `titlepage' option was passed to the tufte-handout
  969. % class.)
  970. \ifthenelse{\boolean{@tufte@titlepage}}
  971. {\renewcommand{\maketitle}{\maketitlepage}}
  972. {}
  973. %%
  974. % When \cleardoublepage is called, produce a blank (empty) page -- i.e.,
  975. % without headers and footers
  976. \def\cleardoublepage{\clearpage\if@twoside\ifodd\c@page\else
  977. \hbox{}
  978. %\vspace*{\fill}
  979. %\begin{center}
  980. % This page intentionally contains only this sentence.
  981. %\end{center}
  982. %\vspace{\fill}
  983. \thispagestyle{empty}
  984. \newpage
  985. \if@twocolumn\hbox{}\newpage\fi\fi\fi}
  986. %%
  987. % Make Tuftian-style section headings and TOC formatting
  988. \RequirePackage{titlesec,titletoc}
  989. \titleformat{\chapter}%
  990. [display]% shape
  991. {\relax\ifthenelse{\NOT\boolean{@tufte@symmetric}}{\begin{fullwidth}}{}}% format applied to label+text
  992. {\itshape\huge\thechapter}% label
  993. {0pt}% horizontal separation between label and title body
  994. {\huge\rm\itshape}% before the title body
  995. [\ifthenelse{\NOT\boolean{@tufte@symmetric}}{\end{fullwidth}}{}]% after the title body
  996. \titleformat{\section}%
  997. [hang]% shape
  998. {\normalfont\Large\itshape}% format applied to label+text
  999. {\thesection}% label
  1000. {1em}% horizontal separation between label and title body
  1001. {}% before the title body
  1002. []% after the title body
  1003. \titleformat{\subsection}%
  1004. [hang]% shape
  1005. {\normalfont\large\itshape}% format applied to label+text
  1006. {\thesubsection}% label
  1007. {1em}% horizontal separation between label and title body
  1008. {}% before the title body
  1009. []% after the title body
  1010. \titlespacing*{\chapter}{0pt}{50pt}{40pt}
  1011. \titlespacing*{\section}{0pt}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex}
  1012. \titlespacing*{\subsection}{0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus.2ex}
  1013. % Subsubsection and following section headings shouldn't be used.
  1014. % See Bringhurst's _The Elements of Typography_, section 4.2.2.
  1015. \renewcommand\subsubsection{%
  1016. \PackageError{\@tufte@pkgname}{\noexpand\subsubsection is undefined by this class.%
  1017. \MessageBreak See Robert Bringhurst's _The Elements of
  1018. \MessageBreak Typographic Style_, section 4.2.2.
  1019. \MessageBreak \noexpand\subsubsection was used}
  1020. {From Bringhurst's _The Elements of Typographic Style_, section 4.2.2: Use as
  1021. \MessageBreak many levels of headings as you need, no more and no fewer. Also see the many
  1022. \MessageBreak related threads on Ask E.T. at http://www.edwardtufte.com/.}
  1023. }
  1024. \renewcommand\paragraph{%
  1025. \PackageError{\@tufte@pkgname}{\noexpand\paragraph is undefined by this class.%
  1026. \MessageBreak See Robert Bringhurst's _The Elements of
  1027. \MessageBreak Typographic Style_, section 4.2.2.
  1028. \MessageBreak \noexpand\paragraph was used}
  1029. {From Bringhurst's _The Elements of Typographic Style_, section 4.2.2: Use as
  1030. \MessageBreak many levels of headings as you need, no more and no fewer. Also see the many
  1031. \MessageBreak related threads on Ask E.T. at http://www.edwardtufte.com/.}
  1032. }
  1033. \renewcommand\subparagraph{%
  1034. \PackageError{\@tufte@pkgname}{\noexpand\subparagraph is undefined by this class.%
  1035. \MessageBreak See Robert Bringhurst's _The Elements of
  1036. \MessageBreak Typographic Style_, section 4.2.2.
  1037. \MessageBreak \noexpand\subparagraph was used}
  1038. {From Bringhurst's _The Elements of Typographic Style_, section 4.2.2: Use as
  1039. \MessageBreak many levels of headings as you need, no more and no fewer. Also see the many
  1040. \MessageBreak related threads on Ask E.T. at http://www.edwardtufte.com/.}
  1041. }
  1042. % Formatting for main TOC (printed in front matter)
  1043. % {section} [left] {above} {before w/label} {before w/o label} {filler + page} [after]
  1044. \ifthenelse{\boolean{@tufte@toc}}
  1045. {\titlecontents{chapter}%
  1046. [0em] % distance from left margin
  1047. {\begin{fullwidth}\fontsize{13pt}{18pt}\selectfont} % above (global formatting of entry)
  1048. {\contentslabel{2em}\rm\itshape} % before w/label (label = ``Chapter 1'')
  1049. {\rm\itshape} % before w/o label
  1050. {\rm\qquad\thecontentspage} % filler + page (leaders and page num)
  1051. [\vspace{1.5\baselineskip}\end{fullwidth}] % after
  1052. }
  1053. {}
  1054. %\titlecontents{chapter}%
  1055. % [0em]% distance from left margin
  1056. % {\fontsize{12pt}{18pt}\selectfont}% above (global formatting of entry)
  1057. % {\textit}% before w/ label (label = ``Chapter 1'')
  1058. % {\textit}% before w/o label
  1059. % {\qquad\thecontentspage}% filler and page (leaders and page num)
  1060. % [\vspace{1.5\baselineskip}]% after
  1061. %%
  1062. % A handy command to disable hyphenation for short bits of text.
  1063. % Borrowed from Peter Wilson's `hyphenat' package.
  1064. \newlanguage\langwohyphens% define a language without hyphenation rules
  1065. \newcommand{\nohyphens}[1]{{\language\langwohyphens #1}}% used for short bits of text
  1066. \newcommand{\nohyphenation}{\language\langwohyphens}% can be used inside environments for longer text
  1067. %%
  1068. % If debugging is enabled, print the Tufte-LaTeX options and the list of
  1069. % files.
  1070. \ifthenelse{\boolean{@tufte@debug}}
  1071. {\PrintTufteSettings\listfiles}
  1072. {}
  1073. %%
  1074. % If there is a `tufte-common-local.tex' file, load it up.
  1075. \IfFileExists{tufte-common-local.tex}
  1076. {\input{tufte-common-local}}
  1077. {}
  1078. %%
  1079. % End of file
  1080. \endinput