Browse Source

* Renamed tufte-common.sty to tufte-common.tex and restructured it so it can be

inputted into the .cls files directly.  This saves us from duplicating some
  code.



git-svn-id: https://tufte-latex.googlecode.com/svn/trunk@109 516e2f36-ce3a-0410-bea4-1d4a03f5df72
master
Kevin M. Godby 16 years ago
parent
commit
2ea2296a86
5 changed files with 70 additions and 156 deletions
  1. BIN
      sample-book.pdf
  2. BIN
      sample-handout.pdf
  3. +7
    -11
      tufte-book.cls
  4. +56
    -126
      tufte-common.tex
  5. +7
    -19
      tufte-handout.cls

BIN
sample-book.pdf View File


BIN
sample-handout.pdf View File


+ 7
- 11
tufte-book.cls View File

@@ -2,18 +2,14 @@

\ProvidesClass{tufte-book}[2009/05/17 v3.0.0 Tufte-book class]

%%
% Declare we're tufte-book
\newcommand{\@tufte@class}{book}% the base LaTeX class (defaults to the article/handout style)
\newcommand{\@tufte@pkgname}{tufte-book}% the name of the package (defaults to tufte-handout)

\PassOptionsToPackage{book}{tufte-common}
\DeclareOption*{% pass options to tufte-common package and the article class
\PassOptionsToPackage{\CurrentOption}{tufte-common}
\PassOptionsToClass{\CurrentOption}{book}
\PackageInfo{tufte-book}{Passing \CurrentOption\space to `book' class}
}
\ProcessOptions

\LoadClass{book}

\RequirePackage{tufte-common}
%%
% Load the common style elements
\input{tufte-common.tex}


%%


tufte-common.sty → tufte-common.tex View File

@@ -1,6 +1,6 @@
\NeedsTeXFormat{LaTeX2e}[1994/06/01]
%\NeedsTeXFormat{LaTeX2e}[1994/06/01]

\ProvidesPackage{tufte-common}[2009/05/17 v3.0.0 Common code for the Tufte-LaTeX styles]
%\ProvidesPackage{tufte-common}[2009/05/17 v3.0.0 Common code for the Tufte-LaTeX styles]

%%
% We use the `xifthen' package to handle our package option switches
@@ -27,26 +27,6 @@
\DeclareOption{ls}{\setboolean{@tufte@letterspace}{true}}
\DeclareOption{nols}{\setboolean{@tufte@letterspace}{false}}

%%
% `book' and `handout' options
\newcommand{\@tufte@class}{article}% the base LaTeX class (defaults to the article/handout style)
\newcommand{\@tufte@pkgname}{tufte-handout}% the name of the package (defaults to tufte-handout)
\DeclareOption{book}{%
\renewcommand{\@tufte@class}{book}
\renewcommand{\@tufte@pkgname}{tufte-book}
\setboolean{@tufte@titlepage}{true}
}
\DeclareOption{handout}{%
\renewcommand{\@tufte@class}{article}
\renewcommand{\@tufte@pkgname}{tufte-handout}
\setboolean{@tufte@titlepage}{false}
}
\DeclareOption{article}{% `article' is just an alias for `handout'
\renewcommand{\@tufte@class}{article}
\renewcommand{\@tufte@pkgname}{tufte-handout}
\setboolean{@tufte@titlepage}{false}
}

%%
% `titlepage' option -- creates a full title page with \maketitle

@@ -73,15 +53,19 @@
\newboolean{@tufte@symmetric}
\DeclareOption{symmetric}{
\setboolean{@tufte@symmetric}{true}
\PackageInfo{\@tufte@pkgname}{The `symmetric' option implies `twoside'}
%\ExecuteOptions{twoside}
\ClassInfo{\@tufte@pkgname}{The `symmetric' option implies `twoside'}
\ExecuteOptions{twoside}
}

%%
% `twoside' option -- alternates running heads

\newboolean{@tufte@twoside}
\DeclareOption{twoside}{\setboolean{@tufte@twoside}{true}}
\DeclareOption{twoside}{%
\setboolean{@tufte@twoside}{true}
\ClassInfo{\@tufte@pkgname}{Passing the `\CurrentOption' option to the `\@tufte@class' class}
\PassOptionsToClass{\CurrentOption}{\@tufte@class}
}

