
% \iffalse
%
% This file is part of the array package.
% ---------------------------------------
%
% This file was contributed. In case of error please inform the
% original author.
%
% \fi

%\iffalse
%%% ====================================================================
%%%  @LaTeX-style-file{
%%%     author          = "David Carlisle",
%%%     version         = "1.01",
%%%     date            = "12 June 1992",
%%%     time            = "16:24:45 BST",
%%%     filename        = "dcolumn.sty",
%%%     address         = "Computer Science Department
%%%                        Manchester University
%%%                        Oxford Road
%%%                        Manchester
%%%                        England
%%%                        M13 9PL",
%%%     telephone       = "+44 61 275 6139",
%%%     FAX             = "+44 61 275 6236",
%%%     checksum        = "48012 272 1205 9538",
%%%     email           = "carlisle@cs.man.ac.uk (Internet)",
%%%     codetable       = "ISO/ASCII",
%%%     keywords        = "LaTeX, tabular, array, decimal",
%%%     supported       = "yes",
%%%     docstring       = "
%%%
%%%     dcolumn.sty
%%%
%%%     A LaTeX style option for producing tabular entries aligned on a
%%%     decimal point.
%%%     The `decimal point' may be any math-mode material, or just `.'.
%%%
%%%     Requires array.sty.
%%%     Documentation requires Mittelbach's doc.sty.
%%%
%%%     The checksum field above was produced by
%%%     Robert Solovay's checksum utility.",
%%%  }
%%% ====================================================================
%
% Version 1.0 17 February 1992
% Version 1.01 Re-issue for the new doc and docstrip.
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\fi
%
\def\fileversion{v1.01}
\def\filedate{92/06/12}
\def\docdate {92/06/17}
%
% \CheckSum{155}
% \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         \~}
%
%
% \title{dcolumn.sty\thanks
%   {Version \fileversion, revised \filedate, documentation dated
%   \docdate}}
% \author{D. P. Carlisle}
% \date{12 June 1992}
%
% \maketitle
% \begin{abstract}
% This style defines a system for defining columns of entries in an {\tt
% array} or {\tt tabular} which are to be aligned on a `decimal point'.
% \end{abstract}
%
% This style defines {\tt D} to be a column specifier with three
% arguments.\\
% "D{"\meta{sep.tex}"}{"\meta{sep.dvi}"}{"\meta{decimal
% places}"}"
%
% \meta{sep.tex} should be a single character, this is used as the
% separator in the {\tt .tex} file. Thus it will usually be `{\tt.}' or
% `{\tt,}'.
%
% \mbox{\meta{sep.dvi}} is used as the separator in the output, this may
% be the same as the first argument, but may be any math-mode
% expression, such as "\cdot".
%
% \meta{decimal places} should be the maximum number of decimal places
% in the column. If this is negative, any number of decimal places can
% be used in the column, and all entries will be centred on the
% separator. Note that this can cause a column to be too wide, compare
% the first two columns in the example below. If this argument is
% positive, the column uses macros equivalent to "\rightdots"
% "\endrightdots" of {\tt array.sty}, otherwise the macros are
% essentially equivalent to "\centerdots" "\endcenterdots".
%
% You may not want to use all three entries in the {\tt array} or {\tt
% tabular} preamble, so you may define your own preamble specifiers
% using "\newcolumntype".
%
% For example we may say:
%
% \noindent"\newcolumntype{d}[1]{D{.}{\cdot}{#1}}"
%
% {\tt d} takes a single argument specifying the number of decimal
% places, and the {\tt .tex} file should use {\tt.}, with $\cdot$ being
% used in the output.
%
% \noindent"\newcolumntype{.}{D{.}{.}{-1}}"
%
% {\tt .} specifies a column of entries to be centred on the $.$.
%
% \noindent"\newcolumntype{,}{D{,}{,}{2}}"
%
% {\tt ,} specifies takes a column of entries with at most two decimal
% places after a $,$.
%
% \newcolumntype{d}[1]{D{.}{\cdot}{#1}}
% \newcolumntype{.}{D{.}{.}{-1}}
% \newcolumntype{,}{D{,}{,}{2}}
%
% The following table begins "\begin{tabular}{|d{-1}|d{2}|.|,|}"
%
% \begin{center}
% \begin{tabular}{|d{-1}|d{2}|.|,|}
% 1.2   & 1.2   &1.2    &1,2    \\
% 1.23  & 1.23  &12.5   &300,2  \\
% 1121.2& 1121.2&861.20 &674,29 \\
% 184   & 184   &10     &69     \\
% .4    & .4    &       &,4     \\
%       &       &.4     &
% \end{tabular}
% \end{center}
%
% Note that the first column, which had a negative \meta{decimal places}
% argument is wider than the second column, so that the decimal point
% appears in the middle of the column.
%
% Also note that this style deals correctly with entries with no decimal
% part, no integer part, and blank entries.
%
% \StopEventually{}
%
%
% \section{The Macros}
%
%    \begin{macrocode}
%<*style>
\@ifundefined{DC@centre}{}{\endinput}
\wlog{Style-Option: `dcolumn' \fileversion
         \space\space <\filedate> (D.P.C.)}
