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.

811 line
24KB

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