%% DotArrow.dtx
%% Copyright 2008 Sven Schneider
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% 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.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
% This work has the LPPL maintenance status `maintained'.
% 
% The Current Maintainer of this work is Sven Schneider.
%
% This work consists of the files DotArrow.dtx, README, DotArrow.pdf and DotArrow.ins
% and the derived file DotArrow.sty, DotArrow.tex.

% Version 0.02a

%<*driver>
\documentclass{ltxdoc}


\usepackage[utf8]{inputenc}
\usepackage{epsfig,ifthen,amsmath,url,hyperref}

\usepackage{DotArrow}

\title{The DotArrow-Package\\ -- Dotted Extendable Arrows --}
\author{Sven Schneider}

\setlength{\parindent}{0pt}
\begin{document}
\maketitle

\begin{abstract}
This package defines a new extendable arrow. This time its a dotted one. Other interesting packages are \verb+extPfeil+\footnote{\url{http://tug.ctan.org/tex-archive/macros/latex/contrib/extpfeil/}} \verb+symbols+\footnote{\url{http://www.ctan.org/tex-archive/info/symbols/comprehensive/}} \verb+extarrows+\footnote{\url{http://tug.ctan.org/tex-archive/macros/latex/contrib/extarrows/}}
\verb+chemarrow+\footnote{\url{http://tug.ctan.org/tex-archive/macros/latex/contrib/chemarrow/}}.
\end{abstract}
\tableofcontents
\section{Simple Usage}
\DescribeMacro{\dotarrow}
	$S\dotarrow{\kappa}S^\prime$\\
	\verb+$S\dotarrow{\kappa}S^\prime$+
\section{Package - Options}
\DescribeMacro{Option:autosep**}
	These Package-Options can be used to adjust the space on left and right to the label. The default is \verb+autosep03+.

	\begin{center}
	\begin{tabular}{ll}
	autosep00 & \DotArrowSetSep{0.0em}$S\dotarrow{\kappa}S^\prime$\\
	autosep01 & \DotArrowSetSep{0.1em}$S\dotarrow{\kappa}S^\prime$\\
	autosep02 & \DotArrowSetSep{0.2em}$S\dotarrow{\kappa}S^\prime$\\
	autosep03 & \DotArrowSetSep{0.3em}$S\dotarrow{\kappa}S^\prime$\\
	autosep04 & \DotArrowSetSep{0.4em}$S\dotarrow{\kappa}S^\prime$\\
	autosep05 & \DotArrowSetSep{0.5em}$S\dotarrow{\kappa}S^\prime$\\
	autosep06 & \DotArrowSetSep{0.6em}$S\dotarrow{\kappa}S^\prime$\\
	autosep07 & \DotArrowSetSep{0.7em}$S\dotarrow{\kappa}S^\prime$\\
	autosep08 & \DotArrowSetSep{0.8em}$S\dotarrow{\kappa}S^\prime$\\
	autosep09 & \DotArrowSetSep{0.9em}$S\dotarrow{\kappa}S^\prime$\\
	autosep10 & \DotArrowSetSep{1.0em}$S\dotarrow{\kappa}S^\prime$
	\end{tabular}
	\end{center}

\DescribeMacro{Option:autoraise**}
	These Package-Options can be used to adjust the space between label and arrow. The default is \verb+autosep06+.

	\begin{center}
	\begin{tabular}{ll}
	autoraise00 & \DotArrowSetRaise{0.0ex}$S\dotarrow{\kappa}S^\prime$\\
	autoraise01 & \DotArrowSetRaise{0.1ex}$S\dotarrow{\kappa}S^\prime$\\
	autoraise02 & \DotArrowSetRaise{0.2ex}$S\dotarrow{\kappa}S^\prime$\\
	autoraise03 & \DotArrowSetRaise{0.3ex}$S\dotarrow{\kappa}S^\prime$\\
	autoraise04 & \DotArrowSetRaise{0.4ex}$S\dotarrow{\kappa}S^\prime$\\
	autoraise05 & \DotArrowSetRaise{0.5ex}$S\dotarrow{\kappa}S^\prime$\\
	autoraise06 & \DotArrowSetRaise{0.6ex}$S\dotarrow{\kappa}S^\prime$\\
	autoraise07 & \DotArrowSetRaise{0.7ex}$S\dotarrow{\kappa}S^\prime$\\
	autoraise08 & \DotArrowSetRaise{0.8ex}$S\dotarrow{\kappa}S^\prime$\\
	autoraise09 & \DotArrowSetRaise{0.9ex}$S\dotarrow{\kappa}S^\prime$\\
	autoraise10 & \DotArrowSetRaise{1.0ex}$S\dotarrow{\kappa}S^\prime$
	\end{tabular}
	\end{center}

\DescribeMacro{Option:head*}
	These Package-Options can be used to choose a different head. The default is \verb+head1+.

	\begin{center}
	\begin{tabular}{ll}
	head1 & \DotArrowSetHead{\ensuremath{\succ}}$S\dotarrow{\kappa}S^\prime$\\
	head2 & \DotArrowSetHead{\ensuremath{>}}$S\dotarrow{\kappa}S^\prime$\\
	head3 & \DotArrowSetHead{\ensuremath{\gg}}$S\dotarrow{\kappa}S^\prime$
	\end{tabular}
	\end{center}

\section{Commands}
\DescribeMacro{\DotArrowSetSep}
	Select a new separation-value. \verb+\DotArrowSetSep{0.3em}+

\DescribeMacro{\DotArrowSetRaise}
	Select a new raisevalue. \verb+\DotArrowSetRaise{0.6ex}+

\DescribeMacro{\DotArrowSetHead}
	Select a new arrowhead. \verb+\DotArrowSetHead{\ensuremath{\succ}}+

\end{document}
%</driver>

%<*package>
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{DotArrow}[2007/02/12 draw dotted arrows]

\RequirePackage{ifthen}

\PackageInfo{DotArrow}{This is the DotArrow-Package-0.02a}

% ####################################################
% Define Setters
% ####################################################
\newcommand{\DotArrowSetRaise}[1]{\setlength{\AUTORAISE}{#1}}
\newcommand{\DotArrowSetSep}[1]{\setlength{\AUTOSEP}{#1}}
\newcommand{\DotArrowSetHead}[1]{\renewcommand*{\ARROWHEAD}{\scalebox{.5}[.5]{#1}}}


\newlength{\AUTOSEP}
\setlength{\AUTOSEP}{0.3em}
\DeclareOption{autosep00}{\DotArrowSetSep{0.0em}}
\DeclareOption{autosep01}{\DotArrowSetSep{0.1em}}
\DeclareOption{autosep02}{\DotArrowSetSep{0.2em}}
\DeclareOption{autosep03}{\DotArrowSetSep{0.3em}}
\DeclareOption{autosep04}{\DotArrowSetSep{0.4em}}
\DeclareOption{autosep05}{\DotArrowSetSep{0.5em}}
\DeclareOption{autosep06}{\DotArrowSetSep{0.6em}}
\DeclareOption{autosep07}{\DotArrowSetSep{0.7em}}
\DeclareOption{autosep08}{\DotArrowSetSep{0.8em}}
\DeclareOption{autosep09}{\DotArrowSetSep{0.9em}}
\DeclareOption{autosep10}{\DotArrowSetSep{1.0em}}


\newlength{\AUTORAISE}
\setlength{\AUTORAISE}{0.6ex}
\DeclareOption{autoraise00}{\DotArrowSetRaise{0.0ex}}
\DeclareOption{autoraise02}{\DotArrowSetRaise{0.2ex}}
\DeclareOption{autoraise04}{\DotArrowSetRaise{0.4ex}}
\DeclareOption{autoraise06}{\DotArrowSetRaise{0.6ex}}
\DeclareOption{autoraise08}{\DotArrowSetRaise{0.8ex}}
\DeclareOption{autoraise10}{\DotArrowSetRaise{1.0ex}}
\DeclareOption{autoraise12}{\DotArrowSetRaise{1.2ex}}
\DeclareOption{autoraise14}{\DotArrowSetRaise{1.4ex}}
\DeclareOption{autoraise16}{\DotArrowSetRaise{1.6ex}}

\newcommand*{\ARROWHEAD}{\scalebox{.5}[.5]{$\succ$}}
\DeclareOption{head1}{\DotArrowSetHead{\ensuremath{\succ}}}
\DeclareOption{head2}{\DotArrowSetHead{\ensuremath{>}}}
\DeclareOption{head3}{\DotArrowSetHead{\ensuremath{\gg}}}

\ProcessOptions\relax

% ##################################################
% \newlength - commands
% ##################################################
% width of the printed horizontal bars
\newlength{\actualWidth}
% the width of one horizontal bar
\newlength{\oneWidth}
% the width of the text on top of the arrow
\newlength{\labelWidth}

% second store for the \labelWidth (the \labelWidth is used for calculation)
\newlength{\labelWidthBack}
% the distance to go backwards/forwards to print the 
% label/to print the arrowhead
\newlength{\captionStart}

% the distance of the bars from the baseline
\newlength{\moveUpBars}
% the distance of the label from the baseline
\newlength{\moveUpLabel}

% the distance the arrowhead is moved up
\newlength{\moveSuccHeight}
\newlength{\succHeight}
% \newcommand*{\ARROWHEAD}{\scalebox{.5}[.5]{$\succ$}}

% ##################################################
% \onePartX : prints one horizontal bar
% ##################################################
\newlength{\WIDTH}
\setlength{\WIDTH}{.4pt}

% this is one single horizontal bar
% \newcommand{\onePartX}{\raisebox{\moveUpBars}{\rule{2pt}{\WIDTH}}}
\newcommand*{\onePartX}{\raisebox{\moveUpBars}{\rule{2pt}{\WIDTH}}}
% oneWidth is the width of one such bar
\settowidth{\oneWidth}{\onePartX}

% ##################################################
% \allPartFront : print the first bar without any space around it
% ##################################################
\newcommand{\allPartFront}{
	% determine the actual width of the horizontal bars:
	\setlength{\actualWidth}{0pt}
	\onePartX%
	\addtolength{\labelWidth}{-\oneWidth}
	\addtolength{\actualWidth}{\oneWidth}
}

% ##################################################
% \allPartFront : prints all further bars with space on the left side
% ##################################################
\newcommand{\allPart}{%
	\ifthenelse{\labelWidth > 0}{%
		\hspace*{1.5pt}%
		\addtolength{\labelWidth}{-1.5pt}%
		\onePartX%
		\addtolength{\labelWidth}{-\oneWidth}%
		\addtolength{\actualWidth}{\oneWidth}%
		\addtolength{\actualWidth}{1.5pt}%
		\allPart%
	}{%
	}%
}%

% ##################################################
% \dotarrow : draws the whole arrow
% ##################################################
\newcommand{\dotarrow}[1]{%
	\setlength{\moveUpBars}{.8ex}%
	\addtolength{\moveUpBars}{-.5\WIDTH}%
	\setlength{\moveUpLabel}{\AUTORAISE}%
	\addtolength{\moveUpLabel}{\moveUpBars}%
	\addtolength{\moveUpLabel}{\WIDTH}%
	% print a little space at the left side
	\;%
	% get the width of the label
	\settowidth{\labelWidthBack}{\hspace*{\AUTOSEP}\scriptsize\ensuremath{#1}\hspace*{\AUTOSEP}}%
	\setlength{\labelWidth}{\labelWidthBack}%
	\setlength{\captionStart}{\labelWidth}%
	% and print the horizontal bars
	\allPartFront{}\allPart%
	% determine the space to go back to print the label
	\addtolength{\captionStart}{\actualWidth}%
	\setlength{\captionStart}{.5\captionStart}%
	% now go back
	\hspace*{-\captionStart}%
	% print the label
	\raisebox{\moveUpLabel}{\hspace*{\AUTOSEP}\scriptsize\ensuremath{#1}\hspace*{\AUTOSEP}}%
	% determine the space to go forward
	\setlength{\captionStart}{\actualWidth}%
	\addtolength{\captionStart}{-\labelWidthBack}%
	\setlength{\captionStart}{.5\captionStart}%
	% and go forward
	\hspace*{\captionStart}%
	% print the top of the arrow
	% arrowhead distance-calculation:
	\settoheight{\succHeight}{\ARROWHEAD}%
	\setlength{\succHeight}{.5\succHeight}%
	\setlength{\moveSuccHeight}{\moveUpBars}%
	\addtolength{\moveSuccHeight}{.5\WIDTH}%
	\addtolength{\moveSuccHeight}{-\succHeight}%
	\raisebox{\moveSuccHeight}{\ARROWHEAD}%
	% print a little space at the right side
	\;%
}%
%</package>