25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

834 satır
25KB

  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]{\vspace{1.8\baselineskip plus 3pt minus 2pt}%
  306. {\noindent\textsc{#1}}}
  307. %%
  308. % Used for doublespacing, and other linespacing
  309. % Note that setspace must be loaded before footmisc or it'll break sidenotes
  310. \usepackage{setspace}
  311. %%
  312. % Transform existing \footnotes into \sidenotes
  313. % Sidenote: ``Where God meant footnotes to go.'' ---Tufte
  314. \RequirePackage[side,multiple,stable]{footmisc}
  315. \providecommand*{\footnotelayout}{\@tufte@marginfont\@tufte@justification}
  316. \renewcommand{\footnotelayout}{\@tufte@marginfont\@tufte@justification}
  317. % Override footmisc's definition to set the sidenote marks (numbers) inside the
  318. % sidenote's text block.
  319. \long\def\@makefntext#1{\@textsuperscript{\@tufte@marginfont\tiny\@thefnmark}\,\footnotelayout#1}
  320. % Set the in-text footnote mark in the same typeface as the body text itself.
  321. \def\@makefnmark{\hbox{\@textsuperscript{\normalfont\scriptsize\@thefnmark}}}
  322. \let\sidenote\footnote
  323. %%
  324. % Sidenote without the footnote mark
  325. \providecommand\marginnote[1]%
  326. {\marginpar{\@tufte@marginfont\@tufte@justification #1}}
  327. %%
  328. % Citations should go in the margin as well
  329. \RequirePackage{natbib}
  330. \RequirePackage{bibentry} % allows bibitems to be typeset outside thebibliography environment
  331. \nobibliography* % pre-loads the bibliography keys
  332. \providecommand{\doi}[1]{\textsc{doi:} #1} % pre-defining this so it may be used before the \bibliography command it issued
  333. \renewcommand{\cite}[1]{%
  334. \@for\@temp@bibkey:=#1\do{%
  335. \sidenote{\bibentry{\@temp@bibkey}.}%
  336. }
  337. }
  338. % TODO: Combine sequences of citations so that 2,3,4,6 becomes 2--4,6
  339. % but be careful of hyperref interaction
  340. %%
  341. % The placeins package provides the \FloatBarrier command. This forces
  342. % LaTeX to place all of the floats before proceeding. We'll use this to
  343. % keep the float (figure and table) numbers in sequence.
  344. \RequirePackage{placeins}
  345. %%
  346. % Margin figure environment
  347. \newsavebox{\@tufte@marginfigbox}
  348. \newenvironment{marginfigure}[1]
  349. [-1.2ex]
  350. {\FloatBarrier% process all floats before this point so the figure numbers stay in order.
  351. \begin{lrbox}{\@tufte@marginfigbox}
  352. \begin{minipage}{\marginparwidth}
  353. \@tufte@marginfont
  354. \def\@captype{figure}
  355. \vspace*{#1}
  356. \@tufte@justification
  357. }
  358. {\end{minipage}%
  359. \end{lrbox}%
  360. \marginpar{\usebox{\@tufte@marginfigbox}}}
  361. %%
  362. % Margin table environment
  363. \newsavebox{\@tufte@margintablebox}
  364. \newenvironment{margintable}[1]
  365. [-1.2ex]
  366. {\FloatBarrier% process all floats before this point so the figure numbers stay in order.
  367. \begin{lrbox}{\@tufte@margintablebox}
  368. \begin{minipage}{\marginparwidth}
  369. \@tufte@marginfont
  370. \def\@captype{table}
  371. \vspace*{#1}
  372. \@tufte@justification
  373. }
  374. {\end{minipage}%
  375. \end{lrbox}%
  376. \marginpar{\usebox{\@tufte@margintablebox}}}
  377. %%
  378. % Full-width figure
  379. \renewenvironment{figure*}[1]%
  380. [htbp]%
  381. {\@float{figure}[#1]%
  382. \ifthenelse{\boolean{@tufte@symmetric}}
  383. {\begin{adjustwidth}[]{}{-\@tufte@overhang}}
  384. {\begin{adjustwidth}{}{-\@tufte@overhang}}
  385. \begin{minipage}{\linewidth}}%
  386. {\end{minipage}%
  387. \end{adjustwidth}%
  388. \end@float}
  389. %%
  390. % Full-width table
  391. \renewenvironment{table*}[1]
  392. [htbp]%
  393. {\@float{table}[#1]%
  394. \ifthenelse{\boolean{@tufte@symmetric}}
  395. {\begin{adjustwidth}[]{}{-\@tufte@overhang}}
  396. {\begin{adjustwidth}{}{-\@tufte@overhang}}
  397. \begin{minipage}{\linewidth}}%
  398. {\end{minipage}%
  399. \end{adjustwidth}%
  400. \end@float}
  401. %%
  402. % Full-page-width area
  403. \newenvironment{fullwidth}
  404. {\ifthenelse{\boolean{@tufte@symmetric}}
  405. {\begin{adjustwidth}[]{}{-\@tufte@overhang}}
  406. {\begin{adjustwidth}{}{-\@tufte@overhang}}
  407. }
  408. {\end{adjustwidth}}
  409. %%
  410. % Format the captions in a style similar to the sidenotes
  411. \RequirePackage[format=default,font={rm,scriptsize},justification=raggedright,singlelinecheck=false]{caption}
  412. % if the `sfsidenotes' option is specified, set the captions in sf, too.
  413. \ifthenelse{\boolean{@tufte@sfsidenotes}}
  414. {\captionsetup{font={sf,scriptsize}}}
  415. {\captionsetup{font={rm,scriptsize}}}
  416. % if the `justified' option is specified, set the captions in flush left
  417. % and flush right
  418. \ifthenelse{\boolean{@tufte@justified}}
  419. {\captionsetup{justification=justified}}
  420. {\captionsetup{justification=raggedright}}
  421. %%
  422. % If the Palatino typeface (and its math symbol set) are installed, load
  423. % them unless the `nofonts' class option was provided, or if we're
  424. % compiling with XeLaTeX.
  425. \ifthenelse{\boolean{@tufte@loadfonts}\AND\NOT\boolean{@tufte@xetex}}{%
  426. \IfFileExists{palatino.sty}{%
  427. \RequirePackage{palatino}
  428. \IfFileExists{mathpazo.sty}{\RequirePackage[osf,sc]{mathpazo}}{}
  429. }{} % if the Palatino typefaces aren't found, do nothing.
  430. }{}
  431. %%
  432. % If the Bera Mono typeface is available, use it unless the `nofonts' class
  433. % option was provided, or if we're compiling with XeLaTeX.
  434. \ifthenelse{\boolean{@tufte@loadfonts}\AND\NOT\boolean{@tufte@xetex}}{%
  435. \IfFileExists{beramono.sty}{%
  436. \RequirePackage[T1]{fontenc}
  437. \RequirePackage[scaled=0.85]{beramono}
  438. }{}
  439. }{}
  440. %%
  441. % Sets up the running heads and folios.
  442. \RequirePackage{fancyhdr}
  443. % Set the default page style to 'fancy'
  444. \pagestyle{fancy}
  445. % Set the header/footer width to be the body text block plus the margin
  446. % note area.
  447. \ifthenelse{\boolean{@tufte@symmetric}}
  448. {\fancyhfoffset[LE,RO]{\@tufte@overhang}}
  449. {\fancyhfoffset[RE,RO]{\@tufte@overhang}}
  450. % The running heads/feet don't have rules
  451. \renewcommand{\headrulewidth}{0pt}
  452. \renewcommand{\footrulewidth}{0pt}
  453. % The 'fancy' page style is the default style for all pages.
  454. \fancyhf{} % clear header and footer fields
  455. \ifthenelse{\boolean{@tufte@twoside}}
  456. {\fancyhead[LE]{\thepage\quad\smallcaps{\theauthor}}%
  457. \fancyhead[RO]{\smallcaps{\thetitle}\quad\thepage}}
  458. {\fancyhead[RE,RO]{\smallcaps{\thetitle}\quad\thepage}}
  459. % The `plain' page style is used on chapter opening pages.
  460. % In Tufte's /Beautiful Evidence/ he never puts page numbers at the
  461. % bottom of pages -- the folios are unexpressed.
  462. \fancypagestyle{plain}{
  463. \fancyhf{} % clear header and footer fields
  464. % Uncomment the following five lines of code if you want the opening page
  465. % of the chapter to express the folio in the lower outside corner.
  466. %\ifthenelse{\boolean{@tufte@twoside}}
  467. % {\fancyfoot[LE,RO]{\thepage}}
  468. % {\fancyfoot[RE,RO]{\thepage}}
  469. }
  470. % The `empty' page style suppresses all headers and footers.
  471. % It's used on title pages and `intentionally blank' pages.
  472. \fancypagestyle{empty}{
  473. \fancyhf{} % clear header and footer fields
  474. }
  475. %%
  476. % Set raggedright and paragraph indentation for document
  477. \AtBeginDocument{\@tufte@justification\setlength\parindent{1em}}
  478. %%
  479. % Prints the list of class options and their states.
  480. \newcommand{\typeoutbool}[2]{%
  481. \ifthenelse{\boolean{#2}}
  482. {\typeout{\space\space#1: true}}
  483. {\typeout{\space\space#1: false}}
  484. }
  485. \newcommand{\typeoutstr}[2]{%
  486. \typeout{\space\space#1: #2}
  487. }
  488. \newcommand{\PrintTufteSettings}{%
  489. \typeout{-------------------- Tufte-LaTeX settings ----------}
  490. \typeout{Class: \@tufte@pkgname}
  491. \typeout{}
  492. \typeout{Class options:}
  493. \typeoutbool{a4paper}{@tufte@afourpaper}
  494. \typeoutbool{load fonts}{@tufte@loadfonts}
  495. \typeoutbool{fully-justified}{@tufte@justified}
  496. \typeoutbool{letterspacing}{@tufte@letterspace}
  497. \typeoutbool{sans-serif sidenotes}{@tufte@sfsidenotes}
  498. \typeoutbool{symmetric margins}{@tufte@symmetric}
  499. \typeoutbool{titlepage}{@tufte@titlepage}
  500. \typeoutbool{twoside}{@tufte@twoside}
  501. \typeoutbool{debug}{@tufte@debug}
  502. \typeout{}
  503. \typeout{Internal variables:}
  504. \typeoutbool{[twoside]}{@twoside}
  505. \typeoutbool{pdflatex}{@tufte@pdf}
  506. \typeoutbool{xelatex}{@tufte@xetex}
  507. \typeout{----------------------------------------------------}
  508. }
  509. %%
  510. % Color
  511. \RequirePackage{xcolor}
  512. %%
  513. % Produces a full title page
  514. \newcommand{\maketitlepage}[0]{%
  515. \cleardoublepage
  516. {
  517. \sffamily
  518. \begin{fullwidth}
  519. \par\noindent\fontsize{18}{18}\selectfont\textcolor{darkgray}{\allcaps{\thanklessauthor}}
  520. \end{fullwidth}
  521. \vspace{11.5pc}
  522. \begin{fullwidth}
  523. \par\noindent\fontsize{36}{36}\selectfont\textcolor{darkgray}{\allcaps{\thanklesstitle}}
  524. \end{fullwidth}
  525. \vfill
  526. \begin{fullwidth}
  527. \par\noindent\fontsize{14}{14}\selectfont\allcaps{\thanklesspublisher}
  528. \end{fullwidth}
  529. }
  530. \thispagestyle{empty}
  531. \clearpage
  532. }
  533. %%
  534. % Title block
  535. \renewcommand{\maketitle}{%
  536. \newpage
  537. \global\@topnum\z@% prevent floats from being placed at the top of the page
  538. \setlength{\parindent}{0pt}
  539. \setlength{\parskip}{4pt}
  540. \ifthenelse{\boolean{@tufte@sfsidenotes}}
  541. {\begingroup
  542. % FIXME fails with \thanks
  543. \sffamily
  544. \par{\Large\allcaps{\@title}}
  545. \par{\large\allcaps{\@author}}
  546. \par{\large\allcaps{\@date}}
  547. \endgroup}
  548. {\begingroup
  549. \par{\Large\textit{\@title}}
  550. \par{\large\textit{\@author}}
  551. \par{\large\textit{\@date}}
  552. \endgroup}
  553. \thispagestyle{plain}% suppress the running head
  554. }
  555. %%
  556. % Title page (if the `titlepage' option was passed to the tufte-handout
  557. % class.)
  558. \ifthenelse{\boolean{@tufte@titlepage}}
  559. {\renewcommand{\maketitle}{\maketitlepage}}
  560. {}
  561. %%
  562. % When \cleardoublepage is called, produce a blank (empty) page -- i.e.,
  563. % without headers and footers
  564. \def\cleardoublepage{\clearpage\if@twoside\ifodd\c@page\else
  565. \hbox{}
  566. %\vspace*{\fill}
  567. %\begin{center}
  568. % This page intentionally contains only this sentence.
  569. %\end{center}
  570. %\vspace{\fill}
  571. \thispagestyle{empty}
  572. \newpage
  573. \if@twocolumn\hbox{}\newpage\fi\fi\fi}
  574. %%
  575. % Make Tuftian-style section headings and TOC formatting
  576. \RequirePackage{titlesec,titletoc}
  577. % TODO: I'd prefer to use the 'titlesec' package for this formatting, but
  578. % I'll do it old-style for now. --Kevin
  579. \renewcommand\section{\@startsection {section}{1}{\z@}%
  580. {-3.5ex \@plus -1ex \@minus -.2ex}%
  581. {2.3ex \@plus.2ex}%
  582. {\normalfont\large\it}}
  583. \renewcommand\subsection{\@startsection{subsection}{2}{\z@}%
  584. {-3.25ex\@plus -1ex \@minus -.2ex}%
  585. {1.5ex \@plus .2ex}%
  586. {\normalfont\normalsize\it}}
  587. % Subsubsection and following section headings shouldn't be used.
  588. % See Bringhurst's _The Elements of Typography_, section 4.2.2.
  589. \renewcommand\subsubsection{%
  590. \PackageError{\@tufte@pkgname}{\noexpand\subsubsection 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\subsubsection 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. \renewcommand\paragraph{%
  599. \PackageError{\@tufte@pkgname}{\noexpand\paragraph is undefined by this class.%
  600. \MessageBreak See Robert Bringhurst's _The Elements of
  601. \MessageBreak Typographic Style_, section 4.2.2.
  602. \MessageBreak \noexpand\paragraph was used}
  603. {From Bringhurst's _The Elements of Typographic Style_, section 4.2.2: Use as
  604. \MessageBreak many levels of headings as you need, no more and no fewer. Also see the many
  605. \MessageBreak related threads on Ask E.T. at http://www.edwardtufte.com/.}
  606. }
  607. \renewcommand\subparagraph{%
  608. \PackageError{\@tufte@pkgname}{\noexpand\subparagraph is undefined by this class.%
  609. \MessageBreak See Robert Bringhurst's _The Elements of
  610. \MessageBreak Typographic Style_, section 4.2.2.
  611. \MessageBreak \noexpand\subparagraph was used}
  612. {From Bringhurst's _The Elements of Typographic Style_, section 4.2.2: Use as
  613. \MessageBreak many levels of headings as you need, no more and no fewer. Also see the many
  614. \MessageBreak related threads on Ask E.T. at http://www.edwardtufte.com/.}
  615. }
  616. % Formatting for main TOC (printed in front matter)
  617. % {section} [left] {above} {before w/label} {before w/o label} {filler + page} [after]
  618. \titlecontents{chapter}%
  619. [0em] % distance from left margin
  620. {\begin{fullwidth}\fontsize{13pt}{18pt}\selectfont} % above (global formatting of entry)
  621. {\contentslabel{2em}\rm\itshape} % before w/label (label = ``Chapter 1'')
  622. {\rm\itshape} % before w/o label
  623. {\rm\qquad\thecontentspage} % filler + page (leaders and page num)
  624. [\vspace{1.5\baselineskip}\end{fullwidth}] % after
  625. %\titlecontents{chapter}%
  626. % [0em]% distance from left margin
  627. % {\fontsize{12pt}{18pt}\selectfont}% above (global formatting of entry)
  628. % {\textit}% before w/ label (label = ``Chapter 1'')
  629. % {\textit}% before w/o label
  630. % {\qquad\thecontentspage}% filler and page (leaders and page num)
  631. % [\vspace{1.5\baselineskip}]% after
  632. \titleformat{\chapter}%
  633. [display]% shape
  634. {\relax\ifthenelse{\NOT\boolean{@tufte@symmetric}}{\begin{fullwidth}}{}}% format applied to label+text
  635. {\itshape\fontsize{22}{24}\selectfont\thechapter}% label
  636. {0pt}% horizontal separation between label and title body
  637. {\fontsize{22}{24}\rm\itshape}% before the title body
  638. [\ifthenelse{\NOT\boolean{@tufte@symmetric}}{\end{fullwidth}}{}]% after the title body
  639. %%
  640. % A handy command to disable hyphenation for short bits of text.
  641. % Borrowed from Peter Wilson's `hyphenat' package.
  642. \newlanguage\langwohyphens% define a language without hyphenation rules
  643. \newcommand{\nohyphens}[1]{{\language\langwohyphens #1}}% used for short bits of text
  644. \newcommand{\nohyphenation}{\language\langwohyphens}% can be used inside environments for longer text
  645. %%
  646. % If debugging is enabled, print the Tufte-LaTeX options and the list of
  647. % files.
  648. \ifthenelse{\boolean{@tufte@debug}}
  649. {\PrintTufteSettings\listfiles}
  650. {}
  651. %%
  652. % If there is a `tufte-common-local.sty' file, load it up.
  653. \IfFileExists{tufte-common-local.sty}
  654. {\RequirePackage{tufte-common-local.sty}}
  655. {}
  656. %%
  657. % End of file
  658. \endinput