%%
%% This is file `photo.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% photo.dtx  (with options: `package')
%% 
%% File: photo.dtx Copyright 1994 1998 1999 Volker Kuhlmann
%% All rights are reserved.
%%
\NeedsTeXFormat{LaTeX2e}[1998/06/01]
\ProvidesPackage{photo}
       [2004/07/15 v2.1f Placing photos in documents (VK)]
%%
%% \CharacterTable
%%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%%   Digits        \0\1\2\3\4\5\6\7\8\9
%%   Exclamation   \!     Double quote  \"     Hash (number) \#
%%   Dollar        \$     Percent       \%     Ampersand     \&
%%   Acute accent  \'     Left paren    \(     Right paren   \)
%%   Asterisk      \*     Plus          \+     Comma         \,
%%   Minus         \-     Point         \.     Solidus       \/
%%   Colon         \:     Semicolon     \;     Less than     \<
%%   Equals        \=     Greater than  \>     Question mark \?
%%   Commercial at \@     Left bracket  \[     Backslash     \\
%%   Right bracket \]     Circumflex    \^     Underscore    \_
%%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%%   Right brace   \}     Tilde         \~}
%%
\DeclareOption{shortlop}{\newcommand\lop@parskip{\parskip 0ex plus0.03ex}}
\DeclareOption{left}{\def\@OEPOSdflt{l}}
\DeclareOption{right}{\def\@OEPOSdflt{r}}
\DeclareOption{in}{\def\@OEPOSdflt{i}}
\DeclareOption{out}{\def\@OEPOSdflt{o}}
\DeclareOption{top}{\def\@CPOSdflt{t}}
\DeclareOption{center}{\def\@CPOSdflt{c}}
\DeclareOption{bottom}{\def\@CPOSdflt{b}}
\DeclareOption{under}{\def\@PPOSdflt{u}}
\DeclareOption{side}{\def\@PPOSdflt{s}}
\ExecuteOptions{out,center,under}
\ProcessOptions
\newcount\oe@labcnt
\newcommand\ifoddpage[3][]{%
\edef\ifoddpagelabel{#1}%
\ifx\ifoddpagelabel\empty
\global\advance\oe@labcnt 1%
\edef\ifoddpagelabel{oelbl@\romannumeral\oe@labcnt}%
\label\ifoddpagelabel
\fi
\ifodd0\page@ref@@\def\oe@temp{#2}\else\def\oe@temp{#3}\fi
\oe@temp
}
\newcommand\page@ref@@{\expandafter\expandafter\expandafter
\@secondoftwo\csname r@\ifoddpagelabel\endcsname}
\newcommand\boxbaset{\raisebox{-\height}}
\newcommand\boxbaseb{\raisebox{\depth}}
\newcommand\boxbasec[1]{\raisebox{-0.5\totalheight}{\boxbaseb{#1}}}
\newcounter{photo}
\renewcommand\thephoto{\@arabic\c@photo}
\newcommand\photoname{Photo}
\newcommand\listphotoname{List of Photos}
\def\fps@photo{tbp}
\def\ftype@photo{4}
\def\ext@photo{lop}
\def\fnum@photo{\photoname~\thephoto}
\newcommand\defaultphotoplacement[1]{\def\fps@photo{#1}}
\newenvironment{photo}%
               {\@float{photo}}%
               {\end@float}
\newenvironment{photo*}%
               {\@dblfloat{photo}}%
               {\end@dblfloat}
\newcommand\listofphotos{%
\begingroup
\csname lop@parskip\endcsname
\@ifundefined{chapter}{\section}{\chapter}*{\listphotoname
      \@mkboth{\MakeUppercase\listphotoname}%
              {\MakeUppercase\listphotoname}}%
    \@starttoc{\ext@photo}%
\endgroup
    }
\newcommand*\l@photo{\@dottedtocline{1}{1.5em}{2.3em}}
\newdimen\oecaptionsep
\newdimen\minoecaptionwidth
\newbox\oe@box
\oecaptionsep 10mm
\minoecaptionwidth 35mm
\newcommand\photographerfont{\tiny\sffamily}
\newcommand\putphoto[4][\@OEPOSdflt\@CPOSdflt\@PPOSdflt]{%
\par
\begingroup
\edef\@OEPOS{#1}\edef\@LAB{#2}\def\@PGR{#3}%
\setbox\oe@box\hbox{#4}%
\putphoto@ii
}
\newcommand*\putphoto@ii[2][]{%
\def\@TCAP{#1}\def\@CAP{#2}%
\def\@captype{photo}% make (photo-)\caption available outside float
\def\cap@width{\dimen0}% shortcut - w/o introducing a new variable
\def\@CPOS{\@CPOSdflt}\def\@PPOS{\@PPOSdflt}%
\def\@tempb{\@tfor\@tempa:=}%
\expandafter\@tempb\@OEPOS\do{%
  %\typeout{loop: \@tempa}
  \if l\@tempa \def\@OEPOS{l}\else
  \if r\@tempa \def\@OEPOS{r}\else
  \if i\@tempa \ifx\@PGR\empty\else
\ifoddpage[\@LAB]{\def\@OEPOS{l}}{\def\@OEPOS{r}}\fi\else
  \if o\@tempa \ifx\@PGR\empty\else
\ifoddpage[\@LAB]{\def\@OEPOS{r}}{\def\@OEPOS{l}}\fi\else
  \if u\@tempa \def\@PPOS{u}\else
  \if s\@tempa \def\@PPOS{s}\else
  \if t\@tempa \def\@CPOS{t}\else
  \if c\@tempa \def\@CPOS{c}\else
  \if b\@tempa \def\@CPOS{b}\else
  \PackageError{photo}{illegal pos: \@tempa}{}%
  \fi\fi\fi\fi\fi\fi\fi\fi\fi}%
\cap@width\columnwidth
\advance\cap@width-\wd\oe@box \advance\cap@width-\oecaptionsep
\ifdim\minoecaptionwidth>\cap@width\photo@ucap\else\photo@scap\fi
\endgroup
}
\newcommand\photo@ucap{%
\begingroup
\centering\parbox{\wd\oe@box}{%
\leavevmode\box\oe@box
\ifx\@PGR\empty\else
  \newline\photographerfont
  \if r\@OEPOS \raggedleft \fi
  \@PGR
\fi
}\par
\endgroup
\photo@caption
}
\newcommand\photo@scap{%
\abovecaptionskip\z@
\belowcaptionskip\z@
\leavevmode
\ifx\@PGR\empty\else\if s\@PPOS \if r\@OEPOS
  \rlap{\boxbaseb{\parbox{\cap@width}{%
    \photographerfont\raggedleft\@PGR}}}\fi\fi\fi
\boxbaseb{%
  \if l\@OEPOS
    \photo@lift{\wd\oe@box}{\box\oe@box}\hskip\oecaptionsep
      \photo@lift\cap@width\photo@caption
  \else
    \photo@lift\cap@width\photo@caption\hskip\oecaptionsep
      \photo@lift{\wd\oe@box}{\box\oe@box}%
  \fi
}%
\ifx\@PGR\empty\else
  \if u\@PPOS
    \newline\photographerfont\if r\@OEPOS \raggedleft \fi\@PGR
  \else\if l\@OEPOS
      \llap{\boxbaseb{\parbox{\cap@width}{\photographerfont\@PGR}}}\fi
  \fi
\fi
\par
}
\newcommand\photo@lift[2]{%
\csname boxbase\@CPOS\endcsname{\parbox{#1}{#2}}%
}
\newcommand\photo@caption{%
\ifx\@CAP\empty\else
\ifx\@TCAP\empty
\caption{\@CAP}\else
\caption[\@TCAP]{\@CAP}\fi
\ifx\@LAB\empty\else\label\@LAB\fi
\fi
}
\newenvironment{Photo}[3][\@OEPOSdflt\@CPOSdflt\@PPOSdflt]{%
\par
\begingroup
\edef\@OEPOS{#1}\edef\@LAB{#2}\def\@PGR{#3}%
\@dblarg\Photo@ii
}{%
\end{lrbox}%
\def\@@t{photo}%
\if@twocolumn\ifdim\wd\oe@box>\columnwidth
\def\@@t{photo*}\columnwidth\textwidth
\fi\fi
\expandafter\begin\expandafter{\@@t}%
\begingroup
\putphoto@ii[\@TCAPf]\@CAPf
\expandafter\end\expandafter{\@@t}%
\endgroup
}
\newcommand\Photo@ii[2][]{%
\def\@TCAPf{#1}\def\@CAPf{#2}%
\begin{lrbox}\oe@box
}
\newcommand\phref[1]{photo~\ref{#1}}
\newcommand\Phref[1]{\photoname~\ref{#1}}
\endinput
%%
%% End of file `photo.sty'.
