diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/tufte-latex')
-rw-r--r-- | Master/texmf-dist/tex/latex/tufte-latex/tufte-book.cls | 29 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/tufte-latex/tufte-common.def (renamed from Master/texmf-dist/tex/latex/tufte-latex/tufte-common.sty) | 1005 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/tufte-latex/tufte-handout.cls | 29 |
3 files changed, 747 insertions, 316 deletions
diff --git a/Master/texmf-dist/tex/latex/tufte-latex/tufte-book.cls b/Master/texmf-dist/tex/latex/tufte-latex/tufte-book.cls index 99ff6dfa219..11d50157b0b 100644 --- a/Master/texmf-dist/tex/latex/tufte-latex/tufte-book.cls +++ b/Master/texmf-dist/tex/latex/tufte-latex/tufte-book.cls @@ -1,19 +1,15 @@ \NeedsTeXFormat{LaTeX2e}[1994/06/01] -\ProvidesClass{tufte-book}[2009/05/17 v3.0.0 Tufte-book class] +\ProvidesClass{tufte-book}[2009/12/11 v3.5.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.def} %% @@ -46,11 +42,11 @@ \ifthenelse{\boolean{@tufte@twoside}}% {% two-side \renewcommand{\chaptermark}[1]{\markboth{##1}{}}% - \fancyhead[LE]{\thepage\quad\smallcaps{\plaintitle}}% book title - \fancyhead[RO]{\smallcaps{\leftmark}\quad\thepage}% chapter title + \fancyhead[LE]{\thepage\quad\smallcaps{\newlinetospace{\plaintitle}}}% book title + \fancyhead[RO]{\smallcaps{\newlinetospace{\leftmark}}\quad\thepage}% chapter title }% {% one-side - \fancyhead[RE,RO]{\smallcaps{\plaintitle}\quad\thepage}% book title + \fancyhead[RE,RO]{\smallcaps{\newlinetospace{\plaintitle}}\quad\thepage}% book title }% } @@ -75,7 +71,8 @@ % If there is a `tufte-book-local.sty' file, load it. \IfFileExists{tufte-book-local.tex} - {\input{tufte-book-local}} + {\input{tufte-book-local} + \TufteInfoNL{Loading tufte-book-local.tex}} {} %% diff --git a/Master/texmf-dist/tex/latex/tufte-latex/tufte-common.sty b/Master/texmf-dist/tex/latex/tufte-latex/tufte-common.def index 5fb331085f0..f71cc52b253 100644 --- a/Master/texmf-dist/tex/latex/tufte-latex/tufte-common.sty +++ b/Master/texmf-dist/tex/latex/tufte-latex/tufte-common.def @@ -1,114 +1,252 @@ -\NeedsTeXFormat{LaTeX2e}[1994/06/01] +%% +%% This file contains the code that's common to the Tufte-LaTeX document classes. +%% -\ProvidesPackage{tufte-common}[2009/05/17 v3.0.0 Common code for the Tufte-LaTeX styles] +\ProvidesFile{tufte-common.def}[2009/12/11 v3.5.0 Common code for the Tufte-LaTeX styles] + +%% +% The `xkeyval' package simplifies the user interface for the document class options +\RequirePackage{xkeyval} %% % We use the `xifthen' package to handle our package option switches \RequirePackage{xifthen} +%% +% Define some shortcut macros for error/warning/info logging. + +\newcommand{\TufteWarning}[1]{\ClassWarning{\@tufte@pkgname}{#1}} +\newcommand{\TufteWarningNL}[1]{\ClassWarningNoLine{\@tufte@pkgname}{#1}} +\newcommand{\TufteInfo}[1]{\ClassInfo{\@tufte@pkgname}{#1}} +\newcommand{\TufteInfoNL}[1]{\ClassInfo{\@tufte@pkgname}{#1\@gobble}} +\newcommand{\TufteDebugInfo}[1]{\ifthenelse{\boolean{@tufte@debug}}{\TufteInfo{#1}}{}} +\newcommand{\TufteDebugInfoNL}[1]{\ifthenelse{\boolean{@tufte@debug}}{\TufteInfoNL{#1}}{}} +\newcommand{\TufteError}[2]{\ClassError{\@tufte@pkgname}{#1}{#2}} %% % `debug' option -- provides more information in the .log file for use in % troubleshooting problems \newboolean{@tufte@debug} -\DeclareOption{debug}{\setboolean{@tufte@debug}{true}} +\DeclareOptionX[tufte]<common>{debug}{\setboolean{@tufte@debug}{true}} %% % `nofonts' option -- doesn't load any fonts % `fonts' option -- tries to load fonts \newboolean{@tufte@loadfonts}\setboolean{@tufte@loadfonts}{true} -\DeclareOption{fonts}{\setboolean{@tufte@loadfonts}{true}} -\DeclareOption{nofonts}{\setboolean{@tufte@loadfonts}{false}} +\DeclareOptionX[tufte]<common>{fonts}{\setboolean{@tufte@loadfonts}{true}} +\DeclareOptionX[tufte]<common>{nofonts}{\setboolean{@tufte@loadfonts}{false}} %% % `nols' option -- doesn't configure letterspacing % `ls' option -- configures letterspacing \newboolean{@tufte@letterspace}\setboolean{@tufte@letterspace}{true} -\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} -} +\DeclareOptionX[tufte]<common>{ls}{\setboolean{@tufte@letterspace}{true}} +\DeclareOptionX[tufte]<common>{nols}{\setboolean{@tufte@letterspace}{false}} %% % `titlepage' option -- creates a full title page with \maketitle \newboolean{@tufte@titlepage} -\DeclareOption{titlepage}{\setboolean{@tufte@titlepage}{true}} -\DeclareOption{notitlepage}{\setboolean{@tufte@titlepage}{false}} +\DeclareOptionX[tufte]<common>{titlepage}{\setboolean{@tufte@titlepage}{true}} +\DeclareOptionX[tufte]<common>{notitlepage}{\setboolean{@tufte@titlepage}{false}} %% % `a4paper' option \newboolean{@tufte@afourpaper} -\DeclareOption{a4paper}{\setboolean{@tufte@afourpaper}{true}} +\DeclareOptionX[tufte]<common>{a4paper}{\setboolean{@tufte@afourpaper}{true}} + +%% +% `b5paper' option + +\newboolean{@tufte@bfivepaper} +\DeclareOptionX[tufte]<common>{b5paper}{\setboolean{@tufte@bfivepaper}{true}} %% % `sfsidenotes' option -- typesets sidenotes in sans serif typeface \newboolean{@tufte@sfsidenotes} -\DeclareOption{sfsidenotes}{\setboolean{@tufte@sfsidenotes}{true}} +\DeclareOptionX[tufte]<common>{sfsidenotes}{\setboolean{@tufte@sfsidenotes}{true}} %% % `symmetric' option -- puts marginpar space to the outside edge of the page % Note: this option forces the twoside option (see the .cls files) \newboolean{@tufte@symmetric} -\DeclareOption{symmetric}{ +\DeclareOptionX[tufte]<common>{symmetric}{ \setboolean{@tufte@symmetric}{true} - \PackageInfo{\@tufte@pkgname}{The `symmetric' option implies `twoside'} - %\ExecuteOptions{twoside} + \TufteInfoNL{The `symmetric' option implies `twoside'} + \ExecuteOptionsX[tufte]<common>{twoside} } %% % `twoside' option -- alternates running heads \newboolean{@tufte@twoside} -\DeclareOption{twoside}{\setboolean{@tufte@twoside}{true}} +\DeclareOptionX[tufte]<common>{twoside}{% + \setboolean{@tufte@twoside}{true} + \TufteInfoNL{Passing the `twoside' option to the `\@tufte@class' class} + \PassOptionsToClass{twoside}{\@tufte@class} +} %% % `notoc' option -- suppresses the Tufte-style table of contents \newboolean{@tufte@toc} \setboolean{@tufte@toc}{true} -\DeclareOption{notoc}{\setboolean{@tufte@toc}{false}} -\DeclareOption{toc}{\setboolean{@tufte@toc}{true}} +\DeclareOptionX[tufte]<common>{notoc}{\setboolean{@tufte@toc}{false}} +\DeclareOptionX[tufte]<common>{toc}{\setboolean{@tufte@toc}{true}} %% % `justified' option -- uses fully justified text (flush left and flush % right) instead of ragged right. \newboolean{@tufte@justified} -\DeclareOption{justified}{\setboolean{@tufte@justified}{true}} +\DeclareOptionX[tufte]<common>{justified}{\setboolean{@tufte@justified}{true}} %% % `bidi' option -- loads the bidi package for bi-directional text \newboolean{@tufte@loadbidi} -\DeclareOption{bidi}{\setboolean{@tufte@loadbidi}{true}} -\DeclareOption{nobidi}{\setboolean{@tufte@loadbibi}{false}} +\DeclareOptionX[tufte]<common>{bidi}{\setboolean{@tufte@loadbidi}{true}} +\DeclareOptionX[tufte]<common>{nobidi}{\setboolean{@tufte@loadbidi}{false}} + +%% +% `nohyper' option -- suppresses loading of the hyperref package + +\newboolean{@tufte@loadhyper} +\setboolean{@tufte@loadhyper}{true} +\DeclareOptionX[tufte]<common>{hyper}{\setboolean{@tufte@loadhyper}{true}} +\DeclareOptionX[tufte]<common>{nohyper}{\setboolean{@tufte@loadhyper}{false}} + +%% +% `sidenote', `marginnote', `caption', `citation', `marginals' options +% Each allows one of {justified,raggedleft,raggedright,raggedouter,auto}. + +\newcommand*{\@tufte@sidenote@justification}{\@tufte@justification@autodetect} +\define@choicekey*+[tufte]{common}{sidenote}[\@tufte@kvtext\@tufte@kvnum]{justified,raggedleft,raggedright,raggedouter,auto}[auto]{% + \ifcase\@tufte@kvnum\relax + \renewcommand*{\@tufte@sidenote@justification}{\justifying}% justified + \or + \renewcommand*{\@tufte@sidenote@justification}{\RaggedLeft}% ragged left + \or + \renewcommand*{\@tufte@sidenote@justification}{\RaggedRight}% ragged right + \or + \renewcommand*{\@tufte@sidenote@justification}{\@tufte@justification@outer}% ragged outer (flush right on verso pages, flush left on recto pages) + \or + \renewcommand*{\@tufte@sidenote@justification}{\@tufte@justification@autodetect}% autodetects best justification mode based on all class options + \fi +}{% + \TufteWarningNL{Invalid option `#1' for sidenote key.\MessageBreak Must be one of: justified, raggedleft,\MessageBreak raggedright, raggedouter, auto} + \renewcommand*{\@tufte@sidenote@justification}{\@tufte@justification@autodetect}% autodetects best justification mode based on all class options +} + +\newcommand*{\@tufte@marginnote@justification}{\@tufte@justification@autodetect} +\define@choicekey*+[tufte]{common}{marginnote}[\@tufte@kvtext\@tufte@kvnum]{justified,raggedleft,raggedright,raggedouter,auto}[auto]{% + \ifcase\@tufte@kvnum\relax + \renewcommand*{\@tufte@marginnote@justification}{\justifying}% justified + \or + \renewcommand*{\@tufte@marginnote@justification}{\RaggedLeft}% ragged left + \or + \renewcommand*{\@tufte@marginnote@justification}{\RaggedRight}% ragged right + \or + \renewcommand*{\@tufte@marginnote@justification}{\@tufte@justification@outer}% ragged outer (flush right on verso pages, flush left on recto pages) + \or + \renewcommand*{\@tufte@marginnote@justification}{\@tufte@justification@autodetect}% autodetects best justification mode based on all class options + \fi +}{% + \TufteWarningNL{Invalid option `#1' for marginnote key.\MessageBreak Must be one of: justified, raggedleft,\MessageBreak raggedright, raggedouter, auto} + \renewcommand*{\@tufte@marginnote@justification}{\@tufte@justification@autodetect}% autodetects best justification mode based on all class options +} + +\newcommand*{\@tufte@caption@justification}{\@tufte@justification@autodetect} +\define@choicekey*+[tufte]{common}{caption}[\@tufte@kvtext\@tufte@kvnum]{justified,raggedleft,raggedright,raggedouter,auto}[auto]{% + \ifcase\@tufte@kvnum\relax + \renewcommand*{\@tufte@caption@justification}{\justifying}% justified + \or + \renewcommand*{\@tufte@caption@justification}{\RaggedLeft}% ragged left + \or + \renewcommand*{\@tufte@caption@justification}{\RaggedRight}% ragged right + \or + \renewcommand*{\@tufte@caption@justification}{\@tufte@justification@caption@outer}% ragged outer (flush right on verso pages, flush left on recto pages) + \or + \renewcommand*{\@tufte@caption@justification}{\@tufte@justification@autodetect}% autodetects best justification mode based on all class options + \fi +}{% + \TufteWarningNL{Invalid option `#1' for caption key.\MessageBreak Must be one of: justified, raggedleft,\MessageBreak raggedright, raggedouter, auto} + \renewcommand*{\@tufte@caption@justification}{\@tufte@justification@autodetect}% autodetects best justification mode based on all class options +} + +\newcommand*{\@tufte@citation@justification}{\@tufte@justification@autodetect} +\define@choicekey*+[tufte]{common}{citation}[\@tufte@kvtext\@tufte@kvnum]{justified,raggedleft,raggedright,raggedouter,auto}[auto]{% + \ifcase\@tufte@kvnum\relax + \renewcommand*{\@tufte@citation@justification}{\justifying}% justified + \or + \renewcommand*{\@tufte@citation@justification}{\RaggedLeft}% ragged left + \or + \renewcommand*{\@tufte@citation@justification}{\RaggedRight}% ragged right + \or + \renewcommand*{\@tufte@citation@justification}{\@tufte@justification@outer}% ragged outer (flush right on verso pages, flush left on recto pages) + \or + \renewcommand*{\@tufte@citation@justification}{\@tufte@justification@autodetect}% autodetects best justification mode based on all class options + \fi +}{% + \TufteWarningNL{Invalid option `#1' for citation key.\MessageBreak Must be one of: justified, raggedleft,\MessageBreak raggedright, raggedouter, auto} + \renewcommand*{\@tufte@citation@justification}{\@tufte@justification@autodetect}% autodetects best justification mode based on all class options +} + +% The ``marginals'' key simultaneously sets the same justification for all marginal material +\define@choicekey*+[tufte]{common}{marginals}[\@tufte@kvtext\@tufte@kvnum]{justified,raggedleft,raggedright,raggedouter,auto}[auto]{% + \ifcase\@tufte@kvnum\relax + \ExecuteOptionsX[tufte]<common>{citation=justified,sidenote=justified,caption=justified,marginnote=justified}% justified + \or + \ExecuteOptionsX[tufte]<common>{citation=raggedleft,sidenote=raggedleft,caption=raggedleft,marginnote=raggedleft}% ragged left + \or + \ExecuteOptionsX[tufte]<common>{citation=raggedright,sidenote=raggedright,caption=raggedright,marginnote=raggedright}% ragged right + \or + \ExecuteOptionsX[tufte]<common>{citation=raggedouter,sidenote=raggedouter,caption=raggedouter,marginnote=raggedouter}% ragged outer (flush right on verso pages, flush left on recto pages) + \or + \ExecuteOptionsX[tufte]<common>{citation=auto,sidenote=auto,caption=auto,marginnote=auto}% autodetects best justification mode based on all class options + \fi +}{% + \TufteWarningNL{Invalid option `#1' for marginals key.\MessageBreak Must be one of: justified, raggedleft,\MessageBreak raggedright, raggedouter, auto} + \ExecuteOptionsX[tufte]<common>{citation=auto,sidenote=auto,caption=auto,marginnote=auto}% autodetects best justification mode based on all class options +} + + +%% +% Unsupported options -% FIXME: should probably specify options not supported like Mittelbach's aipproc.cls +\newcommand{\@tufte@unsupported@option}[1]{\TufteWarningNL{Option `#1' is not supported -- \MessageBreak ignoring option}\OptionNotUsed} -\DeclareOption*{\PassOptionsToClass{\CurrentOption}{\@tufte@class}} -\ProcessOptions +\DeclareOptionX[tufte]<common>{10pt}{\@tufte@unsupported@option{\CurrentOption}} +\DeclareOptionX[tufte]<common>{11pt}{\@tufte@unsupported@option{\CurrentOption}} +\DeclareOptionX[tufte]<common>{12pt}{\@tufte@unsupported@option{\CurrentOption}} +\DeclareOptionX[tufte]<common>{a5paper}{\@tufte@unsupported@option{\CurrentOption}} +\DeclareOptionX[tufte]<common>{executivepaper}{\@tufte@unsupported@option{\CurrentOption}} +\DeclareOptionX[tufte]<common>{legalpaper}{\@tufte@unsupported@option{\CurrentOption}} +\DeclareOptionX[tufte]<common>{landscape}{\@tufte@unsupported@option{\CurrentOption}} +\DeclareOptionX[tufte]<common>{onecolumn}{\@tufte@unsupported@option{\CurrentOption}} +\DeclareOptionX[tufte]<common>{twocolumn}{\@tufte@unsupported@option{\CurrentOption}} + +%% +% Default `book' and `handout' options + +\ifthenelse{\equal{\@tufte@pkgname}{tufte-book}} + {\ExecuteOptionsX[tufte]<common>{titlepage}} + {\ExecuteOptionsX[tufte]<common>{notitlepage}} + + +\DeclareOptionX*{% + \TufteInfoNL{Passing \CurrentOption\space to the `\@tufte@class' class.}% + \PassOptionsToClass{\CurrentOption}{\@tufte@class}% +} +\ProcessOptionsX*[tufte]<common>\relax + +%% +% Load the appropriate base class +\TufteInfoNL{Loading the base class `\@tufte@class'} +\LoadClass{\@tufte@class} %% % Detect whether we're in two-side mode or not. (Used to set up running @@ -147,15 +285,57 @@ } %% -% Load the `hyperref' package. We will set more options later. -% TODO Set nice defaults for hyperref options -\ifthenelse{\boolean{@tufte@xetex}} - {\RequirePackage[hyperfootnotes=false,xetex]{hyperref}} - {\RequirePackage[hyperfootnotes=false]{hyperref}} +% Globally sets the length -\hypersetup{% - pdfborder = {0 0 0}, - bookmarksdepth = section, +\newcommand*{\gsetlength}[2]{% + \setlength{#1}{#2}% + \global#1=#1\relax% +} + +%% +% Globally sets a boolean + +\newcommand*{\gsetboolean}[2]{% based on code from ifthen pkg + \lowercase{\def\@tempa{#2}}% + \@ifundefined{@tempswa\@tempa}% + {\PackageError{ifthen}{You can only set a boolean to `true' or `false'}\@ehc}% + {\@ifundefined{#1\@tempa}% + {\PackageError{ifthen}{Boolean #1 undefined}\@ehc}% + {\global\csname#1\@tempa\endcsname}% + }% +} + +%% +% The titlesec and titletoc packages are used to change the style of the +% section headings. These packages should be loaded before the hyperref +% package. + +\RequirePackage{titlesec,titletoc} + +%%% +%% Loads the hyperref package and sets some default options. + +\newcommand{\TufteLoadHyperref}{% + \ifthenelse{\boolean{@tufte@xetex}} + {\RequirePackage[unicode,hyperfootnotes=false,xetex]{hyperref}} + {\RequirePackage[unicode,hyperfootnotes=false]{hyperref}} + \hypersetup{% + pdfborder = {0 0 0}, + bookmarksdepth = section, + citecolor = DarkGreen, + linkcolor = DarkBlue, + pagecolor = DarkBlue, + urlcolor = DarkGreen, + }% +} + +%%% +%% Load the `hyperref' package. + +\ifthenelse{\boolean{@tufte@loadhyper}}{% + \TufteLoadHyperref% +}{% hyperfootnotes override our modifications to the \footnote* and \@footnote* commands. + \PassOptionsToPackage{hyperfootnotes=false}{hyperref} } %% @@ -197,7 +377,7 @@ \renewcommand\Large{\@setfontsize\Large\@xiipt{16}} \renewcommand\LARGE{\@setfontsize\LARGE\@xivpt{18}} \renewcommand\huge{\@setfontsize\huge\@xxpt{30}} -\renewcommand\Huge{\@setfontsize\Huge\@xxivpt{36}} +\renewcommand\Huge{\@setfontsize\Huge{24}{36}} \setlength\leftmargini {1pc} \setlength\leftmarginii {1pc} @@ -241,6 +421,10 @@ {\geometry{a4paper,left=24.8mm,top=27.4mm,headsep=2\baselineskip,textwidth=107mm,marginparsep=8.2mm,marginparwidth=49.4mm,textheight=49\baselineskip,headheight=\baselineskip}} {} +\ifthenelse{\boolean{@tufte@bfivepaper}} + {\geometry{paperwidth=176mm,paperheight=250mm,left=14.66mm,top=13.88mm,textwidth=102.66mm,marginparsep=7.33mm,marginparwidth=36.66mm,textheight=38\baselineskip,includehead}} + {} + \ifthenelse{\boolean{@tufte@symmetric}} {} {\geometry{asymmetric}}% forces internal LaTeX `twoside' @@ -258,6 +442,15 @@ {\newcommand{\@tufte@marginfont}{\normalfont\footnotesize\sffamily}} {\newcommand{\@tufte@marginfont}{\normalfont\footnotesize}} +\newcommand*{\@tufte@sidenote@font}{\@tufte@marginfont} +\newcommand*{\@tufte@caption@font}{\@tufte@marginfont} +\newcommand*{\@tufte@marginnote@font}{\@tufte@marginfont} +\newcommand*{\@tufte@citation@font}{\@tufte@marginfont} + +\newcommand*{\setsidenotefont}[1]{\renewcommand*{\@tufte@sidenote@font}{#1}} +\newcommand*{\setcaptionfont}[1]{\renewcommand*{\@tufte@caption@font}{#1}} +\newcommand*{\setmarginnotefont}[1]{\renewcommand*{\@tufte@marginnote@font}{#1}} +\newcommand*{\setcitationfont}[1]{\renewcommand*{\@tufte@citation@font}{#1}} %% % Set the justification baesed on the `justified' class option @@ -284,11 +477,11 @@ \newboolean{@tufte@changepage} \IfFileExists{changepage.sty}{% - \PackageInfo{\@tufte@pkgname}{Found changepage.sty} + \TufteDebugInfoNL{Found changepage.sty} \RequirePackage[strict]{changepage} \setboolean{@tufte@changepage}{true} }{% - \PackageInfo{\@tufte@pkgname}{Found chngpage.sty} + \TufteDebugInfoNL{Found chngpage.sty} \RequirePackage[strict]{chngpage} \setboolean{@tufte@changepage}{false} } @@ -309,26 +502,30 @@ \setboolean{@tufte@odd@page}{true}% \else% \setboolean{@tufte@odd@page}{false}% - \fi + \fi% }% } - +%% % Compute lengths used for full-width displays -\newlength{\@tufte@overhang} -\setlength{\@tufte@overhang}{\marginparwidth} -\addtolength{\@tufte@overhang}{\marginparsep} - +\newlength{\@tufte@overhang}% used by the fullwidth environment and the running heads \newlength{\@tufte@fullwidth} -\setlength{\@tufte@fullwidth}{\textwidth} -\addtolength{\@tufte@fullwidth}{\marginparsep} -\addtolength{\@tufte@fullwidth}{\marginparwidth} - \newlength{\@tufte@caption@fill} -\setlength{\@tufte@caption@fill}{\textwidth} -\addtolength{\@tufte@caption@fill}{\marginparsep} +\newcommand{\TufteRecalculate}{% + \setlength{\@tufte@overhang}{\marginparwidth} + \addtolength{\@tufte@overhang}{\marginparsep} + + \setlength{\@tufte@fullwidth}{\textwidth} + \addtolength{\@tufte@fullwidth}{\marginparsep} + \addtolength{\@tufte@fullwidth}{\marginparwidth} + + \setlength{\@tufte@caption@fill}{\textwidth} + \addtolength{\@tufte@caption@fill}{\marginparsep} +} + +\AtBeginDocument{\TufteRecalculate} %% % Modified \title, \author, and \date commands. These store the @@ -359,7 +556,7 @@ \ifthenelse{\isempty{#1}}% {\renewcommand{\plaintitle}{\thanklesstitle}}% use thankless title {\renewcommand{\plaintitle}{#1}}% use provided plain-text title - \hypersetup{pdftitle={\plaintitle}}% set the PDF metadata title + \@ifpackageloaded{hyperref}{\hypersetup{pdftitle={\plaintitle}}}{}% set the PDF metadata title } \def\@author{}% default author is empty (suppresses LaTeX's ``no author'' warning) @@ -373,7 +570,7 @@ \ifthenelse{\isempty{#1}} {\renewcommand{\plainauthor}{\thanklessauthor}}% use thankless author {\renewcommand{\plainauthor}{#1}}% use provided plain-text author - \hypersetup{pdfauthor={\plainauthor}}% set the PDF metadata author + \@ifpackageloaded{hyperref}{\hypersetup{pdfauthor={\plainauthor}}}{}% set the PDF metadata author } \renewcommand*{\date}[1]{% @@ -425,21 +622,13 @@ % Failing that, try to use the `soul' package, if it's available. % Failing that, well, I give up. +\DeclareTextFontCommand{\textsmallcaps}{\scshape} + \RequirePackage{textcase} % provides \MakeTextUppercase and \MakeTextLowercase -\def\allcapsspacing{\relax} -\def\smallcapsspacing{\relax} -\newcommand{\allcaps}[1]{\MakeTextUppercase{\allcapsspacing{#1}}} -\newcommand{\smallcaps}[1]{\MakeTextLowercase{\textsc{#1}}} - -\newcommand{\@tufte@loadsoul}{% - \IfFileExists{soul.sty}{% - \RequirePackage{soul} - \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.} - }% soul not installed... giving up. -} +\def\allcapsspacing{\TufteWarning{Proper spacing of ALL-CAPS letters has not been set up.}} +\def\smallcapsspacing{\TufteWarning{Proper spacing of small-caps letters has not been set up.}} +\newcommand{\allcaps}[1]{\allcapsspacing{\MakeTextUppercase{#1}}} +\newcommand{\smallcaps}[1]{\smallcapsspacing{\MakeTextLowercase{#1}}} % If we're using pdfLaTeX v1.40+, use the letterspace package. % If we're using pdfLaTex < v1.40, use the soul package. @@ -447,12 +636,12 @@ % Otherwise fall back on the soul package. \ifthenelse{\boolean{@tufte@pdf}} - {\PackageInfo{\@tufte@pkgname}{ifpdf = true}} - {\PackageInfo{\@tufte@pkgname}{ifpdf = false}} + {\TufteDebugInfoNL{ifpdf = true}} + {\TufteDebugInfoNL{ifpdf = false}} \ifthenelse{\boolean{@tufte@xetex}} - {\PackageInfo{\@tufte@pkgname}{ifxetex = true}} - {\PackageInfo{\@tufte@pkgname}{ifxetex = false}} + {\TufteDebugInfoNL{ifxetex = true}} + {\TufteDebugInfoNL{ifxetex = false}} % Check pdfLaTeX version \def\@tufte@pdftexversion{0} @@ -470,36 +659,78 @@ \fi \fi -\ifthenelse{\boolean{@tufte@letterspace}} - {% - \ifnum\@tufte@pdftexversion<6 - % 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.} - \@tufte@loadsoul} - {% use `soul' package for letterspacing - \PackageInfo{\@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.} +\newboolean{@tufte@letterspace@pkg@prereqs} +\setboolean{@tufte@letterspace@pkg@prereqs}{true} +\ifnum\@tufte@pdftexversion<6 + \setboolean{@tufte@letterspace@pkg@prereqs}{false} +\fi + + +\ifthenelse{\boolean{@tufte@letterspace}}{% + \ifthenelse{\boolean{@tufte@pdf}\AND\boolean{@tufte@letterspace@pkg@prereqs}\AND\NOT\boolean{@tufte@xetex}}{% + % load letterspace pkg + \IfFileExists{letterspace.sty}{% + \TufteDebugInfoNL{Modern version of pdfTeX detected. \MessageBreak Using `letterspace' package} \RequirePackage{letterspace} % Set up letterspacing (using microtype package) -- requires pdfTeX v1.40+ \renewcommand{\allcapsspacing}[1]{\textls[200]{##1}} \renewcommand{\smallcapsspacing}[1]{\textls[50]{##1}} \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.} - \@tufte@loadsoul - } - \fi} - {} - + \renewcommand{\smallcaps}[1]{\smallcapsspacing{\scshape\MakeTextLowercase{##1}}} + \renewcommand{\textsc}[1]{\smallcapsspacing{\textsmallcaps{##1}}} + }{}% + }{}% + % load soul pkg + \@ifpackageloaded{letterspace}{}{% + \IfFileExists{soul.sty}{% + \RequirePackage{soul} + \sodef\allcapsspacing{}{0.15em}{0.65em}{0.6em} + \sodef\smallcapsspacing{}{0.075em}{0.5em}{0.6em} + \sodef\sotextsc{\scshape}{0.075em}{0.5em}{0.6em} + \renewcommand{\allcaps}[1]{\allcapsspacing{\MakeTextUppercase{##1}}} + \renewcommand{\smallcaps}[1]{\smallcapsspacing{\scshape\MakeTextLowercase{##1}}} + \renewcommand{\textsc}[1]{\sotextsc{##1}} + }{ + \TufteWarningNL{Couldn't locate `soul' package} + }% soul not installed... giving up. + }% +}{} -\DeclareTextFontCommand{\textsmallcaps}{\scshape} -\renewcommand{\textsc}[1]{\textsmallcaps{\smallcapsspacing{#1}}} +%\ifthenelse{\boolean{@tufte@letterspace}}{% + %\ifthenelse{\boolean{pdf}}{% + %\ifthenelse{\NOT\boolean{@tufte@letterspace@pkg@prereqs}}{% + %% pdfLaTeX version is too old or not using pdfLaTeX + %\ifthenelse{\boolean{@tufte@xetex}}{% + %% TODO use xetex letterspacing + %\TufteDebugInfoNL{XeTeX detected. \MessageBreak Reverting to `soul' package for letterspacing}% + %\@tufte@loadsoul% + %}{% + %% use `soul' package for letterspacing + %\TufteDebugInfoNL{Old version of pdfTeX detected. \MessageBreak Reverting to `soul' package for letterspacing}% + %\@tufte@loadsoul% + %} + %}{% + %\IfFileExists{letterspace.sty}{% + %\TufteDebugInfoNL{Modern version of pdfTeX detected. \MessageBreak Using `letterspace' package} + %\RequirePackage{letterspace} + %% Set up letterspacing (using microtype package) -- requires pdfTeX v1.40+ + %\renewcommand{\allcapsspacing}[1]{\textls[200]{##1}} + %\renewcommand{\smallcapsspacing}[1]{\textls[50]{##1}} + %\renewcommand{\allcaps}[1]{\textls[200]{\MakeTextUppercase{##1}}} + %\renewcommand{\smallcaps}[1]{\smallcapsspacing{\MakeTextLowercase{##1}}} + %\renewcommand{\textsc}[1]{\smallcapsspacing{\textsmallcaps{##1}}} + %}{% microtype failed, check for soul + %\TufteDebugInfoNL{Modern version of pdfTeX detected, but `letterspace' \MessageBreak package not installed. \MessageBreak Reverting to `soul' package for letterspacing} + %\@tufte@loadsoul + %}% + %}% + %}{% + %\TufteDebugInfoNL{Plain LaTeX detected. \MessageBreak Using `soul' package for letterspacing} + %\@tufte@loadsoul + %} +%}{% +%% we're not to load letterspacing, so do nothing +%} %% @@ -537,6 +768,11 @@ \item\relax} {\endlist} +%% +% Italicize description run-in headings (instead of the default bold) + +\renewcommand*\descriptionlabel[1]{\hspace\labelsep\normalfont\em #1} + %% % Used for doublespacing, and other linespacing @@ -585,7 +821,7 @@ %% % Citations should go in the margin as sidenotes -\RequirePackage[numbers]{natbib} +\RequirePackage{natbib} \RequirePackage{bibentry} % allows bibitems to be typeset outside thebibliography environment % Redefine the \BR@b@bibitem command to fix a bug with bibentry+chicago style \renewcommand\BR@b@bibitem[2][]{% @@ -606,6 +842,7 @@ \@for\@temp@bibkey:=#2\do{\let\@temp@last@bibkey\@temp@bibkey}% \sidenote[][#1]{% % Loop through all the bibentries, separating them with semicolons and spaces + \normalsize\normalfont\@tufte@citation@font% \setcounter{@tufte@num@bibkeys}{0}% \@for\@temp@bibkeyx:=#2\do{% \ifthenelse{\equal{\@temp@last@bibkey}{\@temp@bibkeyx}}% @@ -637,8 +874,8 @@ \@for\@temp@bibkey:=\@tufte@citations\do{\let\@temp@last@bibkey\@temp@bibkey}% \marginpar{% \hbox{}\vspace*{#1}% - \@tufte@marginfont% - \@tufte@justification% + \@tufte@citation@font% + \@tufte@citation@justification% \@tufte@margin@par% use parindent and parskip settings for marginal text \vspace*{-1\baselineskip}% % Loop through all the bibentries, separating them with semicolons and spaces @@ -675,12 +912,12 @@ \RequirePackage{optparams}% for our new sidenote commands -- provides multiple optional arguments for commands -\providecommand*{\footnotelayout}{\@tufte@marginfont\@tufte@justification} -\renewcommand{\footnotelayout}{\@tufte@marginfont\@tufte@justification} +\providecommand*{\footnotelayout}{\@tufte@sidenote@font\@tufte@sidenote@justification} +\renewcommand{\footnotelayout}{\@tufte@sidenote@font\@tufte@sidenote@justification} % Override footmisc's definition to set the sidenote marks (numbers) inside the % sidenote's text block. -\long\def\@makefntext#1{\@textsuperscript{\@tufte@marginfont\tiny\@thefnmark}\,\footnotelayout#1} +\long\def\@makefntext#1{\@textsuperscript{\@tufte@sidenote@font\tiny\@thefnmark}\,\footnotelayout#1} % Set the in-text footnote mark in the same typeface as the body text itself. \def\@makefnmark{\hbox{\@textsuperscript{\normalfont\footnotesize\@thefnmark}}} @@ -732,13 +969,18 @@ % % Define \sidenote command. Can handle \cite. -\newcommand{\@tufte@sidenote@vertical@offset}{0pt} +\newlength{\@tufte@sidenote@vertical@offset} +\setlength{\@tufte@sidenote@vertical@offset}{0pt} % #1 = footnote num, #2 = vertical offset, #3 = footnote text \long\def\@tufte@sidenote[#1][#2]#3{% \let\cite\@tufte@infootnote@cite% use the in-sidenote \cite command \gdef\@tufte@citations{}% clear out any old citations - \ifthenelse{\NOT\isempty{#2}}{\renewcommand{\@tufte@sidenote@vertical@offset}{#2}}{}% + \ifthenelse{\NOT\isempty{#2}}{% + \gsetlength{\@tufte@sidenote@vertical@offset}{#2}% + }{% + \gsetlength{\@tufte@sidenote@vertical@offset}{0pt}% + }% \ifthenelse{\isempty{#1}}{% % no specific footnote number provided \stepcounter\@mpfn% @@ -769,7 +1011,7 @@ \let\cite\@tufte@infootnote@cite% use the in-sidenote \cite command \gdef\@tufte@citations{}% clear out any old citations \@tufte@margin@par% use parindent and parskip settings for marginal text - \marginpar{\hbox{}\vspace*{#1}\@tufte@marginfont\@tufte@justification\vspace*{-1\baselineskip}\noindent #2}% + \marginpar{\hbox{}\vspace*{#1}\@tufte@marginnote@font\@tufte@marginnote@justification\vspace*{-1\baselineskip}\noindent #2}% \@tufte@reset@par% use parindent and parskip settings for body text \@tufte@print@citations% print any citations \let\cite\@tufte@normal@cite% go back to using normal in-text \cite command @@ -790,10 +1032,10 @@ {\FloatBarrier% process all floats before this point so the figure/table numbers stay in order. \begin{lrbox}{\@tufte@margin@floatbox}% \begin{minipage}{\marginparwidth}% - \@tufte@marginfont% + \@tufte@caption@font% \def\@captype{#2}% \hbox{}\vspace*{#1}% - \@tufte@justification% + \@tufte@caption@justification% \@tufte@margin@par% \noindent% } @@ -814,16 +1056,58 @@ %% % Margin table environment + \newenvironment{margintable}[1][-1.2ex]% {\begin{@tufte@margin@float}[#1]{table}} {\end{@tufte@margin@float}} %% -% A collection of macros to be used with the new Tufte-style float environments +% Auto-detects the proper text alignment based on the various class options + +\newcommand*{\@tufte@justification@autodetect}{% + \ifthenelse{\boolean{@tufte@justified}}% + {\justifying}% + {\RaggedRight}% +} + +%% +% Forces the outer edge of the caption to be set ragged. +% Therefore, on verso pages it's ragged left, and on recto pages it's ragged right. + +\newcommand*{\@tufte@justification@caption@outer}{% + \ifthenelse{\boolean{@tufte@float@recto}}% + {\RaggedRight}% + {\RaggedLeft}% +} + +\newcommand*{\@tufte@justification@outer}{% + \@tufte@checkoddpage% + \ifthenelse{\boolean{@tufte@odd@page}}% + {\RaggedRight}% + {\RaggedLeft}% +} + + + +%% +% 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{\@tufte@float@debug@info}{}% contains debug info generated as the float is processed +\newcommand{\@tufte@float@debug}[1]{% adds debug info to the queue for output +\ifthenelse{\equal{\@tufte@float@debug@info}{}}% + {\def\@tufte@float@debug@info{#1}}% + {\g@addto@macro\@tufte@float@debug@info{\MessageBreak#1}} +} \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}\@tufte@float@debug{Forcing position: [#1]}}% manually sets the float alignment +\newboolean{@tufte@float@recto} +\newcommand{\forcerectofloat}{\gsetboolean{@tufte@float@recto}{true}\@tufte@float@debug{Forcing page: [recto]}} +\newcommand{\forceversofloat}{\gsetboolean{@tufte@float@recto}{false}\@tufte@float@debug{Forcing page: [verso]}} % Boxes to temporarily store our float and caption \newsavebox{\@tufte@figure@box} @@ -833,22 +1117,21 @@ \let\@tufte@orig@float\@float \let\@tufte@orig@endfloat\end@float -% Save original LaTeX \caption and \label commands -\AtBeginDocument{% - \let\@tufte@orig@caption\caption% - \let\@tufte@orig@label\label% -} +% New length for tweaking float captions +\newlength{\@tufte@caption@vertical@offset} +\setlength{\@tufte@caption@vertical@offset}{0pt} % Store the caption and label contents \newcommand{\@tufte@stored@shortcaption}{} \newcommand{\@tufte@stored@caption}{} \newcommand{\@tufte@stored@label}{} -\newcommand{\@tufte@caption}[2][]{% - \ifthenelse{\isempty{#1}} - {\gdef\@tufte@stored@shortcaption{#2}}% +\long\def\@tufte@caption[#1][#2]#3{% + \ifthenelse{\isempty{#1}}% + {\gdef\@tufte@stored@shortcaption{#3}}% {\gdef\@tufte@stored@shortcaption{#1}}% - \gdef\@tufte@stored@caption{#2}% + \gsetlength{\@tufte@caption@vertical@offset}{-#2}% we want a positive offset to lower captions + \gdef\@tufte@stored@caption{#3}% } \newcommand{\@tufte@label}[1]{% @@ -857,26 +1140,47 @@ \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}}% + {\gsetboolean{@tufte@float@star}{true}}% + {\gsetboolean{@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}}% + {\gsetboolean{@tufte@float@recto}{true}\@tufte@float@debug{Detected page: [recto/odd]}}% + {\gsetboolean{@tufte@float@recto}{false}\@tufte@float@debug{Detected page: [verso/even]}}% + % If the float placement specifier is 'b' and only 'b', then bottom-align the mini-pages, otherwise top-align them. \renewcommand{\@tufte@fps}{#1}% + \@tufte@float@debug{Allowed positions: [#1]} \ifthenelse{\equal{#1}{b}\OR\equal{#1}{B}}% - {\renewcommand{\floatalignment}{b}}% - {\renewcommand{\floatalignment}{t}}% - \renewcommand{\caption}[2][]{\@tufte@caption[##1]{##2}}% + {\renewcommand{\floatalignment}{b}\@tufte@float@debug{Presumed position: [bottom]}}% + {\renewcommand{\floatalignment}{t}\@tufte@float@debug{Presumed position: [top]}}% + % Capture the contents of the \caption and \label commands to use later + \global\let\@tufte@orig@caption\caption% + \global\let\@tufte@orig@label\label% + \renewcommand{\caption}{\optparams{\@tufte@caption}{[][0pt]}}% \renewcommand{\label}[1]{\@tufte@label{##1}}% + % Handle subfigure package compatibility + \ifthenelse{\boolean{@tufte@packages@subfigure}}{% + % don't move the label while inside a \subfigure or \subtable command + \global\let\label\@tufte@orig@label% + }{}% subfigure package is not loaded \@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 @@ -890,35 +1194,76 @@ % 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@caption@vertical@offset]{\@tufte@figure@box}{\@tufte@caption@box}}% + {\@tufte@float@textwidth[\@tufte@caption@vertical@offset]{\@tufte@figure@box}{\@tufte@caption@box}}% \end{minipage}% \end{fullwidth}% - \@tufte@orig@endfloat% + \@tufte@orig@endfloat% end original LaTeX float environment + % output debug info + \ifthenelse{\boolean{@tufte@debug}}{% + \typeout{^^J^^J----------- Tufte-LaTeX float information ----------}% + \ifthenelse{\equal{\@tufte@stored@label}{}}% + {\typeout{Warning: Float unlabeled!}}% + {\typeout{Float label: [\@tufte@stored@label]}}% + \typeout{Page number: [\thepage]}% + \def\MessageBreak{^^J}% + \typeout{\@tufte@float@debug@info}% + \ifthenelse{\boolean{@tufte@symmetric}}% + {\typeout{Symmetric: [true]}}% + {\typeout{Symmetric: [false]}}% + \typeout{----------------------------------------------------^^J^^J}% + }{}% % reset commands and temp boxes and captions + \gdef\@tufte@float@debug@info{}% \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{}% + \gdef\@tufte@stored@label{}% + \gsetlength{\@tufte@caption@vertical@offset}{0pt}% reset caption offset } +\newcommand{\@tufte@float@textwidth}[3][0pt]{% + \ifthenelse{\NOT\boolean{@tufte@symmetric}\OR\boolean{@tufte@float@recto}}{% + % asymmetric or page is odd, so caption is on the right + \hbox{% + \usebox{#2}% + \hspace{\marginparsep}% + \smash{\raisebox{#1}{\usebox{#3}}}% + }% + \@tufte@float@debug{Caption position: [right]}% + }{% symmetric pages and page is even, so caption is on the left + \hbox{% + \smash{\raisebox{#1}{\usebox{#3}}}% + \hspace{\marginparsep}% + \usebox{#2}% + }% + \@tufte@float@debug{Caption position: [left]}% + }% +} + +\newcommand{\@tufte@float@fullwidth}[3][0pt]{% + \ifthenelse{\equal{\floatalignment}{b}}% + {% place caption above figure + \ifthenelse{\NOT\boolean{@tufte@symmetric}\OR\boolean{@tufte@float@recto}}% + {\hfill\smash{\raisebox{#1}{\usebox{#3}}}\par\usebox{#2}\@tufte@float@debug{Caption position: [above right]}}% caption on the right + {\smash{\raisebox{#1}{\usebox{#3}}}\hfill\par\usebox{#2}\@tufte@float@debug{Caption position: [above left]}}% caption on the left + }{% place caption below figure + \ifthenelse{\NOT\boolean{@tufte@symmetric}\OR\boolean{@tufte@float@recto}}% + {\usebox{#2}\par\hfill\smash{\raisebox{#1}{\usebox{#3}}}\@tufte@float@debug{Caption position: [below right]}}% caption on the right + {\usebox{#2}\par\smash{\raisebox{#1}{\usebox{#3}}}\hfill\@tufte@float@debug{Caption position: [below left]}}% 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}} @@ -926,106 +1271,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}}% } %% @@ -1035,13 +1311,13 @@ \par% \addcontentsline{\csname ext@#1\endcsname}{#1}% {\protect\numberline{\csname the#1\endcsname}{\ignorespaces #2}}% - \begingroup - \@parboxrestore - \if@minipage - \@setminipage - \fi - \@tufte@marginfont\@tufte@justification% - \noindent\csname fnum@#1\endcsname: \ignorespaces#3\par + \begingroup% + \@parboxrestore% + \if@minipage% + \@setminipage% + \fi% + \@tufte@caption@font\@tufte@caption@justification% + \noindent\csname fnum@#1\endcsname: \ignorespaces#3\par% %\@makecaption{\csname fnum@#1\endcsname}{\ignorespaces #3}\par \endgroup} @@ -1090,9 +1366,11 @@ % Set the header/footer width to be the body text block plus the margin % note area. -\ifthenelse{\boolean{@tufte@symmetric}} - {\fancyhfoffset[LE,RO]{\@tufte@overhang}} - {\fancyhfoffset[RE,RO]{\@tufte@overhang}} +\AtBeginDocument{% + \ifthenelse{\boolean{@tufte@symmetric}} + {\fancyhfoffset[LE,RO]{\@tufte@overhang}} + {\fancyhfoffset[RE,RO]{\@tufte@overhang}} +} % The running heads/feet don't have rules \renewcommand{\headrulewidth}{0pt} @@ -1150,6 +1428,7 @@ \typeout{} \typeout{Class options:} \typeoutbool{a4paper}{@tufte@afourpaper} + \typeoutbool{b5paper}{@tufte@bfivepaper} \typeoutbool{load fonts}{@tufte@loadfonts} \typeoutbool{fully-justified}{@tufte@justified} \typeoutbool{letterspacing}{@tufte@letterspace} @@ -1244,14 +1523,12 @@ %% % Make Tuftian-style section headings and TOC formatting -\RequirePackage{titlesec,titletoc} - \titleformat{\chapter}% [display]% shape {\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}% @@ -1278,7 +1555,6 @@ {}% before the title body []% after the title body - \titlespacing*{\chapter}{0pt}{50pt}{40pt} \titlespacing*{\section}{0pt}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex} \titlespacing*{\subsection}{0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus.2ex} @@ -1286,7 +1562,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.% + \TufteError{\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} @@ -1295,18 +1571,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.% + \TufteError{\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} @@ -1318,25 +1584,84 @@ % 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{chapter}% +\ifthenelse{\boolean{@tufte@toc}}{% + \titlecontents{part}% FIXME [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) - [\vspace{1.5\baselineskip}\end{fullwidth}] % after - } - {} + {\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}% + [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 -%\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\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}% +} + +\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 plus 1fil + \parindent 0.0em + \@afterindenttrue + \interlinepenalty\@M + \leavevmode + \@tempdima 2.0em + \advance\leftskip\@tempdima + \null\nobreak\hskip -\leftskip + {#1}\nobreak\qquad\nobreak#2% + \par% +} +\renewcommand*\l@figure{\@tufte@lof@line} +\let\l@table\l@figure %% @@ -1405,6 +1730,125 @@ %% +% A couple commands to incresae the number of floats you can use at a time. + +\def\morefloats{% provides a total of 52 floats + \ifthenelse{\isundefined{\bx@S}}{% + \TufteDebugInfoNL{Adding 34 more float slots.} + \newinsert\bx@S + \newinsert\bx@T + \newinsert\bx@U + \newinsert\bx@V + \newinsert\bx@W + \newinsert\bx@X + \newinsert\bx@Y + \newinsert\bx@Z + \newinsert\bx@a + \newinsert\bx@b + \newinsert\bx@c + \newinsert\bx@d + \newinsert\bx@e + \newinsert\bx@f + \newinsert\bx@g + \newinsert\bx@h + \newinsert\bx@i + \newinsert\bx@j + \newinsert\bx@k + \newinsert\bx@l + \newinsert\bx@m + \newinsert\bx@n + \newinsert\bx@o + \newinsert\bx@p + \newinsert\bx@q + \newinsert\bx@r + \newinsert\bx@s + \newinsert\bx@t + \newinsert\bx@u + \newinsert\bx@v + \newinsert\bx@w + \newinsert\bx@x + \newinsert\bx@y + \newinsert\bx@z + \gdef\@freelist{\@elt\bx@A\@elt\bx@B\@elt\bx@C\@elt\bx@D\@elt\bx@E + \@elt\bx@F\@elt\bx@G\@elt\bx@H\@elt\bx@I\@elt\bx@J + \@elt\bx@K\@elt\bx@L\@elt\bx@M\@elt\bx@N + \@elt\bx@O\@elt\bx@P\@elt\bx@Q\@elt\bx@R + \@elt\bx@S\@elt\bx@T\@elt\bx@U\@elt\bx@V + \@elt\bx@W\@elt\bx@X\@elt\bx@Y\@elt\bx@Z + \@elt\bx@a\@elt\bx@b\@elt\bx@c\@elt\bx@d\@elt\bx@e + \@elt\bx@f\@elt\bx@g\@elt\bx@h\@elt\bx@i\@elt\bx@j + \@elt\bx@k\@elt\bx@l\@elt\bx@m\@elt\bx@n + \@elt\bx@o\@elt\bx@p\@elt\bx@q\@elt\bx@r + \@elt\bx@s\@elt\bx@t\@elt\bx@u\@elt\bx@v + \@elt\bx@w\@elt\bx@x\@elt\bx@y\@elt\bx@z}% + }{% we've already added another 34 floats, so we'll add 26 more, but that's it! + \ifthenelse{\isundefined{\bx@AA}}{% + \TufteDebugInfoNL{Adding 26 more float slots.} + \newinsert\bx@AA + \newinsert\bx@BB + \newinsert\bx@CC + \newinsert\bx@DD + \newinsert\bx@EE + \newinsert\bx@FF + \newinsert\bx@GG + \newinsert\bx@HH + \newinsert\bx@II + \newinsert\bx@JJ + \newinsert\bx@KK + \newinsert\bx@LL + \newinsert\bx@MM + \newinsert\bx@NN + \newinsert\bx@OO + \newinsert\bx@PP + \newinsert\bx@QQ + \newinsert\bx@RR + \newinsert\bx@SS + \newinsert\bx@TT + \newinsert\bx@UU + \newinsert\bx@VV + \newinsert\bx@WW + \newinsert\bx@XX + \newinsert\bx@YY + \newinsert\bx@ZZ + \gdef\@freelist{\@elt\bx@A\@elt\bx@B\@elt\bx@C\@elt\bx@D\@elt\bx@E + \@elt\bx@F\@elt\bx@G\@elt\bx@H\@elt\bx@I\@elt\bx@J + \@elt\bx@K\@elt\bx@L\@elt\bx@M\@elt\bx@N + \@elt\bx@O\@elt\bx@P\@elt\bx@Q\@elt\bx@R + \@elt\bx@S\@elt\bx@T\@elt\bx@U\@elt\bx@V + \@elt\bx@W\@elt\bx@X\@elt\bx@Y\@elt\bx@Z + \@elt\bx@a\@elt\bx@b\@elt\bx@c\@elt\bx@d\@elt\bx@e + \@elt\bx@f\@elt\bx@g\@elt\bx@h\@elt\bx@i\@elt\bx@j + \@elt\bx@k\@elt\bx@l\@elt\bx@m\@elt\bx@n + \@elt\bx@o\@elt\bx@p\@elt\bx@q\@elt\bx@r + \@elt\bx@s\@elt\bx@t\@elt\bx@u\@elt\bx@v + \@elt\bx@w\@elt\bx@x\@elt\bx@y\@elt\bx@z + \@elt\bx@AA\@elt\bx@BB\@elt\bx@CC\@elt\bx@DD\@elt\bx@EE + \@elt\bx@FF\@elt\bx@GG\@elt\bx@HH\@elt\bx@II\@elt\bx@JJ + \@elt\bx@KK\@elt\bx@LL\@elt\bx@MM\@elt\bx@NN + \@elt\bx@OO\@elt\bx@PP\@elt\bx@QQ\@elt\bx@RR + \@elt\bx@SS\@elt\bx@TT\@elt\bx@UU\@elt\bx@VV + \@elt\bx@WW\@elt\bx@XX\@elt\bx@YY\@elt\bx@ZZ}% + }{% + \TufteError{You may only call \string\morefloats\space twice. See the\MessageBreak Tufte-LaTeX documentation for other workarounds} + {There are already 78 float slots allocated. Try using \string\FloatBarrier\space or\MessageBreak \string\clearpage\space to place some floats before creating more.} + }% + }% +} + + +%% +% Detect if the subfigure package has been loaded + +\newboolean{@tufte@packages@subfigure} +\setboolean{@tufte@packages@subfigure}{false} +\AtBeginDocument{% + \@ifpackageloaded{subfigure} + {\gsetboolean{@tufte@packages@subfigure}{true}} + {\gsetboolean{@tufte@packages@subfigure}{false}}% +} + + +%% % If debugging is enabled, print the Tufte-LaTeX options and the list of % files. @@ -1417,7 +1861,8 @@ % If there is a `tufte-common-local.tex' file, load it up. \IfFileExists{tufte-common-local.tex} - {\input{tufte-common-local}} + {\input{tufte-common-local.tex}% + \TufteInfoNL{Loading tufte-common-local.tex}} {} diff --git a/Master/texmf-dist/tex/latex/tufte-latex/tufte-handout.cls b/Master/texmf-dist/tex/latex/tufte-latex/tufte-handout.cls index ca9ab630829..767f51890d5 100644 --- a/Master/texmf-dist/tex/latex/tufte-latex/tufte-handout.cls +++ b/Master/texmf-dist/tex/latex/tufte-latex/tufte-handout.cls @@ -1,27 +1,15 @@ \NeedsTeXFormat{LaTeX2e}[1994/06/01] -\ProvidesClass{tufte-handout}[2009/05/17 v3.0.0 Tufte-handout class] +\ProvidesClass{tufte-handout}[2009/12/11 v3.5.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} -} +% 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) -\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} +%% +% Load the common style elements +\input{tufte-common.def} %% @@ -41,7 +29,8 @@ % If there is a `tufte-handout-local.tex' file, load it. \IfFileExists{tufte-handout-local.tex} - {\input{tufte-handout-local}} + {\input{tufte-handout-local} + \TufteInfoNL{Loading tufte-handout-local.tex}} {} |