summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/mcaption
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2009-03-13 23:28:23 +0000
committerKarl Berry <karl@freefriends.org>2009-03-13 23:28:23 +0000
commite94c1bb676f5054f55d4410bae611f0df8777fe0 (patch)
tree0922b775b4cf8eb893a102db5ec416af575069cb /Master/texmf-dist/tex/latex/mcaption
parent3bcc3bf88b0e7869b457cc5b50e8ea5815450828 (diff)
mcaption 3.0 (13mar09)
git-svn-id: svn://tug.org/texlive/trunk@12384 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/mcaption')
-rw-r--r--Master/texmf-dist/tex/latex/mcaption/mcaption.sty165
1 files changed, 117 insertions, 48 deletions
diff --git a/Master/texmf-dist/tex/latex/mcaption/mcaption.sty b/Master/texmf-dist/tex/latex/mcaption/mcaption.sty
index 0095e1c53fc..b54881da4a8 100644
--- a/Master/texmf-dist/tex/latex/mcaption/mcaption.sty
+++ b/Master/texmf-dist/tex/latex/mcaption/mcaption.sty
@@ -21,74 +21,143 @@
%% 1999/12/01 or later.
%%
\ProvidesPackage{mcaption}
- [2005/09/30 v2.2 Put captions in margin (SH)]
+ [2009/03/13 v3.0 Put captions into the outer document margin (SH)]
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
-\RequirePackage{ifthen}
-\RequirePackage{chngpage}
-\newcommand*{\margincapalign}{}
-\DeclareOption{top}{\renewcommand*{\margincapalign}{t}}
-\DeclareOption{bottom}{\renewcommand*{\margincapalign}{b}}
+\RequirePackage[strict]{changepage}
+\newcommand*{\mcaption@alignv}{}
+\DeclareOption{top}{\renewcommand*{\mcaption@alignv}{t}}
+\DeclareOption{bottom}{\renewcommand*{\mcaption@alignv}{b}}
\ExecuteOptions{bottom}
+\DeclareOption{v2.2}{%
+ \AtEndOfPackage{%
+ \let\margincap\mcaption@mcIIdotII%
+ \let\endmargincap\endmcaption@mcIIdotII%
+ \newcommand*{\margincapalign}{\mcaption@alignv}
+ }%
+}%
\ProcessOptions\relax
\newlength{\margincapsep}
\AtBeginDocument{%
\setlength{\margincapsep}{\marginparsep}%
}
+\newcommand*{\mcaption@CaptionLong}{}
+\newcommand*{\mcaption@CaptionShort}{}
+\newcommand*{\mcaption@CaptionFlag}{}
+\newcommand*{\mcaption@Label}{}
+\newcommand*{\mcaption@LabelFlag}{}
\newsavebox{\mcaption@ObjectBox}
\newsavebox{\mcaption@CaptionBox}
-\newlength{\mcaption@ObjectHeight}
-\newlength{\mcaption@ObjectRaise}
-\newlength{\mcaption@CaptionRaise}
-\newlength{\mcaption@tempdima}
-\newenvironment{margincap}[2][\mcaption@DefaultOpt]{%
+\newenvironment{mcaption@mcIIdotII}[2][\mcaption@DefaultOpt]{%
\def\mcaption@DefaultOpt{#2}%
- \begin{lrbox}{\mcaption@CaptionBox}%
- \setlength{\mcaption@tempdima}{\marginparsep}%
- \addtolength{\mcaption@tempdima}{\marginparwidth}%
- \addtolength{\mcaption@tempdima}{-\margincapsep}%
- \begin{minipage}[\margincapalign]{\mcaption@tempdima}%
- \caption[#1]{#2}%
+ \def\mcaption@CaptionShort{#1}%
+ \def\mcaption@CaptionLong{#2}%
+ \gdef\mcaption@CaptionFlag{t}%
+ \gdef\mcaption@LabelFlag{f}%
+ \begin{lrbox}{\mcaption@ObjectBox}%
+ \begin{minipage}{\linewidth}%
+}{%
\end{minipage}%
\end{lrbox}%
+ \mcaption@align@boxes%
+ \mcaption@output@boxes%
+}%
+\newenvironment{mcaption@mcIIIdot}{%
+ \let\mcaption@origcaption\caption%
+ \let\caption\mcaption@caption%
+ \gdef\mcaption@CaptionFlag{f}%
+ \let\mcaption@origlabel\label%
+ \let\label\mcaption@label%
+ \gdef\mcaption@LabelFlag{f}%
\begin{lrbox}{\mcaption@ObjectBox}%
- \begin{minipage}[\margincapalign]{\linewidth}%
+ \begin{minipage}{\linewidth}%
}{%
\end{minipage}%
\end{lrbox}%
- \settoheight{\mcaption@ObjectHeight}{\usebox{\mcaption@ObjectBox}}%
- \ifthenelse{\equal{\margincapalign}{t}}{%
- \setlength{\mcaption@ObjectRaise}{-\mcaption@ObjectHeight}%
- \setlength{\mcaption@ObjectHeight}{0pt}%
- \settoheight{\mcaption@CaptionRaise}{\strut}%
- }{%
- \setlength{\mcaption@ObjectRaise}{0pt}%
- \setlength{\mcaption@CaptionRaise}{0pt}%
+ \let\caption\mcaption@origcaption%
+ \let\label\mcaption@origlabel%
+ \mcaption@align@boxes%
+ \mcaption@output@boxes%
+}%
+\newenvironment{margincap}{}{}%
+\let\margincap\mcaption@mcIIIdot%
+\let\endmargincap\endmcaption@mcIIIdot%
+\newcommand*{\mcaption@origcaption}{}
+\newcommand*{\mcaption@origlabel}{}
+\newcommand*{\mcaption@DefaultOpt}{}
+\newcommand*{\mcaption@caption}[2][\mcaption@DefaultOpt]{%
+ \gdef\mcaption@DefaultOpt{#2}%
+ \gdef\mcaption@CaptionShort{#1}%
+ \gdef\mcaption@CaptionLong{#2}%
+ \gdef\mcaption@CaptionFlag{t}%
+ \ignorespaces
+}%
+\newcommand*{\mcaption@label}[1]{%
+ \gdef\mcaption@Label{#1}%
+ \gdef\mcaption@LabelFlag{t}%
+ \ignorespaces
+}%
+\newcommand*{\mcaption@align@boxes}{%
+ \begin{lrbox}{\mcaption@CaptionBox}%
+ \setlength{\@tempdima}{\marginparwidth}%
+ \addtolength{\@tempdima}{\marginparsep}%
+ \addtolength{\@tempdima}{-\margincapsep}%
+ \begin{minipage}{\@tempdima}%
+ \if\mcaption@CaptionFlag t%
+ \setlength{\abovecaptionskip}{0pt}%
+ \setlength{\belowcaptionskip}{0pt}%
+ \caption[\mcaption@CaptionShort]{\strut\mcaption@CaptionLong\strut}%
+ \fi%
+ \if\mcaption@LabelFlag t%
+ \label{\mcaption@Label}%
+ \fi%
+ \end{minipage}%
+ \end{lrbox}%
+\sbox{\mcaption@ObjectBox}{%
+ \if\mcaption@alignv t\vtop
+ \else\vbox
+ \fi
+ {%
+ \vskip0pt%
+ \hbox{\usebox{\mcaption@ObjectBox}}%
+ \vskip0pt%
+ }%
+}%
+\sbox{\mcaption@CaptionBox}{%
+ \if\mcaption@alignv t\vtop
+ \else\vbox
+ \fi
+ {%
+ \vskip0pt%
+ \hbox{\usebox{\mcaption@CaptionBox}}%
+ \vskip0pt%
+ }%
+}%
+}%
+\newcommand*{\mcaption@output@oddpage}{%
+ \makebox[\linewidth][l]{%
+ \usebox{\mcaption@ObjectBox}%
+ \hspace*{\margincapsep}%
+ \smash{\usebox{\mcaption@CaptionBox}}%
}%
+}%
+\newcommand*{\mcaption@output@evenpage}{%
+ \makebox[\linewidth][r]{%
+ \smash{\usebox{\mcaption@CaptionBox}}%
+ \hspace*{\margincapsep}%
+ \usebox{\mcaption@ObjectBox}%
+ }%
+}%
+
+\newcommand*{\mcaption@output@boxes}{%
\if@twoside%
\checkoddpage%
+ \ifoddpage%
+ \mcaption@output@oddpage%
+ \else%
+ \mcaption@output@evenpage%
+ \fi%
\else%
- \cpoddpagetrue%
- \fi%
- \ifcpoddpage%
- \makebox[\linewidth][l]{%
- \raisebox{\mcaption@ObjectRaise}[\mcaption@ObjectHeight]{%
- \usebox{\mcaption@ObjectBox}%
- }%
- \hspace*{\margincapsep}%
- \raisebox{\mcaption@CaptionRaise}[0pt][0pt]{%
- \usebox{\mcaption@CaptionBox}%
- }%
- }%
- \else%
- \makebox[\linewidth][r]{%
- \raisebox{\mcaption@CaptionRaise}[0pt][0pt]{%
- \usebox{\mcaption@CaptionBox}%
- }%
- \hspace*{\margincapsep}%
- \raisebox{\mcaption@ObjectRaise}[\mcaption@ObjectHeight]{%
- \usebox{\mcaption@ObjectBox}%
- }%
- }%
+ \mcaption@output@oddpage%
\fi%
}%
\endinput