summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/decimalcomma
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2023-12-08 03:01:14 +0000
committerNorbert Preining <norbert@preining.info>2023-12-08 03:01:14 +0000
commit24d8cd26aa53d1cac2260d29c6cf1c387a61a32a (patch)
treec3d53bfadcc040224eee7bde265ae2dccd3408d2 /macros/latex/contrib/decimalcomma
parentd1c8f933dea4fce5c8b5628fe829cadf0b33b43d (diff)
CTAN sync 202312080301
Diffstat (limited to 'macros/latex/contrib/decimalcomma')
-rw-r--r--macros/latex/contrib/decimalcomma/README.md33
-rw-r--r--macros/latex/contrib/decimalcomma/decimalcomma.dtx189
-rw-r--r--macros/latex/contrib/decimalcomma/decimalcomma.ins55
-rw-r--r--macros/latex/contrib/decimalcomma/decimalcomma.pdfbin0 -> 88992 bytes
4 files changed, 277 insertions, 0 deletions
diff --git a/macros/latex/contrib/decimalcomma/README.md b/macros/latex/contrib/decimalcomma/README.md
new file mode 100644
index 0000000000..82fcc4ec61
--- /dev/null
+++ b/macros/latex/contrib/decimalcomma/README.md
@@ -0,0 +1,33 @@
+# The decimalcomma package
+
+
+## Presentation
+
+Many countries use a comma instead of a dot as a decimal separator.
+This small package offers a new definition of the comma `,` as an active character.
+It ensures the correct spacing in mathematical mode when using the comma either
+as decimal separator or as list separator.
+
+What's the difference compared to the well-known icomma or ncccomma packages?
+With decimalcomma, the comma behaves similarly to ncccomma, but the code is lighter,
+and several compatibility issues have been fixed.
+
+
+## Installation
+
+- run LaTeX on decimalcomma.ins, you obtain the file decimalcomma.sty,
+- if then you run pdfLaTeX on decimalcomma.dtx you get the file decimalcomma.pdf which is also in the archive,
+- put the files decimalcomma.sty and decimalcomma.pdf in your TeX Directory Structure.
+
+
+## Author
+
+Antoine Missier
+
+Email: antoine.missier@ac-toulouse.fr
+
+
+## License
+
+Released under the LaTeX Project Public License v1.3 or later.
+See http://www.latex-project.org/lppl.txt
diff --git a/macros/latex/contrib/decimalcomma/decimalcomma.dtx b/macros/latex/contrib/decimalcomma/decimalcomma.dtx
new file mode 100644
index 0000000000..ae1fb4fa99
--- /dev/null
+++ b/macros/latex/contrib/decimalcomma/decimalcomma.dtx
@@ -0,0 +1,189 @@
+% \iffalse meta-comment
+%
+% Copyright (C) 2023 by Antoine Missier <antoine.missier@ac-toulouse.fr>
+%
+% This file 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.
+% \fi
+%
+% \iffalse
+%<*driver>
+\ProvidesFile{decimalcomma.dtx}
+%</driver>
+%<*package>
+\NeedsTeXFormat{LaTeX2e}[2005/12/01]
+\ProvidesPackage{decimalcomma}
+ [2023/12/06 v1.0 .dtx decimalcomma file]
+%</package>
+%<*driver>
+\documentclass{ltxdoc}
+\usepackage[utf8]{inputenc}
+\usepackage[T1]{fontenc}
+\usepackage[english]{babel}
+\usepackage[charter]{mathdesign}
+\usepackage{decimalcomma}
+\usepackage{sectsty}
+\usepackage{xcolor}
+\usepackage{centeredline}
+
+\definecolor{darkbrown}{rgb}{0.5,0.1,0.1}
+\allsectionsfont{\color{darkbrown}}
+
+\DisableCrossrefs
+%\CodelineIndex
+%\RecordChanges
+\usepackage{hyperref}
+\hypersetup{%
+ colorlinks,
+ linkcolor=blue,
+ citecolor=red,
+ pdftitle={decimalcomma},
+ pdfsubject={LaTeX package},
+ pdfauthor={Antoine Missier}
+}
+\MakeShortVerb{"}
+\begin{document}
+\DocInput{decimalcomma.dtx}
+%\PrintChanges
+%\PrintIndex
+\end{document}
+%</driver>
+% \fi
+%
+% \CheckSum{26}
+%
+% \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 \~}
+%
+% \changes{v1.0}{2023/12/06}{Initial version}
+%
+% \GetFileInfo{decimalcomma.sty}
+%
+% \title{The \textsf{decimalcomma} package}
+% \author{Antoine Missier \\ \texttt{antoine.missier@ac-toulouse.fr}}
+% \date{\filedate, \fileversion}
+% \maketitle
+%
+% \section{Why this package?}
+%
+% In many countries, except notably in Anglo-Saxon countries,
+% the comma is used as a decimal separator for numbers.
+% However, in the math mode of \LaTeX, the comma is always, by default,
+% treated as a punctuation symbol and therefore is followed by a space.
+% This is appropriate in intervals: "$[a,b]$" results in $[a,b]$,
+% but is not appropriate for numbers where the comma represents the decimal separator.
+% For example, "$12,5$" is displayed as $12, 5$ instead of $12,5$.
+%
+% \medskip
+% Two very convenient packages allow handling the decimal comma. In math mode:
+% \begin{itemize}
+% \item With \textsf{icomma} (intelligent comma) by Walter Schmidt~\cite{ICOMMA},
+% the comma behaves as a punctuation character if it is followed by a space;
+% otherwise, it is treated as an ordinary character.
+% \item With \textsf{ncccomma} by Alexander I.~Rozhenko~\cite{NCC},
+% the comma behaves as an ordinary character if it is followed by a digit
+% (without a space); otherwise, it is considered a punctuation character.
+% \end{itemize}
+%
+% It appears that this second approach is preferable because unlike with icomma,
+% you are not required to add a space after the comma when it's not followed by a digit;
+% however, \textsf{ncccomma} poses several compatibility issues,
+% especially when used with \textsf{babel}
+% in conjunction with \textsf{numprint}~\cite{NUMP} and its \texttt{autolanguage} option
+% (at least for certain languages such as French and Spanish).
+% Another issue with \textsf{ncccomma} is that compiling with Lua\LaTeX,
+% \textsf{unicode-math}, and "\setmathfont" fails.
+%
+% Let it be noted that a code proposed by Claudio Beccari~\cite{BECC},
+% similar to that of \textsf{ncccomma}, presents the same type of issues.
+%
+% \medskip
+% Therefore, we propose a new package, functionally identical to that
+% of \textsf{ncccomma} but with lighter code and without the
+% aforementioned incompatibilities.
+%
+% \section{Bugs and problems}
+% Here, we are revisiting what Walter Schmidt wrote in the documentation of his
+% \textsf{icomma} package:
+%
+% In case the \textsf{decimalcomma} is used together with the \textsf{dcolumn} package,
+% a comma to be printed as the decimal separator in a column of type \texttt{D}
+% is to be specified as "{\mathord\mathcomma}", rather than "{,}",
+% since the latter leads to an error.
+% For instance:
+% \centeredline{"\begin{tabular}{... D{,}{\mathord\mathcomma}{2} ...}"}
+%
+% \medskip
+% Note that specifying the comma as the related input character works as usual.
+% Generally, since the \textsf{decimalcomma} package makes the comma ‘active’,
+% further problems are not unlikely.
+%
+% \StopEventually{}
+%
+% \section{Implementation}
+% We have taken up Walter Schmidt's fundamental idea for looking up the next character,
+% but with an execution loop to test all the digits from 0 to 9 instead of "\space".
+% We could have also used ten nested "\if" \ldots "\else" \ldots "\fi" structures
+% and that works very well.
+%
+% At |\begin{document}|, we store the original "\mathcode" of the comma,
+% in the |\mathcomma| macro, and then we make the comma active in math mode.
+% \begin{macrocode}
+\AtBeginDocument{%
+ \mathchardef\mathcomma\mathcode`\,%
+ \mathcode`\,="8000%
+}
+
+% \end{macrocode}
+% The active comma checks the next input character. If the next character is in
+% the list 0123456789,
+% the active comma returns |\mathord| with the saved |\mathcomma|,
+% so that no space will be added after the comma.
+% Otherwise, |\mathcomma| is returned without |\mathord|, thus the comma behaves
+% by default as a |\mathpunct|.
+% \begin{macrocode}
+{\catcode`,=\active
+ \gdef,{\futurelet\@next\sm@rtcomma}}
+
+\def\sm@rtcomma{%
+ \@tfor\@let@token:=0123456789%
+ \do{\expandafter\ifx\@let@token\@next\mathord\@break@tfor\fi}%
+ \mathcomma}
+
+% \end{macrocode}
+%
+% \begin{thebibliography}{4}
+% % \begin{raggedright}
+% \bibitem{ICOMMA} \emph{The \textsf{icomma} package for \LaTeXe}.
+% Walter Schmidt, CTAN, v2.0 2002/03/10.
+% \bibitem{NCC} \emph{The \textsf{ncccomma} package}. Alexander I.~Rozhenko,
+% CTAN, v1.0 2005/02/10.
+% \bibitem{BECC} \emph{Intelligent commas}. Claudio Beccari, The Prac\TeX\ Journal,
+% 2011, No.\@1.
+% \url{https://tug.org/pracjourn/2011-1/beccari/Intcomma.pdf}
+% \bibitem{NUMP} \emph{The \textsf{numprint} package}. Harald Harders,
+% CTAN, v1.39 2012/08/20.
+% \end{raggedright}
+% \end{thebibliography}
+% \Finale
+\endinput
diff --git a/macros/latex/contrib/decimalcomma/decimalcomma.ins b/macros/latex/contrib/decimalcomma/decimalcomma.ins
new file mode 100644
index 0000000000..b45bf2d2e7
--- /dev/null
+++ b/macros/latex/contrib/decimalcomma/decimalcomma.ins
@@ -0,0 +1,55 @@
+%%
+%% Copyright (C) 2023 by Antoine Missier <antoine.missier@ac-toulouse.fr>
+%%
+%% This file 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.
+%%
+
+\input docstrip.tex
+\keepsilent
+
+\usedir{tex/latex/decimalcomma}
+
+\preamble
+
+This is a generated file.
+
+Copyright (C) 2023 by Antoine Missier <antoine.missier@ac-toulouse.fr>
+
+This file 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.
+
+\endpreamble
+
+\generate{\file{decimalcomma.sty}{\from{decimalcomma.dtx}{package}}}
+
+\obeyspaces
+\Msg{*************************************************************}
+\Msg{* *}
+\Msg{* To finish the installation you have to move the following *}
+\Msg{* files into a directory searched by TeX: *}
+\Msg{* *}
+\Msg{* decimalcomma.sty *}
+\Msg{* *}
+\Msg{* To produce the documentation run the file *}
+\Msg{* ibrackets.dtx through LaTeX. *}
+\Msg{* *}
+\Msg{* Happy TeXing! *}
+\Msg{* *}
+\Msg{*************************************************************}
+
+\endbatchfile
diff --git a/macros/latex/contrib/decimalcomma/decimalcomma.pdf b/macros/latex/contrib/decimalcomma/decimalcomma.pdf
new file mode 100644
index 0000000000..8ebaefab55
--- /dev/null
+++ b/macros/latex/contrib/decimalcomma/decimalcomma.pdf
Binary files differ