25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

tufte-common.sty 28KB

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