%%
% `notoc' option -- suppresses the Tufte-style table of contents
@@ -116,7 +100,7 @@
%%
% Unsupported options

\newcommand{\@tufte@unsupported@option}[1]{\PackageWarningNoLine{\@tufte@pkgname}{Option `#1' is not supported -- \MessageBreak ignoring option}}
\newcommand{\@tufte@unsupported@option}[1]{\ClassWarningNoLine{\@tufte@pkgname}{Option `#1' is not supported -- \MessageBreak ignoring option}\OptionNotUsed}

\DeclareOption{10pt}{\@tufte@unsupported@option{\CurrentOption}}
\DeclareOption{11pt}{\@tufte@unsupported@option{\CurrentOption}}
@@ -129,9 +113,24 @@
\DeclareOption{onecolumn}{\@tufte@unsupported@option{\CurrentOption}}
\DeclareOption{twocolumn}{\@tufte@unsupported@option{\CurrentOption}}

%%
% Default `book' and `handout' options

\ifthenelse{\equal{\@tufte@pkgname}{tufte-book}}
{\ExecuteOptions{titlepage}}
{\ExecuteOptions{notitlepage}}


\DeclareOption*{\PassOptionsToClass{\CurrentOption}{\@tufte@class}}
\ProcessOptions
\DeclareOption*{%
\ClassInfo{\@tufte@pkgname}{Passing \CurrentOption\space to the `\@tufte@class' class}%
\PassOptionsToClass{\CurrentOption}{\@tufte@class}%
}
\ProcessOptions\relax

%%
% Load the appropriate base class
\ClassInfo{\@tufte@pkgname}{Loading the base class `\@tufte@class'}
\LoadClass{\@tufte@class}

%%
% Detect whether we're in two-side mode or not. (Used to set up running
@@ -314,11 +313,11 @@

\newboolean{@tufte@changepage}
\IfFileExists{changepage.sty}{%
\PackageInfo{\@tufte@pkgname}{Found changepage.sty}
\ClassInfo{\@tufte@pkgname}{Found changepage.sty}
\RequirePackage[strict]{changepage}
\setboolean{@tufte@changepage}{true}
}{%
\PackageInfo{\@tufte@pkgname}{Found chngpage.sty}
\ClassInfo{\@tufte@pkgname}{Found chngpage.sty}
\RequirePackage[strict]{chngpage}
\setboolean{@tufte@changepage}{false}
}
@@ -471,7 +470,7 @@
\sodef\allcapsspacing{\upshape}{0.15em}{0.65em}{0.6em}
\sodef\smallcapsspacing{\scshape}{0.075em}{0.5em}{0.6em}
}{
\PackageWarningNoLine{\@tufte@pkgname}{Couldn't locate `soul' package.}
\ClassWarningNoLine{\@tufte@pkgname}{Couldn't locate `soul' package.}
}% soul not installed... giving up.
}

@@ -481,12 +480,12 @@
% Otherwise fall back on the soul package.

\ifthenelse{\boolean{@tufte@pdf}}
{\PackageInfo{\@tufte@pkgname}{ifpdf = true}}
{\PackageInfo{\@tufte@pkgname}{ifpdf = false}}
{\ClassInfo{\@tufte@pkgname}{ifpdf = true}}
{\ClassInfo{\@tufte@pkgname}{ifpdf = false}}

\ifthenelse{\boolean{@tufte@xetex}}
{\PackageInfo{\@tufte@pkgname}{ifxetex = true}}
{\PackageInfo{\@tufte@pkgname}{ifxetex = false}}
{\ClassInfo{\@tufte@pkgname}{ifxetex = true}}
{\ClassInfo{\@tufte@pkgname}{ifxetex = false}}

% Check pdfLaTeX version
\def\@tufte@pdftexversion{0}
@@ -510,14 +509,14 @@
% pdfLaTeX version is too old or not using pdfLaTeX
\ifthenelse{\boolean{@tufte@xetex}}
{% TODO use xetex letterspacing
\PackageInfo{\@tufte@pkgname}{XeTeX detected. Reverting to `soul' package for letterspacing.}
\ClassInfo{\@tufte@pkgname}{XeTeX detected. Reverting to `soul' package for letterspacing.}
\@tufte@loadsoul}
{% use `soul' package for letterspacing
\PackageInfo{\@tufte@pkgname}{Old version of pdfTeX detected. Reverting to `soul' package for letterspacing.}
\ClassInfo{\@tufte@pkgname}{Old version of pdfTeX detected. Reverting to `soul' package for letterspacing.}
\@tufte@loadsoul}
\else
\IfFileExists{letterspace.sty}{%
\PackageInfo{\@tufte@pkgname}{Modern version of pdfTeX detected. Using `letterspace' package.}
\ClassInfo{\@tufte@pkgname}{Modern version of pdfTeX detected. Using `letterspace' package.}
\RequirePackage{letterspace}
% Set up letterspacing (using microtype package) -- requires pdfTeX v1.40+
\renewcommand{\allcapsspacing}[1]{\textls[200]{##1}}
@@ -525,7 +524,7 @@
\renewcommand{\allcaps}[1]{\textls[200]{\MakeTextUppercase{##1}}}
\renewcommand{\smallcaps}[1]{\textsc{\MakeTextLowercase{##1}}}
}{% microtype failed, check for soul
\PackageInfo{\@tufte@pkgname}{Modern version of pdfTeX detected, but `letterspace' package not installed. Reverting to `soul' package for letterspacing.}
\ClassInfo{\@tufte@pkgname}{Modern version of pdfTeX detected, but `letterspace' package not installed. Reverting to `soul' package for letterspacing.}
\@tufte@loadsoul
}
\fi}
@@ -1298,7 +1297,7 @@
% Subsubsection and following section headings shouldn't be used.
% See Bringhurst's _The Elements of Typography_, section 4.2.2.
\renewcommand\subsubsection{%
\PackageError{\@tufte@pkgname}{\noexpand\subsubsection is undefined by this class.%
\ClassError{\@tufte@pkgname}{\noexpand\subsubsection is undefined by this class.%
\MessageBreak See Robert Bringhurst's _The Elements of
\MessageBreak Typographic Style_, section 4.2.2.
\MessageBreak \noexpand\subsubsection was used}
@@ -1307,18 +1306,8 @@
\MessageBreak related threads on Ask E.T. at http://www.edwardtufte.com/.}
}

%\renewcommand\paragraph{%
% \PackageError{\@tufte@pkgname}{\noexpand\paragraph is undefined by this class.%
% \MessageBreak See Robert Bringhurst's _The Elements of
% \MessageBreak Typographic Style_, section 4.2.2.
% \MessageBreak \noexpand\paragraph was used}
% {From Bringhurst's _The Elements of Typographic Style_, section 4.2.2: Use as
% \MessageBreak many levels of headings as you need, no more and no fewer. Also see the many
% \MessageBreak related threads on Ask E.T. at http://www.edwardtufte.com/.}
%}

\renewcommand\subparagraph{%
\PackageError{\@tufte@pkgname}{\noexpand\subparagraph is undefined by this class.%
\ClassError{\@tufte@pkgname}{\noexpand\subparagraph is undefined by this class.%
\MessageBreak See Robert Bringhurst's _The Elements of
\MessageBreak Typographic Style_, section 4.2.2.
\MessageBreak \noexpand\subparagraph was used}
@@ -1330,84 +1319,25 @@

% Formatting for main TOC (printed in front matter)
% {section} [left] {above} {before w/label} {before w/o label} {filler + page} [after]
\ifthenelse{\boolean{@tufte@toc}}{%
\titlecontents{part}% FIXME
[0em] % distance from left margin
{\vspace{1.5\baselineskip}\begin{fullwidth}\LARGE\rmfamily\itshape} % above (global formatting of entry)
{\contentslabel{2em}} % before w/label (label = ``II'')
{} % before w/o label
{\rmfamily\upshape\qquad\thecontentspage} % filler + page (leaders and page num)
[\end{fullwidth}] % after
\titlecontents{chapter}%
\ifthenelse{\boolean{@tufte@toc}}
{\titlecontents{chapter}%
[0em] % distance from left margin
{\vspace{1.5\baselineskip}\begin{fullwidth}\LARGE\rmfamily\itshape} % above (global formatting of entry)
{\hspace*{0em}\contentslabel{2em}} % before w/label (label = ``2'')
{\hspace*{0em}} % before w/o label
{\rmfamily\upshape\qquad\thecontentspage} % filler + page (leaders and page num)
[\end{fullwidth}] % after
\titlecontents{section}% FIXME
[0em] % distance from left margin
{\vspace{0\baselineskip}\begin{fullwidth}\Large\rmfamily\itshape} % above (global formatting of entry)
{\hspace*{2em}\contentslabel{2em}} % before w/label (label = ``2.6'')
{\hspace*{2em}} % before w/o label
{\rmfamily\upshape\qquad\thecontentspage} % filler + page (leaders and page num)
[\end{fullwidth}] % after
\titlecontents{subsection}% FIXME
[0em] % distance from left margin
{\vspace{0\baselineskip}\begin{fullwidth}\large\rmfamily\itshape} % above (global formatting of entry)
{\hspace*{4em}\contentslabel{4em}} % before w/label (label = ``2.6.1'')
{\hspace*{4em}} % before w/o label
{\rmfamily\upshape\qquad\thecontentspage} % filler + page (leaders and page num)
[\end{fullwidth}] % after
\titlecontents{paragraph}% FIXME
[0em] % distance from left margin
{\vspace{0\baselineskip}\begin{fullwidth}\normalsize\rmfamily\itshape} % above (global formatting of entry)
{\hspace*{6em}\contentslabel{2em}} % before w/label (label = ``2.6.0.0.1'')
{\hspace*{6em}} % before w/o label
{\rmfamily\upshape\qquad\thecontentspage} % filler + page (leaders and page num)
[\end{fullwidth}] % after
}{}

%%
% Format lists of figures/tables

\renewcommand\listoffigures{%
\ifthenelse{\equal{\@tufte@class}{book}}%
{\chapter*{\listfigurename}}%
{\section*{\listfigurename}}%
% \begin{fullwidth}%
\@starttoc{lof}%
% \end{fullwidth}%
}

\renewcommand\listoftables{%
\ifthenelse{\equal{\@tufte@class}{book}}%
{\chapter*{\listtablename}}%
{\section*{\listtablename}}%
% \begin{fullwidth}%
\@starttoc{lot}%
% \end{fullwidth}%
}
{\begin{fullwidth}\fontsize{13pt}{18pt}\selectfont} % above (global formatting of entry)
{\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
}
{}

\newcommand{\@tufte@lof@line}[2]{%
% #1 is the figure/table number and its caption text
% #2 is the page number on which the figure/table appears
\leftskip 0.0em
\rightskip 0em
\parfillskip 0em
\parindent 0.0em
\@afterindenttrue
\interlinepenalty\@M
\leavevmode
\@tempdima 2.0em
\advance\leftskip\@tempdima
\null\nobreak\hskip -\leftskip
{#1}\nobreak\qquad\nobreak#2%
\par%
}
%\titlecontents{chapter}%
% [0em]% distance from left margin
% {\fontsize{12pt}{18pt}\selectfont}% above (global formatting of entry)
% {\textit}% before w/ label (label = ``Chapter 1'')
% {\textit}% before w/o label
% {\qquad\thecontentspage}% filler and page (leaders and page num)
% [\vspace{1.5\baselineskip}]% after

\renewcommand*\l@figure{\@tufte@lof@line}
\let\l@table\l@figure


%%

+ 7
- 19
tufte-handout.cls View File

@@ -3,25 +3,13 @@
\ProvidesClass{tufte-handout}[2009/05/17 v3.0.0 Tufte-handout class]

%%
% The symmetric option forces twoside.
\DeclareOption{symmetric}{%
\ExecuteOptions{twoside}
\PassOptionsToPackage{twoside}{tufte-common}
\PassOptionsToClass{twoside}{article}
\PackageInfo{tufte-handout}{Passing twoside to `article' class}
}

\PassOptionsToPackage{handout}{tufte-common}
\DeclareOption*{% pass options to tufte-common package and the article class
\PassOptionsToPackage{\CurrentOption}{tufte-common}
\PassOptionsToClass{\CurrentOption}{article}
\PackageInfo{tufte-handout}{Passing \CurrentOption\space to `article' class}
}
\ProcessOptions

\LoadClass{article}

\RequirePackage{tufte-common}
% Declare we're tufte-handout
\newcommand{\@tufte@class}{article}% the base LaTeX class (defaults to the article/handout style)
\newcommand{\@tufte@pkgname}{tufte-handout}% the name of the package (defaults to tufte-handout)

%%
% Load the common style elements
\input{tufte-common.tex}


%%


Loading…
Cancel
Save