%%
%% This is file `mcaption.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% mcaption.dtx  (with options: `package')
%% 
%% This is a generated file.
%% 
%% Copyright (C) 2005 by Stephan Hennig <stephanhennig@arcor.de>
%% 
%% This file may be distributed and/or modified under the conditions of
%% the LaTeX Project Public License, either version 1.2 of this license
%% or (at your option) any later version.  The latest version of this
%% license is in:
%% 
%%    http://www.latex-project.org/lppl.txt
%% 
%% and version 1.2 or later is part of all distributions of LaTeX version
%% 1999/12/01 or later.
%% 
\ProvidesPackage{mcaption}
  [2009/03/13 v3.0 Put captions into the outer document margin (SH)]
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\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}
\newenvironment{mcaption@mcIIdotII}[2][\mcaption@DefaultOpt]{%
  \def\mcaption@DefaultOpt{#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}{\linewidth}%
}{%
    \end{minipage}%
  \end{lrbox}%
  \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%
    \mcaption@output@oddpage%
  \fi%
}%
\endinput
%%
%% End of file `mcaption.sty'.