diff --git a/sample-book.pdf b/sample-book.pdf index 8ecb681..2553477 100644 Binary files a/sample-book.pdf and b/sample-book.pdf differ diff --git a/sample-book.tex b/sample-book.tex index 9d2fe59..20c8c91 100644 --- a/sample-book.tex +++ b/sample-book.tex @@ -91,7 +91,7 @@ \newcommand{\measure}[3]{#1/#2$\times$\unit[#3]{pc}} % Macros for typesetting the documentation -\newcommand{\hl}[1]{\textcolor{Maroon}{#1}}% prints in red +\newcommand{\hlred}[1]{\textcolor{Maroon}{#1}}% prints in red \newcommand{\hangleft}[1]{\makebox[0pt][r]{#1}} \newcommand{\hairsp}{\hspace{1pt}}% hair space \newcommand{\hquad}{\hskip0.5em\relax}% half quad space @@ -466,7 +466,7 @@ The Tufte-\LaTeX\ classes will emit an error if you try to use \newthought{In his later books},\cite{Tufte2006} Tufte starts each section with a bit of vertical space, a non-indented paragraph, and sets the first few words of the sentence in \textsc{small caps}. To -accomplish this using this style, use the \hl{\doccmd{newthought}} command: +accomplish this using this style, use the \hlred{\doccmd{newthought}} command: \begin{docspec} \doccmd{newthought}\{In his later books\}, Tufte starts\ldots \end{docspec} @@ -479,11 +479,11 @@ for sidenotes and small figures. Any \doccmd{footnote}s will automatically be converted to sidenotes.\footnote{This is a sidenote that was entered using the \texttt{\textbackslash footnote} command.} If you'd like to place ancillary information in the margin without the sidenote mark (the superscript -number), you can use the \hl{\doccmd{marginnote}} command.\marginnote{This is a +number), you can use the \hlred{\doccmd{marginnote}} command.\marginnote{This is a margin note. Notice that there isn't a number preceding the note, and there is no number in the main text where this note was written.} -The specification of the \hl{\doccmd{sidenote}} command is: +The specification of the \hlred{\doccmd{sidenote}} command is: \begin{docspec} \doccmd{sidenote}[\docopt{number}][\docopt{offset}]\{\docarg{Sidenote text.}\} \end{docspec} @@ -525,13 +525,13 @@ The \doccmd{marginnote} command has a similar \docarg{offset} argument: \section{References} References are placed alongside their citations as sidenotes, -as well. This can be accomplished using the normal \hl{\doccmd{cite}} +as well. This can be accomplished using the normal \hlred{\doccmd{cite}} command.\sidenote{The first paragraph of this document includes a citation.} The complete list of references may also be printed automatically by using -the \hl{\doccmd{bibliography}} command. (See the end of this document for an +the \hlred{\doccmd{bibliography}} command. (See the end of this document for an example.) If you do not want to print a bibliography at the end of your -document, use the \hl{\doccmd{nobibliography}} command in its place. +document, use the \hlred{\doccmd{nobibliography}} command in its place. To enter multiple citations at one location,\cite[-3\baselineskip]{Tufte2006,Tufte1990} you can provide a list of keys separated by commas and the same optional vertical @@ -542,13 +542,13 @@ offset argument: \Verb|\cite{Tufte2006,Tufte1990}|. \section{Figures and Tables}\label{sec:figures-and-tables} Images and graphics play an integral role in Tufte's work. -In addition to the standard \hl{\docenv{figure}} and \hl{\docenv{tabular}} environments, +In addition to the standard \hlred{\docenv{figure}} and \hlred{\docenv{tabular}} environments, this style provides special figure and table environments for full-width floats. -Full page--width figures and tables may be placed in \hl{\docenv{figure*}} or -\hl{\docenv{table*}} environments. To place figures or tables in the margin, -use the \hl{\docenv{marginfigure}} or \hl{\docenv{margintable}} environments as follows +Full page--width figures and tables may be placed in \hlred{\docenv{figure*}} or +\hlred{\docenv{table*}} environments. To place figures or tables in the margin, +use the \hlred{\docenv{marginfigure}} or \hlred{\docenv{margintable}} environments as follows (see figure~\ref{fig:marginfig}): \begin{marginfigure}% @@ -623,7 +623,7 @@ the table's data. \section{Full-width text blocks} -In addition to the new float types, there is a \hl{\docenv{fullwidth}} +In addition to the new float types, there is a \hlred{\docenv{fullwidth}} environment that stretches across the main text block and the sidenotes area. @@ -650,13 +650,13 @@ existing commands for letterspacing. When setting strings of \allcaps{ALL CAPS} or \smallcaps{small caps}, the letter\-spacing---that is, the spacing between the letters---should be -increased slightly.\cite{Bringhurst2005} The \hl{\doccmd{allcaps}} command has proper letterspacing for -strings of \allcaps{FULL CAPITAL LETTERS}, and the \hl{\doccmd{smallcaps}} command +increased slightly.\cite{Bringhurst2005} The \hlred{\doccmd{allcaps}} command has proper letterspacing for +strings of \allcaps{FULL CAPITAL LETTERS}, and the \hlred{\doccmd{smallcaps}} command has letterspacing for \smallcaps{small capital letters}. These commands will also automatically convert the case of the text to upper- or lowercase, respectively. -The \hl{\doccmd{textsc}} command has also been redefined to include +The \hlred{\doccmd{textsc}} command has also been redefined to include letterspacing. The case of the \doccmd{textsc} argument is left as is, however. This allows one to use both uppercase and lowercase letters: \textsc{The Initial Letters Of The Words In This Sentence Are Capitalized.} @@ -671,60 +671,60 @@ document class. Therefore, you can pass any of the typical book options. There are a few options that are specific to the \doccls{tufte-book} document class, however. -The \hl{\docclsopt{a4paper}} option will set the paper size to \smallcaps{A4} instead of +The \hlred{\docclsopt{a4paper}} option will set the paper size to \smallcaps{A4} instead of the default \smallcaps{US} letter size. -The \hl{\docclsopt{sfsidenotes}} option will set the sidenotes and title block in a +The \hlred{\docclsopt{sfsidenotes}} option will set the sidenotes and title block in a \textsf{sans serif} typeface instead of the default roman. -The \hl{\docclsopt{twoside}} option will modify the running heads so that the page +The \hlred{\docclsopt{twoside}} option will modify the running heads so that the page number is printed on the outside edge (as opposed to always printing the page -number on the right-side edge in \hl{\docclsopt{oneside}} mode). +number on the right-side edge in \hlred{\docclsopt{oneside}} mode). -The \hl{\docclsopt{symmetric}} option typesets the sidenotes on the outside edge of +The \hlred{\docclsopt{symmetric}} option typesets the sidenotes on the outside edge of the page. This is how books are traditionally printed, but is contrary to Tufte's book design which sets the sidenotes on the right side of the page. This option implicitly sets the \docclsopt{twoside} option. -The \hl{\docclsopt{justified}} option sets all the text fully justified (flush left +The \hlred{\docclsopt{justified}} option sets all the text fully justified (flush left and right). The default is to set the text ragged right. The body text of Tufte's books are set ragged right. This prevents needless hyphenation and makes it easier to read the text in the slightly narrower column. -The \hl{\docclsopt{bidi}} option loads the \docpkg{bidi} package which is used with +The \hlred{\docclsopt{bidi}} option loads the \docpkg{bidi} package which is used with \tXeLaTeX\ to typeset bi-directional text. Since the \docpkg{bidi} package needs to be loaded before the sidenotes and cite commands are defined, it can't be loaded in the document preamble. -The \hl{\docclsopt{debug}} option causes the Tufte-\LaTeX\ classes to output debug +The \hlred{\docclsopt{debug}} option causes the Tufte-\LaTeX\ classes to output debug information to the log file which is useful in troubleshooting bugs. It will also cause the graphics to be replaced by outlines. -The \hl{\docclsopt{nofonts}} option prevents the Tufte-\LaTeX\ classes from +The \hlred{\docclsopt{nofonts}} option prevents the Tufte-\LaTeX\ classes from automatically loading the Palatino and Helvetica typefaces. You should use this option if you wish to load your own fonts. If you're using \tXeLaTeX, this option is implied (\ie, the Palatino and Helvetica fonts aren't loaded if you use \tXeLaTeX). -The \hl{\docclsopt{nols}} option inhibits the letterspacing code. The Tufte-\LaTeX\ +The \hlred{\docclsopt{nols}} option inhibits the letterspacing code. The Tufte-\LaTeX\ classes try to load the appropriate letterspacing package (either pdf\TeX's \docpkg{letterspace} package or the \docpkg{soul} package). If you're using \tXeLaTeX\ with \docpkg{fontenc}, however, you should configure your own letterspacing. -The \hl{\docclsopt{notitlepage}} option causes \verb|\maketitle| to generate a title +The \hlred{\docclsopt{notitlepage}} option causes \verb|\maketitle| to generate a title block instead of a title page. The \doccls{book} class defaults to a title page and the \doccls{handout} class defaults to the title block. There is an -analogous \hl{\docclsopt{titlepage}} option that forces \verb|\maketitle| to +analogous \hlred{\docclsopt{titlepage}} option that forces \verb|\maketitle| to generate a full title page instead of the title block. -The \hl{\docclsopt{notoc}} option suppresses Tufte-\LaTeX's custom table of contents +The \hlred{\docclsopt{notoc}} option suppresses Tufte-\LaTeX's custom table of contents (\textsc{toc}) design. The current \textsc{toc} design only shows unnumbered chapter titles; it doesn't show sections or subsections. The \docclsopt{notoc} option will revert to \LaTeX's \textsc{toc} design. -The \hl{\docclsopt{nohyper}} option prevents the \docpkg{hyperref} package from +The \hlred{\docclsopt{nohyper}} option prevents the \docpkg{hyperref} package from being loaded. The default is to load the \docpkg{hyperref} package and use the \doccmd{title} and \doccmd{author} contents as metadata for the generated \textsc{pdf}. diff --git a/sample-handout.pdf b/sample-handout.pdf index b2ead99..48e729f 100644 Binary files a/sample-handout.pdf and b/sample-handout.pdf differ diff --git a/tufte-common.sty b/tufte-common.sty index 6bcc0c3..61848c2 100644 --- a/tufte-common.sty +++ b/tufte-common.sty @@ -320,7 +320,7 @@ \setboolean{@tufte@odd@page}{true}% \else% \setboolean{@tufte@odd@page}{false}% - \fi + \fi% }% } @@ -831,10 +831,16 @@ %% -% A collection of macros to be used with the new Tufte-style float environments +% A collection of macros to be used with the new Tufte-style float environments. +% \setfloatalignment forces the caption placement to be treated as top, bottom, etc. +% \forcerectofloat forces the float to be treated as if it were appearing on a recto page. +% \forceversofloat does the same, but for verso pages. \newcommand{\floatalignment}{x}% holds the current float alignment (t, b, h, p) -\newcommand{\setfloatalignment}[1]{\renewcommand{\floatalignment}{#1}}% manually sets the float alignment +\newcommand{\setfloatalignment}[1]{\global\def\floatalignment{#1}}% manually sets the float alignment +\newboolean{@tufte@float@recto} +\newcommand{\forcerectofloat}{\global\@tufte@float@rectotrue} +\newcommand{\forceversofloat}{\global\@tufte@float@rectofalse} % Boxes to temporarily store our float and caption \newsavebox{\@tufte@figure@box} @@ -856,7 +862,7 @@ \newcommand{\@tufte@stored@label}{} \newcommand{\@tufte@caption}[2][]{% - \ifthenelse{\isempty{#1}} + \ifthenelse{\isempty{#1}}% {\gdef\@tufte@stored@shortcaption{#2}}% {\gdef\@tufte@stored@shortcaption{#1}}% \gdef\@tufte@stored@caption{#2}% @@ -868,26 +874,40 @@ \newcommand{\@tufte@fps}{} -% TODO make sure new caption and figure code can handle [p] and [h] placements well -% TODO handle the symmetric class option (move caption to other side of verso pages) +\newboolean{@tufte@float@star} +\newlength{\@tufte@float@contents@width} %% % Define a float environment to place the captions in the margin space -\newenvironment{@tufte@float}[2][htbp] - {% If the float placement specifier is 'b' and only 'b', then bottom-align the mini-pages, otherwise top-align them. +\newenvironment{@tufte@float}[3][htbp]% + {% begin @tufte@float + % Should this float be full-width or just text-width? + \ifthenelse{\equal{#3}{star}}% + {\setboolean{@tufte@float@star}{true}}% + {\setboolean{@tufte@float@star}{false}}% + % Check page side (recto/verso) and store detected value -- can be overriden in environment contents + \@tufte@checkoddpage% + \ifthenelse{\boolean{@tufte@odd@page}}% + {\global\@tufte@float@rectotrue}% + {\global\@tufte@float@rectofalse}% + + % If the float placement specifier is 'b' and only 'b', then bottom-align the mini-pages, otherwise top-align them. \renewcommand{\@tufte@fps}{#1}% \ifthenelse{\equal{#1}{b}\OR\equal{#1}{B}}% {\renewcommand{\floatalignment}{b}}% {\renewcommand{\floatalignment}{t}}% + % Caption the contents of the \caption and \label commands to use later \renewcommand{\caption}[2][]{\@tufte@caption[##1]{##2}}% \renewcommand{\label}[1]{\@tufte@label{##1}}% \@tufte@orig@float{#2}[#1]% + \ifthenelse{\boolean{@tufte@float@star}}% + {\setlength{\@tufte@float@contents@width}{\@tufte@fullwidth}}% + {\setlength{\@tufte@float@contents@width}{\textwidth}}% \begin{lrbox}{\@tufte@figure@box}% - \begin{minipage}[\floatalignment]{\textwidth}\hbox{}% - } - {% end @tufte@float - \par\hbox{}\vspace{-\baselineskip}\ifthenelse{\prevdepth>0}{\vspace{-\prevdepth}}{}% align baselines of boxes + \begin{minipage}[\floatalignment]{\@tufte@float@contents@width}\hbox{}% + }{% end @tufte@float + \par\hbox{}\vspace{-\baselineskip}\ifthenelse{\prevdepth>0}{\vspace{-\prevdepth}}{}% align baselines of boxes \end{minipage}% \end{lrbox}% % build the caption box @@ -901,18 +921,9 @@ % now typeset the stored boxes \begin{fullwidth}% \begin{minipage}[\floatalignment]{\linewidth}% - \@tufte@checkoddpage% - \ifthenelse{\NOT\boolean{@tufte@symmetric}\OR\boolean{@tufte@odd@page}}{% - % asymmetric or page is odd, so caption is on the right - \usebox{\@tufte@figure@box}% - \hspace{\marginparsep}% - \smash{\usebox{\@tufte@caption@box}}% - }{% - % symmetric pages and page is even, so caption is on the left - \strut\smash{\usebox{\@tufte@caption@box}}% - \hspace{\marginparsep}% - \usebox{\@tufte@figure@box}% - }% + \ifthenelse{\boolean{@tufte@float@star}}% + {\@tufte@float@fullwidth{\@tufte@figure@box}{\@tufte@caption@box}}% + {\@tufte@float@textwidth{\@tufte@figure@box}{\@tufte@caption@box}}% \end{minipage}% \end{fullwidth}% \@tufte@orig@endfloat% @@ -925,11 +936,40 @@ \gdef\@tufte@stored@caption{}% } +\newcommand{\@tufte@float@textwidth}[2]{% + \ifthenelse{\NOT\boolean{@tufte@symmetric}\OR\boolean{@tufte@float@recto}}{% + % asymmetric or page is odd, so caption is on the right + \usebox{#1}% + \hspace{\marginparsep}% + \smash{\usebox{#2}}% + }{% + % symmetric pages and page is even, so caption is on the left + \strut\smash{\usebox{#2}}% + \hspace{\marginparsep}% + \usebox{#1}% + }% +} + +\newcommand{\@tufte@float@fullwidth}[2]{% + \ifthenelse{\equal{\floatalignment}{b}}% + {% place caption above figure + \ifthenelse{\NOT\boolean{@tufte@symmetric}\OR\boolean{@tufte@float@recto}}% + {\hfill\smash{\usebox{#2}}\par\usebox{#1}}% caption on the right + {\smash{\usebox{#2}\hfill}\par\usebox{#1}}% caption on the left + }% + {% place caption below figure + \ifthenelse{\NOT\boolean{@tufte@symmetric}\OR\boolean{@tufte@float@recto}}% + {\usebox{#1}\par\hfill\smash{\usebox{#2}}}% caption on the right + {\usebox{#1}\par\smash{\usebox{#2}\hfill}}% caption on the left + }% +} + + %% % Redefine the figure environment to place the captions in the margin space \renewenvironment{figure}[1][htbp] - {\begin{@tufte@float}[#1]{figure}} + {\begin{@tufte@float}[#1]{figure}{}} {\end{@tufte@float}} @@ -937,106 +977,37 @@ % Redefine the table environment to place the captions in the margin space \renewenvironment{table}[1][htbp] - {\begin{@tufte@float}[#1]{table}} + {\begin{@tufte@float}[#1]{table}{}} {\end{@tufte@float}} -%% -% Full-width figures and tables - -\newenvironment{@tufte@float@star}[2][htbp]% - {% begin - % If the float placement specifier is 'b' and only 'b', then place the caption above the figure, else place the caption below the figure. - \renewcommand{\@tufte@fps}{#1}% - \ifthenelse{\equal{#1}{b}\OR\equal{#1}{B}}% - {\renewcommand{\floatalignment}{b}}% - {\renewcommand{\floatalignment}{t}}% - \renewcommand{\caption}[2][]{\@tufte@caption[##1]{##2}}% - \renewcommand{\label}[1]{\@tufte@label{##1}}% - \@tufte@orig@float{#2}[#1]% - \begin{lrbox}{\@tufte@figure@box}% - \begin{minipage}[\floatalignment]{\textwidth}\hbox{}% - \begin{fullwidth} - }% - {% end figure* - \par\hbox{}\vspace{-\baselineskip}\ifthenelse{\prevdepth>0}{\vspace{-\prevdepth}}{}% align baselines of boxes - \end{fullwidth}% - \end{minipage}% - \end{lrbox}% - % build the caption box - % TODO use \captionaboveskip and \captionbelowskip for spacing between caption and figure boxes - \begin{lrbox}{\@tufte@caption@box}% - \begin{minipage}[\floatalignment]{\marginparwidth}\hbox{}% - \ifthenelse{\NOT\equal{\@tufte@stored@caption}{}}{\@tufte@orig@caption[\@tufte@stored@shortcaption]{\@tufte@stored@caption}}{}% - \ifthenelse{\NOT\equal{\@tufte@stored@label}{}}{\@tufte@orig@label{\@tufte@stored@label}}{}% - \par\vspace{-\prevdepth}%% TODO: DOUBLE-CHECK FOR SAFETY - \end{minipage}% - \end{lrbox}% - % now typeset the stored boxes - \@tufte@checkoddpage% - \begin{fullwidth}% - \begin{minipage}[\floatalignment]{\linewidth}% - \ifthenelse{\equal{\floatalignment}{b}} - {% place caption above figure - \ifthenelse{\NOT\boolean{@tufte@symmetric}\OR\boolean{@tufte@odd@page}} - {% caption on the right - \hfill\smash{\usebox{\@tufte@caption@box}}% - \par\usebox{\@tufte@figure@box}% - }{% caption on the left - \smash{\usebox{\@tufte@caption@box}}\hfill\null% - \par\hspace{\@tufte@overhang}\usebox{\@tufte@figure@box}% - }% - } - {% place caption below figure - \ifthenelse{\NOT\boolean{@tufte@symmetric}\OR\boolean{@tufte@odd@page}} - {% caption on the right - \usebox{\@tufte@figure@box}\par% - \hspace{\@tufte@caption@fill}\smash{\usebox{\@tufte@caption@box}}% - }{% caption on the left - \null\hspace{\@tufte@overhang}\usebox{\@tufte@figure@box}\par% - \smash{\usebox{\@tufte@caption@box}}\hfill% - }% - } - \end{minipage}% - \end{fullwidth}% - \@tufte@orig@endfloat% - % reset commands and temp boxes and captions - \let\caption\@tufte@orig@caption% - \let\label\@tufte@orig@label% - \begin{lrbox}{\@tufte@figure@box}\hbox{}\end{lrbox} - \begin{lrbox}{\@tufte@caption@box}\hbox{}\end{lrbox} - \gdef\@tufte@stored@shortcaption{} - \gdef\@tufte@stored@caption{} - } - - %% % Full-width figure \renewenvironment{figure*}[1][htbp]% - {\begin{@tufte@float@star}[#1]{figure}} - {\end{@tufte@float@star}} + {\begin{@tufte@float}[#1]{figure}{star}} + {\end{@tufte@float}} %% % Full-width table \renewenvironment{table*}[1][htbp]% - {\begin{@tufte@float@star}[#1]{table}} - {\end{@tufte@float@star}} + {\begin{@tufte@float}[#1]{table}{star}} + {\end{@tufte@float}} %% % Full-page-width area \newenvironment{fullwidth} - {\ifthenelse{\boolean{@tufte@symmetric}} - {\ifthenelse{\boolean{@tufte@changepage}}{\begin{adjustwidth*}{}{-\@tufte@overhang}}{\begin{adjustwidth}[]{}{-\@tufte@overhang}}} + {\ifthenelse{\boolean{@tufte@symmetric}}% + {\ifthenelse{\boolean{@tufte@changepage}}{\begin{adjustwidth*}{}{-\@tufte@overhang}}{\begin{adjustwidth}[]{}{-\@tufte@overhang}}}% {\begin{adjustwidth}{}{-\@tufte@overhang}}% - } - {\ifthenelse{\boolean{@tufte@symmetric}} - {\ifthenelse{\boolean{@tufte@changepage}}{\end{adjustwidth*}}{\end{adjustwidth}}} - {\end{adjustwidth}} + }% + {\ifthenelse{\boolean{@tufte@symmetric}}% + {\ifthenelse{\boolean{@tufte@changepage}}{\end{adjustwidth*}}{\end{adjustwidth}}}% + {\end{adjustwidth}}% } %% @@ -1046,13 +1017,13 @@ \par% \addcontentsline{\csname ext@#1\endcsname}{#1}% {\protect\numberline{\csname the#1\endcsname}{\ignorespaces #2}}% - \begingroup - \@parboxrestore - \if@minipage - \@setminipage - \fi + \begingroup% + \@parboxrestore% + \if@minipage% + \@setminipage% + \fi% \@tufte@marginfont\@tufte@justification% - \noindent\csname fnum@#1\endcsname: \ignorespaces#3\par + \noindent\csname fnum@#1\endcsname: \ignorespaces#3\par% %\@makecaption{\csname fnum@#1\endcsname}{\ignorespaces #3}\par \endgroup} @@ -1262,7 +1233,7 @@ {\relax\ifthenelse{\NOT\boolean{@tufte@symmetric}}{\begin{fullwidth}}{}}% format applied to label+text {\itshape\huge\thechapter}% label {0pt}% horizontal separation between label and title body - {\huge\rm\itshape}% before the title body + {\huge\rmfamily\itshape}% before the title body [\ifthenelse{\NOT\boolean{@tufte@symmetric}}{\end{fullwidth}}{}]% after the title body \titleformat{\section}% @@ -1333,9 +1304,9 @@ {\titlecontents{chapter}% [0em] % distance from left margin {\begin{fullwidth}\fontsize{13pt}{18pt}\selectfont} % above (global formatting of entry) - {\contentslabel{2em}\rm\itshape} % before w/label (label = ``Chapter 1'') - {\rm\itshape} % before w/o label - {\rm\qquad\thecontentspage} % filler + page (leaders and page num) + {\contentslabel{2em}\rmfamily\itshape} % before w/label (label = ``Chapter 1'') + {\rmfamily\itshape} % before w/o label + {\rmfamily\qquad\thecontentspage} % filler + page (leaders and page num) [\vspace{1.5\baselineskip}\end{fullwidth}] % after } {}