% \iffalse meta-comment % % Copyright 1993 1994 1995 1996 1997 1998 1999 % The LaTeX3 Project and any individual authors listed elsewhere % in this file. % % This file is part of the Standard LaTeX `Tools Bundle'. % ------------------------------------------------------- % % It 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. % % The list of all files belonging to the LaTeX `Tools Bundle' is % given in the file `manifest.txt'. % % \fi % \iffalse %% File: dcolumn.dtx Copyright (C) 1992-1996 1999 David Carlisle % %<*dtx> \ProvidesFile{f-dcolumn.dtx} % %\NeedsTeXFormat{LaTeX2e} %\ProvidesPackage{dcolumn} %\ProvidesFile{dcolumn.drv} % \fi % \ProvidesFile{f-dcolumn.dtx} [1999/07/05 v1.05 decimal alignment package (DPC)] % % \iffalse %<*driver> \documentclass{ltxdoc} \usepackage{dcolumn} \usepackage[T1]{fontenc} \usepackage{lmodern} \usepackage[english,frenchb]{babel} \DeleteShortVerb{\|} \EnableCrossrefs %\DisableCrossrefs % Say \DisableCrossrefs if index is ready \RecordChanges % Gather update information \CodelineIndex % Index code by line number %\OnlyDescription % comment out for implementation details %\OldMakeindex % use if your MakeIndex is pre-v2.9 \begin{document} \DocInput{f-dcolumn.dtx} \end{document} % % \fi % % \GetFileInfo{f-dcolumn.dtx} % % \title{Le package \textsf{dcolumn}\thanks{Ce fichier % a le num\'ero de version \fileversion, % r\'evis\'e le \filedate.}} % \author{David Carlisle \and % \makebox[0.9\linewidth]{Traduction fran\c{c}aise % par Jean-Pierre Drucbert\thanks{Derni\`ere mise \`a % jour le 19/01/2000}}} % \date{\filedate} % \maketitle % % \changes{v1.00}{1992/02/17}{Version initiale} % \changes{v1.01}{1992/06/12}{R\'e-\'edition pour les nouveaux doc et docstrip.} % \changes{v1.02}{1994/03/14}{R\'e-\'edition pour LaTeX2e} % \changes{v1.03}{1996/02/28}{Nouvelle fonctionnalit\'e, apr\`es tools/2093} % \changes{v1.05}{1999/07/05} % {changements mineurs dans la doc latex/3058} % % \CheckSum{143} % % % \begin{abstract} % Ce package permet de d\'efinir des entr\'ees de colonnes dans % un environnement \texttt{array} ou \texttt{tabular} qui doivent \^etre % align\'es sur un <<~point d\'ecimal~>>. % \end{abstract} % % \MakeShortVerb{\"} % % Ce package d\'efinit un sp\'ecificateur de colonne {\tt D} qui prend % trois arguments.\\ % "D{"\meta{sep.tex}"}{"\meta{sep.dvi}"}{"\meta{nombre de % d\'ecimales}"}" % % \begin{itemize} % \item % L'argument \meta{sep.tex} doit \^etre un unique caract\`ere, qui sera % utilis\'e comme s\'eparateur dans le fichier {\tt .tex}. Ce sera en % g\'en\'eral <<~{\tt .}~>> ou <<~{\tt ,}~>>. % % \item % L'argument \mbox{\meta{sep.dvi}} est utilis\'e comme s\'eparateur dans % la sortie, il peut \^etre identique au premier argument, mais peut % \^etre toute expression en mode math\'ematique, comme "\cdot". % Il faut noter que \texttt{dcolumn} utilise toujours le mode % math\'ematique pour \'ecrire les chiffres, ainsi que le s\'eparateur. % % \item % L'argument \meta{nombre de d\'ecimales} doit \^etre le nombre maximal % de chiffres plac\'es apr\`es la virgule dans la colonne. Si ce nombre % est n\'egatif, un nombre quelconque de chiffres pourra \^etre % utilis\'e dans la colonne, et toutes les entr\'ees seront centr\'ees % sur le s\'eparateur. Notez que ceci peut rendre la colonne trop % large, comme c'est le cas pour la premi\`ere colonne de l'exemple % ci-dessous. Si cet argument est positif, la colonne utilise des macros % \'equivalentes \`a "\rightdots" et "\endrightdots" de {\tt array.sty}, % sinon les macros sont essentiellement \'equivalentes \`a "\centerdots" % et "\endcenterdots". % \end{itemize} % % Vous pouvez ne pas d\'esirer utiliser toutes les trois entr\'ees dans % le pr\'eambule de {\tt array} ou {\tt tabular}, et vous pouvez % d\'efinir vos propres sp\'ecificateurs de pr\'eambule en utilisant % "\newcolumntype". % % Par exemple, nous pouvons \'ecrire: % % \noindent"\newcolumntype{d}[1]{D{.}{\cdot}{#1}}" % % {\tt d} prend un seul argument, qui sp\'ecifie le nombre de chiffres % d\'ecimaux, et le fichier {\tt .tex} utilisera un <<~{\tt .}~>>, tandis que % <<~$\cdot$~>> sera utilis\'e dans la sortie. % % \noindent"\newcolumntype{.}{D{.}{.}{-1}}" % % <<~{\tt .}~>> sp\'ecifie une colonne d'entr\'ees \`a centrer sur le % point~<<~$.$~>>. % % \noindent"\newcolumntype{,}{D{,}{,}{2}}" % % <<~{\tt ,}~>> sp\'ecifie qu'il faut prendre une colonne d'entr\'ees avec % au plus deux d\'ecimales apr\`es la virgule <<~$,$~>>. % % \newcolumntype{d}[1]{D{.}{\cdot}{#1}} % \newcolumntype{.}{D{.}{.}{-1}} % \newcolumntype{,}{D{,}{,}{2}} % % Avec ces d\'efinitions, la table d\'ecrite par: %\begin{verbatim} % \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} %\end{verbatim} %donne: % % \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} % % Notez que la premi\`ere colonne, qui a un \meta{nombre de d\'ecimales} % n\'egatif (premier argument du sp\'ecificateur "d"), est plus % large que la seconde colonne, et donc le point d\'ecimal appara\^{\i}t % au milieu de la colonne. % % Notez aussi que les entr\'ees sans point d\'ecimal, sans partie % d\'ecimale ou sans partie enti\`ere sont correctement trait\'ees, % ainsi que les entr\'ees vides. % % Si vous avez des cellules avec en-t\^etes, entr\'ees avec % "\multicolumn{1}{c}{..}" pour remplacer le type de colonne "D"), alors % il se peut qu'aucune des deux formes <<~centr\'ees~>> et <<~align\'ees % \`a droite~>> ne soit satisfaisante. % \begin{center}\small % \begin{tabular}[t]{|D..{-1}|D..{1}|D..{5.1}|} %\multicolumn{1}{|c|}{titre}& %\multicolumn{1}{c|}{titre}& %\multicolumn{1}{c|}{titre}\\[3pt] % 1.2 & 1.2 &1.2 \\ % 11212.2& 11212.2&11212.2 \\ % .4 & .4 &.4 % \end{tabular} % \hfill % \begin{tabular}[t]{|D..{-1}|D..{1}|D..{1.1}|} %\multicolumn{1}{|c|}{en-t\^ete large}& %\multicolumn{1}{c|}{en-t\^ete large}& %\multicolumn{1}{c|}{en-t\^ete large}\\[3pt] % 1.2 & 1.2 &1.2 \\ % .4 & .4 &.4 % \end{tabular} % \end{center} % % Dans chacune de ces deux tables, la premi\`ere colonne est d\'efinie % par "D{.}{.}{-1}" pour afficher une colonne centr\'ee sur le <<~"."~>>, et % la seconde colonne est d\'efinie par "D{.}{.}{1}" pour afficher une % colonne cadr\'ee \`a droite. % % La colonne centr\'ee produit des colonnes qui sont plus larges que % n\'ecessaire pour s'assurer que le point d\'ecimal est centr\'e. % La deuxi\`eme colonne, qui est cadr\'ee \`a droite, n'a pas cet % inconv\'enient, mais sous un en-t\^ete large, l'apparence visuelle est % pas bonne avec peu de chiffres dans les colonnes. % % Dans la version v1.03, une troisi\`eme alternative a \'et\'e introduite. % Le troisi\`eme argument, \meta{nombre de d\'ecimales}, peut d\'efinir % \`a la fois le nombre de chiffres \`a gauche et \`a droite de la % virgule. La troisi\`eme colonne est d\'efinie par "D{.}{.}{5.1}" % dans la table de gauche ci-dessus, et par "D{.}{.}{1.1}" dans la table % de droite, pour indiquer respectivement <<~cinq chiffres \`a gauche et % un \`a droite~>> et <<~un chiffre \`a gauche et un chiffre \`a % droite~>>. Le <<~.~>> peut \^etre remplac\'e par <<~,~>> ou tout autre % caract\`ere dans cet argument. Les colonnes de chiffres sont alors % positionn\'ees de telle sorte qu'un nombre avec ce format soit % centr\'e dans la colonne. % \StopEventually{} % %\selectlanguage{english} % \section{The Macros} % % \begin{macrocode} %<*package> % \end{macrocode} % % First we load {\tt array.sty} if it not already loaded. % \begin{macrocode} \RequirePackage{array} % \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{macro}{\DC@} % \changes{v1.03}{1996/02/28}{New feature, after tools/2093} % Set up uppercase tables as required, and then grab the first part of % the numerical argument into "\count@". % \begin{macrocode} \def\DC@#1#2#3{% \uccode`\~=`#1\relax \m@th \afterassignment\DC@x\count@#3\relax{#1}{#2}} % \end{macrocode} % \end{macro} % % \begin{macro}{\DC@x} % \changes{v1.03}{1996/02/28}{Macro added} % If "\count@" is negative, centre on the decimal point. If it is % positive either "#1" will be empty in which case bad out decimal % part to the number of digits specified by "\count@" or (new feature % in v1.03) it is none empty in which case "\count@" contains the % number of digits to the left of the point, and "#1" contains a junk % token (probably ".") followed by the number of digits to the right % of the point. In either of these latter cases, "\DC@right" is used. % \begin{macrocode} \def\DC@x#1\relax#2#3{% \ifnum\z@>\count@ \expandafter\DC@centre \else \expandafter\DC@right \fi {#2}{#3}{#1}} % \end{macrocode} % \end{macro} % % \begin{macro}{\DC@centre} % If centering on the decimal point, just need to box up the two halves. % \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} % \end{macro} % % \begin{macro}{\DC@endcentre} % and then pad out the smaller of the two boxes so there is the same % amount of stuff either side of the point. % \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} % \end{macro} % % \begin{macro}{\DC@right} % \changes{v1.03}{1996/02/28}{Re-implemeted, after tools/2093} % This deals with both the cases where a specified number of decimal % places is given. % \begin{macrocode} \def\DC@right#1#2#3{% \ifx\relax#3\relax % \end{macrocode} % If "#3" is empty, add "\hfill" to right align the column, and % Just set "\DC@rl" to begin a group, so nothing fancy is done with % the whole number part. % \begin{macrocode} \hfill \let\DC@rl\bgroup \else % \end{macrocode} % Otherwise set "\DC@rl" so that the whole number part is put in a % box "\count@" times as wide as a digit. % In order to share code with the other branch, then move "#3" (the % number of decimal places) into "\count@" throwing away the `.' from % the user syntax. % \changes{v1.04}{1996/09/23}{Add \cs{hfill} so integer part % is still flush right if no decimal point used.} % \begin{macrocode} \edef\DC@rl{to\the\count@\dimen@ii\bgroup\hss\hfill}% \count@\@gobble#3\relax \fi % \end{macrocode} % % \begin{macrocode} \let\DC@end\DC@endright % \end{macrocode} % Box 2 contains the decimal part, set to "\dimen@" which is % calculated below to be "\count@" times the width of a digit, plus % the with of the `decimal point'. % \begin{macrocode} \uppercase{\def~}{$\egroup\setbox\tw@\hbox to\dimen@\bgroup${#2}}% \setbox\z@\hbox{$1$}\dimen@ii\wd\z@ \dimen@\count@\dimen@ii \setbox\z@\hbox{${#2}$}\advance\dimen@\wd\z@ \setbox\tw@\hbox to\dimen@{}% % \end{macrocode} % Box 0 contains the whole number part, either just at its natural % size for right aligned columns, or set to (the old value of) % "\count@" times the width of a digit. "\DC@rl" defined above % determines the two cases. % \begin{macrocode} \setbox\z@\hbox\DC@rl$\mathcode`#1="8000 } % \end{macrocode} % \end{macro} % % \begin{macro}{\DC@endright} % \changes{v1.03}{1996/02/28}{Re-implemeted, after tools/2093} % Just finish off the second box, and then put out both boxes. % \begin{macrocode} \def\DC@endright{$\hfil\egroup\box\z@\box\tw@} % \end{macrocode} % \end{macro} % % \begin{macro}{D} % The user interface, define the {\tt D} column to take three arguments. % For special purposes, you may need to directly access "\DC@" rather % than the "D" column, eg to get a bold version you could use %\begin{verbatim} % \newcolumntype{E}[3]{>{\boldmath\DC@{#1}{#2}{#3}}c<{\DC@end}} %\end{verbatim} % \begin{macrocode} \newcolumntype{D}[3]{>{\DC@{#1}{#2}{#3}}c<{\DC@end}} % \end{macrocode} % \end{macro} % % \begin{macrocode} % % \end{macrocode} % % % \Finale \endinput