% \iffalse meta comment
% File: contour.dtx Copyright (C) 1999 Harald Harders
% \fi
%
% \iffalse
%
%<*package>
\def\packagename{contour}
\def\fileversion{1.03}
\def\filedate{2000/03/14}
\def\docdate{2000/03/14}
%</package>
%<*driver>
\documentclass{ltxdoc}
\IfFileExists{contour.sty}{\usepackage{contour}
 \let\contourSTYfound\active}{\GenericWarning{contour.dtx}{Package
 file contour.sty not found (Documentation will be messed up!^^J^^A
 Generate contour.sty by (La)TeXing contour.ins, process
 contour.dtx again)^^J}\stop}
\usepackage{longtable}
\usepackage{graphicx}
\usepackage{url}
\title{The \texttt{contour} package\thanks{This file has version
    \fileversion\ last revised \filedate, documentation dated \docdate.}}
\author{Harald Harders\\\texttt{h.harders@tu-bs.de}}
\date{File Date \filedate, Printed \today}
\newlength{\tempdima}%
\makeatletter
\renewenvironment{table}[1][]{%
  \@float{table}[#1]%
  \centering%
  \setlength{\tempdima}{\abovecaptionskip}%
  \setlength{\abovecaptionskip}{\belowcaptionskip}%
  \setlength{\belowcaptionskip}{\tempdima}%
  }{%
\end@float
}
\newcommand{\contoura}[2]{%
  \setlength{\con@length}{0.03em}%
  \con@put{1\con@length}{0\con@length}{\color{#1}\con@off#2\con@on}%
  #2%
}
\newcommand{\contourb}[2]{%
  \setlength{\con@length}{0.03em}%
  \con@put{1\con@length}{0\con@length}{\color{#1}\con@off#2\con@on}%
  \con@put{-1\con@length}{0\con@length}{\color{#1}\con@off#2\con@on}%
  #2%
}
\newcommand{\contourc}[2]{%
  \setlength{\con@length}{0.03em}%
  \con@put{1\con@length}{0\con@length}{\color{#1}\con@off#2\con@on}%
  \con@put{-1\con@length}{0\con@length}{\color{#1}\con@off#2\con@on}%
  \con@put{0\con@length}{1\con@length}{\color{#1}\con@off#2\con@on}%
  #2%
}
\newcommand{\contourd}[2]{%
  \setlength{\con@length}{0.03em}%
  \con@put{1\con@length}{0\con@length}{\color{#1}\con@off#2\con@on}%
  \con@put{-1\con@length}{0\con@length}{\color{#1}\con@off#2\con@on}%
  \con@put{0\con@length}{1\con@length}{\color{#1}\con@off#2\con@on}%
  \con@put{0\con@length}{-1\con@length}{\color{#1}\con@off#2\con@on}%
  #2%
}
\newcommand{\contoure}[2]{%
  \setlength{\con@length}{0.03em}%
  \con@put{1\con@length}{0\con@length}{\color{#1}\con@off#2\con@on}%
  \con@put{-1\con@length}{0\con@length}{\color{#1}\con@off#2\con@on}%
  \con@put{0\con@length}{1\con@length}{\color{#1}\con@off#2\con@on}%
  \con@put{0\con@length}{-1\con@length}{\color{#1}\con@off#2\con@on}%
  \con@put{0.707\con@length}{0.707\con@length}{\color{#1}\con@off#2\con@on}%
  \con@put{0.707\con@length}{-0.707\con@length}{\color{#1}\con@off#2\con@on}%
  \con@put{-0.707\con@length}{0.707\con@length}{\color{#1}\con@off#2\con@on}%
  \con@put{-0.707\con@length}{-0.707\con@length}{\color{#1}\con@off#2\con@on}%
  #2%
}
\makeatother
\EnableCrossrefs
\CodelineIndex
\DoNotIndex{\def,\edef,\let,\newcommand,\newenvironment,\newcounter}
\DoNotIndex{\setcounter,\space}
\CodelineNumbered
\RecordChanges
\CheckSum{259}
\begin{document}
 \DocInput{contour.dtx}
\end{document}
%</driver>
% \fi
%
% \maketitle
% \begin{abstract}
% \noindent This package is based on an idea of Richard Pfeiffer
% (\url{richard.pfeiffer@t-online.de}). It generates a colored contour
% around a given text in order to enable printing text over a
% background without the need of a color box around the text.
% \end{abstract}
%
% \tableofcontents
%
% \section*{Copyright}
% Copyright  1999, 2000 Harald Harders.
%
% This program can be redistributed and/or modified under the terms
% of the LaTeX Project Public License Distributed from CTAN
% archives in directory macros/latex/base/lppl.txt; either
% version 1 of the License, or any later version.
%
% \section{Introduction}
% Sometimes it is necessary to print text over a background that is
% not pure white e.\,g. in gnuplot plots. It is not always wished to
% plot the text in a rectangular box since this can cover important
% information or look poor. This package provides a solution to cover
% less space with the text and ensure readable text in the same time.
%
% The used technique is quite simple. In a circle
% around the original text position the same text 
% is printed evenly distributed 16 or 32 times. The default radius for the
% circle is $0.03\,\mathrm{em}$.
%
% \section{User interface}
% To use this package place\\
% \hspace*{1cm}\verb|\usepackage{contour}|\\
% in the preamble of your document. No options are necessary.
%
% The package provides the commands\\
% \hspace*{1cm}\verb|\contour{<color>}{<text>}| and\\
% \hspace*{1cm}\verb|\contour*{<color>}{<text>}|\\
% which produce the text \verb|<text>| with a colored contour around. 
% The \verb|*| variant makes 32 instead of 16 copies.
%
% The radius of the circle (= thickness of the contour) can be changed using
% the command \verb|\contourlength{<length>}|, where \verb|<length>| is a
% length understood by \LaTeX. The length is not expanded when defining the
% contour length but when using it. For example when using \verb|0.05em|, 
% $0.05\,\mathrm{em}$ of the font used in the command \verb|\contour| are used.
%
% \section{Example}
% The command\\
% \hspace*{1cm}%
% \verb|\colorbox{black}{This text is not visible |%
% \verb|\contour{yellow}{but this is}}|\\
% produces:\\
% \colorbox{black}{This text is not visible \contour{yellow}{but this is}}
%
% Another example is shown in figure~\ref{fig:comparison}.
% \begin{figure}[h!tbp]
% \centering
% \begin{minipage}{0.6\linewidth}
% \centering
% \unitlength1mm
% \begin{picture}(50,30)%
% \put(0,0){\line(1,0){50}}%
% \put(0,30){\line(1,0){50}}%
% \put(0,0){\line(0,1){30}}%
% \put(50,0){\line(0,1){30}}%
% \put(0,25){\line(1,1){5}}%
% \put(0,20){\line(1,1){10}}%
% \put(0,15){\line(1,1){15}}%
% \put(0,10){\line(1,1){20}}%
% \put(0,5){\line(1,1){25}}%
% \multiput(0,0)(5,0){5}{\line(1,1){30}}%
% \put(25,0){\line(1,1){25}}%
% \put(30,0){\line(1,1){20}}%
% \put(35,0){\line(1,1){15}}%
% \put(40,0){\line(1,1){10}}%
% \put(45,0){\line(1,1){5}}%
% \put(0,5){\line(1,-1){5}}%
% \put(0,10){\line(1,-1){10}}%
% \put(0,15){\line(1,-1){15}}%
% \put(0,20){\line(1,-1){20}}%
% \put(0,25){\line(1,-1){25}}%
% \multiput(0,30)(5,0){5}{\line(1,-1){30}}%
% \put(25,30){\line(1,-1){25}}%
% \put(30,30){\line(1,-1){20}}%
% \put(35,30){\line(1,-1){15}}%
% \put(40,30){\line(1,-1){10}}%
% \put(45,30){\line(1,-1){5}}%
% \put(25,23){\makebox(0,0)%
%   {{\Large\colorbox{white}{text with colorbox}}}}%
% \put(25,15){\makebox(0,0)%
%   {{\Large\contour{white}{text with contour}}}}%
% \put(25,7){\makebox(0,0)%
%   {{\Large simple text}}}%
% \end{picture}
% \caption[]{Comparison of the commands 
% \texttt{\bslash colorbox\{white\}\{$<$text$>$\}} and 
% \texttt{\bslash contour\{$<$text$>$\}}}
% \label{fig:comparison}
% \end{minipage}
% \end{figure}
%
% In figure~\ref{fig:anzahl} you can see the looking of the output
% depending on the number of copies.
% \begin{figure}[h!tbp]
% \centering
% \begin{minipage}{0.85\linewidth}
% \centering
% \let\lw\linewidth
% \definecolor{gray50}{rgb}{0.5,0.5,0.5}
% \begin{minipage}{0.3\lw}
% \resizebox{\lw}{!}{\colorbox{gray50}{{\Huge\contoura{white}{Test}}}}\\%
% a) 1 white copy
% \end{minipage}
% \hfill
% \begin{minipage}{0.3\lw}
% \resizebox{\lw}{!}{\colorbox{gray50}{{\Huge\contourb{white}{Test}}}}\\%
% b) 2 white copies
% \end{minipage}
% \hfill
% \begin{minipage}{0.3\lw}
% \resizebox{\lw}{!}{\colorbox{gray50}{{\Huge\contourc{white}{Test}}}}\\%
% c) 3 white copies
% \end{minipage}\\[5pt]
% \begin{minipage}{0.3\lw}
% \resizebox{\lw}{!}{\colorbox{gray50}{{\Huge\contourd{white}{Test}}}}\\%
% e) 4 white copies
% \end{minipage}
% \hfill
% \begin{minipage}{0.3\lw}
% \resizebox{\lw}{!}{\colorbox{gray50}{{\Huge\contoure{white}{Test}}}}\\%
% f) 8 white copies
% \end{minipage}
% \hfill
% \begin{minipage}{0.3\lw}
% \resizebox{\lw}{!}{\colorbox{gray50}{{\Huge\contour{white}{Test}}}}\\%
% g) 16 white copies
% \end{minipage}\\[5pt]
% \begin{minipage}{0.3\lw}
% \resizebox{\lw}{!}{\colorbox{gray50}{{\Huge\contour*{white}{Test}}}}\\%
% h) 32 white copies
% \end{minipage}
% \caption{Looking of the contour with different numbers of copies}
% \label{fig:anzahl}
% \end{minipage}
% \end{figure}
%
%
% \StopEventually{\PrintChanges \PrintIndex}
%
%
% \section{The implementation}
% \iffalse
%<*package>
% \fi
% Heading of the package:
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{contour}
         [\filedate\space version \fileversion]
\message{Package `contour', Version \fileversion\space of \filedate.}
%    \end{macrocode}
% This package requires the color package from the graphics bundle:
%    \begin{macrocode}
\RequirePackage{color}
%    \end{macrocode}
% Set text to a specified relative position without using space:
%    \begin{macrocode}
\newcommand{\con@put}[3]{\makebox[0pt][l]{\hspace*{#1}\raisebox{#2}[0pt]{#3}}}
%old version (did not work with characters with depth (e.g. g, y, q))
%\newcommand{\con@put}[3]{\makebox(0,0)[lb]{\hspace*{#1}\vspace*{#2}#3}}
%old version (did not work within \makebox macro:
%\newcommand{\con@put}[3]{\hbox to 0pt{\hskip#1\vbox to 0pt{\vskip#2\vbox 
%      to 0pt{\vss\noindent#3}\vss}\hss}}
%    \end{macrocode}
% Rename \verb|\color| command to \verb|con@color|. This is down in
% order to prevent the background text color from being changed:
%    \begin{macrocode}
\def\con@off{\let\con@color=\color%
          \def\color##1##2{##2}}%
%    \end{macrocode}
% Restor \verb|color| command:
%    \begin{macrocode}
\def\con@on{\let\color=\con@color}
%    \end{macrocode}
% \begin{macro}{\contourlength}
% Define the commands for changing the base length:
%    \begin{macrocode}
\newcommand{\contourlength}[1]{\def\contourbaselength{#1}}
\contourlength{0.03em}
%    \end{macrocode}
% \end{macro}
% Define new offset length:
%    \begin{macrocode}
\newlength{\con@length}
%    \end{macrocode}
% \begin{macro}{\contour}
% The new macro for producing text with a white contour.
%
% Devide between a normal and a star version.
%    \begin{macrocode}
\newcommand{\contour}{\@ifstar{\@contour[*]}{\@contour}}
%    \end{macrocode}
% The command itself. The optional parameter is used for the star version
% \verb|\contour*|.
%    \begin{macrocode}
\newcommand{\@contour}[3][\@empty]{%
%    \end{macrocode}
% Specifiing the offset length relative to the text size
%    \begin{macrocode}
  \setlength{\con@length}{\contourbaselength}%
%    \end{macrocode}
% Put the text many times around the current text position.\\
% $0^\circ$, $90^\circ$, $180^\circ$ and $270^\circ$:
%    \begin{macrocode}
  \con@put{1\con@length}{0\con@length}{\color{#2}\con@off#3\con@on}%
  \con@put{-1\con@length}{0\con@length}{\color{#2}\con@off#3\con@on}%
  \con@put{0\con@length}{1\con@length}{\color{#2}\con@off#3\con@on}%
  \con@put{0\con@length}{-1\con@length}{\color{#2}\con@off#3\con@on}%
%    \end{macrocode}
% $45^\circ$, $135^\circ$, $225^\circ$ and $315^\circ$:
%    \begin{macrocode}
  \con@put{0.707\con@length}{0.707\con@length}{\color{#2}\con@off#3\con@on}%
  \con@put{0.707\con@length}{-0.707\con@length}{\color{#2}\con@off#3\con@on}%
  \con@put{-0.707\con@length}{0.707\con@length}{\color{#2}\con@off#3\con@on}%
  \con@put{-0.707\con@length}{-0.707\con@length}{\color{#2}\con@off#3\con@on}%
%    \end{macrocode}
% $22.5^\circ$, $67.5^\circ$, $112.5^\circ$, $157.5^\circ$ \dots:
%    \begin{macrocode}
  \con@put{0.383\con@length}{0.924\con@length}{\color{#2}\con@off#3\con@on}%
  \con@put{0.383\con@length}{-0.924\con@length}{\color{#2}\con@off#3\con@on}%
  \con@put{-0.383\con@length}{0.924\con@length}{\color{#2}\con@off#3\con@on}%
  \con@put{-0.383\con@length}{-0.924\con@length}{\color{#2}\con@off#3\con@on}%
  \con@put{0.924\con@length}{0.383\con@length}{\color{#2}\con@off#3\con@on}%
  \con@put{0.924\con@length}{-0.383\con@length}{\color{#2}\con@off#3\con@on}%
  \con@put{-0.924\con@length}{0.383\con@length}{\color{#2}\con@off#3\con@on}%
  \con@put{-0.924\con@length}{-0.383\con@length}{\color{#2}\con@off#3\con@on}%
%    \end{macrocode}
% $11.25^\circ$, $33.75^\circ$, $56.25^\circ$ \dots:
%    \begin{macrocode}
  %
\ifx#1\@empty%
\else%
  \con@put{0.195\con@length}{0.981\con@length}{\color{#2}\con@off#3\con@on}%
  \con@put{0.195\con@length}{-0.981\con@length}{\color{#2}\con@off#3\con@on}%
  \con@put{-0.195\con@length}{0.981\con@length}{\color{#2}\con@off#3\con@on}%
  \con@put{-0.195\con@length}{-0.981\con@length}{\color{#2}\con@off#3\con@on}%
  \con@put{0.981\con@length}{0.195\con@length}{\color{#2}\con@off#3\con@on}%
  \con@put{0.981\con@length}{-0.195\con@length}{\color{#2}\con@off#3\con@on}%
  \con@put{-0.981\con@length}{0.195\con@length}{\color{#2}\con@off#3\con@on}%
  \con@put{-0.981\con@length}{-0.195\con@length}{\color{#2}\con@off#3\con@on}%
  \con@put{0.556\con@length}{0.831\con@length}{\color{#2}\con@off#3\con@on}%
  \con@put{0.556\con@length}{-0.831\con@length}{\color{#2}\con@off#3\con@on}%
  \con@put{-0.556\con@length}{0.831\con@length}{\color{#2}\con@off#3\con@on}%
  \con@put{-0.556\con@length}{-0.831\con@length}{\color{#2}\con@off#3\con@on}%
  \con@put{0.831\con@length}{0.556\con@length}{\color{#2}\con@off#3\con@on}%
  \con@put{0.831\con@length}{-0.556\con@length}{\color{#2}\con@off#3\con@on}%
  \con@put{-0.831\con@length}{0.556\con@length}{\color{#2}\con@off#3\con@on}%
  \con@put{-0.831\con@length}{-0.556\con@length}{\color{#2}\con@off#3\con@on}%
\fi%
  %
%    \end{macrocode}
% Print the normal text:
%    \begin{macrocode}
  #3%
}
%    \end{macrocode}
% \end{macro}
% The end of the style file
%    \begin{macrocode}
\endinput
%    \end{macrocode}
% \message{^^J^^JRun dvips contour to generate a postscript file.^^J^^J}
% \iffalse
%</package>
% \fi
% \Finale