\wlog{English documentation dated \space <\docdate> (D.P.C.)}
%    \end{macrocode}
%
% First we load {\tt array.sty} if it not already loaded.
%    \begin{macrocode}
\@ifundefined{newcolumntype}{\input array.sty}{}
%    \end{macrocode}
%
% The basic ideas behind these macros are explained in the documentation
% for {\tt array.sty}. However they use three
% tricks which may be useful in other contexts.
% \begin{itemize}
% \item The separator is surrounded in extra "{ }", so that it is set
% with "\mathord" spacing, otherwise, for instance a `,' would have
% extra space after it.
% \item The separator is not given its special definition by making it
% active, as this would not work for an entry such as "& .5 &", as the
% first token of an alignment entry is read {\em before\/} the preamble
% part, incase it is an "\omit", in which case the preamble is to be
% omitted. Instead we switch the mathcode to (hex) 8000, which makes the
% token act as if it were active.
% \item Although \verb|\mathcode`.="8000|  makes {\tt.} act as if it
% were active, it is still not allowed in constructions such as
% "\def.{}", even in math-mode, so we have to construct an active
% version of the separator, this is done by making it the uppercase of
% "~", and then using the construct\\
% "\uppercase{\def~}{"\meta{definition}"}".\\
% Note that the \meta{definition} is not uppercased, so the definition
% can refer to the standard, non-active use of the separator.
% \end{itemize}
%    \begin{macrocode}
\def\DC@#1#2#3{%
  \uccode`\~=`#1\relax
  \m@th
  \ifnum #3 < \z@ \expandafter\DC@centre
  \else \expandafter\DC@right \fi
  {#1}{#2}{#3}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\DC@centre#1#2#3{%
  \let\DC@end\DC@endcentre
  \uppercase{\def~}{$\egroup\setbox\tw@=\hbox\bgroup${#2}}%
  \setbox\tw@=\hbox{${\phantom{{#2}}}$}%
  \setbox\z@=\hbox\bgroup$\mathcode`#1="8000 }
%    \end{macrocode}
%
%    \begin{macrocode}
\def\DC@endcentre{$\egroup
    \ifdim \wd\z@>\wd\tw@
      \setbox\tw@=\hbox to\wd\z@{\unhbox\tw@\hfill}%
    \else
      \setbox\z@=\hbox to\wd\tw@{\hfill\unhbox\z@}\fi
    \box\z@\box\tw@}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\DC@right#1#2#3{%
  \let\DC@end\DC@endright
  \uppercase{\def~}{$\egroup\setbox\tw@=\hbox to \dimen@\bgroup${#2}}%
   \setbox\z@=\hbox{$1$}\dimen@=#3\wd\z@
   \setbox\z@=\hbox{${#2}$}\advance\dimen@\wd\z@
   \setbox\tw@=\hbox to \dimen@{}%
   \setbox\z@=\hbox\bgroup$\mathcode`#1="8000 }
%    \end{macrocode}
%
%    \begin{macrocode}
\def\DC@endright{$\hfil\egroup\hfill\box\z@\box\tw@}
%    \end{macrocode}
%
% The user interface, define the {\tt D} column to take three arguments.
%    \begin{macrocode}
\newcolumntype{D}[3]{>{\DC@{#1}{#2}{#3}}c<{\DC@end}}
%    \end{macrocode}
%
%    \begin{macrocode}
%</style>
%    \end{macrocode}
%
% \section{The documentation driver file}
%
% The next bit of code contains the documentation driver file for
% \TeX{}, i.e., the file that will produce the documentation you are
% currently reading. It will be extracted from this file by the {\tt
% docstrip} program.
%    \begin{macrocode}
%<+driver>\documentstyle[dcolumn,doc]{article}
%<+driver>
%<+driver>% dimensions from ltugboat.sty:
%<+driver>
%<+driver>\setlength\textwidth{31pc} \setlength\textheight{54pc}
%<+driver>\parindent 0pt \parskip 2pt plus 1pt minus 1pt
%<+driver>\setlength{\oddsidemargin}{8pc}
%<+driver>\setlength{\marginparwidth}{8pc}
%<+driver>\setlength{\topmargin}{-2.5pc}
%<+driver>\setlength{\headsep}{20pt}
%<+driver>\setlength{\columnsep}{1.5pc}
%<+driver>\setlength{\columnwidth}{18.75pc}
%<+driver>
%<+driver>\MakeShortVerb{\"}  % "\foo" acts like \verb+\foo+
%<+driver>
%<+driver>\DisableCrossrefs
%<+driver>
%<+driver>\CodelineIndex                  % Index code by line number
%<+driver>
%<+driver>%\OnlyDescription    % comment out for implementation details
%<+driver>
%<+driver>\setcounter{StandardModuleDepth}{1}
%<+driver>
%<+driver>\begin{document}
%<+driver>   \DocInput{dcolumn.doc}
%<+driver>\end{document}
%    \end{macrocode}
%
%
% \Finale
\endinput

