From d5d54175dbf7c2555e1ae5d9e30cb8318302716f Mon Sep 17 00:00:00 2001 From: "Kevin M. Godby" Date: Sat, 22 Aug 2009 07:52:27 +0000 Subject: [PATCH] * Added vertical offset feature to \captions. (Thanks, Dan!) \caption[short caption][offset]{normal caption} git-svn-id: https://tufte-latex.googlecode.com/svn/trunk@120 516e2f36-ce3a-0410-bea4-1d4a03f5df72 --- sample-book.pdf | Bin 321736 -> 321736 bytes sample-handout.pdf | Bin 123585 -> 123585 bytes tufte-common.def | 46 ++++++++++++++++++++++++--------------------- 3 files changed, 25 insertions(+), 21 deletions(-) diff --git a/sample-book.pdf b/sample-book.pdf index 4ffc450926ed8517f57857984bd7b2d0eacbd065..f6d21893ba850210c260bb653389031390bc9359 100644 GIT binary patch delta 122 zcmX?cQTW6~;f5B*7N!>FEiBh|uo{^f7@JH!6DYxLX<%VwWB}p656sw}wv&ZP-`T~* t*}%-i%*Ddg*xbFEiBh|uo@T}m>Ntz6DYxLX<%VwWB}p656sw}wv&ZP-`UB) t(A2`f(agfq+||s`*v!bn*x1q3$iUgz$jQ~k(#=l6hLDo!t6#9l0s!~7B3J+b diff --git a/sample-handout.pdf b/sample-handout.pdf index a22a3423f9ce0c5edc0987990ae317bea413c634..aab9deb202b4c04dc98df5fff70ecc9de78b9fbe 100644 GIT binary patch delta 131 zcmX?jl>OjQ_J%EtkFT;CnHm_GPk(WhQ4Ye~&V7wBj3>d;(b?I;!pX?l#KhR#z}3mb z*~rk?%+1Wj#Kp|b#MsSF!G@rcSOq&fuHur!qLPZD)HE(bBLfo)V=h%ySARDy02{m` Ax&QzG delta 131 zcmX?jl>OjQ_J%EtkFT;C7#o-vPk(WhQ4Ye~&V7wBj3>d-)zsM1#L3Oc)YRO-)x^xv z)WFfi%+Sct)Y8n**v;5Z!G@rcSOq&fuHur!qLPZD)HE(bBLfo)V=h%ySARDy0QZC= A8~^|S diff --git a/tufte-common.def b/tufte-common.def index b70711f..ab05cc0 100644 --- a/tufte-common.def +++ b/tufte-common.def @@ -1030,16 +1030,21 @@ \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][]{% +\long\def\@tufte@caption[#1][#2]#3{% \ifthenelse{\isempty{#1}}% - {\gdef\@tufte@stored@shortcaption{#2}}% + {\gdef\@tufte@stored@shortcaption{#3}}% {\gdef\@tufte@stored@shortcaption{#1}}% - \gdef\@tufte@stored@caption{#2}% + \gdef\@tufte@caption@vertical@offset{-#2}% we want positive push to lower captions + \gdef\@tufte@stored@caption{#3}% } \newcommand{\@tufte@label}[1]{% @@ -1071,8 +1076,8 @@ \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}}% + % Capture the contents of the \caption and \label commands to use later + \renewcommand{\caption}{\optparams{\@tufte@caption}{[][0pt]}}% \renewcommand{\label}[1]{\@tufte@label{##1}}% \@tufte@orig@float{#2}[#1]% \ifthenelse{\boolean{@tufte@float@star}}% @@ -1096,8 +1101,8 @@ \begin{fullwidth}% \begin{minipage}[\floatalignment]{\linewidth}% \ifthenelse{\boolean{@tufte@float@star}}% - {\@tufte@float@fullwidth{\@tufte@figure@box}{\@tufte@caption@box}}% - {\@tufte@float@textwidth{\@tufte@figure@box}{\@tufte@caption@box}}% + {\@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% @@ -1108,37 +1113,36 @@ \begin{lrbox}{\@tufte@caption@box}\hbox{}\end{lrbox}% \gdef\@tufte@stored@shortcaption{}% \gdef\@tufte@stored@caption{}% + \gdef\@tufte@caption@vertical@offset{0pt}% reset caption push } -\newcommand{\@tufte@float@textwidth}[2]{% +\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{#1}% + \usebox{#2}% \hspace{\marginparsep}% - \smash{\usebox{#2}}% + \smash{\raisebox{#1}{\usebox{#3}}}% }% - }{% - % symmetric pages and page is even, so caption is on the left + }{% symmetric pages and page is even, so caption is on the left \hbox{% - \smash{\usebox{#2}}% + \smash{\raisebox{#1}{\usebox{#3}}}% \hspace{\marginparsep}% - \usebox{#1}% + \usebox{#2}% }% }% } -\newcommand{\@tufte@float@fullwidth}[2]{% +\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{\usebox{#2}}\par\usebox{#1}}% caption on the right - {\smash{\usebox{#2}\hfill}\par\usebox{#1}}% caption on the left - }% - {% place caption below figure + {\hfill\smash{\raisebox{#1}{\usebox{#3}}}\par\usebox{#2}}% caption on the right + {\smash{\raisebox{#1}{\usebox{#3}}}\hfill\par\usebox{#2}}% 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 + {\usebox{#2}\par\hfill\smash{\raisebox{#1}{\usebox{#3}}}}% caption on the right + {\usebox{#2}\par\smash{\raisebox{#1}{\usebox{#3}}}\hfill}% caption on the left }% }