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.

858 lines
26KB

  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}{
  68. \setboolean{@tufte@twoside}{true}
  69. }
  70. %%
  71. % `justified' option -- uses fully justified text (flush left and flush
  72. % right) instead of ragged right.
  73. \newboolean{@tufte@justified}
  74. \DeclareOption{justified}{\setboolean{@tufte@justified}{true}}
  75. % FIXME: should probably specify options not supported like Mittelbach's aipproc.cls
  76. \DeclareOption*{\PassOptionsToClass{\CurrentOption}{\@tufte@class}}
  77. \ProcessOptions
  78. %%
  79. % Detect whether we're in two-side mode or not. (Used to set up running
  80. % heads later.)
  81. \ifthenelse{\boolean{@twoside}}
  82. {\setboolean{@tufte@twoside}{true}}
  83. {}
  84. %%
  85. % Detect if we're using pdfLaTeX
  86. \newboolean{@tufte@pdf}
  87. \IfFileExists{ifpdf.sty}{%
  88. \RequirePackage{ifpdf}
  89. \ifthenelse{\boolean{pdf}}
  90. {\setboolean{@tufte@pdf}{true}}
  91. {\setboolean{@tufte@pdf}{false}}
  92. }{% assume we're not using pdfTex?
  93. \setboolean{@tufte@pdf}{false}
  94. }
  95. %%
  96. % Detect if we're using XeLaTeX
  97. \newboolean{@tufte@xetex}
  98. \IfFileExists{ifxetex.sty}{%
  99. \RequirePackage{ifxetex}
  100. \ifthenelse{\boolean{xetex}}
  101. {\setboolean{@tufte@xetex}{true}}
  102. {\setboolean{@tufte@xetex}{false}}
  103. }{% not using xelatex
  104. \setboolean{@tufte@xetex}{false}
  105. }
  106. %%
  107. % Load the `hyperref' package. We will set more options later.
  108. % TODO Set nice defaults for hyperref options
  109. \ifthenelse{\boolean{@tufte@xetex}}
  110. {\RequirePackage[xetex]{hyperref}}
  111. {\RequirePackage{hyperref}}
  112. \hypersetup{%
  113. pdfborder = {0 0 0}
  114. }
  115. %%
  116. % Set page layout geometry
  117. \RequirePackage[letterpaper,includemp,width=6.5in,marginparsep=0.375in,marginparwidth=2in]{geometry}
  118. \ifthenelse{\boolean{@tufte@afourpaper}}
  119. {\geometry{a4paper,includemp,width=170mm,marginparsep=10mm,marginparwidth=50mm}}
  120. {}
  121. \ifthenelse{\boolean{@tufte@symmetric}}
  122. {}
  123. {\geometry{asymmetric}}% forces internal LaTeX `twoside'
  124. %%
  125. % Separation marginpars by a line's worth of space.
  126. \setlength\marginparpush{\baselineskip}
  127. %%
  128. % Font for margin items
  129. \ifthenelse{\boolean{@tufte@sfsidenotes}}
  130. {\newcommand{\@tufte@marginfont}{\normalfont\scriptsize\sffamily}}
  131. {\newcommand{\@tufte@marginfont}{\normalfont\scriptsize}}
  132. %%
  133. % \RaggedRight allows hyphenation
  134. \RequirePackage{ragged2e}
  135. \setlength{\RaggedRightRightskip}{\z@ plus 0.08\hsize}
  136. %%
  137. % Set the justification baesed on the `justified' class option
  138. \newcommand{\@tufte@justification}{%
  139. \ifthenelse{\boolean{@tufte@justified}}
  140. {\justifying}
  141. {\RaggedRight}
  142. }
  143. %%
  144. % Turn off section numbering
  145. \setcounter{secnumdepth}{-1}
  146. %%
  147. % Tighten up space between displays (e.g., a figure or table) and make symmetric
  148. \setlength\abovedisplayskip{6pt plus 2pt minus 4pt}
  149. \setlength\belowdisplayskip{6pt plus 2pt minus 4pt}
  150. %%
  151. % To implement full-width display environments
  152. \RequirePackage[strict]{chngpage}
  153. % TODO this package may be obsolete -- see the changepage package for a replacement
  154. % Compute length used for full-width displays
  155. \newlength{\@tufte@overhang}
  156. \setlength{\@tufte@overhang}{\marginparwidth}
  157. \addtolength{\@tufte@overhang}{\marginparsep}
  158. %%
  159. % Modified \title, \author, and \date commands. These store the
  160. % (footnote-less) values in \thetitle, \theauthor, and \thedate, respectively.
  161. \newcommand{\thetitle}{}% plain-text-only title
  162. \newcommand{\theauthor}{}% plain-text-only author
  163. \newcommand{\thepublisher}{}% plain-text-only publisher
  164. \newcommand{\thanklesstitle}{}% full title text minus \thanks{}
  165. \newcommand{\thanklessauthor}{}% full author text minus \thanks{}
  166. \newcommand{\thanklesspublisher}{}% full publisher minus \thanks{}
  167. \newcommand{\@publisher}{}% full publisher with \thanks{}
  168. \newcommand{\thedate}{\today}
  169. % TODO Fix it so that \thanks is not spaced out (with `soul') and can be
  170. % used in \maketitle when the `sfsidenotes' option is provided.
  171. \renewcommand{\thanks}[1]{\NoCaseChange{\footnote{#1}}}
  172. \renewcommand{\title}[2][]{%
  173. \gdef\@title{#2}%
  174. \begingroup%
  175. % TODO store contents of \thanks command
  176. \renewcommand{\thanks}[1]{}% swallow \thanks contents
  177. \protected@xdef\thanklesstitle{#2}%
  178. \endgroup%
  179. \ifthenelse{\isempty{#1}}%
  180. {\renewcommand{\thetitle}{\thanklesstitle}}% use thankless title
  181. {\renewcommand{\thetitle}{#1}}% use provided plain-text title
  182. \hypersetup{pdftitle={\thetitle}}% set the PDF metadata title
  183. }
  184. \renewcommand*{\author}[2][]{%
  185. \gdef\@author{#2}%
  186. \begingroup%
  187. % TODO store contents of \thanks command
  188. \renewcommand{\thanks}[1]{}% swallow \thanks contents
  189. \protected@xdef\thanklessauthor{#2}%
  190. \endgroup%
  191. \ifthenelse{\isempty{#1}}
  192. {\renewcommand{\theauthor}{\thanklessauthor}}% use thankless author
  193. {\renewcommand{\theauthor}{#1}}% use provided plain-text author
  194. \hypersetup{pdfauthor={\theauthor}}% set the PDF metadata author
  195. }
  196. \renewcommand*{\date}[1]{%
  197. \gdef\@date{#1}%
  198. \begingroup%
  199. % TODO store contents of \thanks command
  200. \renewcommand{\thanks}[1]{}% swallow \thanks contents
  201. \protected@xdef\thedate{#1}%
  202. \endgroup%
  203. }
  204. %%
  205. % Provides a \publisher command to set the publisher
  206. \newcommand{\publisher}[2][]{%
  207. \gdef\@publisher{#2}%
  208. \begingroup%
  209. \renewcommand{\thanks}[1]{}% swallow \thanks contents
  210. \protected@xdef\thanklesspublisher{#2}%
  211. \endgroup%
  212. \ifthenelse{\isempty{#1}}
  213. {\renewcommand{\thepublisher}{\thanklesspublisher}}% use thankless publisher
  214. {\renewcommand{\thepublisher}{#1}}% use provided plain-text publisher
  215. }
  216. % TODO: Test \hypersetup{pdfauthor,pdftitle} with DVI and XeTeX
  217. %%
  218. % Require paralist package for tighter lists
  219. \RequirePackage{paralist}
  220. % Add rightmargin to compactenum
  221. \def\@compactenum@{%
  222. \expandafter\list\csname label\@enumctr\endcsname{%
  223. \usecounter{\@enumctr}%
  224. \rightmargin=2em% added this
  225. \parsep\plparsep
  226. \itemsep\plitemsep
  227. \topsep\pltopsep
  228. \partopsep\plpartopsep
  229. \def\makelabel##1{\hss\llap{##1}}}}
  230. %%
  231. % Improved letterspacing of small caps and all-caps text.
  232. %
  233. % First, try to use the `microtype' package, if it's available.
  234. % Failing that, try to use the `soul' package, if it's available.
  235. % Failing that, well, I give up.
  236. \RequirePackage{textcase} % provides \MakeTextUppercase and \MakeTextLowercase
  237. \def\allcapsspacing{\relax}
  238. \def\smallcapsspacing{\relax}
  239. \newcommand{\allcaps}[1]{\MakeTextUppercase{\allcapsspacing{#1}}}
  240. \newcommand{\smallcaps}[1]{\MakeTextLowercase{\textsc{#1}}}
  241. \newcommand{\@tufte@loadsoul}{%
  242. \IfFileExists{soul.sty}{%
  243. \RequirePackage{soul}
  244. \sodef\allcapsspacing{\upshape}{0.15em}{0.65em}{0.6em}
  245. \sodef\smallcapsspacing{\scshape}{0.075em}{0.5em}{0.6em}
  246. }{
  247. \PackageWarningNoLine{\@tufte@pkgname}{Couldn't locate `soul' package.}
  248. }% soul not installed... giving up.
  249. }
  250. % If we're using pdfLaTeX v1.40+, use the letterspace package.
  251. % If we're using pdfLaTex < v1.40, use the soul package.
  252. % If we're using XeLaTeX, use XeLaTeX letterspacing options.
  253. % Otherwise fall back on the soul package.
  254. \ifthenelse{\boolean{@tufte@pdf}}
  255. {\PackageInfo{\@tufte@pkgname}{ifpdf = true}}
  256. {\PackageInfo{\@tufte@pkgname}{ifpdf = false}}
  257. \ifthenelse{\boolean{@tufte@xetex}}
  258. {\PackageInfo{\@tufte@pkgname}{ifxetex = true}}
  259. {\PackageInfo{\@tufte@pkgname}{ifxetex = false}}
  260. % Check pdfLaTeX version
  261. \def\@tufte@pdftexversion{0}
  262. \ifx\normalpdftexversion\@undefined \else
  263. \let\pdftexversion \normalpdftexversion
  264. \let\pdftexrevision\normalpdftexrevision
  265. \let\pdfoutput \normalpdfoutput
  266. \fi
  267. \ifx\pdftexversion\@undefined \else
  268. \ifx\pdftexversion\relax \else
  269. \def\@tufte@pdftexversion{6}
  270. \ifnum\pdftexversion < 140
  271. \def\@tufte@pdftexversion{5}
  272. \fi
  273. \fi
  274. \fi
  275. \ifthenelse{\boolean{@tufte@letterspace}}
  276. {%
  277. \ifnum\@tufte@pdftexversion<6
  278. % pdfLaTeX version is too old or not using pdfLaTeX
  279. \ifthenelse{\boolean{@tufte@xetex}}
  280. {% TODO use xetex letterspacing
  281. \PackageInfo{\@tufte@pkgname}{XeTeX detected. Reverting to `soul' package for letterspacing.}
  282. \@tufte@loadsoul}
  283. {% use `soul' package for letterspacing
  284. \PackageInfo{\tufte@pkgname}{Old version of pdfTeX detected. Reverting to `soul' package for letterspacing.}
  285. \@tufte@loadsoul}
  286. \else
  287. \IfFileExists{letterspace.sty}{%
  288. \PackageInfo{\@tufte@pkgname}{Modern version of pdfTeX detected. Using `letterspace' package.}
  289. \RequirePackage{letterspace}
  290. % Set up letterspacing (using microtype package) -- requires pdfTeX v1.40+
  291. \renewcommand{\allcapsspacing}[1]{\textls[200]{##1}}
  292. \renewcommand{\smallcapsspacing}[1]{\textls[50]{##1}}
  293. \renewcommand{\allcaps}[1]{\textls[200]{\MakeTextUppercase{##1}}}
  294. \renewcommand{\smallcaps}[1]{\textsc{\MakeTextLowercase{##1}}}
  295. }{% microtype failed, check for soul
  296. \PackageInfo{\@tufte@pkgname}{Modern version of pdfTeX detected, but `letterspace' package not installed. Reverting to `soul' package for letterspacing.}
  297. \@tufte@loadsoul
  298. }
  299. \fi}
  300. {}
  301. \DeclareTextFontCommand{\textsmallcaps}{\scshape}
  302. \renewcommand{\textsc}[1]{\textsmallcaps{\smallcapsspacing{#1}}}
  303. %%
  304. % An environment for paragraph-style section
  305. \providecommand\newthought[1]{%
  306. \addvspace{1.0\baselineskip plus 0.5ex minus 0.2ex}%
  307. \noindent\textsc{#1}%
  308. }
  309. %%
  310. % Used for doublespacing, and other linespacing
  311. % Note that setspace must be loaded before footmisc or it'll break sidenotes
  312. \usepackage{setspace}
  313. %%
  314. % Transform existing \footnotes into \sidenotes
  315. % Sidenote: ``Where God meant footnotes to go.'' ---Tufte
  316. \RequirePackage[side,multiple,stable]{footmisc}
  317. \providecommand*{\footnotelayout}{\@tufte@marginfont\@tufte@justification}
  318. \renewcommand{\footnotelayout}{\@tufte@marginfont\@tufte@justification}
  319. % Override footmisc's definition to set the sidenote marks (numbers) inside the
  320. % sidenote's text block.
  321. \long\def\@makefntext#1{\@textsuperscript{\@tufte@marginfont\tiny\@thefnmark}\,\footnotelayout#1}
  322. % Set the in-text footnote mark in the same typeface as the body text itself.
  323. \def\@makefnmark{\hbox{\@textsuperscript{\normalfont\scriptsize\@thefnmark}}}
  324. \let\sidenote\footnote
  325. %%
  326. % Sidenote without the footnote mark
  327. \providecommand\marginnote[1]%
  328. {\marginpar{\@tufte@marginfont\@tufte@justification #1}}
  329. %%
  330. % Citations should go in the margin as well
  331. \RequirePackage{natbib}
  332. \RequirePackage{bibentry} % allows bibitems to be typeset outside thebibliography environment
  333. \nobibliography* % pre-loads the bibliography keys
  334. \providecommand{\doi}[1]{\textsc{doi:} #1} % pre-defining this so it may be used before the \bibliography command it issued
  335. \renewcommand{\cite}[1]{%
  336. \@for\@temp@bibkey:=#1\do{%
  337. \sidenote{\bibentry{\@temp@bibkey}.}%
  338. }
  339. }
  340. % TODO: Combine sequences of citations so that 2,3,4,6 becomes 2--4,6
  341. % but be careful of hyperref interaction
  342. %%
  343. % The placeins package provides the \FloatBarrier command. This forces
  344. % LaTeX to place all of the floats before proceeding. We'll use this to
  345. % keep the float (figure and table) numbers in sequence.
  346. \RequirePackage{placeins}
  347. %%
  348. % Margin figure environment
  349. \newsavebox{\@tufte@marginfigbox}
  350. \newenvironment{marginfigure}[1]
  351. [-1.2ex]
  352. {\FloatBarrier% process all floats before this point so the figure numbers stay in order.
  353. \begin{lrbox}{\@tufte@marginfigbox}
  354. \begin{minipage}{\marginparwidth}
  355. \@tufte@marginfont
  356. \def\@captype{figure}
  357. \vspace*{#1}
  358. \@tufte@justification
  359. }
  360. {\end{minipage}%
  361. \end{lrbox}%
  362. \marginpar{\usebox{\@tufte@marginfigbox}}}
  363. %%
  364. % Margin table environment
  365. \newsavebox{\@tufte@margintablebox}
  366. \newenvironment{margintable}[1]
  367. [-1.2ex]
  368. {\FloatBarrier% process all floats before this point so the figure numbers stay in order.
  369. \begin{lrbox}{\@tufte@margintablebox}
  370. \begin{minipage}{\marginparwidth}
  371. \@tufte@marginfont
  372. \def\@captype{table}
  373. \vspace*{#1}
  374. \@tufte@justification
  375. }
  376. {\end{minipage}%
  377. \end{lrbox}%
  378. \marginpar{\usebox{\@tufte@margintablebox}}}
  379. %%
  380. % Full-width figure
  381. \renewenvironment{figure*}[1]%
  382. [htbp]%
  383. {\@float{figure}[#1]%
  384. \ifthenelse{\boolean{@tufte@symmetric}}
  385. {\begin{adjustwidth}[]{}{-\@tufte@overhang}}
  386. {\begin{adjustwidth}{}{-\@tufte@overhang}}
  387. \begin{minipage}{\linewidth}}%
  388. {\end{minipage}%
  389. \end{adjustwidth}%
  390. \end@float}
  391. %%
  392. % Full-width table
  393. \renewenvironment{table*}[1]
  394. [htbp]%
  395. {\@float{table}[#1]%
  396. \ifthenelse{\boolean{@tufte@symmetric}}
  397. {\begin{adjustwidth}[]{}{-\@tufte@overhang}}
  398. {\begin{adjustwidth}{}{-\@tufte@overhang}}
  399. \begin{minipage}{\linewidth}}%
  400. {\end{minipage}%
  401. \end{adjustwidth}%
  402. \end@float}
  403. %%
  404. % Full-page-width area
  405. \newenvironment{fullwidth}
  406. {\ifthenelse{\boolean{@tufte@symmetric}}
  407. {\begin{adjustwidth}[]{}{-\@tufte@overhang}}
  408. {\begin{adjustwidth}{}{-\@tufte@overhang}}
  409. }
  410. {\end{adjustwidth}}
  411. %%
  412. % Format the captions in a style similar to the sidenotes
  413. \RequirePackage[format=default,font={rm,scriptsize},justification=raggedright,singlelinecheck=false]{caption}
  414. % if the `sfsidenotes' option is specified, set the captions in sf, too.
  415. \ifthenelse{\boolean{@tufte@sfsidenotes}}
  416. {\captionsetup{font={sf,scriptsize}}}
  417. {\captionsetup{font={rm,scriptsize}}}
  418. % if the `justified' option is specified, set the captions in flush left
  419. % and flush right
  420. \ifthenelse{\boolean{@tufte@justified}}
  421. {\captionsetup{justification=justified}}
  422. {\captionsetup{justification=raggedright}}
  423. %%
  424. % If the Palatino typeface (and its math symbol set) are installed, load
  425. % them unless the `nofonts' class option was provided, or if we're
  426. % compiling with XeLaTeX.
  427. \ifthenelse{\boolean{@tufte@loadfonts}\AND\NOT\boolean{@tufte@xetex}}{%
  428. \IfFileExists{palatino.sty}{%
  429. \RequirePackage{palatino}
  430. \IfFileExists{mathpazo.sty}{\RequirePackage[osf,sc]{mathpazo}}{}
  431. }{} % if the Palatino typefaces aren't found, do nothing.
  432. }{}
  433. %%
  434. % If the Bera Mono typeface is available, use it unless the `nofonts' class
  435. % option was provided, or if we're compiling with XeLaTeX.
  436. \ifthenelse{\boolean{@tufte@loadfonts}\AND\NOT\boolean{@tufte@xetex}}{%
  437. \IfFileExists{beramono.sty}{%
  438. \RequirePackage[T1]{fontenc}
  439. \RequirePackage[scaled=0.85]{beramono}
  440. }{}
  441. }{}
  442. %%
  443. % Turns newlines into spaces. Based on code from the `titlesec' package.
  444. \DeclareRobustCommand{\@tufte@newlinetospace}{%
  445. \@ifstar{\@tufte@newlinetospace@i}{\@tufte@newlinetospace@i}%
  446. }
  447. \def\@tufte@newlinetospace@i{%
  448. \ifdim\lastskip>\z@\else\space\fi
  449. \ignorespaces%
  450. }
  451. \DeclareRobustCommand{\newlinetospace}[1]{%
  452. \let\@tufte@orig@cr\\% save the original meaning of \\
  453. \def\\{\@tufte@newlinetospace}% turn \\ and \\* into \space
  454. \let\newline\\% turn \newline into \space
  455. #1
  456. \let\\\@tufte@orig@cr% revert to original meaning of \\
  457. }
  458. %%
  459. % Sets up the running heads and folios.
  460. \RequirePackage{fancyhdr}
  461. % Set the default page style to 'fancy'
  462. \pagestyle{fancy}
  463. % Set the header/footer width to be the body text block plus the margin
  464. % note area.
  465. \ifthenelse{\boolean{@tufte@symmetric}}
  466. {\fancyhfoffset[LE,RO]{\@tufte@overhang}}
  467. {\fancyhfoffset[RE,RO]{\@tufte@overhang}}
  468. % The running heads/feet don't have rules
  469. \renewcommand{\headrulewidth}{0pt}
  470. \renewcommand{\footrulewidth}{0pt}
  471. % The 'fancy' page style is the default style for all pages.
  472. \fancyhf{} % clear header and footer fields
  473. \ifthenelse{\boolean{@tufte@twoside}}
  474. {\fancyhead[LE]{\thepage\quad\smallcaps{\newlinetospace{\theauthor}}}%
  475. \fancyhead[RO]{\smallcaps{\newlinetospace{\thetitle}}\quad\thepage}}
  476. {\fancyhead[RE,RO]{\smallcaps{\newlinetospace{\thetitle}}\quad\thepage}}
  477. % The `plain' page style is used on chapter opening pages.
  478. % In Tufte's /Beautiful Evidence/ he never puts page numbers at the
  479. % bottom of pages -- the folios are unexpressed.
  480. \fancypagestyle{plain}{
  481. \fancyhf{} % clear header and footer fields
  482. % Uncomment the following five lines of code if you want the opening page
  483. % of the chapter to express the folio in the lower outside corner.
  484. %\ifthenelse{\boolean{@tufte@twoside}}
  485. % {\fancyfoot[LE,RO]{\thepage}}
  486. % {\fancyfoot[RE,RO]{\thepage}}
  487. }
  488. % The `empty' page style suppresses all headers and footers.
  489. % It's used on title pages and `intentionally blank' pages.
  490. \fancypagestyle{empty}{
  491. \fancyhf{} % clear header and footer fields
  492. }
  493. %%
  494. % Set raggedright and paragraph indentation for document
  495. \AtBeginDocument{\@tufte@justification\setlength\parindent{1em}}
  496. %%
  497. % Prints the list of class options and their states.
  498. \newcommand{\typeoutbool}[2]{%
  499. \ifthenelse{\boolean{#2}}
  500. {\typeout{\space\space#1: true}}
  501. {\typeout{\space\space#1: false}}
  502. }
  503. \newcommand{\typeoutstr}[2]{%
  504. \typeout{\space\space#1: #2}
  505. }
  506. \newcommand{\PrintTufteSettings}{%
  507. \typeout{-------------------- Tufte-LaTeX settings ----------}
  508. \typeout{Class: \@tufte@pkgname}
  509. \typeout{}
  510. \typeout{Class options:}
  511. \typeoutbool{a4paper}{@tufte@afourpaper}
  512. \typeoutbool{load fonts}{@tufte@loadfonts}
  513. \typeoutbool{fully-justified}{@tufte@justified}
  514. \typeoutbool{letterspacing}{@tufte@letterspace}
  515. \typeoutbool{sans-serif sidenotes}{@tufte@sfsidenotes}
  516. \typeoutbool{symmetric margins}{@tufte@symmetric}
  517. \typeoutbool{titlepage}{@tufte@titlepage}
  518. \typeoutbool{twoside}{@tufte@twoside}
  519. \typeoutbool{debug}{@tufte@debug}
  520. \typeout{}
  521. \typeout{Internal variables:}
  522. \typeoutbool{[twoside]}{@twoside}
  523. \typeoutbool{pdflatex}{@tufte@pdf}
  524. \typeoutbool{xelatex}{@tufte@xetex}
  525. \typeout{----------------------------------------------------}
  526. }
  527. %%
  528. % Color
  529. \RequirePackage{xcolor}
  530. %%
  531. % Produces a full title page
  532. \newcommand{\maketitlepage}[0]{%
  533. \cleardoublepage
  534. {
  535. \sffamily
  536. \begin{fullwidth}
  537. \par\noindent\fontsize{18}{18}\selectfont\textcolor{darkgray}{\allcaps{\thanklessauthor}}
  538. \end{fullwidth}
  539. \vspace{11.5pc}
  540. \begin{fullwidth}
  541. \par\noindent\fontsize{36}{36}\selectfont\textcolor{darkgray}{\allcaps{\thanklesstitle}}
  542. \end{fullwidth}
  543. \vfill
  544. \begin{fullwidth}
  545. \par\noindent\fontsize{14}{14}\selectfont\allcaps{\thanklesspublisher}
  546. \end{fullwidth}
  547. }
  548. \thispagestyle{empty}
  549. \clearpage
  550. }
  551. %%
  552. % Title block
  553. \renewcommand{\maketitle}{%
  554. \newpage
  555. \global\@topnum\z@% prevent floats from being placed at the top of the page
  556. \setlength{\parindent}{0pt}
  557. \setlength{\parskip}{4pt}
  558. \ifthenelse{\boolean{@tufte@sfsidenotes}}
  559. {\begingroup
  560. % FIXME fails with \thanks
  561. \sffamily
  562. \par{\Large\allcaps{\@title}}
  563. \par{\large\allcaps{\@author}}
  564. \par{\large\allcaps{\@date}}
  565. \endgroup}
  566. {\begingroup
  567. \par{\Large\textit{\@title}}
  568. \par{\large\textit{\@author}}
  569. \par{\large\textit{\@date}}
  570. \endgroup}
  571. \par
  572. \thispagestyle{plain}% suppress the running head
  573. }
  574. %%
  575. % Title page (if the `titlepage' option was passed to the tufte-handout
  576. % class.)
  577. \ifthenelse{\boolean{@tufte@titlepage}}
  578. {\renewcommand{\maketitle}{\maketitlepage}}
  579. {}
  580. %%
  581. % When \cleardoublepage is called, produce a blank (empty) page -- i.e.,
  582. % without headers and footers
  583. \def\cleardoublepage{\clearpage\if@twoside\ifodd\c@page\else
  584. \hbox{}
  585. %\vspace*{\fill}
  586. %\begin{center}
  587. % This page intentionally contains only this sentence.
  588. %\end{center}
  589. %\vspace{\fill}
  590. \thispagestyle{empty}
  591. \newpage
  592. \if@twocolumn\hbox{}\newpage\fi\fi\fi}
  593. %%
  594. % Make Tuftian-style section headings and TOC formatting
  595. \RequirePackage{titlesec,titletoc}
  596. % TODO: I'd prefer to use the 'titlesec' package for this formatting, but
  597. % I'll do it old-style for now. --Kevin
  598. \renewcommand\section{\@startsection {section}{1}{\z@}%
  599. {-3.5ex \@plus -1ex \@minus -.2ex}%
  600. {2.3ex \@plus.2ex}%
  601. {\normalfont\large\it}}
  602. \renewcommand\subsection{\@startsection{subsection}{2}{\z@}%
  603. {-3.25ex\@plus -1ex \@minus -.2ex}%
  604. {1.5ex \@plus .2ex}%
  605. {\normalfont\normalsize\it}}
  606. % Subsubsection and following section headings shouldn't be used.
  607. % See Bringhurst's _The Elements of Typography_, section 4.2.2.
  608. \renewcommand\subsubsection{%
  609. \PackageError{\@tufte@pkgname}{\noexpand\subsubsection is undefined by this class.%
  610. \MessageBreak See Robert Bringhurst's _The Elements of
  611. \MessageBreak Typographic Style_, section 4.2.2.
  612. \MessageBreak \noexpand\subsubsection was used}
  613. {From Bringhurst's _The Elements of Typographic Style_, section 4.2.2: Use as
  614. \MessageBreak many levels of headings as you need, no more and no fewer. Also see the many
  615. \MessageBreak related threads on Ask E.T. at http://www.edwardtufte.com/.}
  616. }
  617. \renewcommand\paragraph{%
  618. \PackageError{\@tufte@pkgname}{\noexpand\paragraph is undefined by this class.%
  619. \MessageBreak See Robert Bringhurst's _The Elements of
  620. \MessageBreak Typographic Style_, section 4.2.2.
  621. \MessageBreak \noexpand\paragraph was used}
  622. {From Bringhurst's _The Elements of Typographic Style_, section 4.2.2: Use as
  623. \MessageBreak many levels of headings as you need, no more and no fewer. Also see the many
  624. \MessageBreak related threads on Ask E.T. at http://www.edwardtufte.com/.}
  625. }
  626. \renewcommand\subparagraph{%
  627. \PackageError{\@tufte@pkgname}{\noexpand\subparagraph is undefined by this class.%
  628. \MessageBreak See Robert Bringhurst's _The Elements of
  629. \MessageBreak Typographic Style_, section 4.2.2.
  630. \MessageBreak \noexpand\subparagraph was used}
  631. {From Bringhurst's _The Elements of Typographic Style_, section 4.2.2: Use as
  632. \MessageBreak many levels of headings as you need, no more and no fewer. Also see the many
  633. \MessageBreak related threads on Ask E.T. at http://www.edwardtufte.com/.}
  634. }
  635. % Formatting for main TOC (printed in front matter)
  636. % {section} [left] {above} {before w/label} {before w/o label} {filler + page} [after]
  637. \titlecontents{chapter}%
  638. [0em] % distance from left margin
  639. {\begin{fullwidth}\fontsize{13pt}{18pt}\selectfont} % above (global formatting of entry)
  640. {\contentslabel{2em}\rm\itshape} % before w/label (label = ``Chapter 1'')
  641. {\rm\itshape} % before w/o label
  642. {\rm\qquad\thecontentspage} % filler + page (leaders and page num)
  643. [\vspace{1.5\baselineskip}\end{fullwidth}] % after
  644. %\titlecontents{chapter}%
  645. % [0em]% distance from left margin
  646. % {\fontsize{12pt}{18pt}\selectfont}% above (global formatting of entry)
  647. % {\textit}% before w/ label (label = ``Chapter 1'')
  648. % {\textit}% before w/o label
  649. % {\qquad\thecontentspage}% filler and page (leaders and page num)
  650. % [\vspace{1.5\baselineskip}]% after
  651. \titleformat{\chapter}%
  652. [display]% shape
  653. {\relax\ifthenelse{\NOT\boolean{@tufte@symmetric}}{\begin{fullwidth}}{}}% format applied to label+text
  654. {\itshape\fontsize{22}{24}\selectfont\thechapter}% label
  655. {0pt}% horizontal separation between label and title body
  656. {\fontsize{22}{24}\rm\itshape}% before the title body
  657. [\ifthenelse{\NOT\boolean{@tufte@symmetric}}{\end{fullwidth}}{}]% after the title body
  658. %%
  659. % A handy command to disable hyphenation for short bits of text.
  660. % Borrowed from Peter Wilson's `hyphenat' package.
  661. \newlanguage\langwohyphens% define a language without hyphenation rules
  662. \newcommand{\nohyphens}[1]{{\language\langwohyphens #1}}% used for short bits of text
  663. \newcommand{\nohyphenation}{\language\langwohyphens}% can be used inside environments for longer text
  664. %%
  665. % If debugging is enabled, print the Tufte-LaTeX options and the list of
  666. % files.
  667. \ifthenelse{\boolean{@tufte@debug}}
  668. {\PrintTufteSettings\listfiles}
  669. {}
  670. %%
  671. % If there is a `tufte-common-local.tex' file, load it up.
  672. \IfFileExists{tufte-common-local.tex}
  673. {\input{tufte-common-local}}
  674. {}
  675. %%
  676. % End of file
  677. \endinput