diff options
author | Karl Berry <karl@freefriends.org> | 2011-07-29 14:12:43 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2011-07-29 14:12:43 +0000 |
commit | 599299b8f3cffe1e3759d3f42e2c1425520eabce (patch) | |
tree | 181286547aca16ecca9300060e2859fd1175ca19 /Master/texmf-dist/source | |
parent | 554b089e59c2631f8a6cbd760beabc02ea227ef7 (diff) |
siunitx 2.3a (9jul11)
git-svn-id: svn://tug.org/texlive/trunk@23269 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source')
-rw-r--r-- | Master/texmf-dist/source/latex/siunitx/siunitx.dtx | 4138 | ||||
-rw-r--r-- | Master/texmf-dist/source/latex/siunitx/siunitx.ins | 4 |
2 files changed, 2162 insertions, 1980 deletions
diff --git a/Master/texmf-dist/source/latex/siunitx/siunitx.dtx b/Master/texmf-dist/source/latex/siunitx/siunitx.dtx index 0d49fbd2d99..e642a598b4a 100644 --- a/Master/texmf-dist/source/latex/siunitx/siunitx.dtx +++ b/Master/texmf-dist/source/latex/siunitx/siunitx.dtx @@ -39,10 +39,10 @@ unpack the dtx yourself, running "tex siunitx.dtx" will extract the package whereas "latex siunitx.dtx" will extract it and also typeset the documentation. -The package requires LaTeX3 support as provided in the expl3 -and xpackages bundles. Both of these are available on CTAN +The package requires LaTeX3 support as provided in the l3kernel +and l3packages bundles. Both of these are available on CTAN (http://www.ctan.org/) as ready-to-install zip files. Suitable -versions are available in MiKTeX 2.9 and TeX Live 2010 +versions are available in MiKTeX 2.9 and TeX Live 2011 (updating the relevant packages online may be necessary). LaTeX3, and so siunitx, requires the e-TeX extensions: these are available on all modern TeX systems. @@ -99,6 +99,7 @@ the LaTeX Project Public License (LPPL), either version 1.3c of this license or (at your option) any later version. The latest version of this license is in the file: http://www.latex-project.org/lppl.txt + This work is "maintained" (as per LPPL maintenance status) by Joseph Wright. @@ -106,7 +107,6 @@ This work consists of the file siunitx.dtx and the derived files siunitx.pdf, siunitx.sty and siunitx.ins. - \endpostamble \usedir{tex/latex/siunitx} \generate{ @@ -142,9 +142,7 @@ This work consists of the file siunitx.dtx %</driver|package> %<*driver> \documentclass[german,french,english,UKenglish]{l3doc} - \usepackage[table]{xcolor} - \usepackage{amsmath,babel,booktabs,cancel,caption,colortbl,csquotes} \usepackage{datatool,helvet,multirow,pgfplots,siunitx,xtab} \IfFileExists{xfrac.sty} @@ -160,7 +158,6 @@ This work consists of the file siunitx.dtx \usepackage[capitalise]{cleveref} \usepackage[final]{listings} \usepackage[osf]{mathpazo} - \crefformat{section}{#2Section~#1#3} \Crefformat{section}{#2Section~#1#3} \crefformat{subsection}{#2Section~#1#3} @@ -173,26 +170,16 @@ This work consists of the file siunitx.dtx \Crefrangeformat{table}{#3Tables~#1#4 to~#5#2#6} \crefmultiformat{table}{#2Tables~#1#3}{ and~#2#1#3}{, #2#1#3}{, and~#2#1#3} \Crefmultiformat{table}{#2Tables~#1#3}{ and~#2#1#3}{, #2#1#3}{, and~#2#1#3} - - % Silence annoying fp package messages \FPmessagesfalse \pgfplotsset{compat = newest} - -\sisetup{ - load-configurations = - { - abbreviations, - binary, - } -} +\sisetup{binary-units} \DeclareSIUnit{\KWH}{kWh} \DeclareSIPrePower\quartic{4} \DeclareSIPostPower\tothefourth{4} \DeclareSIQualifier\catalyst{cat} \DeclareSIQualifier\isotropic{i} \DeclareSIQualifier\polymer{pol} - \newlength\mylength %\DisableImplementation \begin{document} @@ -343,6 +330,7 @@ This work consists of the file siunitx.dtx % translate, % unit, % volt, +% watt % } % }^^A %} @@ -542,6 +530,14 @@ This work consists of the file siunitx.dtx % for some integer part values} %\changes{v2.2i}{2011/06/15}{Fix \opt{detect-mode} option inside % table cells} +%\changes{v2.2j}{2011/06/26}{Fix incorrect line breaking in \cs{SIrange}} +%\changes{v2.2k}{2011/06/27}{Fix behaviour of subscripts inside alignments +% when printing in text mode} +%\changes{v2.2l}{2011/06/30}{Fix loss of main unit when \opt{per-mode} is set +% to \opt{symbol} and a pre-unit is used} +%\changes{v2.3}{2011/06/19}{New implementation for alignment in \texttt{S} +% column} +%\changes{v2.3a}{2011/07/09}{Restore fix in v2.2l missing in v2.3} % %\begin{abstract} % Physical quantities have both numbers and units, and each physical @@ -596,11 +592,11 @@ This work consists of the file siunitx.dtx % documentation. % % The package requires \LaTeX3 support as provided in the -% \pkg{expl3} and \pkg{xpackages} bundles. Both of these are available +% \pkg{l3kernel} and \pkg{l3packages} bundles. Both of these are available % on \href{http://www.ctan.org}{\textsc{ctan}} as ready-to-install -% zip files. Suitable versions are available in MiK\TeX~2.9 and -% \TeX~Live 2010 (updating the relevant packages online may be -% necessary). \LaTeX3, and so \pkg{siunitx}, requires the \eTeX\ +% zip files. Suitable versions are available in MiK\TeX{}~2.9 and +% \TeX{}~Live 2011 (updating the relevant packages online may be +% necessary). \LaTeX3, and so \pkg{siunitx}, requires the \eTeX{} % extensions: these are available on all modern \TeX{} systems. % % Typesetting the documentation requires a number of packages in @@ -642,7 +638,7 @@ This work consists of the file siunitx.dtx % \item \cs{tablenum}\oarg{options}\marg{number} %\end{itemize} % plus the \texttt{S} and \texttt{s} column types for decimal -% alignments and units in tabular environments. These user macros and +% alignments and units in tabular environments. These user macros and % column types are designed for % typesetting numbers and units with control of appearance and with % intelligent processing. @@ -691,7 +687,7 @@ This work consists of the file siunitx.dtx % The key--value options described later in this document can be used % when loading the package, for example %\begin{LaTeXdemo}[code only] -% \usepackage[load-configurations = version-1]{siunitx} +% \usepackage[version-1-compatibility]{siunitx} %\end{LaTeXdemo} % to use options from version 1 of the package. % @@ -1704,7 +1700,7 @@ This work consists of the file siunitx.dtx % %\DescribeOption{input-complex-roots} % When using complex numbers in input, the complex root -% (\( \mathrm{i} = \sqrt{-1}\)) is indicated by one of the tokens stored +% \( ( \mathrm{i} = \sqrt{-1} \, ) \) is indicated by one of the tokens stored % in \opt{input-complex-roots}. The parser understands complex root % symbols given either before or after the associated number (but will % detect any invalid arrangement): @@ -1900,7 +1896,7 @@ This work consists of the file siunitx.dtx % choices \opt{false}, \opt{true}, \opt{fixed} and % \opt{engineering}. The \opt{fixed} setting will use the exponent value % by the \opt{fixed-exponent} option. When \opt{engineering} is set, -% the exponent is always a power of three. +% the exponent is always a power of three. %\begin{LaTeXdemo} % \num{0.001} \\ % \num{0.0100} \\ @@ -1948,10 +1944,8 @@ This work consists of the file siunitx.dtx % copy-decimal-marker & Choice & false \\ % exponent-base & Literal & 10 \\ % exponent-product & Math & \cs{times} \\ -% group-decimal-digits & Switch & true \\ -% group-digits & Switch & true \\ -% group-four-digits & Switch & false \\ -% group-integer-digits & Switch & true \\ +% group-digits & Choice & true \\ +% group-minimum-digits & integer & 5 \\ % group-separator & Math & \cs{,} \\ % negative-color & Literal & \meta{none} \\ % open-bracket & Literal & ( @@ -1970,35 +1964,43 @@ This work consists of the file siunitx.dtx % %\DescribeOption{group-digits} %\changes{v2.2a}{2011/04/15}{Add missing default for \opt{group-digits} option} -%\DescribeOption{group-decimal-digits} -%\DescribeOption{group-integer-digits} +% \changes{v2.3}{2011/06/06}{Extend \opt{group-digits} option, deprecating +% \opt{group-decimal-digits} and \opt{group-integer-digits}} %\DescribeOption{group-four-digits} %\DescribeOption{group-separator} % Grouping digits into blocks of three is a common method to increase -% the ease of reading of numbers. The \opt{group-digits} choice -% turns this behaviour on and off, with grouping for numbers of exactly -% four digits controlled by the \opt{group-four-digits} choice. Note -% that the later only applies if \opt{group-digits} is turned on. +% the ease of reading of numbers. The \opt{group-digits} choice controls +% whether this behaviour applies, and takes the values \opt{true}, \opt{false}, +% \opt{decimal} and \opt{integer}. Grouping can be activated separately for +% the integer and decimal parts of a number using the appropriately-named +% values. +%\begin{LaTeXdemo} +% \num{12345.67890} \\ +% \num[group-digits = false]{12345.67890} \\ +% \num[group-digits = decimal]{12345.67890} \\ +% \num[group-digits = integer]{12345.67890} +%\end{LaTeXdemo} % The separator used between groups of digits is stored by the % \opt{group-separator} option. This takes literal input and is -% used in math mode: for a text-mode full space use "\text{~}". +% used in math mode: for a text-mode full space use |\text{~}|. %\begin{LaTeXdemo} % \num{12345} \\ -% \num[group-digits = false]{12345} \\ -% \num{1234} \\ -% \num[group-four-digits = true]{1234} \\ -% \num{12345} \\ % \num[group-separator = {,}]{12345} \\ % \num[group-separator = \text{~}]{12345} %\end{LaTeXdemo} -% Grouping can be activated separately for the integer and decimal -% parts of a number using the \opt{group-integer-digits} and -% \opt{group-decimal-digits} options. +% \DescribeOption{group-minimum-digits} +% \changes{v2.3}{2011/06/06}{New \opt{group-minimum-digits} option to +% replace \opt{group-four-digits}} +% Grouping is not always applied to smaller numbers, and the option +% \opt{group-minimum-digits} is available to specify how many digits must +% be present before grouping is applied. The number of digits is considered +% separately for the integer and decimal parts of the number: grouping +% does not \enquote{cross the boundary}. %\begin{LaTeXdemo} -% \sisetup{group-digits = false}% -% \num{12345.67890} \\ -% \num[group-decimal-digits]{12345.67890} \\ -% \num[group-integer-digits]{12345.67890} +% \num{1234} \\ +% \num[group-minimum-digits = 4]{1234} \\ +% \num{1234.5678} \\ +% \num[group-minimum-digits = 4]{1234.5678} %\end{LaTeXdemo} % %\DescribeOption{output-complex-root} @@ -2424,22 +2426,17 @@ This work consists of the file siunitx.dtx % %\subsection{Loading additional units} % -%\DescribeOption{load-configurations} -% \pkg{siunitx} includes a set of configuration files which are intended -% to make life easier for the user. The files are loaded using the -% \opt{load-configurations} option, which accepts a comma-separated of -% file names. -% -% The first configuration file provides a number of convenient -% abbreviations for the SI units (\cref{tab:unit:abbr}). The -% standard \pkg{siunitx} settings only create these abbreviations within -% the scope of the \cs{si} and \cs{SI} functions, meaning that no -% clashes should occur (for example with the standard \cs{pm} symbol). +% \DescribeOption{abbreviations} +% As standard, \pkg{siunitx} loads a set of abbreviated versions of the +% SI units (\cref{tab:unit:abbr}). The standard \pkg{siunitx} settings only +% create these abbreviations within the scope of the \cs{si} and \cs{SI} +% functions, meaning that no clashes should occur (for example with the +% standard \cs{pm} symbol). Loading of these abbreviations can be prevented +% by setting the option \opt{abbreviations = false} in the preamble. % %\begin{center} % \changes{v2.0n}{2010/07/15}{More abbreviated units} -% \tablecaption{Abbreviated units \endgraf -% (\opt{load-configurations=abbreviations}).} +% \tablecaption{Abbreviated units.} % \label{tab:unit:abbr} % \tablefirsthead{^^A % \toprule @@ -2516,9 +2513,11 @@ This work consists of the file siunitx.dtx % \DescribeNamedUnit{microlitre}{ul} \\ % \DescribeNamedUnit{millilitre}{ml} \\ % \DescribeNamedUnit{litre}{l} \\ +% \DescribeNamedUnit{hectolitre}{hl} \\ % \DescribeNamedUnit{microliter}{uL} \\ % \DescribeNamedUnit{milliliter}{mL} \\ % \DescribeNamedUnit{liter}{L} \\ +% \DescribeNamedUnit{hectoliter}{hL} \\ % % \midrule % @@ -2582,22 +2581,24 @@ This work consists of the file siunitx.dtx % \end{xtabular} %\end{center} % -%\DescribeMacro{\bit} -%\DescribeMacro{\byte} +% \DescribeOption{binary-units} +% \DescribeMacro{\bit} +% \DescribeMacro{\byte} % Binary data is expressed in units of bits and bytes. These are % normally given prefixes which use powers of two, rather than the % powers of ten used by the SI prefixes. As these binary prefixes are % closely related to the SI prefixes, they are defined by \pkg{siunitx} +% but do have to be loaded using \opt{binary-units = true} (or +% simply \opt{binary-units}) % (\cref{tab:unit:binary}). The units \cs{bit} and \cs{byte} are -% also available. +% then also available. %\begin{LaTeXdemo} % \SI{100}{\mebi\byte} \\ % \SI[prefixes-as-symbols=false]{30}{\kibi\bit} %\end{LaTeXdemo} % %\begin{table} -% \caption{Binary prefixes \protect \\ -% (\opt{load-configurations=binary}).} +% \caption{Binary prefixes.} % \label{tab:unit:binary} % \centering % \begin{tabular}{llc>{$}l<{$}} @@ -2616,9 +2617,10 @@ This work consists of the file siunitx.dtx % \end{tabular} %\end{table} % +% \DescribeOption{version-1-compatibility} % A configuration file is also included which will use settings % and define macros as defined by version 1 of \pkg{siunitx}: this -% can be accessed with the option \opt{load-configurations = version-1}. +% can be accessed with the option \opt{version-1-compatibility}. % This is intended to allow easy transition to version 2: users % should update their source to use the new interfaces and functions. % @@ -2687,17 +2689,18 @@ This work consists of the file siunitx.dtx % \multicolumn{1}{l}{Option name} & % Type & % \multicolumn{1}{l}{Default} \\ -% \midrule ^^A ( -% bracket-unit-denominator & Switch & true \\ -% forbid-literal-units & Switch & false \\ -% inter-unit-product & Math & \cs{,} \\ -% parse-units & Switch & true \\ -% per-mode & Choice & reciprocal \\ -% per-symbol & Math & / \\ -% power-font & Choice & number \\ -% prefixes-as-symbols & Switch & true \\ -% qualifier-mode & Choice & subscript \\ -% sticky-per & Switch & false \\ +% \midrule +% bracket-unit-denominator & Switch & true \\ +% forbid-literal-units & Switch & false \\ +% literal-superscript-as-power & Switch & true \\ +% inter-unit-product & Math & \cs{,} \\ +% parse-units & Switch & true \\ +% per-mode & Choice & reciprocal \\ +% per-symbol & Math & / \\ +% power-font & Choice & number \\ +% prefixes-as-symbols & Switch & true \\ +% qualifier-mode & Choice & subscript \\ +% sticky-per & Switch & false \\ % \bottomrule % \end{tabular} %\end{table} @@ -2807,10 +2810,24 @@ This work consists of the file siunitx.dtx % for numbers and units are very different, for example when the % \pkg{euler} package is loaded. %\begin{LaTeXdemo} -% \sisetup{unit-mode = text}% % \si{\metre\per\second\squared} \\ % \si[power-font = unit]{\metre\per\second\squared} %\end{LaTeXdemo} +% \DescribeOption{literal-superscript-as-power} +% \changes{v2.3}{2011/06/08}{New \opt{literal-superscript-as-power} option for +% controlling how literal units superscripts behave} +% When printing units in \enquote{literal} mode, it is possible that simply +% printing superscripts \enquote{as is} may lead to poor appearance for the +% numbers. This is most likely if the text font of the document uses +% old style (lower case) numerals, but the math font uses lining (upper +% case) numerals. It is therefore possible to treat superscripts within +% literal units as powers, and thus for the \opt{power-font} option to +% apply within these literal units. This behaviour is controlled using the +% \opt{literal-superscript-as-power} switch. +%\begin{LaTeXdemo} +% \si{m.s^{2}} \\ +% \si[literal-superscript-as-power = false]{m.s^{2}} +%\end{LaTeXdemo} % %\DescribeOption{qualifier-mode} %\changes{v2.1c}{2010/11/13}{New \opt{text} choice for @@ -2995,6 +3012,7 @@ This work consists of the file siunitx.dtx % \midrule ^^A ( % table-align-comparator & Switch & true \\ % table-align-exponent & Switch & true \\ +% table-align-text-pre & Switch & true \\ % table-align-text-post & Switch & true \\ % table-align-uncertainty & Switch & true \\ % table-alignment & Choice & \m{none} \\ @@ -3393,16 +3411,19 @@ This work consists of the file siunitx.dtx % \end{table} %\end{LaTeXdemo} % +%\DescribeOption{table-align-text-pre} +% \changes{v2.3}{2011/06/19}{New \opt{table-align-text-pre} option} %\DescribeOption{table-align-text-post} % Note markers are often given in tables after the numerical content. It % may be desirable for these to close up to the numbers. Whether this -% takes place is controlled by the \opt{table-align-text-post} +% takes place is controlled by the \opt{table-align-text-pre} +% and \opt{\ldots-post} % option (\cref{tab:S:notes}). %\begin{LaTeXdemo}[code and float] % \begin{table} % \caption{Closing notes up to text.} % \label{tab:S:notes} -% \newcommand\NoteMark[1]{% +% \newrobustcmd\NoteMark[1]{% % \textsuperscript{\emph{#1}}% % } % \centering @@ -3410,9 +3431,25 @@ This work consists of the file siunitx.dtx % table-number-alignment = center, % table-figures-integer = 2, % table-figures-decimal = 4, +% table-space-text-pre = \NoteMark{a} % } % \begin{tabular}{ % S +% S[table-align-text-pre = false] +% } +% \toprule +% {Values} & {Values} \\ +% \midrule +% 2.3456 & 2.3456 \\ +% \NoteMark{a} 4.234 & \NoteMark{a} 4.234 \\ +% \NoteMark{b} .78 & \NoteMark{b} .78 \\ +% \NoteMark{d} 88 & \NoteMark{d} 88 \\ +% \bottomrule +% \end{tabular} +% \hfil +% \sisetup{table-space-text-post = \NoteMark{a}} +% \begin{tabular}{ +% S % S[table-align-text-post = false] % } % \toprule @@ -3422,6 +3459,7 @@ This work consists of the file siunitx.dtx % 34.234 \NoteMark{a} & 34.234 \NoteMark{a} \\ % 56.78 \NoteMark{b} & 56.78 \NoteMark{b} \\ % 90.4 \NoteMark{c} & 90.4 \NoteMark{c} \\ +% 88 \NoteMark{d} & 88 \NoteMark{d} \\ % \bottomrule % \end{tabular} % \end{table} @@ -3568,7 +3606,7 @@ This work consists of the file siunitx.dtx % to the same value using the \opt{table-alignment} option. This will % set all three alignment options to the same value (one of % \opt{center}, \opt{right} or \opt{left}). -% +% %\DescribeOption{table-column-width} %\changes{v2.2}{2011/04/02}{New \opt{table-column-width} option} %\changes{v2.2f}{2011/05/25}{Fix setting \opt{table-column-width} to @@ -3604,7 +3642,7 @@ This work consists of the file siunitx.dtx % \end{tabular} % \end{table} %\end{LaTeXdemo} -% +% % The \opt{table-column-width} option can also be used to achieve % special effects. One example is centring a column of numbers under % a wide heading, with the numbers themselves right-aligned @@ -3789,6 +3827,10 @@ This work consists of the file siunitx.dtx % \SIrange{1}{10}{\degreeCelsius} \\ %\end{LaTeXdemo} % +% Note that the in order for this to work correctly, languages should +% be given as global (class) options rather than as package options +% for \pkg{babel}. +% %\section{Hints for using \pkg{siunitx}} % %\subsection{Ensuring text or math output} @@ -3811,7 +3853,7 @@ This work consists of the file siunitx.dtx % (\cref{tab:xmpl:macro}). Values which would otherwise be expanded % can be protected by wrapping them in a set of braces. As \TeX{} itself % will expand the first token in a table cell before \pkg{siunitx} -% can act on it, using the \eTeX\ protected mechanism is the +% can act on it, using the \eTeX{} protected mechanism is the % recommended course of action to prevent expansion of macros in % table cells. (As is shown in the table, \TeX's expansion of % \LaTeXe{} robust commands can lead to unexpected results.) @@ -3844,7 +3886,7 @@ This work consists of the file siunitx.dtx % work, the calculation must take place before attempting to parse % the number. An added complication is that \TeX{} itself will % expand the first macro in a table cell until it finds -% something unexpandable. The \eTeX\ protected mechanism can be +% something unexpandable. The \eTeX{} protected mechanism can be % used to prevent this; using the \pkg{etoolbox} package provides % a convenient way to apply this protection to existing functions. % The general approach is illustrated in \cref{tab:xmpl:calc}. @@ -3937,10 +3979,10 @@ This work consists of the file siunitx.dtx % glyphs for these which are correct in the sense that they are upright % (not italic) symbols, and match the \LaTeX{} standard Computer Modern % font. However, this does not make them the best choice if other -% fonts are in use, which is particularly common when \XeTeX\ is +% fonts are in use, which is particularly common when \XeTeX{} is % being used. % -% \XeTeX\ users will probably need to choose appropriate symbols +% \XeTeX{} users will probably need to choose appropriate symbols % themselves. The correct choice depends on the fonts in use, but many % system fonts include Greek letters and other symbols (which is not % the case with most \TeX-specific fonts). An appropriate setting @@ -4207,7 +4249,7 @@ This work consists of the file siunitx.dtx % %\section{Information for those upgrading} % -%\subsection{Upgrading from version 1} +%\subsection{Upgrading from version 1} %\changes{v2.0a}{2010/05/28}{Fix various errors in \file{version-1} % configuration file} %\changes{v2.0a}{2010/05/28}{Detect use of version 1 options and @@ -4228,7 +4270,7 @@ This work consists of the file siunitx.dtx % can be loaded with a configuration file to provide most of the % same options and defaults as in version 1: %\begin{LaTeXdemo}[code only] -% \usepackage[load-configurations = version-1]{siunitx} +% \usepackage[version-1-compatibility]{siunitx} %\end{LaTeXdemo} % Many of the options from version 1 map to similar ones in version 2 % (\cref{tab:opt:map}). The correspondence often includes a syntax @@ -4418,7 +4460,7 @@ This work consists of the file siunitx.dtx %\subsection{Upgrading from version 2.0 or 2.1} % % User feedback on \pkg{siunitx} means that over time some renaming -% takes place. The following functions and options have been depreciated +% takes place. The following functions and options have been deprecated % in version 2.2. They are therefore available in version 2.2, but % should be replaced in new or updated documents with the successor % names. @@ -4448,6 +4490,36 @@ This work consists of the file siunitx.dtx % \cs{DeclareSIUnitWithOptions}. This function is therefore depreciated % but retained for compatibility. % +% \subsection{Upgrading from version 2.2} +% +% \DescribeOption{load-configurations} +% \changes{v2.3}{2011/03/20}{Load abbreviations as standard} +% \changes{v2.3}{2011/03/20}{Replace \opt{load-configurations} option +% with separate \opt{abbreviations}, \opt{binary-units} and +% \opt{version-1-compatibility} options} +% The option \opt{load-configurations} has been deprecated in favour of the +% three options \opt{abbreviations}, \opt{binary-units} and +% \opt{version-1-compatibility}. At the same time, loading of the abbreviations +% is now the standard behaviour, and so in most cases no +% explicit configuration file loading will be needed. +% +% \DescribeOption{group-decimal-digits} +% \DescribeOption{group-integer-digits} +% The digit grouping options have been revised, and the options +% \opt{group-decimal-digits} and \opt{group-integer-digits} are now +% integrated into \opt{group-digits}. +% \DescribeOption{group-four-digits} +% At the same time, the \opt{group-four-digits} option has been extended +% to the new option \opt{group-minimum-digits}. +% +% \DescribeOption{literal-superscript-as-power} +% The new {literal-superscript-as-power} option means that the standard +% behaviour now uses the current math font for superscripts, even when +% units are printed literally. This will only be obvious in documents such +% as this manual, where the text and math mode numerals are (deliberately) +% different. To restore the previous behaviour, set +% \opt{literal-superscript-as-power = false}. +% %\section{Correct application of (SI) units} % % Consistent and logical units are a necessity for scientific work, @@ -4797,7 +4869,7 @@ This work consists of the file siunitx.dtx % % The usual preliminaries. % \begin{macrocode} -\ProvidesExplPackage {siunitx} {2011/06/15} {2.2i} +\ProvidesExplPackage {siunitx} {2011/07/09} {2.3a} {A comprehensive (SI) units package} % \end{macrocode} % @@ -4807,9 +4879,9 @@ This work consists of the file siunitx.dtx % old then the message system may not be in place at all: there is a % back up for that case. % \begin{macrocode} -\cs_if_exist:NTF \msg_set:nnnn +\cs_if_exist:NTF \msg_new:nnnn { - \msg_set:nnnn { siunitx } { support-outdated } + \msg_new:nnnn { siunitx } { support-outdated } { Support~package~#1~too~old. } { Please~install~an~up~to~date~version~of~#1. \\ @@ -4824,7 +4896,7 @@ This work consists of the file siunitx.dtx } \tex_endinput:D } -\@ifpackagelater { expl3 } { 2010/11/13 } +\@ifpackagelater { l3clist } { 2011/07/09 } { } { \msg_error:nnx { siunitx } { support-outdated } { expl3 } @@ -4840,7 +4912,7 @@ This work consists of the file siunitx.dtx % document as well. The message for this may be needed immediately, so % it is created here not with the other messages. % \begin{macrocode} -\msg_set:nnnn { siunitx } { incompatible-package } +\msg_new:nnnn { siunitx } { incompatible-package } { Package~'#1'~incompatible. } { The~#1~package~and~siunitx~are~incompatible. } \cs_new_protected_nopar:Npn \siunitx_load_check:n #1 { @@ -4864,7 +4936,7 @@ This work consists of the file siunitx.dtx % errors. % \begin{macrocode} \RequirePackage{ xparse } -\@ifpackagelater { xparse } { 2010/10/13 } +\@ifpackagelater { xparse } { 2011/05/30 } { } { \msg_error:nnx { siunitx } { support-outdated } { xparse } @@ -4887,14 +4959,16 @@ This work consists of the file siunitx.dtx %\begin{macro}{ % \l_siunitx_tmp_bool , % \l_siunitx_tmp_box , +% \l_siunitx_tmp_dim , % \l_siunitx_tmp_int , % \l_siunitx_tmpa_tl , -% \l_siunitx_tmpb_tl , +% \l_siunitx_tmpb_tl %} % Scratch variables. % \begin{macrocode} \bool_new:N \l_siunitx_tmp_bool \box_new:N \l_siunitx_tmp_box +\dim_new:N \l_siunitx_tmp_dim \int_new:N \l_siunitx_tmp_int \tl_new:N \l_siunitx_tmpa_tl \tl_new:N \l_siunitx_tmpb_tl @@ -4904,7 +4978,7 @@ This work consists of the file siunitx.dtx %\begin{macro}{ % \siunitx_error:nxx , % \siunitx_error:nx , -% \siunitx_error:n , +% \siunitx_error:n %} %\begin{macro}{\l_siunitx_error_bool} % General-purpose functions for throwing errors. @@ -4939,7 +5013,7 @@ This work consists of the file siunitx.dtx % %\begin{macro}{ % \c_siunitx_minus_tl , -% \c_siunitx_minus_int , +% \c_siunitx_minus_int %} % To allow the correct symbol to appear in text mode: this is the same % as \cs{textminus} from \pkg{textcomp}. If \pkg{fontspec} is loaded @@ -4961,7 +5035,7 @@ This work consists of the file siunitx.dtx % %\begin{macro}{ % \c_siunitx_mu_tl , -% \c_siunitx_mu_int , +% \c_siunitx_mu_int %} % The lack of an upright mu has to be sorted out. The same consideration % for \pkg{fontspec} as above. @@ -4998,7 +5072,7 @@ This work consists of the file siunitx.dtx % \siunitx_tl_put_left_math:cV , % \siunitx_tl_put_right_math:Nn , % \siunitx_tl_put_right_math:NV , -% \siunitx_tl_put_right_math:cV , +% \siunitx_tl_put_right_math:cV %} % To add stuff in math mode. % \begin{macrocode} @@ -5186,7 +5260,7 @@ This work consists of the file siunitx.dtx \tl_if_blank:nF {#1} { = \exp_not:n {#1} } } } - \keys_set:nn { siunitx } { load-configurations = version-1 } + \keys_set:nn { siunitx } { version-1-compatibility } \tl_use:N \l_siunitx_key_tl } { @@ -5239,24 +5313,17 @@ This work consists of the file siunitx.dtx %\end{macro} %\end{macro} % -%\begin{macro}{ -% \prop_del:cn , -% \prop_put:cnV , -% \tl_if_in:NVTF , -% \tl_replace_all_in:NnV , -%} -% Variants needed which are not in \pkg{expl3}. +% \begin{macro}{\tl_if_in:NVTF, \tl_replace_all:NnV} +% Variants needed which are not in \pkg{expl3}. % \begin{macrocode} -\cs_generate_variant:Nn \prop_del:Nn { c } -\cs_generate_variant:Nn \prop_put:Nnn { cnV } \cs_generate_variant:Nn \tl_if_in:NnTF { NV } -\cs_generate_variant:Nn \tl_replace_all_in:Nnn { NnV } +\cs_generate_variant:Nn \tl_replace_all:Nnn { NnV } % \end{macrocode} -%\end{macro} +% \end{macro} % %\begin{macro}[pTF]{ % \siunitx_cs_if_tl:N , -% \siunitx_cs_if_macro:N , +% \siunitx_cs_if_macro:N %} %\begin{macro}[aux]{\siunitx_cs_if_tl_aux:w} % This is basically a re-hash of stuff from \pkg{expl3}, but to test for @@ -5265,7 +5332,7 @@ This work consists of the file siunitx.dtx % \begin{macrocode} \group_begin: \tl_map_inline:nn { \M \A \C \R \O } - { \char_make_other:n { `#1 } } + { \char_set_catcode_other:n { `#1 } } \tl_map_inline:nn { \F \N \T } { \char_set_lccode:nn { `#1 } { `#1 } } \tl_to_lowercase:n { @@ -5313,13 +5380,25 @@ This work consists of the file siunitx.dtx % \end{macrocode} %\end{macro} % +% \begin{macro}{\siunitx_textsuperscript:n} +% This function is set up here so that it can be redefined +% elsewhere as expandable. That is used in the bookmark system so +% that \pkg{hyperref} does not raise any unnecessary warnings. +% \begin{macrocode} +\cs_new_eq:NN \siunitx_textsuperscript:n \textsuperscript +% \end{macrocode} +% \end{macro} +% %\begin{macro}{\l_siunitx_display_math_bool} % To test for display math, a flag is added to the start of every % display environment. % \begin{macrocode} \bool_new:N \l_siunitx_display_math_bool -\toks_put_right:Nn \tex_everydisplay:D - { \bool_set_true:N \l_siunitx_display_math_bool } +\tex_everydisplay:D \exp_after:wN + { + \tex_the:D \tex_everydisplay:D + \bool_set_true:N \l_siunitx_display_math_bool + } % \end{macrocode} %\end{macro} % @@ -5334,7 +5413,7 @@ This work consists of the file siunitx.dtx %\begin{macro}{\siunitx_set_math_fam:n} %\begin{macro}{ % \c_siunitx_mathsf_int , -% \c_siunitx_mathtt_int , +% \c_siunitx_mathtt_int %} % The detection routine needs some basic data about the sans serif and % monospaced fonts in use. This is collected up at the start of the @@ -5369,7 +5448,7 @@ This work consists of the file siunitx.dtx %\begin{macro}{\siunitx_font_set_text_fam:n} %\begin{macro}{ % \c_siunitx_textsf_tl , -% \c_siunitx_texttt_tl , +% \c_siunitx_texttt_tl %} % The text families are done in a somewhat different manner: there are % no issues with \cs{AtBeginDocument}, luckily. The need to define @@ -5402,7 +5481,7 @@ This work consists of the file siunitx.dtx % \l_siunitx_detect_inline_weight_tl , % \l_siunitx_detect_shape_bool , % \l_siunitx_detect_mode_bool , -% \l_siunitx_detect_weight_bool , +% \l_siunitx_detect_weight_bool %} % Font detection is all about creating switches, with just a little % gloss for \texttt{detect-all} and \texttt{detect-none}. @@ -5473,7 +5552,7 @@ This work consists of the file siunitx.dtx % %\begin{macro}{ % \l_siunitx_font_set_bool , -% \l_siunitx_font_math_mode_bool , +% \l_siunitx_font_math_mode_bool %} % The internals of the package need a number of switches to track what % is happening. @@ -5492,7 +5571,7 @@ This work consists of the file siunitx.dtx % %\begin{macro}{ % \siunitx_font_shape: , -% \siunitx_font_weight: , +% \siunitx_font_weight: %} % These could be token lists or functions! % \begin{macrocode} @@ -5569,7 +5648,7 @@ This work consists of the file siunitx.dtx %\end{macro} %\begin{macro}{ % \siunitx_detect_font_weight_math: , -% \siunitx_detect_font_weight_text: , +% \siunitx_detect_font_weight_text: %} % The tests for font weight depend on whether the module is testing % text or math content. @@ -5630,7 +5709,7 @@ This work consists of the file siunitx.dtx %\end{macro} %\begin{macro}{ % \siunitx_detect_font_family_math: , -% \siunitx_detect_font_family_text: , +% \siunitx_detect_font_family_text: %} % The two detections routines check if the current font is sans serif or % monospaced. The method used depends on whether the current math or @@ -5691,7 +5770,7 @@ This work consists of the file siunitx.dtx % %\begin{macro}{ % \l_siunitx_number_math_mode_bool , -% \l_siunitx_unit_math_mode_bool , +% \l_siunitx_unit_math_mode_bool %} % Most of the variables are created by the keys system: these are not. % \begin{macrocode} @@ -5706,7 +5785,7 @@ This work consists of the file siunitx.dtx % \siunitx_number_mathtt:n , % \siunitx_number_textrm: , % \siunitx_number_textsf: , -% \siunitx_number_texttt: , +% \siunitx_number_texttt: %} % Functions for number-mode fonts. % \begin{macrocode} @@ -5752,7 +5831,7 @@ This work consists of the file siunitx.dtx % \siunitx_unit_mathtt:n , % \siunitx_unit_textrm: , % \siunitx_unit_textsf: , -% \siunitx_unit_texttt: , +% \siunitx_unit_texttt: %} % The same storage for unit-mode fonts. % \begin{macrocode} @@ -5862,12 +5941,12 @@ This work consists of the file siunitx.dtx \tl_set:Nx \l_siunitx_tmpa_tl { \familydefault } \tl_if_eq:NNT \l_siunitx_tmpa_tl \c_siunitx_textsf_tl { - \@ifpackageloaded { arev } + \@ifpackageloaded { arev } { } { \@ifpackageloaded { cmbright } { } - { \keys_set:nn { siunitx } { math-rm = \mathsf } } + { \keys_set:nn { siunitx } { math-rm = \mathsf } } } \keys_set:nn { siunitx } { text-rm = \sffamily } } @@ -5907,7 +5986,7 @@ This work consists of the file siunitx.dtx % %\begin{macro}{ % \siunitx_print:nn , -% \siunitx_print:nV , +% \siunitx_print:nV %} %\begin{macro}[aux]{\siunitx_print_aux:} % The main printing function does everything inside a group, as @@ -5957,7 +6036,7 @@ This work consists of the file siunitx.dtx % %\begin{macro}{ % \siunitx_print_color: , -% \siunitx_textcolor:n , +% \siunitx_textcolor:n %} % The colour system checks if \pkg{color} is loaded, and only does % anything if it is. This will change when \LaTeX3 proper is available: @@ -5975,7 +6054,7 @@ This work consists of the file siunitx.dtx \AtBeginDocument { \@ifpackageloaded { color } { \cs_new_eq:NN \siunitx_textcolor:n \textcolor } - { + { \cs_set_eq:NN \siunitx_print_color: \scan_stop: \cs_new_eq:NN \siunitx_textcolor:n \use_none:n } @@ -5985,7 +6064,7 @@ This work consists of the file siunitx.dtx % %\begin{macro}{ % \siunitx_print_math: , -% \siunitx_print_text: , +% \siunitx_print_text: %} % Printing the text means replacing any awkward characters, which is % dependent on the output mode. The rest of the package uses "_" and @@ -5996,9 +6075,9 @@ This work consists of the file siunitx.dtx % \begin{macrocode} \group_begin: \char_set_lccode:nn { `\@ } { `\_ } - \char_make_math_subscript:N \@ + \char_set_catcode_math_subscript:N \@ \char_set_lccode:nn { `\! } { `\_ } - \char_make_active:N \! + \char_set_catcode_active:N \! \tl_to_lowercase:n { \group_end: \cs_set_protected_nopar:Npn \siunitx_print_math: @@ -6019,11 +6098,11 @@ This work consists of the file siunitx.dtx { \cs_set_eq:NN \PrintSubscript \siunitx_print_text_sub:n \cs_set_eq:NN \PrintSuperscript \siunitx_print_text_super:n - \tl_replace_all_in:Nnn \l_siunitx_print_arg_tl { @ } + \tl_replace_all:Nnn \l_siunitx_print_arg_tl { @ } { \siunitx_print_text_sub:n } - \tl_replace_all_in:Nnn \l_siunitx_print_arg_tl { ! } + \tl_replace_all:Nnn \l_siunitx_print_arg_tl { ! } { \siunitx_print_text_sub:n } - \tl_replace_all_in:Nnn \l_siunitx_print_arg_tl { ^ } + \tl_replace_all:Nnn \l_siunitx_print_arg_tl { ^ } { \siunitx_print_text_super:n } \l_siunitx_print_arg_tl } @@ -6033,18 +6112,20 @@ This work consists of the file siunitx.dtx % %\begin{macro}{ % \siunitx_print_text_sub:n , -% \siunitx_print_text_super:n , +% \siunitx_print_text_super:n %} %\begin{macro}[aux]{\siunitx_print_text_sub_super:n} % The appropriate macros for sub- and superscript in text mode ensure % the appearance is the same as math mode. As "_" is a letter, there % is the need to do a category-code juggle. The search and replace % code for superscripts deals with the case where a literal number has -% been given with text mode printing. +% been given with text mode printing. There is currently an issue with +% \pkg{expl3}'s \cs{peek_\ldots} functions, which means that the peek +% code is written out here in full. % \begin{macrocode} \group_begin: \char_set_lccode:nn { `\@ } { `\_ } - \char_make_math_subscript:N \@ + \char_set_catcode_math_subscript:N \@ \tl_to_lowercase:n { \group_end: \cs_set_protected:Npn \siunitx_print_text_sub:n #1 @@ -6057,15 +6138,21 @@ This work consists of the file siunitx.dtx ^ { \text {##1} } } } - \peek_meaning_remove:NTF \siunitx_print_text_super:n - { \siunitx_print_text_sub_super:n } - { \ensuremath { @ { \text {#1} } } } + \cs_set_eq:NN \l_peek_search_token \siunitx_print_text_super:n + \cs_set_nopar:Npn \peek_true:w + { + \tex_afterassignment:D \peek_true_aux:w + \cs_set_eq:NN \peek_tmp:w + } + \cs_set_nopar:Npn \peek_true_aux:w { \siunitx_print_text_sub_super:n } + \cs_set_nopar:Npn \peek_false:w { \ensuremath { @ { \text {#1} } } } + \peek_after:Nw \peek_execute_branches_meaning: } } \cs_new_protected:Npn \siunitx_print_text_sub_super:n { } \cs_new_protected:Npn \siunitx_print_text_super:n #1 { \tl_set:Nn \l_siunitx_tmpa_tl {#1} - \tl_replace_all_in:Nnn \l_siunitx_tmpa_tl { - } + \tl_replace_all:Nnn \l_siunitx_tmpa_tl { - } { \c_siunitx_minus_tl } \tl_set:Nx \l_siunitx_tmpa_tl { @@ -6082,7 +6169,7 @@ This work consists of the file siunitx.dtx % %\begin{macro}{ % \PrintSubscript , -% \PrintSuperscript , +% \PrintSuperscript %} % In the unit-construction code, there are places where it cannot % be guarenteed that the search-and-replace approach will work. @@ -6115,7 +6202,7 @@ This work consists of the file siunitx.dtx % %\begin{macro}{ % \l_siunitx_number_arg_tl , -% \l_siunitx_number_next_tl , +% \l_siunitx_number_next_tl %} % Storage for the pre-parsed material. The \texttt{arg} variable % contains the current argument, the \texttt{next} variable contains @@ -6135,7 +6222,7 @@ This work consists of the file siunitx.dtx % %\begin{macro}{ % \l_siunitx_number_denominator_tl , -% \l_siunitx_number_numerator_tl , +% \l_siunitx_number_numerator_tl %} % When searching for quotients, some more storage is needed. % \begin{macrocode} @@ -6146,7 +6233,7 @@ This work consists of the file siunitx.dtx % %\begin{macro}{ % \siunitx_number_preprocess:n , -% \siunitx_number_preprocess:V , +% \siunitx_number_preprocess:V %} % The pre-processor starts with the obvious: the most likely outcome is % that all of the argument is passed through unchanged. @@ -6260,7 +6347,7 @@ This work consists of the file siunitx.dtx % \l_siunitx_number_in_first_bool , % \l_siunitx_number_in_sign_bool , % \l_siunitx_number_in_uncert_bool , -% \l_siunitx_number_in_value_bool , +% \l_siunitx_number_in_value_bool %} % \begin{macrocode} \bool_new:N \l_siunitx_number_in_complex_bool @@ -6295,7 +6382,7 @@ This work consists of the file siunitx.dtx % \l_siunitx_number_part_decimal_marker_tl , % \l_siunitx_number_part_integer_tl , % \l_siunitx_number_part_sign_tl , -% \l_siunitx_number_part_uncert_tl , +% \l_siunitx_number_part_uncert_tl %} % The names of various parts of a number are set up as stored values. % This lets some code be used for different parts of a number, while @@ -6327,7 +6414,7 @@ This work consists of the file siunitx.dtx %\begin{macro}{\l_siunitx_input_uncert_sign_tl} % This one is stored by some low-level code, so is declared explicitly. % \begin{macrocode} -\tl_new:N \l_siunitx_input_uncert_sign_tl +\tl_new:N \l_siunitx_input_uncert_sign_tl % \end{macrocode} %\end{macro} % @@ -6343,7 +6430,7 @@ This work consists of the file siunitx.dtx % \l_siunitx_input_protect_tl , % \l_siunitx_input_sign_tl , % \l_siunitx_input_symbol_tl , -% \l_siunitx_input_uncert_sign_tl , +% \l_siunitx_input_uncert_sign_tl %} % The various tokens to check against when parsing are all set up here. % These are valid inside a single number: the pre-processor has already @@ -6361,7 +6448,7 @@ This work consists of the file siunitx.dtx input-protect-tokens .tl_set:N = \l_siunitx_input_protect_tl , input-signs .tl_set:N = \l_siunitx_input_sign_tl , input-symbols .tl_set:N = \l_siunitx_input_symbol_tl , - input-uncertainty-signs .code:n = + input-uncertainty-signs .code:n = { \tl_set:Nn \l_siunitx_input_uncert_sign_tl {#1} \tl_map_inline:nn {#1} @@ -6389,7 +6476,7 @@ This work consists of the file siunitx.dtx % %\begin{macro}{ % \siunitx_number_in_parse:n , -% \siunitx_number_in_parse:V , +% \siunitx_number_in_parse:V %} %\begin{macro}[aux]{\siunitx_number_in_parse_aux:n} % The parsing routine starts by replacing any formatting in the input @@ -6412,9 +6499,9 @@ This work consists of the file siunitx.dtx \tl_set_rescan:Nnx \l_siunitx_number_arg_tl { \siunitx_number_in_protect: - \char_make_ignore:N \~ - \char_make_other:N \, - \char_make_other:N \. + \char_set_catcode_ignore:N \~ + \char_set_catcode_other:N \, + \char_set_catcode_other:N \. \cs_set_eq:NN \, \prg_do_nothing: } {#1} @@ -6450,7 +6537,7 @@ This work consists of the file siunitx.dtx % %\begin{macro}{ % \siunitx_number_in_init: , -% \siunitx_number_in_init_part:n , +% \siunitx_number_in_init_part:n %} % The set up code is divided into to parts. First, code only needed % once to start the entire parser. Then a second group, which is @@ -6508,19 +6595,19 @@ This work consists of the file siunitx.dtx % A short spin-out to keep the replacement of tokens clear. % \begin{macrocode} \cs_new_protected_nopar:Npn \siunitx_number_in_sign_replace:N #1 { - \tl_replace_all_in:Nnn #1 { -+ } { \mp } - \tl_replace_all_in:Nnn #1 { +- } { \pm } - \tl_replace_all_in:Nnn #1 { << } { \ll } - \tl_replace_all_in:Nnn #1 { <= } { \le } - \tl_replace_all_in:Nnn #1 { >> } { \gg } - \tl_replace_all_in:Nnn #1 { >= } { \ge } + \tl_replace_all:Nnn #1 { -+ } { \mp } + \tl_replace_all:Nnn #1 { +- } { \pm } + \tl_replace_all:Nnn #1 { << } { \ll } + \tl_replace_all:Nnn #1 { <= } { \le } + \tl_replace_all:Nnn #1 { >> } { \gg } + \tl_replace_all:Nnn #1 { >= } { \ge } } % \end{macrocode} %\end{macro} % %\begin{macro}{ % \siunitx_number_in_parse_error:nn , -% \siunitx_number_in_parse_error:nV , +% \siunitx_number_in_parse_error:nV %} % There are lots of rather similar errors in the parser, all of which % require a \cs{tl_map_break:}. To keep life simple, this is set up @@ -6536,7 +6623,7 @@ This work consists of the file siunitx.dtx % %\begin{macro}{ % \siunitx_number_in_parse_loop:N , -% \siunitx_number_in_parse_more:N , +% \siunitx_number_in_parse_more:N %} % The main loop is set up as a place holder, as the definition is % varied to keep things fast. There is also a place holder for the @@ -7029,7 +7116,7 @@ This work consists of the file siunitx.dtx % %\begin{macro}{ % \siunitx_number_in_uncert_open:N , -% \siunitx_number_in_uncert_close:N , +% \siunitx_number_in_uncert_close:N %} % Opening and closing uncertainty tokens are handled separately. For % opening tokens, a check is made that there is something else to the @@ -7097,7 +7184,7 @@ This work consists of the file siunitx.dtx %\begin{macro}{ % \siunitx_number_in_check:n , % \siunitx_number_in_check_short:n , -% \siunitx_number_in_check_full:n , +% \siunitx_number_in_check_full:n %} % The checks needed for a number depend on whether there is a complex % part. In all cases, there must be some digits, as well as a sign or @@ -7174,7 +7261,7 @@ This work consists of the file siunitx.dtx %\begin{macro}{\siunitx_number_in_complex_to_uncert:n} %\begin{macro}[aux]{ % \siunitx_number_in_complex_to_uncert_int: , -% \siunitx_number_in_complex_to_uncert_dec: , +% \siunitx_number_in_complex_to_uncert_dec: %} % Internally, uncertainties are stored in \enquote{compact} form. % The code here takes a putative complex part and converts it to @@ -7194,7 +7281,7 @@ This work consists of the file siunitx.dtx { \tl_if_single:NTF \l_siunitx_number_uncert_tl { - \int_compare:nNnTF + \int_compare:nNnTF { \l_siunitx_number_uncert_tl } = { \c_zero } { \siunitx_number_in_complex_to_uncert_dec:n {#1} } { \siunitx_number_in_complex_to_uncert_int: } @@ -7225,12 +7312,12 @@ This work consists of the file siunitx.dtx % only the significant digits are needed. This means that a loop is % needed to drop non-significant ones. % \begin{macrocode} -\cs_new_protected_nopar:Npn \siunitx_number_in_complex_to_uncert_dec:n - #1 +\cs_new_protected_nopar:Npn \siunitx_number_in_complex_to_uncert_dec:n + #1 { \tl_clear:N \l_siunitx_number_uncert_tl \prop_get:NnN \l_siunitx_number_in_prop { complex-decimal } - \l_siunitx_tmpa_tl + \l_siunitx_tmpa_tl \quark_if_no_value:NTF \l_siunitx_tmpa_tl { \siunitx_error:nx { misplaced-sign-token } @@ -7244,7 +7331,7 @@ This work consists of the file siunitx.dtx \tl_map_function:NN \l_siunitx_tmpa_tl \siunitx_number_in_complex_to_uncert_dec_loop:N - \siunitx_number_in_complex_to_uncert_pad: + \siunitx_number_in_complex_to_uncert_pad: } } \cs_new_protected_nopar:Npn @@ -7306,7 +7393,7 @@ This work consists of the file siunitx.dtx { 0 } } \tl_if_empty:NF \l_siunitx_tmpb_tl - { + { \prop_put:NnV \l_siunitx_number_in_prop { mantissa-decimal } \l_siunitx_tmpb_tl \prop_if_in:NnF \l_siunitx_number_in_prop @@ -7315,7 +7402,7 @@ This work consists of the file siunitx.dtx \prop_put:Nnn \l_siunitx_number_in_prop { mantissa-decimal-marker } { . } } - } + } } \tl_put_right:NV \l_siunitx_number_uncert_tl \l_siunitx_tmpa_tl \prop_put:NnV \l_siunitx_number_in_prop { mantissa-uncertainty } @@ -7340,7 +7427,7 @@ This work consists of the file siunitx.dtx % \l_siunitx_round_decimal_in_tl , % \l_siunitx_round_decimal_out_tl , % \l_siunitx_round_integer_in_tl , -% \l_siunitx_round_integer_out_tl , +% \l_siunitx_round_integer_out_tl %} % The rounding system needs a number of variables. % \begin{macrocode} @@ -7358,7 +7445,7 @@ This work consists of the file siunitx.dtx % \l_siunitx_process_decimal_int , % \l_siunitx_process_uncertainty_int , % \l_siunitx_uncertainty_decimal_tl , -% \l_siunitx_uncertainty_integer_tl , +% \l_siunitx_uncertainty_integer_tl %} % The code to expand uncertainties needs to know numbers of digits, and % to store various data. @@ -7373,7 +7460,7 @@ This work consists of the file siunitx.dtx %\begin{macro}{ % \l_siunitx_process_fixed_bool , % \l_siunitx_process_engineering_bool , -% \l_siunitx_process_scientific_bool , +% \l_siunitx_process_scientific_bool %} % Settings for the scientific notation system. % \begin{macrocode} @@ -7395,7 +7482,7 @@ This work consists of the file siunitx.dtx % \l_siunitx_process_zero_exponent_bool , % \l_siunitx_process_int_to_dec_bool , % \l_siunitx_process_round_min_tl , -% \l_siunitx_process_precision_int , +% \l_siunitx_process_precision_int %} % First, the options are set up. % \begin{macrocode} @@ -7404,7 +7491,7 @@ This work consists of the file siunitx.dtx add-integer-zero .bool_set:N = \l_siunitx_process_integer_zero_bool, explicit-sign .tl_set:N = \l_siunitx_process_sign_tl, fixed-exponent .int_set:N = \l_siunitx_process_fixed_int, - minimum-integer-digits .int_set:N = + minimum-integer-digits .int_set:N = \l_siunitx_process_integer_min_int, retain-explicit-plus .bool_set:N = \l_siunitx_process_plus_tl, retain-unity-mantissa .bool_set:N = @@ -7480,7 +7567,7 @@ This work consists of the file siunitx.dtx \prop_if_in:NnF \l_siunitx_number_in_prop { uncertainty } { \siunitx_number_process_round: } } - \siunitx_number_process_integer_digits: + \siunitx_number_process_integer_digits: } % \end{macrocode} %\end{macro} @@ -7526,7 +7613,7 @@ This work consists of the file siunitx.dtx %\begin{macro}{\siunitx_number_process_figures:n} %\begin{macro}[aux]{ % \siunitx_number_process_figures_aux:n , -% \siunitx_number_process_figures_init:n , +% \siunitx_number_process_figures_init:n %} % The approach here is to find how many digits there are in each part % of the number, working out which are significant. The next stage is @@ -7718,7 +7805,7 @@ This work consists of the file siunitx.dtx % \siunitx_number_process_fixed_large:nnn , % \siunitx_number_process_fixed_large_aux:w , % \siunitx_number_process_fixed_small:nnn , -% \siunitx_number_process_fixed_small_aux:w , +% \siunitx_number_process_fixed_small_aux:w %} % When working to a fixed exponent value, the idea is to use the stack % to do the work. First, there is some set up to do. @@ -7747,7 +7834,7 @@ This work consists of the file siunitx.dtx { \tl_put_left:NV \l_siunitx_tmpb_tl \l_siunitx_tmpa_tl } - \exp_args:NNNV \group_end: + \exp_args:NNNV \group_end: \tl_set:Nn \l_siunitx_tmpb_tl \l_siunitx_tmpb_tl \tl_set:Nx \l_siunitx_tmpa_tl { \l_siunitx_tmpa_tl { \l_siunitx_tmpb_tl } } @@ -7906,7 +7993,7 @@ This work consists of the file siunitx.dtx } \prop_put:NnV \l_siunitx_number_in_prop { mantissa-integer } \l_siunitx_tmpa_tl - } + } } } } @@ -7975,7 +8062,7 @@ This work consists of the file siunitx.dtx % \siunitx_number_process_places_aux_i:n , % \siunitx_number_process_places_aux_ii:n , % \siunitx_number_process_places_loop:n , -% \siunitx_number_process_places_integer:n , +% \siunitx_number_process_places_integer:n %} % For rounding to a fixed number of places, a check is made to see if % the decimal part is exactly zero. If it is, just create the @@ -8268,7 +8355,7 @@ This work consists of the file siunitx.dtx % \siunitx_number_process_scientific_engineering_1:nw , % \siunitx_number_process_scientific_engineering_2:nnn , % \siunitx_number_process_scientific_engineering_2_i:nw , -% \siunitx_number_process_scientific_engineering_2_ii:nw , +% \siunitx_number_process_scientific_engineering_2_ii:nw %} % Converting a number to scientific form is done such that the number % of places involved is unchanged. The first step is to skip any @@ -8296,7 +8383,7 @@ This work consists of the file siunitx.dtx \l_siunitx_tmpa_tl \quark_if_no_value:NF \l_siunitx_tmpa_tl { \tl_put_left:NV \l_siunitx_tmpb_tl \l_siunitx_tmpa_tl } - \exp_args:NNNV \group_end: + \exp_args:NNNV \group_end: \tl_set:Nn \l_siunitx_tmpb_tl \l_siunitx_tmpb_tl \tl_set:Nx \l_siunitx_tmpa_tl { \l_siunitx_tmpa_tl { \l_siunitx_tmpb_tl } } @@ -8353,12 +8440,12 @@ This work consists of the file siunitx.dtx % For small numbers, the important digit is easy to find. % \begin{macrocode} \cs_new_protected_nopar:Npn - \siunitx_number_process_scientific_small:wn #1#2 \q_stop #3 + \siunitx_number_process_scientific_small:wn #1#2 \q_stop #3 { \siunitx_number_process_scientific_aux_ii:nnn {#1} {#2} { #3 - 1 } } % \end{macrocode} % A tidy-up and store routine. % \begin{macrocode} -\cs_new_protected_nopar:Npn +\cs_new_protected_nopar:Npn \siunitx_number_process_scientific_store:nnn #1#2#3 { \prop_put:Nnn \l_siunitx_number_in_prop { mantissa-integer } {#1} @@ -8388,13 +8475,13 @@ This work consists of the file siunitx.dtx \prop_put:Nnn \l_siunitx_number_in_prop { exponent } { true } \int_compare:nNnTF {#3} > { 0 } { - \int_set:Nn \l_siunitx_tmp_int {#3} + \int_set:Nn \l_siunitx_tmp_int {#3} \prop_put:NnV \l_siunitx_number_in_prop { exponent-integer } \l_siunitx_tmp_int \prop_del:Nn \l_siunitx_number_in_prop { exponent-sign } } { - \int_set:Nn \l_siunitx_tmp_int { 0 - (#3) } + \int_set:Nn \l_siunitx_tmp_int { 0 - (#3) } \prop_put:NnV \l_siunitx_number_in_prop { exponent-integer } \l_siunitx_tmp_int \prop_put:Nnn \l_siunitx_number_in_prop { exponent-sign } @@ -8435,7 +8522,7 @@ This work consists of the file siunitx.dtx { \tl_if_empty:nTF {#2} { - \siunitx_number_process_scientific_store:nnn { #1 0 } { } + \siunitx_number_process_scientific_store:nnn { #1 0 } { } { #3 - 1 } } { @@ -8445,7 +8532,7 @@ This work consists of the file siunitx.dtx } } \cs_new_protected_nopar:cpn - { siunitx_number_process_scientific_engineering_1:nw } + { siunitx_number_process_scientific_engineering_1:nw } #1#2#3 \q_stop #4 { \siunitx_number_process_scientific_store:nnn @@ -8456,7 +8543,7 @@ This work consists of the file siunitx.dtx { \tl_if_empty:nTF {#2} { - \siunitx_number_process_scientific_store:nnn { #1 00 } { } + \siunitx_number_process_scientific_store:nnn { #1 00 } { } { #3 - 2 } } { @@ -8466,12 +8553,12 @@ This work consists of the file siunitx.dtx } } \cs_new_protected_nopar:cpn - { siunitx_number_process_scientific_engineering_2_i:nw } + { siunitx_number_process_scientific_engineering_2_i:nw } #1#2#3 \q_stop #4 { \tl_if_empty:nTF {#3} { - \siunitx_number_process_scientific_store:nnn { #1#2 0 } { } + \siunitx_number_process_scientific_store:nnn { #1#2 0 } { } { #4 - 2 } } { @@ -8481,10 +8568,10 @@ This work consists of the file siunitx.dtx } } \cs_new_protected_nopar:cpn - { siunitx_number_process_scientific_engineering_2_ii:nw } + { siunitx_number_process_scientific_engineering_2_ii:nw } #1#2#3 \q_stop #4 { - \siunitx_number_process_scientific_store:nnn { #1#2 } {#3} + \siunitx_number_process_scientific_store:nnn { #1#2 } {#3} { #4 - 2 } } % \end{macrocode} @@ -8494,7 +8581,7 @@ This work consists of the file siunitx.dtx %\begin{macro}{\siunitx_number_process_sign:} %\begin{macro}[aux]{ % \siunitx_number_process_sign_add:n , -% \siunitx_number_process_sign_plus:n , +% \siunitx_number_process_sign_plus:n %} %\begin{macro}{\c_siunitx_plus_tl} % Sorting out signs consists of two parts: retaining a plus if necessary @@ -8517,14 +8604,9 @@ This work consists of the file siunitx.dtx } \tl_if_empty:NF \l_siunitx_process_sign_tl { - \prop_if_in:NnTF \l_siunitx_number_in_prop { mantissa } - { \siunitx_number_process_sign_add:n { mantissa } } - { - \prop_if_in:NnT \l_siunitx_number_in_prop { complex } - { \siunitx_number_process_sign_add:n { complex } } - } - \prop_if_in:NnT \l_siunitx_number_in_prop { exponent } - { \siunitx_number_process_sign_add:n { exponent } } + \siunitx_number_process_sign_add:n { mantissa } + \prop_if_in:NnTF \l_siunitx_number_in_prop { complex } + { \siunitx_number_process_sign_add:n { complex } } } } % \end{macrocode} @@ -8686,7 +8768,7 @@ This work consists of the file siunitx.dtx %\begin{macro}{\siunitx_number_process_zero_fill:} %\begin{macro}[aux]{ % \siunitx_number_process_zero_fill_aux:n , -% \siunitx_number_process_zero_fill_aux:nn , +% \siunitx_number_process_zero_fill_aux:nn %} % Checks for adding zeros to each component are carried out. The nesting % here makes checking the appropriate flag a little more efficient. @@ -8733,7 +8815,7 @@ This work consists of the file siunitx.dtx % %\begin{macro}{ % \l_siunitx_group_sep_tl , -% \l_siunitx_output_decimal_tl , +% \l_siunitx_output_decimal_tl %} % A couple of variables are declared here, as they need a little more % work than just storage. @@ -8750,6 +8832,15 @@ This work consists of the file siunitx.dtx % \end{macrocode} %\end{macro} % +% \begin{variable} +% {\l_siunitx_group_decimal_bool, \l_siunitx_group_integer_bool} +% Used for grouping digits. +% \begin{macrocode} +\bool_new:N \l_siunitx_group_decimal_bool +\bool_new:N \l_siunitx_group_integer_bool +% \end{macrocode} +% \end{variable} +% %\begin{macro}{ % \l_siunitx_negative_bracket_bool , % \l_siunitx_brackets_bool , @@ -8758,9 +8849,7 @@ This work consists of the file siunitx.dtx % \l_siunitx_output_decimal_copy_bool , % \l_siunitx_exponent_base_tl , % \l_siunitx_exponent_product_tl , -% \l_siunitx_group_decimal_bool , -% \l_siunitx_group_four_bool , -% \l_siunitx_group_integer_bool , +% \l_siunitx_group_min_int , % \l_siunitx_negative_color_tl , % \l_siunitx_bracket_open_tl , % \l_siunitx_output_uncert_close_tl , @@ -8769,12 +8858,12 @@ This work consists of the file siunitx.dtx % \l_siunitx_output_uncert_open_tl , % \l_siunitx_uncert_sep_bool , % \l_siunitx_tight_bool , -% \l_siunitx_uncert_sep_tl , +% \l_siunitx_uncert_sep_tl %} % Lots of settings, some used only for numbers, some more widely. % \begin{macrocode} \keys_define:nn { siunitx } { - bracket-negative-numbers .bool_set:N = + bracket-negative-numbers .bool_set:N = \l_siunitx_negative_bracket_bool , bracket-numbers .bool_set:N = \l_siunitx_brackets_bool, close-bracket .tl_set:N = \l_siunitx_bracket_close_tl, @@ -8792,30 +8881,50 @@ This work consists of the file siunitx.dtx exponent-base .tl_set:N = \l_siunitx_exponent_base_tl, exponent-product .tl_set:N = \l_siunitx_exponent_product_tl, - group-decimal-digits .bool_set:N = - \l_siunitx_group_decimal_bool, - group-digits .meta:n = - { - group-decimal-digits = #1, - group-integer-digits = #1 - }, + group-decimal-digits .meta:n = { group-digits = decimal }, + group-digits .choice: , + group-digits / + decimal .code:n = + { + \bool_set_true:N \l_siunitx_group_decimal_bool + \bool_set_false:N \l_siunitx_group_integer_bool + }, + group-digits / + false .code:n = + { + \bool_set_false:N \l_siunitx_group_decimal_bool + \bool_set_false:N \l_siunitx_group_integer_bool + }, + group-digits / + integer .code:n = + { + \bool_set_false:N \l_siunitx_group_decimal_bool + \bool_set_true:N \l_siunitx_group_integer_bool + }, + group-digits / + true .code:n = + { + \bool_set_true:N \l_siunitx_group_decimal_bool + \bool_set_true:N \l_siunitx_group_integer_bool + }, group-digits .default:n = true , - group-four-digits .bool_set:N = \l_siunitx_group_four_bool, - group-integer-digits .bool_set:N = - \l_siunitx_group_integer_bool, + group-four-digits .choice:, + group-four-digits / + false .meta:n = { group-minimum-digits = 5 }, + group-four-digits / + true .meta:n = { group-minimum-digits = 4 }, + group-four-digits .default:n = true, + group-integer-digits .meta:n = { group-digits = integer }, + group-minimum-digits .int_set:N = \l_siunitx_group_min_int, group-separator .code:n = - { - \tl_set:Nn \l_siunitx_group_sep_tl { {#1} } - }, + { \tl_set:Nn \l_siunitx_group_sep_tl { {#1} } }, negative-color .tl_set:N = \l_siunitx_negative_color_tl, open-bracket .tl_set:N = \l_siunitx_bracket_open_tl, output-close-uncertainty .tl_set:N = \l_siunitx_output_uncert_close_tl, output-complex-root .tl_set:N = \l_siunitx_output_complex_tl , output-decimal-marker .code:n = - { - \tl_set:Nn \l_siunitx_output_decimal_tl { {#1} } - }, + { \tl_set:Nn \l_siunitx_output_decimal_tl { {#1} } }, output-exponent-marker .tl_set:N = \l_siunitx_output_exponent_tl, output-open-uncertainty .tl_set:N = \l_siunitx_output_uncert_open_tl, @@ -8830,8 +8939,8 @@ This work consists of the file siunitx.dtx copy-decimal-marker = false, exponent-base = 10, exponent-product = \times, - group-decimal-digits = true, - group-integer-digits = true, + group-digits = true, + group-minimum-digits = 5, group-separator = \,, open-bracket = (, % ) ( output-close-uncertainty = ), @@ -8929,7 +9038,7 @@ This work consists of the file siunitx.dtx %\begin{macro}{\siunitx_number_format_complex:} %\begin{macro}[aux]{ % \siunitx_number_format_complex_aux:n , -% \siunitx_number_format_complex_aux: , +% \siunitx_number_format_complex_aux: %} % The real and complex parts of each number are reassembled, with % brackets if needed. @@ -9002,7 +9111,7 @@ This work consists of the file siunitx.dtx % %\begin{macro}{ % \siunitx_number_format_copy:n , -% \siunitx_number_format_copy:nn , +% \siunitx_number_format_copy:nn %} % Just copy across. % \begin{macrocode} @@ -9106,7 +9215,7 @@ This work consists of the file siunitx.dtx \prop_get:NnN \l_siunitx_number_out_prop { exponent } \l_siunitx_tmpa_tl \tl_if_empty:NTF \l_siunitx_output_exponent_tl - { + { \tl_set:Nx \l_siunitx_tmpa_tl { ^ { \exp_not:V \l_siunitx_tmpa_tl } } \tl_put_left:NV \l_siunitx_tmpa_tl \l_siunitx_exponent_base_tl @@ -9191,49 +9300,31 @@ This work consists of the file siunitx.dtx \prop_if_in:NnT \l_siunitx_number_in_prop { #1 - #2 } { \bool_if:cTF { l_siunitx_group_ #2 _bool } - { \siunitx_number_format_group_four:nn {#1} {#2} } + { \siunitx_number_format_group:nn {#1} {#2} } { \siunitx_number_format_copy:n { #1 - #2 } } } } % \end{macrocode} %\end{macro} %\end{macro} -%\begin{macro}{\siunitx_number_format_group_four:nn} -%\begin{macro}[aux]{ -% \siunitx_number_format_group_four_aux:NNNNNNw , -% \siunitx_number_format_group_four_aux:nn , -%} -% The idea here is that grouping is only needed for items with at -% least four tokens in them, and perhaps five if the grouping of -% four-digit numbers is turned off. +% \begin{macro}{\siunitx_number_format_group:nn} +% The idea here is that grouping is only needed for numbers with sufficient +% digits: this is done simply by counting up all of the digits. % \begin{macrocode} -\cs_new_protected_nopar:Npn \siunitx_number_format_group_four:nn #1#2 { - \prop_get:NnN \l_siunitx_number_in_prop { #1 - #2 } - \l_siunitx_tmpa_tl - \bool_if:NTF \l_siunitx_group_four_bool - { \siunitx_number_format_group_four_aux:nn {#1} {#2} } - { - \exp_after:wN \siunitx_number_format_group_four_aux:NNNNNNw - \l_siunitx_tmpa_tl \q_no_value \q_no_value \q_no_value - \q_no_value \q_no_value \q_stop - { \siunitx_number_format_copy:n {#1 - #2} } - { \siunitx_number_format_group_four_aux:nn {#1} {#2} } - } -} -\cs_new_protected:Npn \siunitx_number_format_group_four_aux:NNNNNNw - #1#2#3#4#5#6 \q_stop { - \quark_if_no_value:NTF #5 -} -\cs_new_protected_nopar:Npn \siunitx_number_format_group_four_aux:nn - #1#2 { - \tl_clear:N \l_siunitx_tmpb_tl - \use:c { siunitx_number_format_group_ #2 : } - \prop_put:NnV \l_siunitx_number_out_prop { #1 - #2 } - \l_siunitx_tmpb_tl -} +\cs_new_protected_nopar:Npn \siunitx_number_format_group:nn #1#2 + { + \prop_get:NnN \l_siunitx_number_in_prop { #1 - #2 } \l_siunitx_tmpa_tl + \int_compare:nNnTF + { \tl_length:N \l_siunitx_tmpa_tl } < \l_siunitx_group_min_int + { \siunitx_number_format_copy:n { #1 - #2 } } + { + \tl_clear:N \l_siunitx_tmpb_tl + \use:c { siunitx_number_format_group_ #2 : } + \prop_put:NnV \l_siunitx_number_out_prop { #1 - #2 } \l_siunitx_tmpb_tl + } + } % \end{macrocode} -%\end{macro} -%\end{macro} +% \end{macro} %\begin{macro}{\siunitx_number_format_group_decimal:} %\begin{macro}[aux]{\siunitx_number_format_group_decimal_aux:} % Using the \enquote{keep everything on the stack} approach, relatively @@ -9273,7 +9364,7 @@ This work consists of the file siunitx.dtx % \siunitx_number_format_group_integer_setup:n , % \siunitx_number_format_group_integer_setup:V , % \siunitx_number_format_group_integer_setup_aux:NNNN , -% \siunitx_number_format_group_integer_aux:NNNN , +% \siunitx_number_format_group_integer_aux:NNNN %} % By keeping everything on the stack, recursion can occur quite % efficiently here. @@ -9356,9 +9447,9 @@ This work consists of the file siunitx.dtx % %\begin{macro}{ % \siunitx_number_format_join_uncert: , -% \siunitx_number_format_join_uncert:n , +% \siunitx_number_format_join_uncert:n %} -%\begin{macro}[aux]{\siunitx_number_format_join_uncert_pm:} +%\begin{macro}[aux]{\siunitx_number_format_join_uncert_pm:N} % For adding separated uncertainties to the main part of a number. % \begin{macrocode} \cs_new_protected_nopar:Npn \siunitx_number_format_join_uncert: { @@ -9376,7 +9467,7 @@ This work consists of the file siunitx.dtx { \siunitx_number_format_copy:nn {#1} { #1 -result } } { \bool_if:NT \l_siunitx_uncert_sep_bool - { \siunitx_number_format_join_uncert_pm: } + { \siunitx_number_format_join_uncert_pm:N \l_siunitx_tmpb_tl } \tl_put_right:NV \l_siunitx_tmpa_tl \l_siunitx_tmpb_tl \prop_put:NnV \l_siunitx_number_out_prop { #1 -result } \l_siunitx_tmpa_tl @@ -9385,17 +9476,12 @@ This work consists of the file siunitx.dtx } } } -\cs_new_protected_nopar:Npn \siunitx_number_format_join_uncert_pm: { - \bool_if:NTF \l_siunitx_tight_bool - { - \tl_put_left:Nn \l_siunitx_tmpb_tl - { \siunitx_ensuremath:n { { \pm } } } - } - { - \tl_put_left:Nn \l_siunitx_tmpb_tl - { \siunitx_ensuremath:n { { } \pm { } } } - } -} +\cs_new_protected_nopar:Npn \siunitx_number_format_join_uncert_pm:N #1 + { + \bool_if:NTF \l_siunitx_tight_bool + { \tl_put_left:Nn #1 { \siunitx_ensuremath:n { { \pm } } } } + { \tl_put_left:Nn #1 { \siunitx_ensuremath:n { { } \pm { } } } } + } % \end{macrocode} %\end{macro} %\end{macro} @@ -9447,12 +9533,12 @@ This work consists of the file siunitx.dtx % %\begin{macro}{ % \siunitx_number_format_sign:n , -% \siunitx_number_format_sign_complex: , +% \siunitx_number_format_sign_complex: %} %\begin{macro}[aux]{ % \siunitx_number_format_sign_aux:n , % \siunitx_number_format_sign_negative_brackets:n , -% \siunitx_number_format_sign_complex:n , +% \siunitx_number_format_sign_complex:n %} % Some simple sign manipulation: for tight signs, a little shuffling. % In the complex number case, there is a need for a correction to get @@ -9475,7 +9561,7 @@ This work consists of the file siunitx.dtx { \siunitx_number_format_sign_aux:n {#1} } } } -} +} \cs_new_protected_nopar:Npn \siunitx_number_format_sign_aux:n #1 { \bool_if:NT \l_siunitx_tight_bool { @@ -9498,7 +9584,7 @@ This work consists of the file siunitx.dtx \l_siunitx_tmpa_tl } } -\cs_new_protected_nopar:Npn +\cs_new_protected_nopar:Npn \siunitx_number_format_sign_negative_brackets:n #1 { \siunitx_number_format_brackets_aux:n {#1} @@ -9507,7 +9593,7 @@ This work consists of the file siunitx.dtx \quark_if_no_value:NF \l_siunitx_tmpa_tl { \siunitx_tl_put_left_math:NV \l_siunitx_tmpa_tl - \l_siunitx_bracket_open_tl + \l_siunitx_bracket_open_tl \siunitx_tl_put_right_math:NV \l_siunitx_tmpa_tl \l_siunitx_bracket_close_tl \prop_put:NnV \l_siunitx_number_out_prop { #1 } @@ -9557,7 +9643,7 @@ This work consists of the file siunitx.dtx %\begin{macro}{\siunitx_number_format_uncertainty:n} %\begin{macro}[aux]{ % \siunitx_number_format_uncertainty_joined:n , -% \siunitx_number_format_uncertainty_sep:n , +% \siunitx_number_format_uncertainty_sep:n %} % Uncertainty output varies depending on whether there is a need to % separate the error form the number in the output. @@ -9612,7 +9698,7 @@ This work consists of the file siunitx.dtx % %\begin{macro}{ % \l_siunitx_number_out_tl , -% \l_siunitx_number_out_saved_tl , +% \l_siunitx_number_out_saved_tl %} % The final result, plus a version for loops. % \begin{macrocode} @@ -9652,7 +9738,7 @@ This work consists of the file siunitx.dtx % %\begin{macro}{ % \l_siunitx_output_quotient_tl , -% \l_siunix_number_parse_bool , +% \l_siunix_number_parse_bool %} % Some options related to numbers at the output stage. % \begin{macrocode} @@ -9680,7 +9766,7 @@ This work consists of the file siunitx.dtx % %\begin{macro}{ % \siunitx_number_output:n , -% \siunitx_number_output:V , +% \siunitx_number_output:V %} % The number output system simply sets up for the combined number and % unit system. @@ -9723,7 +9809,7 @@ This work consists of the file siunitx.dtx % %\begin{macro}{ % \siunitx_number_output_parse:n , -% \siunitx_number_output_parse:V , +% \siunitx_number_output_parse:V %} %\begin{macro}[aux]{\siunitx_number_output_parse_aux:} % The parsing system just has to check if there are multiple parts to @@ -9774,7 +9860,7 @@ This work consists of the file siunitx.dtx %\begin{macro}[aux]{ % \siunitx_number_output_parts_aux: , % \siunitx_number_output_parts_aux:n , -% \siunitx_number_output_parts_print:n , +% \siunitx_number_output_parts_print:n %} % Printing numbers by parts is necessary when there are units to % repeat. That means doing things that have already been done by the @@ -9992,7 +10078,7 @@ This work consists of the file siunitx.dtx %\end{macro} %\begin{macro}[aux]{ % \siunitx_number_output_quotient_aux_i: , -% \siunitx_number_output_quotient_aux_ii: , +% \siunitx_number_output_quotient_aux_ii: %} % The two parts of the number are parsed and formatted. % \begin{macrocode} @@ -10074,7 +10160,7 @@ This work consists of the file siunitx.dtx % %\begin{macro}{ % \l_siunitx_angle_degree_space_bool , -% \l_siunitx_angle_minute_space_bool , +% \l_siunitx_angle_minute_space_bool %} % The need for spaces between parts of an arc needs to be accommodated: % this is achieved by flagging up the need for such spaces using two @@ -10089,7 +10175,7 @@ This work consists of the file siunitx.dtx % \l_siunitx_angle_marker_box , % \l_siunitx_angle_unit_box , % \l_siunitx_angle_marker_dim , -% \l_siunitx_angle_unit_dim , +% \l_siunitx_angle_unit_dim %} % When creating astronomy-style angles, the decimal marker and angle % symbol have to be boxed up and measured. @@ -10104,7 +10190,7 @@ This work consists of the file siunitx.dtx %\begin{macro}{ % \l_siunitx_angle_degree_prop , % \l_siunitx_angle_minute_prop , -% \l_siunitx_angle_second_prop , +% \l_siunitx_angle_second_prop %} % As there are potentially three numbers to parse, three properly lists % are made available to hold the results. This allows the code to be @@ -10122,7 +10208,7 @@ This work consists of the file siunitx.dtx % \l_siunitx_angle_second_zero_bool , % \l_siunitx_angle_arc_separator_tl , % \l_siunitx_angle_astronomy_bool , -% \l_siunitx_angle_unit_product_tl , +% \l_siunitx_angle_unit_product_tl %} % The angle-specific options are created here. % \begin{macrocode} @@ -10201,7 +10287,7 @@ This work consists of the file siunitx.dtx %\begin{macro}[aux]{ % \siunitx_angle_direct_aux_i:nnn , % \siunitx_angle_direct_aux_ii:nnn , -% \siunitx_angle_direct_aux_iii:nnn , +% \siunitx_angle_direct_aux_iii:nnn %} % When printing an arc directly, there is still the need to fill in % any zero values required and to check the spacing is correct. That @@ -10256,12 +10342,12 @@ This work consists of the file siunitx.dtx % \siunitx_angle_parse:nnn , % \siunitx_angle_check_sign: , % \siunitx_angle_zero_fill: , -% \siunitx_angle_sign_shuffle:nn , +% \siunitx_angle_sign_shuffle:nn %} %\begin{macro}[aux]{ % \siunitx_angle_parse_aux:nnn , % \siunitx_angle_check_sign:n , -% \siunitx_angle_sign_shuffle_aux:nnn , +% \siunitx_angle_sign_shuffle_aux:nnn %} % Parsing an arc requires a number of stages. First, there is the % basic conversion of the input numbers into three property lists, @@ -10439,7 +10525,7 @@ This work consists of the file siunitx.dtx % \siunitx_angle_print_astronomy_aux: , % \siunitx_angle_print_astronomy_aux:n , % \siunitx_angle_print_astronomy_marker: , -% \siunitx_angle_print_astronomy_unit: , +% \siunitx_angle_print_astronomy_unit: %} % The first check for astronomy-style angles is that there is a decimal % marker in the current input: if not, the standard method can be used. @@ -10577,21 +10663,21 @@ This work consists of the file siunitx.dtx % %\begin{macro}{ % \siunitx_declare_power_after:Nn , -% \siunitx_declare_power_before:Nn , +% \siunitx_declare_power_before:Nn %} % Creating powers is all about storing values. % \begin{macrocode} \cs_new_protected:Npn \siunitx_declare_power_after:Nn #1#2 { \tl_put_right:Nn \l_siunitx_declare_list_tl {#1} \cs_set:cpn { siunitx_ \token_to_str:N #1 _literal:w } - { \textsuperscript {#2} } + { \siunitx_textsuperscript {#2} } \cs_set:cpn { siunitx_ \token_to_str:N #1 _function:w } { \siunitx_unit_parse_power_after:n {#2} } } \cs_new_protected:Npn \siunitx_declare_power_before:Nn #1#2 { \tl_put_right:Nn \l_siunitx_declare_list_tl {#1} \cs_set:cpn { siunitx_ \token_to_str:N #1 _literal:w } ##1 - { ##1 \textsuperscript {#2} } + { ##1 \siunitx_textsuperscript {#2} } \cs_set:cpn { siunitx_ \token_to_str:N #1 _function:w } { \siunitx_unit_parse_power_before:n {#2} } } @@ -10644,15 +10730,9 @@ This work consists of the file siunitx.dtx {#2} } \tl_if_empty:nTF {#3} + { \cs_undefine:c { l_siunitx_ \token_to_str:N #1 _options_tl } } { - \cs_if_free:cF { l_siunitx_ \token_to_str:N #1 _options_tl } - { - \cs_gundefine:c { l_siunitx_ \token_to_str:N #1 _options_tl } - } - } - { - \cs_if_free:cT { l_siunitx_ \token_to_str:N #1 _options_tl } - { \tl_new:c { l_siunitx_ \token_to_str:N #1 _options_tl } } + \tl_clear_new:c { l_siunitx_ \token_to_str:N #1 _options_tl } \tl_set:cn { l_siunitx_ \token_to_str:N #1 _options_tl } {#3} } } @@ -10676,20 +10756,20 @@ This work consists of the file siunitx.dtx % %\begin{macro}{ % \raiseto , -% \tothe , +% \tothe %} % Generic versions of the pre-set powers. % \begin{macrocode} \cs_new:cpn { siunitx_ \token_to_str:N \raiseto _literal:w } #1#2 { #2 - \textsuperscript {#1} + \siunitx_textsuperscript {#1} } \cs_new_protected:cpn { siunitx_ \token_to_str:N \raiseto _function:w } #1 { \siunitx_unit_parse_power_before:n {#1} } \cs_new:cpn { siunitx_ \token_to_str:N \tothe _literal:w } #1 { - \textsuperscript {#1} + \siunitx_textsuperscript {#1} } \cs_new_protected:cpn { siunitx_ \token_to_str:N \tothe _function:w } #1 { @@ -10720,7 +10800,7 @@ This work consists of the file siunitx.dtx { \cs_set_eq:NN \siunitx_cancel:n \cancel \tl_put_right:Nn \l_siunitx_declare_list_tl { \cancel } - \cs_new_protected:cpn + \cs_new_protected:cpn { siunitx_ \token_to_str:N \cancel _function:w } { \siunitx_unit_parse_special:n { \siunitx_cancel:n } } } @@ -10752,7 +10832,7 @@ This work consists of the file siunitx.dtx % \l_siunitx_create_overwrite_bool , % \l_siunitx_create_prespace_bool , % \l_siunitx_create_optional_bool , -% \l_siunitx_create_xspace_bool , +% \l_siunitx_create_xspace_bool %} % There are a few options which control this behaviour: these are all % preamble-only. @@ -10805,7 +10885,7 @@ This work consists of the file siunitx.dtx % \begin{macrocode} \cs_new_protected_nopar:Npn \siunitx_unit_create_functions: { \bool_if:NT \l_siunitx_create_overwrite_bool - { \tl_map_function:NN \l_siunitx_declare_list_tl \cs_gundefine:N } + { \tl_map_function:NN \l_siunitx_declare_list_tl \cs_undefine:N } \bool_if:NTF \l_siunitx_create_optional_bool { \tl_map_function:NN \l_siunitx_declare_list_tl @@ -10823,7 +10903,7 @@ This work consists of the file siunitx.dtx % %\begin{macro}{ % \siunitx_unit_create:N , -% \siunitx_unit_create_with_arg:N , +% \siunitx_unit_create_with_arg:N %} % The creation functions expand everything as far as possible so that % there is less to do in the document. @@ -10940,7 +11020,7 @@ This work consists of the file siunitx.dtx % %\begin{macro}{ % \l_siunitx_unit_forbid_literal_bool , -% \l_siunitx_unit_parse_bool , +% \l_siunitx_unit_parse_bool %} % One option is related to how units are pre-processed. % \begin{macrocode} @@ -10959,7 +11039,7 @@ This work consists of the file siunitx.dtx %\begin{macro}{ % \siunitx_unit_in:nn , % \siunitx_unit_in:Vn , -% \siunitx_pm: , +% \siunitx_pm: %} % The master function does a very simple checks then hands off. % The definition of \cs{pm} needs to be saved here so that it can @@ -11032,7 +11112,7 @@ This work consists of the file siunitx.dtx % %\begin{macro}{ % \l_siunitx_unit_int , -% \l_siunitx_unit_prop , +% \l_siunitx_unit_prop %} % Parsed units are stored in a property list, to keep things compact. % An integer is also needed to count up units. @@ -11051,7 +11131,7 @@ This work consists of the file siunitx.dtx % %\begin{macro}{ % \l_siunitx_prefix_symbols_bool , -% \l_siunitx_sticky_per_bool , +% \l_siunitx_sticky_per_bool %} % Some options are directly related to how units are handled at this % stage, so need be created before the reconstruction part of the code. @@ -11121,7 +11201,7 @@ This work consists of the file siunitx.dtx % %\begin{macro}{ % \siunitx_unit_parse_power_before:n , -% \siunitx_unit_parse_power_after:n , +% \siunitx_unit_parse_power_after:n %} % Storing powers depends on whether they are given before or after % the unit. @@ -11141,7 +11221,7 @@ This work consists of the file siunitx.dtx % %\begin{macro}{ % \siunitx_unit_parse_prefix:n , -% \siunitx_unit_parse_prefix:nn , +% \siunitx_unit_parse_prefix:nn %} % Saving prefixes always increments the counter. For non-symbolic % mode, the base needs to be saved along with the power. @@ -11256,7 +11336,7 @@ This work consists of the file siunitx.dtx % \l_siunitx_unit_current_tl , % \l_siunitx_unit_denominator_tl , % \l_siunitx_unit_numerator_tl , -% \l_siunitx_unit_saved_tl , +% \l_siunitx_unit_saved_tl %} % Storage space for creating unit output. % \begin{macrocode} @@ -11271,7 +11351,7 @@ This work consists of the file siunitx.dtx % %\begin{macro}{ % \l_siunitx_unit_denominator_int , -% \l_siunitx_unit_numerator_int , +% \l_siunitx_unit_numerator_int %} % For tracking in case brackets are needed. % \begin{macrocode} @@ -11283,7 +11363,7 @@ This work consists of the file siunitx.dtx %\begin{macro}{ % \l_siunitx_unit_prefix_int , % \l_siunitx_unit_prefix_base_int , -% \l_siunitx_unit_prefix_current_tl , +% \l_siunitx_unit_prefix_current_tl %} % Used to calculate the overall prefix value. % \begin{macrocode} @@ -11315,7 +11395,7 @@ This work consists of the file siunitx.dtx % \l_siunitx_per_mode_tl , % \l_siunitx_power_number_bool , % \l_siunitx_qualifier_mode_tl , -% \l_siunitx_per_two_parts_bool , +% \l_siunitx_per_two_parts_bool %} % For saving settings. % \begin{macrocode} @@ -11331,7 +11411,8 @@ This work consists of the file siunitx.dtx %\begin{macro}{ % \l_siunitx_unit_denominator_bracket_bool , % \l_siunitx_unit_product_tl , -% \l_siunitx_per_symbol_tl , +% \l_siunitx_literal_power_bool , +% \l_siunitx_per_symbol_tl %} % At this stage, output formatting options are created. % \begin{macrocode} @@ -11340,6 +11421,8 @@ This work consists of the file siunitx.dtx = \l_siunitx_unit_denominator_bracket_bool, inter-unit-product .tl_set:N = \l_siunitx_unit_product_tl , inter-unit-separator .tl_set:N = \l_siunitx_unit_product_tl , + literal-superscript-as-power + .bool_set:N = \l_siunitx_literal_power_bool, per-mode .choice:, per-mode / fraction .code:n = { @@ -11403,12 +11486,13 @@ This work consists of the file siunitx.dtx { \tl_set:Nn \l_siunitx_qualifier_mode_tl { text } }, } \keys_set:nn { siunitx } { - bracket-unit-denominator = true, - inter-unit-product = \,, - per-mode = reciprocal, - per-symbol = /, - power-font = number, - qualifier-mode = subscript + bracket-unit-denominator = true, + inter-unit-product = \,, + literal-superscript-as-power = true, + per-mode = reciprocal, + per-symbol = /, + power-font = number, + qualifier-mode = subscript } % \end{macrocode} %\end{macro} @@ -11487,14 +11571,14 @@ This work consists of the file siunitx.dtx { special- \int_use:N \l_siunitx_unit_int } \prop_get:NVN \l_siunitx_unit_prop \l_siunitx_tmpa_tl \l_siunitx_tmpa_tl - \quark_if_no_value:NTF \l_siunitx_tmpa_tl + \quark_if_no_value:NTF \l_siunitx_tmpa_tl { - \tl_put_left:cV { l_siunitx_unit #1 _tl } + \tl_put_left:cV { l_siunitx_unit #1 _tl } \l_siunitx_unit_current_tl } { \tl_put_left:cx { l_siunitx_unit #1 _tl } - { + { \exp_not:V \l_siunitx_tmpa_tl { \exp_not:V \l_siunitx_unit_current_tl } } @@ -11510,7 +11594,7 @@ This work consists of the file siunitx.dtx % \siunitx_unit_format_auto: , % \siunitx_unit_format_symbol: , % \siunitx_unit_format_symbol_aux: , -% \siunitx_unit_format_symbol_aux_alt: , +% \siunitx_unit_format_symbol_aux_alt: %} % When making (\emph{psuedo}-)fractions there is a check to place a % \( 1 \) in the numerator is it's blank. For symbol mode, this is @@ -11643,37 +11727,44 @@ This work consists of the file siunitx.dtx % \end{macrocode} %\end{macro} % -%\begin{macro}{\siunitx_unit_format_literal:n} -%\begin{macro}[aux]{\siunitx_unit_format_literal_aux:N} -% If the unit given contains anything which is not a unit macro, then -% any unit macros that are there simply dump literal meanings. There is -% then a little work to do sorting out "~" and \texttt{.} characters at -% the outer level. +% \begin{macro}{\siunitx_unit_format_literal:n} +% \begin{macro}[aux]{\siunitx_unit_format_literal_aux:N} +% \begin{macro}[aux]{\siunitx_unit_format_literal_power:n} +% If the unit given contains anything which is not a unit macro, then +% any unit macros that are there simply dump literal meanings. There is +% then a little work to do sorting out |~| and |.| characters at +% the outer level. % \begin{macrocode} -\char_make_active:N \~ -\cs_new_protected:Npn \siunitx_unit_format_literal:n #1 { - \int_zero:N \l_siunitx_unit_prefix_int - \tl_map_function:NN \l_siunitx_declare_list_tl - \siunitx_unit_print_literal_aux:N - \tl_set:Nn \l_siunitx_unit_tl {#1} - \tl_set:Nx \l_siunitx_tmpa_tl - { - \exp_not:N \siunitx_ensuremath:n - { \exp_not:V \l_siunitx_unit_product_tl } - } - \tl_replace_all_in:NnV \l_siunitx_unit_tl { . } - \l_siunitx_tmpa_tl - \tl_replace_all_in:NnV \l_siunitx_unit_tl { ~ } - \l_siunitx_tmpa_tl - \siunitx_unit_format_literal_extras: -} -\cs_new_protected:Npn \siunitx_unit_print_literal_aux:N #1 { - \cs_set_eq:Nc #1 { siunitx_ \token_to_str:N #1 _literal:w } -} -\char_make_space:N \~ +\char_set_catcode_active:N \~ +\cs_new_protected:Npn \siunitx_unit_format_literal:n #1 + { + \int_zero:N \l_siunitx_unit_prefix_int + \tl_map_function:NN \l_siunitx_declare_list_tl + \siunitx_unit_print_literal_aux:N + \tl_set:Nn \l_siunitx_unit_tl {#1} + \tl_set:Nx \l_siunitx_tmpa_tl + { + \exp_not:N \siunitx_ensuremath:n + { \exp_not:o \l_siunitx_unit_product_tl } + } + \tl_replace_all:NnV \l_siunitx_unit_tl { . } \l_siunitx_tmpa_tl + \tl_replace_all:NnV \l_siunitx_unit_tl { ~ } \l_siunitx_tmpa_tl + \bool_if:NT \l_siunitx_literal_power_bool + { + \tl_replace_all:Nnn \l_siunitx_unit_tl { ^ } + { \siunitx_unit_format_literal_power:n } + } + \siunitx_unit_format_literal_extras: + } +\char_set_catcode_space:N \~ +\cs_new_protected:Npn \siunitx_unit_print_literal_aux:N #1 + { \cs_set_eq:Nc #1 { siunitx_ \token_to_str:N #1 _literal:w } } +\cs_new_protected:Npn \siunitx_unit_format_literal_power:n #1 + { \PrintSuperscript { \siunitx_unit_format_power_aux:n {#1} } } % \end{macrocode} -%\end{macro} -%\end{macro} +% \end{macro} +% \end{macro} + %\end{macro} % %\begin{macro}{\siunitx_unit_format_literal_extras:} %\begin{macro}[aux]{\siunitx_unit_format_literal_extras_aux:nN} @@ -11694,7 +11785,7 @@ This work consists of the file siunitx.dtx \char_set_lccode:nn { `\@ } {#1} \tl_to_lowercase:n { - \tl_replace_all_in:NnV \l_siunitx_unit_tl { @ } + \tl_replace_all:NnV \l_siunitx_unit_tl { @ } \l_siunitx_unit_tl } } @@ -11730,7 +11821,7 @@ This work consists of the file siunitx.dtx % \siunitx_unit_format_power_aux:nn , % \siunitx_unit_format_power_brackets: , % \siunitx_unit_format_power_per: , -% \siunitx_unit_format_power_repeat: , +% \siunitx_unit_format_power_repeat: %} % To format powers, there are a few issues: are brackets needed, is % the power reciprocal and is fraction-formatting in operation. Repeated @@ -11787,7 +11878,7 @@ This work consists of the file siunitx.dtx { \siunitx_print:nn {#1} {#2} } { \tl_set:Nn \l_siunitx_tmpa_tl {#2} - \tl_replace_all_in:Nnn \l_siunitx_tmpa_tl { - } + \tl_replace_all:Nnn \l_siunitx_tmpa_tl { - } { \text { \c_siunitx_minus_tl } } \siunitx_print:nV {#1} \l_siunitx_tmpa_tl } @@ -11846,7 +11937,7 @@ This work consists of the file siunitx.dtx %\begin{macro}[aux]{ % \siunitx_unit_format_prefix_number: , % \siunitx_unit_format_prefix_number_calc: , -% \siunitx_unit_format_prefix_symbol: , +% \siunitx_unit_format_prefix_symbol: %} % If there is a prefix, it is added to the output. When using numerical % output, some conversion is needed instead. @@ -11939,7 +12030,7 @@ This work consists of the file siunitx.dtx % \siunitx_unit_format_qualifier_brackets: , % \siunitx_unit_format_qualifier_space: , % \siunitx_unit_format_qualifier_subscript: , -% \siunitx_unit_format_qualifier_text: , +% \siunitx_unit_format_qualifier_text: %} % Four methods for showing qualifiers, each with its own sub-function. % For the \texttt{space} methods, a warning is set in the property list @@ -11966,7 +12057,7 @@ This work consists of the file siunitx.dtx \siunitx_tl_put_right_math:NV \l_siunitx_unit_current_tl \l_siunitx_bracket_close_tl } -\char_make_active:N \~ +\char_set_catcode_active:N \~ \cs_new_protected_nopar:Npn \siunitx_unit_format_qualifier_space: { \tl_put_right:Nn \l_siunitx_unit_current_tl { \text { ~ } } \tl_put_right:NV \l_siunitx_unit_current_tl \l_siunitx_tmpa_tl @@ -11974,7 +12065,7 @@ This work consists of the file siunitx.dtx { bracket- \int_use:N \l_siunitx_unit_int } \prop_put:NVn \l_siunitx_unit_prop \l_siunitx_tmpa_tl { true } } -\char_make_space:N \~ +\char_set_catcode_space:N \~ \cs_new_protected_nopar:Npn \siunitx_unit_format_qualifier_subscript: { \tl_put_right:Nx \l_siunitx_unit_current_tl { \exp_not:N \PrintSubscript { \exp_not:V \l_siunitx_tmpa_tl } } @@ -12009,7 +12100,7 @@ This work consists of the file siunitx.dtx %\begin{macro}{\siunitx_unit_format_symbol:} %\begin{macro}[aux]{ % \siunitx_unit_format_symbol_aux: , -% \siunitx_unit_format_symbol_aux_alt: , +% \siunitx_unit_format_symbol_aux_alt: %} % If there is no symbol, something is wrong! The only exception is % when the code is inside the \cs{si} function (or similar) and there @@ -12295,8 +12386,11 @@ This work consists of the file siunitx.dtx \IfNoValueTF {#3} { \tl_clear:N \l_siunitx_pre_unit_tl } { - \siunitx_unit_in:nn {#3} {#1} - \cs_set_eq:NN \l_siunitx_pre_unit_tl \l_siunitx_unit_tl + \group_begin: + \siunitx_unit_in:nn {#3} {#1} + \cs_set_eq:NN \l_siunitx_pre_unit_tl \l_siunitx_unit_tl + \exp_args:NNNo \group_end: + \tl_set:Nn \l_siunitx_pre_unit_tl { \l_siunitx_unit_tl } } \cs_set_eq:NN \l_siunitx_brackets_bool \l_siunitx_multi_brackets_bool @@ -12478,6 +12572,7 @@ This work consists of the file siunitx.dtx % once life is easier as the normal unit printer can operate. % \begin{macrocode} \cs_new_protected:Npn \siunitx_list_units:nnn #1#2#3 { + \siunitx_unit_parse_options:nn {#2} {#3} \bool_if:NTF \l_siunitx_list_repeat_bool { \siunitx_unit_in:nn {#2} {#3} @@ -12495,7 +12590,6 @@ This work consists of the file siunitx.dtx \siunitx_print:nn { number } { \siunitx_ensuremath:n { \l_siunitx_bracket_close_tl } } } - \siunitx_unit_parse_options:nn {#2} {#3} \siunitx_unit_output_number_sep: \siunitx_unit_output:nn {#2} {#3} } @@ -12554,7 +12648,7 @@ This work consists of the file siunitx.dtx % \begin{macrocode} \cs_new_protected:Npn \siunitx_range_numbers:nn #1#2 { \siunitx_range_numbers_aux:n {#1} - \tl_use:N \l_siunitx_range_phrase_tl + \l_siunitx_range_phrase_tl \siunitx_range_numbers_aux:n {#2} } \cs_new_protected:Npn \siunitx_range_numbers_aux:n #1 { @@ -12581,11 +12675,12 @@ This work consists of the file siunitx.dtx % Unit printing is also simple: basically a past-up job. % \begin{macrocode} \cs_new_protected:Npn \siunitx_range_unit:nnnn #1#2#3#4 { + \siunitx_unit_parse_options:nn {#1} {#2} \bool_if:NTF \l_siunitx_range_repeat_bool { \siunitx_unit_in:nn {#1} {#2} \siunitx_range_numbers_aux:n {#3} - \text { \l_siunitx_range_phrase_tl } + \l_siunitx_range_phrase_tl \siunitx_range_numbers_aux:n {#4} } { @@ -12599,8 +12694,7 @@ This work consists of the file siunitx.dtx { \siunitx_print:nn { number } { \siunitx_ensuremath:n { \l_siunitx_bracket_close_tl } } - } - \siunitx_unit_parse_options:nn {#1} {#2} + } \siunitx_unit_output_number_sep: \siunitx_unit_output:nn {#1} {#2} } @@ -12623,9 +12717,9 @@ This work consists of the file siunitx.dtx \newcolumntype { C } [1] { > { \bcolumn #1 \@nil } #1 < { \ecolumn } } \cs_set:Npn \siunitx_tmp:w #1 \NC@do S #2 \q_stop - { \toks_set:Nn \NC@list { #1 #2 } } + { \NC@list { #1 #2 } } \exp_after:wN \siunitx_tmp:w \tex_the:D \NC@list \q_stop - \cs_gundefine:N \NC@find@S + \cs_undefine:N \NC@find@S } { } } @@ -12646,11 +12740,12 @@ This work consists of the file siunitx.dtx \cs_set_protected_nopar:Npn \siunitx_table_rewrite_create_aux:w \NC@do ##1##2 \NC@do #1 { \NC@list { \NC@do ##1 \NC@do #1 ##2 } } - \exp_after:wN \siunitx_table_rewrite_create_aux:w \toks_use:N \NC@list + \exp_after:wN \siunitx_table_rewrite_create_aux:w \tex_the:D \NC@list \exp_args:NNc \renewcommand * { NC@rewrite@ #1 } [1] [ ] { - \toks_put_right:Nn \@temptokena + \@temptokena \exp_after:wN { + \tex_the:D \@temptokena > { \siunitx_table_collect_begin:Nn #1 {##1} } c < { \siunitx_table_print: } @@ -12739,7 +12834,7 @@ This work consists of the file siunitx.dtx \siunitx_detect_font: \bool_if:NTF \l_siunitx_number_parse_bool { \siunitx_table_collect_get: } - { \siunitx_table_direct: } + { \siunitx_table_print_S_direct: } } % \end{macrocode} %\end{macro} @@ -12837,13 +12932,13 @@ This work consists of the file siunitx.dtx \siunitx_table_collect_get: \cs_set_nopar:Npn \peek_execute_branches: { - \tex_ifcat:D \exp_not:N \l_peek_token \c_group_begin_token + \if_catcode:w \exp_not:N \l_peek_token \c_group_begin_token \exp_after:wN \siunitx_table_collect_braced:n - \tex_else:D + \else: \exp_after:wN \siunitx_table_collect_not_braced:N - \tex_fi:D + \fi: } - \peek_after:NN \peek_ignore_spaces_execute_branches: + \peek_after:Nw \peek_ignore_spaces_execute_branches: } % \end{macrocode} %\end{macro} @@ -12870,7 +12965,7 @@ This work consists of the file siunitx.dtx \cs_new_protected_nopar:Npn \siunitx_table_collect_init_s: { \siunitx_table_collect_init: \bool_set_false:N \l_siunitx_table_collect_pre_bool - \cs_set:Npn \siunitx_table_collect_braced:n ##1 + \cs_set_protected:Npn \siunitx_table_collect_braced:n ##1 { \tl_put_right:Nn \l_siunitx_table_collect_tl { {##1} } \siunitx_table_collect_next: @@ -12892,7 +12987,7 @@ This work consists of the file siunitx.dtx \exp_not:V \l_siunitx_input_symbol_tl } \bool_set_true:N \l_siunitx_table_collect_pre_bool - \cs_set:Npn \siunitx_table_collect_braced:n ##1 + \cs_set_protected:Npn \siunitx_table_collect_braced:n ##1 { \bool_if:NTF \l_siunitx_table_collect_pre_bool { \tl_put_right:Nn \l_siunitx_table_collect_pre_tl { {##1} } } @@ -13021,233 +13116,199 @@ This work consists of the file siunitx.dtx % \end{macrocode} %\end{macro} % -%\subsection{Table printing: general code} +% \subsection{Table printing: general code} % % Getting the general alignment correct in tables is made more % complex than one would like by the \pkg{colortbl} package. In the % original \LaTeXe{} definition, cell material is centred by a % construction of the (primitive) form -%\begin{verbatim} -% \hfil -% # -% \hfil -%\end{verbatim} +% \begin{verbatim} +% \hfil +% # +% \hfil +% \end{verbatim} % which only uses \texttt{fil} stretch. That is altered by % \pkg{colortbl} to broadly -%\begin{verbatim} -% \hskip 0 pt plus 0.5 fill -% \kern 0 pt -% # -% \hskip 0 pt plus 0.5 fill -%\end{verbatim} +% \begin{verbatim} +% \hskip 0 pt plus 0.5 fill +% \kern 0 pt +% # +% \hskip 0 pt plus 0.5 fill +% \end{verbatim} % which means there is \texttt{fill} stretch to worry about and % the kern as well. % -%\begin{macro}{\c_siunitx_one_fill_skip} -% A fixed skip of one \texttt{fill}. +% \begin{variable}{\c_siunitx_one_fill_skip} +% A fixed skip of one \texttt{fill}. % \begin{macrocode} \skip_new:N \c_siunitx_one_fill_skip \skip_set:Nn \c_siunitx_one_fill_skip { \c_zero_skip plus 1 fill } % \end{macrocode} -%\end{macro} +% \end{variable} % -%\begin{macro}{\siunitx_table_colortbl_correction:} -% If the package \pkg{colortbl} is loaded, there is a need to allow -% that it changes how centring is carried out. +% \begin{macro}{\siunitx_table_colortbl_correction:} +% If the package \pkg{colortbl} is loaded, there is a need to allow +% that it changes how centring is carried out. % \begin{macrocode} -\AtBeginDocument { - \@ifpackageloaded { colortbl } - { - \cs_new_protected_nopar:Npn \siunitx_table_colortbl_correction: - { - \skip_horizontal:n { \c_zero_skip plus -0.5 fill } - \tex_kern:D \c_zero_skip - } - } - { - \cs_new_protected_nopar:Npn \siunitx_table_colortbl_correction: - { } - } -} +\AtBeginDocument + { + \@ifpackageloaded { colortbl } + { + \cs_new_protected_nopar:Npn \siunitx_table_colortbl_correction: + { + \skip_horizontal:n { \c_zero_skip plus -0.5 fill } + \tex_kern:D \c_zero_skip + } + } + { \cs_new_protected_nopar:Npn \siunitx_table_colortbl_correction: { } } + } % \end{macrocode} -%\end{macro} +% \end{macro} % -%\begin{macro}{\siunitx_table_align_left:n} -%\begin{macro}{\siunitx_table_align_right:n} -% These are simple shortcuts to keep life clearer in the rest of the -% code. The idea is that the kern acts as a \enquote{stop} for the -% horizontal skip. The correction for \pkg{colortbl} is separate as the -% spacing needs to be explicitly deleted. +% \begin{macro}{\siunitx_table_align_left:n} +% \begin{macro}{\siunitx_table_align_right:n} +% These are simple shortcuts to keep life clearer in the rest of the +% code. The idea is that the kern acts as a \enquote{stop} for the +% horizontal skip. The correction for \pkg{colortbl} is separate as the +% spacing needs to be explicitly deleted. % \begin{macrocode} -\cs_new_protected_nopar:Npn \siunitx_table_align_left:n #1 { - \siunitx_table_colortbl_correction: - \skip_horizontal:n {#1} - \tex_kern:D \c_zero_skip -} -\cs_new_protected_nopar:Npn \siunitx_table_align_right:n #1 { - \skip_horizontal:n { \c_siunitx_one_fill_skip - #1 } - \tex_kern:D \c_zero_skip - \siunitx_table_colortbl_correction: -} +\cs_new_protected_nopar:Npn \siunitx_table_align_left:n #1 + { + \siunitx_table_colortbl_correction: + \skip_horizontal:n {#1} + \tex_kern:D \c_zero_skip + } +\cs_new_protected_nopar:Npn \siunitx_table_align_right:n #1 + { + \skip_horizontal:n { \c_siunitx_one_fill_skip - #1 } + \tex_kern:D \c_zero_skip + \siunitx_table_colortbl_correction: + } % \end{macrocode} -%\end{macro} -%\end{macro} +% \end{macro} +% \end{macro} % -%\begin{macro}{\siunitx_table_column_begin:} -%\begin{macro}{\siunitx_table_column_end:} +% \begin{macro}{\siunitx_table_column_begin:} +% \begin{macro}{\siunitx_table_column_end:} % \begin{macrocode} \cs_new_eq:NN \siunitx_table_column_begin:n \siunitx_table_align_left:n \cs_new_eq:NN \siunitx_table_column_end:n \siunitx_table_align_right:n % \end{macrocode} -%\end{macro} -%\end{macro} +% \end{macro} +% \end{macro} % % Setting up for a fixed column width is done so that the check is % made at the key-setting stage. In that way, there will be some % speed gained if the key is set before the table, as the comparison % is not made for every cell. % \begin{macrocode} -\keys_define:nn { siunitx } { - table-column-width .code:n = - { - \dim_compare:nNnTF {#1} = { \c_zero_dim } - { - \cs_set_eq:NN \siunitx_table_column_begin:n - \siunitx_table_align_left:n - \cs_set_eq:NN \siunitx_table_column_end:n - \siunitx_table_align_right:n - } - { - \cs_set_protected_nopar:Npn \siunitx_table_column_begin:n ##1 - { - \siunitx_table_colortbl_correction: - \tex_hbox:D to \dim_eval:n {#1} - \c_group_begin_token - \skip_horizontal:n {##1} - \tex_kern:D \c_zero_skip - } - \cs_set_protected_nopar:Npn \siunitx_table_column_end:n ##1 - { - \skip_horizontal:n { \c_siunitx_one_fill_skip - ##1 } - \tex_kern:D \c_zero_skip - \hbox_set_inline_end: - \siunitx_table_colortbl_correction: - } - } - } -} +\keys_define:nn { siunitx } + { + table-column-width .code:n = + { + \dim_compare:nNnTF {#1} = { \c_zero_dim } + { + \cs_set_eq:NN \siunitx_table_column_begin:n + \siunitx_table_align_left:n + \cs_set_eq:NN \siunitx_table_column_end:n + \siunitx_table_align_right:n + } + { + \cs_set_protected_nopar:Npn \siunitx_table_column_begin:n ##1 + { + \siunitx_table_colortbl_correction: + \tex_hbox:D to \dim_eval:n {#1} + \c_group_begin_token + \skip_horizontal:n {##1} + \tex_kern:D \c_zero_skip + } + \cs_set_protected_nopar:Npn \siunitx_table_column_end:n ##1 + { + \skip_horizontal:n { \c_siunitx_one_fill_skip - ##1 } + \tex_kern:D \c_zero_skip + \hbox_set_inline_end: + \siunitx_table_colortbl_correction: + } + } + } + } % \end{macrocode} % -%\subsection{Printing units in \texttt{s} columns} +% \subsection{Printing units in \texttt{s} columns} % % The easiest type of printing is the \texttt{s} column. Here, there is % no real problem with alignment. All that has to happen is to print the % collected input as the argument to the internal part of an \cs{si} % function. % -%\begin{macro}{\l_siunitx_table_unit_align_skip} +% \begin{variable}{\l_siunitx_table_unit_align_skip} % The spacing used is stored as a skip, which needs to be set up first. % \begin{macrocode} \skip_new:N \l_siunitx_table_unit_align_skip % \end{macrocode} -%\end{macro} +% \end{variable} % % \begin{macrocode} -\keys_define:nn { siunitx } { - table-unit-alignment .choice:, - table-unit-alignment / center .code:n = - { - \skip_set:Nn \l_siunitx_table_unit_align_skip - { \c_zero_skip plus 0.5 fill } - }, - table-unit-alignment / left .code:n = - { - \skip_set:Nn \l_siunitx_table_unit_align_skip - { \c_zero_skip } - }, - table-unit-alignment / right .code:n = - { - \skip_set:Nn \l_siunitx_table_unit_align_skip - { \c_zero_skip plus 1 fill } - }, -} -\keys_set:nn { siunitx } { - table-unit-alignment = center -} +\keys_define:nn { siunitx } + { + table-unit-alignment .choice:, + table-unit-alignment / + center .code:n = + { + \skip_set:Nn \l_siunitx_table_unit_align_skip + { \c_zero_skip plus 0.5 fill } + }, + table-unit-alignment / + left .code:n = + { \skip_set:Nn \l_siunitx_table_unit_align_skip { \c_zero_skip } }, + table-unit-alignment / + right .code:n = + { + \skip_set:Nn \l_siunitx_table_unit_align_skip + { \c_zero_skip plus 1 fill } + } + } +\keys_set:nn { siunitx } { table-unit-alignment = center } % \end{macrocode} % -%\begin{macro}{\siunitx_table_print_s:} -% Actually printing an \texttt{s} column is not very complex. There is -% some spacing to do at each side, with the main part of the job being -% to print the material using the internal version of \cs{si}. +% \begin{macro}{\siunitx_table_print_s:} +% Actually printing an \texttt{s} column is not very complex. There is +% some spacing to do at each side, with the main part of the job being +% to print the material using the internal version of \cs{si}. % \begin{macrocode} -\cs_new_protected_nopar:Npn \siunitx_table_print_s: { - \siunitx_table_column_begin:n { \l_siunitx_table_unit_align_skip } - \siunitx_unit_output:Vn \l_siunitx_table_collect_tl { } - \siunitx_table_column_end:n { \l_siunitx_table_unit_align_skip } -} +\cs_new_protected_nopar:Npn \siunitx_table_print_s: + { + \siunitx_table_column_begin:n { \l_siunitx_table_unit_align_skip } + \siunitx_unit_output:Vn \l_siunitx_table_collect_tl { } + \siunitx_table_column_end:n { \l_siunitx_table_unit_align_skip } + } % \end{macrocode} -%\end{macro} +% \end{macro} % -%\subsection{Formatting and printing in tables} +% \subsection{Formatting and printing in tables} % % With the content grabbed, the next stage is to turn it into formatted % output then print it. Most of the formatting is done elsewhere, so % most of the work here is in printing. % -%\begin{macro}{\l_siunitx_table_center_decimal_bool} -% A switch for the basic \enquote{decimal marker in the middle} -% mode. -% \begin{macrocode} -\bool_new:N \l_siunitx_table_center_decimal_bool -% \end{macrocode} -%\end{macro} -% -%\begin{macro}{\l_siunitx_table_fill_box} -% A box which is only ever filled with \texttt{fil} glue, for padding -% out numbers. -% \begin{macrocode} -\box_new:N \l_siunitx_table_fill_box -% \end{macrocode} -%\end{macro} -% -%\begin{macro}{\l_siunitx_table_fill_dim} -% Calculating the fill needed can be a bit complicated, so is best -% done using a dedicated dimension. +% \begin{variable}{\l_siunitx_table_model_prop} +% A place to store the model for reserved-space table columns. % \begin{macrocode} -\dim_new:N \l_siunitx_table_fill_dim -% \end{macrocode} -%\end{macro} -% -%\begin{macro}{\l_siunitx_table_pre_box} -%\begin{macro}{\l_siunitx_table_post_box} -% Boxes for the content before and after the numerical part. -% \begin{macrocode} -\box_new:N \l_siunitx_table_pre_box -\box_new:N \l_siunitx_table_post_box -% \end{macrocode} -%\end{macro} -%\end{macro} -% -%\begin{macro}{\l_siunitx_table_result_box} -% The box which is actually needed for printing. -% \begin{macrocode} -\box_new:N \l_siunitx_table_result_box +\prop_new:N \l_siunitx_table_model_prop % \end{macrocode} -%\end{macro} +% \end{variable} % -%\begin{macro}{\l_siunitx_table_comparator_dim} -%\begin{macro}{\l_siunitx_table_decimal_dim} -%\begin{macro}{\l_siunitx_table_exponent_dim} -%\begin{macro}{\l_siunitx_table_integer_dim} -%\begin{macro}{\l_siunitx_table_mantissa_dim} -%\begin{macro}{\l_siunitx_table_marker_dim} -%\begin{macro}{\l_siunitx_table_result_dim} -%\begin{macro}{\l_siunitx_table_uncert_dim} -% Dimensions for the various model measurements. +% \begin{variable} +% { +% \l_siunitx_table_exponent_dim , +% \l_siunitx_table_integer_dim , +% \l_siunitx_table_mantissa_dim , +% \l_siunitx_table_marker_dim , +% \l_siunitx_table_result_dim , +% \l_siunitx_table_uncert_dim +% } +% Dimensions to track the various spaces needed. % \begin{macrocode} -\dim_new:N \l_siunitx_table_comparator_dim -\dim_new:N \l_siunitx_table_decimal_dim \dim_new:N \l_siunitx_table_exponent_dim \dim_new:N \l_siunitx_table_integer_dim \dim_new:N \l_siunitx_table_mantissa_dim @@ -13255,1139 +13316,1343 @@ This work consists of the file siunitx.dtx \dim_new:N \l_siunitx_table_result_dim \dim_new:N \l_siunitx_table_uncert_dim % \end{macrocode} -%\end{macro} -%\end{macro} -%\end{macro} -%\end{macro} -%\end{macro} -%\end{macro} -%\end{macro} -%\end{macro} +%\end{variable} % -%\begin{macro}{\l_siunitx_table_gap_dim} -% This is used to work out the potential gap between a number and -% any following material. +% \begin{variable} +% {\l_siunitx_table_fill_pre_dim, \l_siunitx_table_fill_post_dim} +% Calculating the fill needed can be a bit complicated, so is best +% done using a dedicated dimension. There is a second one for cases dealing +% with fill at the end of a number, where there may be some rearrangement. % \begin{macrocode} -\dim_new:N \l_siunitx_table_gap_dim +\dim_new:N \l_siunitx_table_fill_pre_dim +\dim_new:N \l_siunitx_table_fill_post_dim % \end{macrocode} -%\end{macro} +% \end{variable} % -%\begin{macro}{\l_siunitx_table_model_prop} -% To store the model version of a number, used when reserving space. +% \begin{variable}{\l_siunitx_table_fill_mid_dim} +% For the reserved space approach there is also the need for a third +% piece of fill, which may or may not be used. % \begin{macrocode} -\prop_new:N \l_siunitx_table_model_prop +\dim_new:N \l_siunitx_table_fill_mid_dim % \end{macrocode} -%\end{macro} +% \end{variable} % -%\begin{macro}{\l_siunitx_table_space_dim} -% This dim is used to keep a track of how much space might need to be -% deleted if exponents are not being aligned. +% \begin{variable}{\l_siunitx_table_pre_box, \l_siunitx_table_post_box} +% Boxes for the content before and after the numerical part. % \begin{macrocode} -\dim_new:N \l_siunitx_table_space_dim +\box_new:N \l_siunitx_table_pre_box +\box_new:N \l_siunitx_table_post_box % \end{macrocode} -%\end{macro} +% \end{variable} % -%\begin{macro}{\l_siunitx_table_text_align_skip} -%\begin{macro}{\l_siunitx_table_number_align_skip} -% Skips for aligning text and numbers. +% \begin{variable}{\l_siunitx_table_mantissa_box} +% When printing with space reserved, the mantissa needs to hang around +% for a while. This is best done by storing the typeset result in a box. +% \begin{macrocode} +\box_new:N \l_siunitx_table_mantissa_box +% \end{macrocode} +% \end{variable} +% +% \begin{variable}{\l_siunitx_table_result_box} +% The box which is actually needed for printing. +% \begin{macrocode} +\box_new:N \l_siunitx_table_result_box +% \end{macrocode} +% \end{variable} +% +% \begin{variable} +% {\l_siunitx_table_number_align_skip, \l_siunitx_table_text_align_skip} +% Skips for aligning text and numbers. % \begin{macrocode} \skip_new:N \l_siunitx_table_number_align_skip \skip_new:N \l_siunitx_table_text_align_skip % \end{macrocode} -%\end{macro} -%\end{macro} +% \end{variable} +% +% \begin{macro} +% { +% \siunitx_table_print_S_direct_main: , +% \siunitx_table_print_S_main: , +% \siunitx_table_print_S_parsed: , +% \siunitx_table_print_S_pre: , +% \siunitx_table_print_S_post: , +% \siunitx_table_print_S_reserved_exponent_aux: , +% \siunitx_table_print_S_reserved_mantissa_uncert_aux: , +% \siunitx_table_print_S_reserved_round: +% } +% \begin{macro}{\siunitx_table_print_S_reserved_store_fill:n} +% Various functions which are set up by the option system, and so are +% reserved here first for completeness. +% \begin{macrocode} +\cs_new_protected_nopar:Npn \siunitx_table_print_S_direct_main: { } +\cs_new_protected_nopar:Npn \siunitx_table_print_S_main: { } +\cs_new_protected_nopar:Npn \siunitx_table_print_S_parsed: { } +\cs_new_protected_nopar:Npn \siunitx_table_print_S_pre: { } +\cs_new_protected_nopar:Npn \siunitx_table_print_S_post: { } +\cs_new_protected_nopar:Npn \siunitx_table_print_S_reserved_exponent_aux: { } +\cs_new_protected_nopar:Npn + \siunitx_table_print_S_reserved_mantissa_uncert_aux: { } +\cs_new_protected_nopar:Npn \siunitx_table_print_S_reserved_round: { } +\cs_new_protected_nopar:Npn \siunitx_table_print_S_reserved_store_fill:n #1 { } +% \end{macrocode} +% \end{macro} +% \end{macro} % -%\begin{macro}{ -% \l_siunitx_table_align_comparator_bool , -% \l_siunitx_table_align_exp_bool , -% \l_siunitx_table_align_post_bool , -% \l_siunitx_table_align_uncert_bool , -% \l_siunitx_table_omit_exp_bool , -% \l_siunitx_table_auto_bool , -% \l_siunitx_table_comparator_bool , -% \l_siunitx_table_decimal_int , -% \l_siunitx_table_exponent_int , -% \l_siunitx_table_integer_int , -% \l_siunitx_table_uncert_int , -% \l_siunitx_table_parse_only_bool , -% \l_siunitx_table_pre_tl , -% \l_siunitx_table_post_tl , -% \l_siunitx_table_sign_exponent_bool , -% \l_siunitx_table_sign_manitssa_bool , -%} -% As usual, set up the options. +% \begin{variable}{\l_siunitx_table_pre_tl, \l_siunitx_table_post_tl} % \begin{macrocode} -\keys_define:nn { siunitx } { - table-align-comparator .bool_set:N - = \l_siunitx_table_align_comparator_bool, - table-align-exponent .bool_set:N - = \l_siunitx_table_align_exp_bool, - table-align-text-post .bool_set:N - = \l_siunitx_table_align_post_bool, - table-align-uncertainty .bool_set:N - = \l_siunitx_table_align_uncert_bool, - table-number-alignment .choice:, - table-number-alignment / - center .code:n = +\keys_define:nn { siunitx } + { + table-align-comparator .choice:, + table-align-comparator / + false .code:n = + { + \cs_set_eq:NN \siunitx_table_print_S_reserved_store_fill:n + \siunitx_table_print_S_reserved_store_fill_pre:n + }, + table-align-comparator / + true .code:n = + { + \cs_set_eq:NN \siunitx_table_print_S_reserved_store_fill:n + \siunitx_table_print_S_reserved_store_fill_mid:n + }, + table-align-comparator .default:n = true, + table-align-exponent .choice:, + table-align-exponent / + false .code:n = + { + \cs_set_eq:NN \siunitx_table_print_S_reserved_exponent_aux: + \siunitx_table_print_S_reserved_exponent_not_aligned: + }, + table-align-exponent / + true .code:n = + { + \cs_set_eq:NN \siunitx_table_print_S_reserved_exponent_aux: + \siunitx_table_print_S_reserved_exponent_aligned: + }, + table-align-exponent .default:n = true, + table-align-text-pre .choice:, + table-align-text-pre / + false .code:n = + { + \cs_set_eq:NN \siunitx_table_print_S_pre: + \siunitx_table_print_S_pre_not_aligned: + }, + table-align-text-pre / + true .code:n = + { + \cs_set_eq:NN \siunitx_table_print_S_pre: + \siunitx_table_print_S_pre_aligned: + }, + table-align-text-pre .default:n = true , + table-align-text-post .choice:, + table-align-text-post / + false .code:n = + { + \cs_set_eq:NN \siunitx_table_print_S_post: + \siunitx_table_print_S_post_not_aligned: + }, + table-align-text-post / + true .code:n = + { + \cs_set_eq:NN \siunitx_table_print_S_post: + \siunitx_table_print_S_post_aligned: + }, + table-align-text-post .default:n = true , + table-align-uncertainty .choice:, + table-align-uncertainty / + false .code:n = + { + \cs_set_eq:NN \siunitx_table_print_S_reserved_mantissa_uncert_aux: + \siunitx_table_print_S_reserved_mantissa_uncert_not_aligned: + }, + table-align-uncertainty / + true .code:n = + { + \cs_set_eq:NN \siunitx_table_print_S_reserved_mantissa_uncert_aux: + \siunitx_table_print_S_reserved_mantissa_uncert_aligned: + }, + table-align-uncertainty .default:n = true, + table-auto-round .choice:, + table-auto-round / + false .code:n = + { \cs_set_eq:NN \prg_do_nothing: }, + table-auto-round / + true .code:n = + { + \cs_set_eq:NN \siunitx_table_print_S_reserved_round: + \siunitx_table_print_S_reserved_round_auto: + }, + table-auto-round .default:n = true, + table-number-alignment .choice:, + table-number-alignment / + center .code:n = + { + \skip_set:Nn \l_siunitx_table_number_align_skip + { \c_zero_skip plus 0.5 fill } + \cs_set_eq:NN \siunitx_table_print_S_direct_main: + \siunitx_table_print_S_direct_reserved: + \cs_set_eq:NN \siunitx_table_print_S_parsed: + \siunitx_table_print_S_reserved: + }, + table-number-alignment / + center-decimal-marker .code:n = + { + \skip_set:Nn \l_siunitx_table_number_align_skip + { \c_zero_skip plus 0.5 fill } + \cs_set_eq:NN \siunitx_table_print_S_direct_main: + \siunitx_table_print_S_direct_centered: + \cs_set_eq:NN \siunitx_table_print_S_parsed: + \siunitx_table_print_S_centered: + }, + table-number-alignment / + left .code:n = + { + \skip_zero:N \l_siunitx_table_number_align_skip + \cs_set_eq:NN \siunitx_table_print_S_direct_main: + \siunitx_table_print_S_direct_reserved: + \cs_set_eq:NN \siunitx_table_print_S_parsed: + \siunitx_table_print_S_reserved: + }, + table-number-alignment / + right .code:n = + { + \skip_set:Nn \l_siunitx_table_number_align_skip + { \c_zero_skip plus 1 fill } + \cs_set_eq:NN \siunitx_table_print_S_direct_main: + \siunitx_table_print_S_direct_reserved: + \cs_set_eq:NN \siunitx_table_print_S_parsed: + \siunitx_table_print_S_reserved: + }, + table-omit-exponent .choice:, + table-omit-exponent / + false .code:n = + { + \cs_set_eq:NN \siunitx_table_print_S_parse_aux: + \siunitx_number_process: + }, + table-omit-exponent / + true .code:n = + { + \cs_set_eq:NN \siunitx_table_print_S_parse_aux: + \siunitx_table_print_S_parse_omit_exp: + }, + table-omit-exponent .default:n = true, + table-text-alignment .choice:, + table-text-alignment / + center .code:n = + { + \skip_set:Nn \l_siunitx_table_text_align_skip + { \c_zero_skip plus 0.5 fill } + }, + table-text-alignment / + left .code:n = + { \skip_zero:N \l_siunitx_table_text_align_skip }, + table-text-alignment / + right .code:n = + { + \skip_set:Nn \l_siunitx_table_text_align_skip + { \c_zero_skip plus 1 fill } + }, + table-comparator .choice:, + table-comparator / + false .code:n = + { \prop_del:Nn \l_siunitx_table_model_prop { comparator } }, + table-comparator / + true .code:n = + { \prop_put:Nnn \l_siunitx_table_model_prop { comparator } { \ll } }, + table-comparator .default:n = true, + table-figures-decimal .code:n = { - \skip_set:Nn \l_siunitx_table_number_align_skip - { \c_zero_skip plus 0.5 fill } - \bool_set_false:N \l_siunitx_table_center_decimal_bool + \int_compare:nNnTF {#1} = \c_zero + { + \prop_del:Nn \l_siunitx_table_model_prop { mantissa-decimal } + \prop_del:Nn \l_siunitx_table_model_prop { mantissa-decimal-raw } + \prop_del:Nn \l_siunitx_table_model_prop + { mantissa-decimal-marker } + \prop_if_in:NnTF \l_siunitx_table_model_prop { mantissa-integer } + { + \prop_put:Nnn \l_siunitx_table_model_prop { mantissa } + { true } + } + { \prop_del:Nn \l_siunitx_table_model_prop { mantissa } } + } + { + \prop_put:Nnx \l_siunitx_table_model_prop { mantissa-decimal } + { \prg_replicate:nn {#1} { 8 } } + \prop_put:Nnn \l_siunitx_table_model_prop { mantissa-decimal-raw } + {#1} + \prop_put:Nnn \l_siunitx_table_model_prop { mantissa } { true } + \prop_put:NnV \l_siunitx_table_model_prop + { mantissa-decimal-marker } \l_siunitx_output_decimal_tl + } }, - table-number-alignment / - center-decimal-marker .code:n = + table-figures-exponent .code:n = { - \skip_set:Nn \l_siunitx_table_number_align_skip - { \c_zero_skip plus 0.5 fill } - \bool_set_true:N \l_siunitx_table_center_decimal_bool + \int_compare:nNnTF {#1} = \c_zero + { \prop_del:Nn \l_siunitx_table_model_prop { exponent-integer } } + { + \prop_put:Nnx \l_siunitx_table_model_prop { exponent-integer } + { \prg_replicate:nn {#1} { 8 } } + \prop_put:Nnn \l_siunitx_table_model_prop { exponent } { true } + } }, - table-number-alignment / - left .code:n = + table-figures-integer .code:n = { - \skip_set:Nn \l_siunitx_table_number_align_skip - { \c_zero_skip } - \bool_set_false:N \l_siunitx_table_center_decimal_bool + \int_compare:nNnTF {#1} = \c_zero + { + \prop_del:Nn \l_siunitx_table_model_prop { mantissa-integer } + \prop_if_in:NnTF \l_siunitx_table_model_prop { mantissa-decimal } + { + \prop_put:Nnn \l_siunitx_table_model_prop { mantissa } + { true } + } + { \prop_del:Nn \l_siunitx_table_model_prop { mantissa } } + } + { + \prop_put:Nnx \l_siunitx_table_model_prop { mantissa-integer } + { \prg_replicate:nn {#1} { 8 } } + \prop_put:Nnn \l_siunitx_table_model_prop { mantissa } { true } + } }, - table-number-alignment / - right .code:n = + table-figures-uncertainty .code:n = { - \skip_set:Nn \l_siunitx_table_number_align_skip - { \c_zero_skip plus 1 fill } - \bool_set_false:N \l_siunitx_table_center_decimal_bool + \int_compare:nNnTF {#1} = \c_zero + { \prop_del:Nn \l_siunitx_table_model_prop { mantissa-uncertainty } } + { + \prop_put:Nnx \l_siunitx_table_model_prop { mantissa-uncertainty } + { \prg_replicate:nn {#1} { 8 } } + } }, - table-omit-exponent .bool_set:N = \l_siunitx_table_omit_exp_bool , - table-text-alignment .choice:, - table-text-alignment / - center .code:n = - { - \skip_set:Nn \l_siunitx_table_text_align_skip - { \c_zero_skip plus 0.5 fill } - }, - table-text-alignment / - left .code:n = - { - \skip_set:Nn \l_siunitx_table_text_align_skip - { \c_zero_skip } - }, - table-text-alignment / - right .code:n = - { - \skip_set:Nn \l_siunitx_table_text_align_skip - { \c_zero_skip plus 1 fill } - }, - table-auto-round .bool_set:N = \l_siunitx_table_auto_bool, - table-comparator .bool_set:N = - \l_siunitx_table_comparator_bool, - table-figures-decimal .int_set:N = \l_siunitx_table_decimal_int, - table-figures-exponent .int_set:N = - \l_siunitx_table_exponent_int, - table-figures-integer .int_set:N = \l_siunitx_table_integer_int, - table-figures-uncertainty .int_set:N = \l_siunitx_table_uncert_int , - table-parse-only .bool_set:N = - \l_siunitx_table_parse_only_bool, - table-space-text-pre .tl_set:N = - \l_siunitx_table_pre_tl, - table-space-text-post .tl_set:N = - \l_siunitx_table_post_tl, - table-sign-exponent .bool_set:N = - \l_siunitx_table_sign_exponent_bool, - table-sign-mantissa .bool_set:N = - \l_siunitx_table_sign_mantissa_bool -} -\keys_set:nn { siunitx } { - table-align-comparator = true, - table-align-exponent = true, - table-align-text-post = true, - table-align-uncertainty = true, - table-number-alignment = center-decimal-marker, - table-text-alignment = center, - table-figures-decimal = 2, - table-figures-integer = 3 -} + table-parse-only .choice: , + table-parse-only / + false .code:n = + { + \cs_set_eq:NN \siunitx_table_print_S_main: + \siunitx_table_print_S_alignment: + }, + table-parse-only / + true .code:n = + { + \cs_set_eq:NN \siunitx_table_print_S_main: + \siunitx_table_print_S_no_alignment: + }, + table-parse-only .default:n = true, + table-space-text-pre .tl_set:N = \l_siunitx_table_pre_tl, + table-space-text-post .tl_set:N = \l_siunitx_table_post_tl, + table-sign-exponent .code:n = + { \prop_put:Nnn \l_siunitx_table_model_prop { exponent-sign } { - } }, + table-sign-mantissa .code:n = + { \prop_put:Nnn \l_siunitx_table_model_prop { mantissa-sign } { - } }, + } % \end{macrocode} -%\end{macro} +% \end{variable} % % A meta-choice for all table alignment is also provided. % \begin{macrocode} -\keys_define:nn { siunitx } { - table-alignment .meta:n = - { - table-number-alignment = #1, - table-text-alignment = #1, - table-unit-alignment = #1 - } -} +\keys_define:nn { siunitx } + { + table-alignment .meta:n = + { + table-number-alignment = #1, + table-text-alignment = #1, + table-unit-alignment = #1 + } + } % \end{macrocode} % -%\begin{macro}{\siunitx_table_format_convert:nn} % Another special option. This converts a number format in compacted -% form into the various internal settings needed. The function is used -% for the conversion to keep code down. +% form into the various internal settings needed. % \begin{macrocode} -\cs_new_protected_nopar:Npn \siunitx_table_format_convert:nn #1#2 { - \prop_get:NnN \l_siunitx_number_in_prop {#1} \l_siunitx_tmpa_tl - \quark_if_no_value:NTF \l_siunitx_tmpa_tl - { \int_set:cn { l_siunitx_table_ #2 _int } { 0 } } - { - \prop_get:NnN \l_siunitx_number_in_prop {#1} \l_siunitx_tmpa_tl - \int_set:cn { l_siunitx_table_ #2 _int } { \l_siunitx_tmpa_tl } - } -} -\keys_define:nn { siunitx } { - table-format .code:n = - { - \siunitx_number_in_parse:n {#1} - \siunitx_table_format_convert:nn { mantissa-integer } { integer } - \siunitx_table_format_convert:nn { mantissa-decimal } { decimal } - \siunitx_table_format_convert:nn { mantissa-uncertainty } - { uncert } - \siunitx_table_format_convert:nn { exponent-integer } - { exponent } - \prop_if_in:NnTF \l_siunitx_number_in_prop { comparator } - { \bool_set_true:N \l_siunitx_table_comparator_bool } - { \bool_set_false:N \l_siunitx_table_comparator_bool } - \prop_if_in:NnTF \l_siunitx_number_in_prop { mantissa-sign } - { \bool_set_true:N \l_siunitx_table_sign_mantissa_bool } - { \bool_set_false:N \l_siunitx_table_sign_mantissa_bool } - \prop_if_in:NnTF \l_siunitx_number_in_prop { exponent-sign } - { \bool_set_true:N \l_siunitx_table_sign_exponent_bool } - { \bool_set_false:N \l_siunitx_table_sign_exponent_bool } - \keys_set:nn { siunitx } { table-number-alignment = center } - }, -} +\keys_define:nn { siunitx } + { + table-format .code:n = + { + \siunitx_number_in_parse:n {#1} + \prop_set_eq:NN \l_siunitx_table_model_prop \l_siunitx_number_in_prop + \tl_clear:N \l_siunitx_tmpa_tl + \prop_get:NnNT \l_siunitx_number_in_prop { mantissa-integer } + \l_siunitx_tmpb_tl + { + \tl_set:Nx \l_siunitx_tmpa_tl + { table-figures-integer = \l_siunitx_tmpb_tl } + } + \prop_get:NnNT \l_siunitx_number_in_prop { mantissa-decimal } + \l_siunitx_tmpb_tl + { + \clist_put_right:Nx \l_siunitx_tmpa_tl + { table-figures-decimal = \l_siunitx_tmpb_tl } + } + \prop_get:NnNT \l_siunitx_number_in_prop { mantissa-uncertainty } + \l_siunitx_tmpb_tl + { + \clist_put_right:Nx \l_siunitx_tmpa_tl + { table-figures-uncertainty = \l_siunitx_tmpb_tl } + } + \prop_get:NnNT \l_siunitx_number_in_prop { exponent-integer } + \l_siunitx_tmpb_tl + { + \clist_put_right:Nx \l_siunitx_tmpa_tl + { table-figures-exponent = \l_siunitx_tmpb_tl } + } + \clist_put_right:Nn \l_siunitx_tmpa_tl + { table-number-alignment = center } + \keys_set:nV { siunitx } \l_siunitx_tmpa_tl + } + } % \end{macrocode} -%\end{macro} % -%\begin{macro}{\siunitx_table_print_S:} -% The main printing function does a simple test: was there anything -% found that counts as a number. If there was, most of the detail -% is handled elsewhere. If there is only test (such as a heading) -% then it can be printed. +% \begin{macro}{\siunitx_table_print_S:} +% The main printing function makes a choice depending on whether there is +% any numerical part to print at all. This affects which set of skips to +% insert. Font detection for the \texttt{S} column is included here as +% this is needed to do this work outside of an \cs{hbox}. % \begin{macrocode} -\cs_new_protected_nopar:Npn \siunitx_table_print_S: { - \bool_if:NTF \l_siunitx_table_collect_pre_bool - { - \siunitx_table_column_begin:n - { \l_siunitx_table_text_align_skip } - \tl_use:N \l_siunitx_table_collect_pre_tl - \siunitx_table_column_end:n - { \l_siunitx_table_text_align_skip } - } - { - \siunitx_table_column_begin:n - { \l_siunitx_table_number_align_skip } - \siunitx_table_print_S_aux: - \siunitx_table_column_end:n - { \l_siunitx_table_number_align_skip } - } -} +\cs_new_protected_nopar:Npn \siunitx_table_print_S: + { + \bool_if:NTF \l_siunitx_table_collect_pre_bool + { + \siunitx_table_column_begin:n { \l_siunitx_table_text_align_skip } + \l_siunitx_table_collect_pre_tl + \siunitx_table_column_end:n { \l_siunitx_table_text_align_skip } + } + { + \siunitx_table_column_begin:n { \l_siunitx_table_number_align_skip } + \siunitx_detect_font: + \siunitx_table_print_S_main: + \siunitx_table_print_S_pre: + \box_use:N \l_siunitx_table_result_box + \siunitx_table_print_S_post: + \siunitx_table_column_end:n { \l_siunitx_table_number_align_skip } + } + } % \end{macrocode} -%\end{macro} -%\begin{macro}[aux]{\siunitx_table_print_S_aux:} -% The auxiliary function now splits the path. If the number is only -% being parsed, then it is printed with no more fuss. Otherwise, there -% is a second choice based on the alignment approach. +% \end{macro} +% +% \begin{macro}{\siunitx_table_print_S_no_alignment:} +% With no alignment to do, the code can be pretty simple. The collected +% number is simply printed between the two non-numerical parts. % \begin{macrocode} -\cs_new_protected_nopar:Npn \siunitx_table_print_S_aux: { - \bool_if:NTF \l_siunitx_table_parse_only_bool - { - \tl_use:N \l_siunitx_table_collect_pre_tl - \siunitx_number_output:V \l_siunitx_table_collect_tl - \tl_use:N \l_siunitx_table_collect_post_tl - } - { - \bool_if:NTF \l_siunitx_table_center_decimal_bool - { \siunitx_table_print_S_centered: } - { \siunitx_table_print_S_reserved: } - } -} +\cs_new_protected_nopar:Npn \siunitx_table_print_S_no_alignment: + { + \l_siunitx_table_collect_pre_tl + \siunitx_number_output:V \l_siunitx_table_collect_tl + \l_siunitx_table_collect_post_tl + } % \end{macrocode} -%\end{macro} +% \end{macro} % -%\begin{macro}[aux]{\siunitx_table_print_S_parse:} -% A modified version of the number parser for tables. +% \begin{macro}{\siunitx_table_print_S_alignment:} +% This is a pass-through, so that the appropriate alignment mode is +% retained without needing to retest on each use. % \begin{macrocode} -\cs_new_protected_nopar:Npn \siunitx_table_print_S_parse: { - \bool_set_false:N \l_siunitx_error_bool - \siunitx_number_in_parse:V \l_siunitx_table_collect_tl - \bool_if:NF \l_siunitx_error_bool - { - \bool_if:NT \l_siunitx_table_omit_exp_bool - { \bool_set_true:N \l_siunitx_process_fixed_bool } - \siunitx_number_process: - \bool_if:NT \l_siunitx_table_omit_exp_bool - { - \prop_del:Nn \l_siunitx_number_in_prop { exponent } - \prop_del:Nn \l_siunitx_number_in_prop { exponent-integer } - } - \siunitx_number_format: - \siunitx_number_output_color: - } -} +\cs_new_protected_nopar:Npn \siunitx_table_print_S_alignment: + { \siunitx_table_print_S_parsed: } % \end{macrocode} -%\end{macro} +% \end{macro} % -%\begin{macro}{\siunitx_table_print_S_centered:} -% When centring the decimal marker, the logic is relatively simple. -% First, box up the integer part of the number, the entire number and -% the decimal marker itself. There is then a measurement to see -% which part of the number is bigger: before or after the decimal -% marker. Based on that, a path is chosen. The two then come back -% together to print any material after the number: the filling -% space needed will be equal to the correction required to place notes, -% \emph{etc}.~flush with the number. +% \begin{macro}{\siunitx_table_print_S_parse:} +% \begin{macro}[aux]{\siunitx_table_print_S_parse_omit_exp:} +% A modified version of the number parser for tables. % \begin{macrocode} -\cs_new_protected_nopar:Npn \siunitx_table_print_S_centered: { - \siunitx_table_print_S_centered_ends: - \dim_compare:nNnTF - { \box_wd:N \l_siunitx_table_pre_box } = { \c_zero_skip } - { \tl_use:N \l_siunitx_table_collect_pre_tl } - { \box_use:N \l_siunitx_table_pre_box } - \bool_if:NT \l_siunitx_table_math_bool { \c_math_shift_token } - \siunitx_table_print_S_parse: - \siunitx_table_print_S_measure_comparator_integer:N - \l_siunitx_number_out_prop - \siunitx_table_print_S_measure:Nnn \l_siunitx_number_out_prop - { marker } { mantissa } - \siunitx_table_print_S_measure:Nnn \l_siunitx_number_out_prop - { result } { } - \box_set_eq:NN \l_siunitx_table_result_box \l_siunitx_tmp_box - \dim_set:Nn \l_siunitx_table_fill_dim - { \l_siunitx_table_result_dim - \l_siunitx_table_integer_dim } - \prop_if_in:NnT \l_siunitx_number_out_prop - { mantissa-decimal-marker } - { - \dim_set:Nn \l_siunitx_table_fill_dim - { \l_siunitx_table_fill_dim - \l_siunitx_table_marker_dim } - } - \dim_compare:nNnTF - { \l_siunitx_table_integer_dim } > { \l_siunitx_table_fill_dim } - { \siunitx_table_print_S_centered_integer: } - { \siunitx_table_print_S_centered_decimal: } - \bool_if:NT \l_siunitx_table_math_bool { \c_math_shift_token } - \bool_if:NTF \l_siunitx_table_align_post_bool - { \box_use:N \l_siunitx_table_post_box } - { - \dim_set:Nn \l_siunitx_table_fill_dim - { - \dim_use:N \l_siunitx_table_fill_dim } - \skip_horizontal:N \l_siunitx_table_fill_dim - \box_use:N \l_siunitx_table_post_box - \box_use:N \l_siunitx_table_fill_box - } +\cs_new_protected_nopar:Npn \siunitx_table_print_S_parse: + { + \bool_set_false:N \l_siunitx_error_bool + \siunitx_number_in_parse:V \l_siunitx_table_collect_tl + \bool_if:NF \l_siunitx_error_bool + { + \siunitx_table_print_S_parse_aux: + \siunitx_number_format: + \siunitx_number_output_color: + } + } +\cs_new_protected_nopar:Npn \siunitx_table_print_S_parse_omit_exp: + { + \bool_set_true:N \l_siunitx_process_fixed_bool + \siunitx_number_process: + \prop_del:Nn \l_siunitx_number_in_prop { exponent } + \prop_del:Nn \l_siunitx_number_in_prop { exponent-integer } } % \end{macrocode} -%\end{macro} -%\begin{macro}[aux]{\siunitx_table_print_S_centered_ends:} -% Here, the material before and after the numerical content is boxed up. -% The shorter one is then re-boxed so that both sides are the same -% length: this stops the alignment going out. +% \end{macro} +% \end{macro} +% +% \begin{macro}{\siunitx_table_print_S_measure:NN} +% A short routine to measure up whatever has been extracted from the +% storage system. Boxing up is avoided for the empty cases, as this saves +% a little time(the print routine is relatively slow). % \begin{macrocode} -\cs_new_protected_nopar:Npn \siunitx_table_print_S_centered_ends: { - \hbox_set:Nn \l_siunitx_table_pre_box - { +\cs_new_protected_nopar:Npn \siunitx_table_print_S_measure:NN #1#2 + { + \tl_if_empty:NTF #1 + { \dim_zero:N #2 } + { + \group_begin: + \hbox_set:Nn \l_siunitx_tmp_box + { \siunitx_print:nV { number } #1 } + \exp_args:NNNo \group_end: + \dim_set:Nn #2 { \tex_the:D \box_wd:N \l_siunitx_tmp_box } + } + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro} +% { +% \siunitx_table_print_S_pre_aligned: , +% \siunitx_table_print_S_pre_not_aligned: , +% \siunitx_table_print_S_post_aligned: , +% \siunitx_table_print_S_post_not_aligned: +% } +% The non-numerical material is inserted along with the filler needed +% to maintain alignment. The order in which the two are inserted depends +% on whether those parts are also aligned. +% \begin{macrocode} +\cs_new_protected_nopar:Npn \siunitx_table_print_S_pre_aligned: + { + \box_use:N \l_siunitx_table_pre_box + \hbox_to_wd:nn { \l_siunitx_table_fill_pre_dim } { \tex_hfil:D } + } +\cs_new_protected_nopar:Npn \siunitx_table_print_S_pre_not_aligned: + { + \hbox_to_wd:nn { \l_siunitx_table_fill_pre_dim } { \tex_hfil:D } + \box_use:N \l_siunitx_table_pre_box + } +\cs_new_protected_nopar:Npn \siunitx_table_print_S_post_aligned: + { + \hbox_to_wd:nn { \l_siunitx_table_fill_post_dim } { \tex_hfil:D } + \box_use:N \l_siunitx_table_post_box + } +\cs_new_protected_nopar:Npn \siunitx_table_print_S_post_not_aligned: + { + \box_use:N \l_siunitx_table_post_box + \hbox_to_wd:nn { \l_siunitx_table_fill_post_dim } { \tex_hfil:D } + } +% \end{macrocode} +% \end{macro} +% +% \subsection{Printing the \texttt{S} column with the decimal marker centred} +% +% \begin{macro}{\siunitx_table_print_S_centered:} +% The main routine for decimal-centred alignment works by boxing up the +% entire output, the integer part and the decimal marker. It then works +% out which part is bigger and calculates the fill correction accordingly. +% Once all of that is done, the various boxes and fill can be inserted. +% \begin{macrocode} +\cs_new_protected_nopar:Npn \siunitx_table_print_S_centered: + { + \siunitx_table_print_S_centered_ends: + \bool_if:NT \l_siunitx_table_math_bool { \c_math_shift_token } + \siunitx_table_print_S_parse: + \siunitx_table_print_S_centered_measure: + \bool_if:NT \l_siunitx_table_math_bool { \c_math_shift_token } + \dim_set:Nn \l_siunitx_table_fill_pre_dim + { + \l_siunitx_table_result_dim + - \l_siunitx_table_integer_dim + \prop_if_in:NnT \l_siunitx_number_out_prop { mantissa-decimal-marker } + { - \l_siunitx_table_marker_dim } + } + \dim_compare:nNnTF \l_siunitx_table_integer_dim > + \l_siunitx_table_fill_pre_dim + { \siunitx_table_print_S_centered_integer: } + { \siunitx_table_print_S_centered_decimal: } + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\siunitx_table_print_S_centered_ends:} +% To deal with the material outside of the number, the first step is to +% box up both parts. If the pre-numeral part has no width, the tokens are +% inserted into the input stream to cover cases where they make a change +% to the colour, font or so forth. After that, the narrower of the two +% boxes is made the same size as the wider: this maintains the alignment. +% \begin{macrocode} +\cs_new_protected_nopar:Npn \siunitx_table_print_S_centered_ends: + { + \hbox_set:Nn \l_siunitx_table_pre_box + { + { + \l_siunitx_table_collect_pre_tl + \bool_if:NT \l_siunitx_table_math_bool + { + \scan_stop: + \c_math_shift_token + } + } + } + \dim_compare:nNnT + { \box_wd:N \l_siunitx_table_pre_box } = \c_zero_skip + { \l_siunitx_table_collect_pre_tl } + \hbox_set:Nn \l_siunitx_table_post_box { - \tl_use:N \l_siunitx_table_collect_pre_tl \bool_if:NT \l_siunitx_table_math_bool { - \scan_stop: \c_math_shift_token + \scan_stop: } + \l_siunitx_table_collect_post_tl } - } - \hbox_set:Nn \l_siunitx_table_post_box - { - \bool_if:NT \l_siunitx_table_math_bool - { - \c_math_shift_token - \scan_stop: - } - \tl_use:N \l_siunitx_table_collect_post_tl - } - \dim_compare:nNnTF - { \box_wd:N \l_siunitx_table_pre_box } > - { \box_wd:N \l_siunitx_table_post_box } - { - \hbox_set_to_wd:Nnn \l_siunitx_table_post_box - { \box_wd:N \l_siunitx_table_pre_box } - { - \hbox_unpack:N \l_siunitx_table_post_box - \tex_hfil:D - } - } - { - \hbox_set_to_wd:Nnn \l_siunitx_table_pre_box + \dim_compare:nNnTF + { \box_wd:N \l_siunitx_table_pre_box } > { \box_wd:N \l_siunitx_table_post_box } - { - \tex_hfil:D - \hbox_unpack:N \l_siunitx_table_pre_box - } - } -} -% \end{macrocode} -%\end{macro} -%\begin{macro}[aux]{\siunitx_table_print_S_centered_integer:} -%\begin{macro}[aux]{\siunitx_table_print_S_centered_decimal:} -% Actually printing the content is a case of calculating a suitable -% filler box, then printing it and the content. -% \begin{macrocode} -\cs_new_protected_nopar:Npn \siunitx_table_print_S_centered_integer: { - \dim_set:Nn \l_siunitx_table_fill_dim - { \l_siunitx_table_integer_dim - \l_siunitx_table_fill_dim } - \hbox_set_to_wd:Nnn \l_siunitx_table_fill_box - { \l_siunitx_table_fill_dim } { \tex_hfil:D } - \box_use:N \l_siunitx_table_result_box - \box_use:N \l_siunitx_table_fill_box -} -\cs_new_protected_nopar:Npn \siunitx_table_print_S_centered_decimal: { - \dim_set:Nn \l_siunitx_table_fill_dim - { \l_siunitx_table_fill_dim - \l_siunitx_table_integer_dim } - \hbox_set_to_wd:Nnn \l_siunitx_table_fill_box - { \l_siunitx_table_fill_dim } { \tex_hfil:D } - \box_use:N \l_siunitx_table_fill_box - \box_use:N \l_siunitx_table_result_box -} + { + \hbox_set_to_wd:Nnn \l_siunitx_table_post_box + { \box_wd:N \l_siunitx_table_pre_box } + { + \hbox_unpack:N \l_siunitx_table_post_box + \tex_hfil:D + } + } + { + \hbox_set_to_wd:Nnn \l_siunitx_table_pre_box + { \box_wd:N \l_siunitx_table_post_box } + { + \tex_hfil:D + \hbox_unpack:N \l_siunitx_table_pre_box + } + } + } % \end{macrocode} -%\end{macro} -%\end{macro} +% \end{macro} % -%\begin{macro}{\siunitx_table_print_S_reserved:} -% Sorting out a number with reserved space means checking each part -% in turn. After sorting out the ends, a model number is constructed, -% and this is then used by the various sub-routines to get the spacing -% correct. +% \begin{macro}{\siunitx_table_print_S_centered_measure:} +% \begin{macro}[aux] +% { +% \siunitx_table_print_S_centered_measure_int_part: , +% \siunitx_table_print_S_centered_measure_marker: , +% \siunitx_table_print_S_centered_measure_result: +% } +% Here, there are three parts of the number to measure: the integer part, +% the decimal marker and the entire number. Most of the work consists +% of collecting up parts of the number. % \begin{macrocode} -\cs_new_protected_nopar:Npn \siunitx_table_print_S_reserved: { - \dim_zero:N \l_siunitx_table_gap_dim - \dim_zero:N \l_siunitx_table_space_dim - \siunitx_table_print_S_reserved_ends: - \dim_compare:nNnTF - { \box_wd:N \l_siunitx_table_pre_box } = { \c_zero_skip } - { \tl_use:N \l_siunitx_table_collect_pre_tl } - { - \box_use:N \l_siunitx_table_pre_box - \bool_if:NT \l_siunitx_table_math_bool { \c_math_shift_token } - } - \siunitx_table_print_S_model_create: - \bool_if:NT \l_siunitx_table_auto_bool - { - \int_set:Nn \l_siunitx_process_precision_int - { \l_siunitx_table_decimal_int } - \tl_set:Nn \l_siunitx_round_tl { places } - } - \siunitx_table_print_S_parse: - \bool_if:NTF \l_siunitx_table_comparator_bool - { - \bool_if:NT \l_siunitx_table_align_comparator_bool - { \siunitx_table_print_S_reserved_comparator: } - } - { - \prop_if_in:NnT \l_siunitx_number_out_prop { comparator } - { - \msg_error:nnx { siunitx } { table-partial-number } - { a~comparator } - } - } - \int_compare:nNnTF - { \l_siunitx_table_integer_int + \l_siunitx_table_decimal_int } > - { 0 } - { \siunitx_table_print_S_reserved_mantissa: } - { - \prop_if_in:NnT \l_siunitx_number_out_prop { mantissa-result } - { - \msg_error:nnx { siunitx } { table-partial-number } - { a~mantissa } - } - } - \prop_if_in:NnT \l_siunitx_number_out_prop { complex-result } - { - \msg_error:nnx { siunitx } { table-partial-number } - { a~complex } - } - \int_compare:nNnTF { \l_siunitx_table_exponent_int } > { 0 } - { \siunitx_table_print_S_reserved_exponent: } - { - \prop_if_in:NnT \l_siunitx_number_out_prop { exponent-result } - { - \msg_error:nnx { siunitx } { table-partial-number } - { an~exponent } - } - } - \bool_if:NT \l_siunitx_table_math_bool { \c_math_shift_token } - \bool_if:NTF \l_siunitx_table_align_post_bool - { \box_use:N \l_siunitx_table_post_box } - { - \hbox_set_to_wd:Nnn \l_siunitx_table_fill_box - { \dim_use:N \l_siunitx_table_gap_dim } - { \tex_hfil:D } - \dim_set:Nn \l_siunitx_table_gap_dim - { - \dim_use:N \l_siunitx_table_gap_dim } - \skip_horizontal:N \l_siunitx_table_gap_dim - \box_use:N \l_siunitx_table_post_box - \box_use:N \l_siunitx_table_fill_box - } -} +\cs_new_protected_nopar:Npn \siunitx_table_print_S_centered_measure: + { + \siunitx_table_print_S_centered_measure_int_part: + \siunitx_table_print_S_centered_measure_marker: + \siunitx_table_print_S_centered_measure_result: + } +\cs_new_protected_nopar:Npn \siunitx_table_print_S_centered_measure_int_part: + { + \prop_get:NnNF \l_siunitx_number_out_prop { comparator } \l_siunitx_tmpa_tl + { \tl_clear:N \l_siunitx_tmpa_tl } + \prop_get:NnNT \l_siunitx_number_out_prop { mantissa-sign } + \l_siunitx_tmpb_tl + { \tl_put_right:No \l_siunitx_tmpa_tl \l_siunitx_tmpb_tl } + \prop_get:NnNT \l_siunitx_number_out_prop { mantissa-integer } + \l_siunitx_tmpb_tl + { \tl_put_right:No \l_siunitx_tmpa_tl \l_siunitx_tmpb_tl } + \siunitx_table_print_S_measure:NN \l_siunitx_tmpa_tl + \l_siunitx_table_integer_dim + } +\cs_new_protected_nopar:Npn \siunitx_table_print_S_centered_measure_marker: + { + \tl_set:Nx \l_siunitx_tmpa_tl + { + \exp_not:N \siunitx_ensuremath:n + { \exp_not:o \l_siunitx_output_decimal_tl } + } + \siunitx_table_print_S_measure:NN \l_siunitx_tmpa_tl + \l_siunitx_table_marker_dim + } % \end{macrocode} -%\end{macro} -%\begin{macro}{\siunitx_table_print_S_reserved_ends:} -% For the reserved case, the two ends are simply boxed up in correctly -% created spaces. +% As the overall result will be needed later, the boxing up here is done +% using a named box that will be retained. % \begin{macrocode} -\cs_new_protected_nopar:Npn \siunitx_table_print_S_reserved_ends: { - \hbox_set:Nn \l_siunitx_tmp_box - { - \l_siunitx_table_pre_tl - \bool_if:NT \l_siunitx_table_math_bool - { - \scan_stop: - \c_math_shift_token - } - } - \hbox_set_to_wd:Nnn \l_siunitx_table_pre_box - { \box_wd:N \l_siunitx_tmp_box } - { - \tex_hfil:D - { \tl_use:N \l_siunitx_table_collect_pre_tl } - } - \hbox_set:Nn \l_siunitx_tmp_box { \l_siunitx_table_post_tl } - \hbox_set_to_wd:Nnn \l_siunitx_table_post_box - { \box_wd:N \l_siunitx_tmp_box } - { - \bool_if:NT \l_siunitx_table_math_bool - { - \c_math_shift_token - \scan_stop: - } - \tl_use:N \l_siunitx_table_collect_post_tl - \tex_hfil:D - } -} +\cs_new_protected_nopar:Npn \siunitx_table_print_S_centered_measure_result: + { + \prop_get:NnN \l_siunitx_number_out_prop { result } \l_siunitx_tmpa_tl + \hbox_set:Nn \l_siunitx_table_result_box + { \siunitx_print:nV { number } \l_siunitx_tmpa_tl } + \dim_set:Nn \l_siunitx_table_result_dim + { \box_wd:N \l_siunitx_table_result_box } + } % \end{macrocode} -%\end{macro} -%\begin{macro}{\siunitx_table_print_S_model_create:} -%\begin{macro}[aux]{\siunitx_table_print_S_model_aux:nn} -% A model value is created from the various numbers set up as -% options. The main formatting routine is used to get everything sorted -% out, so that there is no code copying here. +% \end{macro} +% \end{macro} +% +% \begin{macro} +% { +% \siunitx_table_print_S_centered_integer: , +% \siunitx_table_print_S_centered_decimal: +% } +% The appropriate place to insert the fill is determined by whether the +% integer or decimal part of the number is bigger. Two dimensions are +% therefore set, for fill before the number and after it. One of these +% will always be zero. % \begin{macrocode} -\cs_new_protected_nopar:Npn \siunitx_table_print_S_model_create: { - \prop_clear:N \l_siunitx_number_in_prop - \bool_if:NT \l_siunitx_table_comparator_bool - { \prop_put:Nnn \l_siunitx_number_in_prop { comparator } { \ll } } - \siunitx_table_print_S_model_aux:nn { integer } { mantissa-integer } - \siunitx_table_print_S_model_aux:nn { decimal } { mantissa-decimal } - \siunitx_table_print_S_model_aux:nn { uncert } - { mantissa-uncertainty } - \siunitx_table_print_S_model_aux:nn { exponent } { exponent-integer } - \int_compare:nNnF - { \l_siunitx_table_integer_int + \l_siunitx_table_decimal_int } = - { 0 } - { - \prop_put:Nnn \l_siunitx_number_in_prop { mantissa } - { true } - } - \int_compare:nNnT { \l_siunitx_table_decimal_int } > { 0 } - { - \prop_put:NnV \l_siunitx_number_in_prop - { mantissa-decimal-marker } - \l_siunitx_output_decimal_tl - } - \bool_if:NT \l_siunitx_table_sign_mantissa_bool - { \prop_put:Nnn \l_siunitx_number_in_prop { mantissa-sign } { - } } - \int_compare:nNnT { \l_siunitx_table_exponent_int } > { 0 } - { - \bool_if:NT \l_siunitx_table_sign_exponent_bool - { - \prop_put:Nnn \l_siunitx_number_in_prop { exponent-sign } - { - } - } - } - \siunitx_number_process_sign: - \siunitx_number_process_zero_fill: - \siunitx_number_process_mantissa: - \prop_if_in:NnF \l_siunitx_number_in_prop { symbolic } - { \siunitx_number_process_uncertainty: } - \siunitx_number_format: - \prop_set_eq:NN \l_siunitx_table_model_prop - \l_siunitx_number_out_prop -} -\cs_new_protected_nopar:Npn \siunitx_table_print_S_model_aux:nn #1#2 { - \tl_set:Nx \l_siunitx_tmpa_tl - { - \prg_replicate:nn { \int_use:c { l_siunitx_table_ #1 _int } } - { 8 } - } - \tl_if_empty:NF \l_siunitx_tmpa_tl - { - \prop_put:NnV \l_siunitx_number_in_prop {#2} \l_siunitx_tmpa_tl - \prop_put:Nnn \l_siunitx_number_in_prop {#1} { true } - } -} +\cs_new_protected_nopar:Npn \siunitx_table_print_S_centered_integer: + { + \dim_set:Nn \l_siunitx_table_fill_post_dim + { \l_siunitx_table_integer_dim - \l_siunitx_table_fill_pre_dim } + \dim_zero:N \l_siunitx_table_fill_pre_dim + } +\cs_new_protected_nopar:Npn \siunitx_table_print_S_centered_decimal: + { + \dim_sub:Nn \l_siunitx_table_fill_pre_dim + { \l_siunitx_table_integer_dim } + \dim_zero:N \l_siunitx_table_fill_post_dim + } % \end{macrocode} -%\end{macro} -%\end{macro} -%\begin{macro}{\siunitx_table_print_S_reserved_reserved_comparator:} -% Space for a comparator is pretty easy: it has to be at the start of -% the output so there is not so much to worry about. +% \end{macro} +% +% \subsection{Printing the \texttt{S} column with space reserved} +% +% \begin{macro}{\siunitx_table_print_S_reserved:} +% The procedure for inserting a number with space reserved requires a model +% for each part of the number. % \begin{macrocode} -\cs_new_protected_nopar:Npn \siunitx_table_print_S_reserved_comparator: +\cs_new_protected_nopar:Npn \siunitx_table_print_S_reserved: { - \siunitx_table_print_S_measure:Nnn \l_siunitx_table_model_prop - { comparator } { } - \siunitx_table_print_S_get_comparator:Nn - \l_siunitx_number_out_prop { } - \hbox_set_to_wd:Nnn \l_siunitx_table_result_box - { \l_siunitx_table_comparator_dim } - { - \siunitx_print:nV { number } \l_siunitx_tmpa_tl - \tex_hfil:D - } - \box_use:N \l_siunitx_table_result_box -} + \siunitx_table_print_S_reserved_init: + \siunitx_table_print_S_reserved_ends: + \siunitx_table_print_S_reserved_round: + \siunitx_table_print_S_parse: + \bool_if:NT \l_siunitx_table_math_bool { \c_math_shift_token } + \siunitx_table_print_S_reserved_comparator: + \siunitx_table_print_S_reserved_mantissa: + \siunitx_table_print_S_reserved_exponent: + \bool_if:NT \l_siunitx_table_math_bool { \c_math_shift_token } + } % \end{macrocode} -%\end{macro} -%\begin{macro}{\siunitx_table_print_S_reserved_mantissa:} -%\begin{macro}[aux]{\siunitx_table_print_S_reserved_mantissa_aux:n} -% Printing the mantissa is done by measuring the integer part of the -% model and the real number, and padding out if necessary. Everything -% else is straight forward. The reason for the two box setting -% operations here is to allow the amount of empty space left after -% the decimal marker to be measured: this is needed if exponents are -% not being aligned. +% \end{macro} +% +% \begin{macro}{\siunitx_table_print_S_reserved_init:} +% The creation of a model for the cell to follow. Creation of the finalised +% model is done here so that all of the other options will apply without +% needing complex internal tracking. % \begin{macrocode} -\cs_new_protected_nopar:Npn \siunitx_table_print_S_reserved_mantissa: { - \siunitx_table_print_S_reserved_mantissa_aux:n { mantissa } - \siunitx_table_print_S_measure:Nnn \l_siunitx_table_model_prop - { mantissa } { } - \siunitx_table_print_S_get_mantissa:Nn - \l_siunitx_number_out_prop { } - \dim_set:Nn \l_siunitx_table_space_dim - { \l_siunitx_table_mantissa_dim } - \hbox_set:Nn \l_siunitx_table_result_box - { - \box_use:N \l_siunitx_table_fill_box - \siunitx_print:nV { number } \l_siunitx_tmpa_tl - } - \dim_sub:Nn \l_siunitx_table_space_dim - { \box_wd:N \l_siunitx_table_result_box } - \hbox_set_to_wd:Nnn \l_siunitx_table_result_box - { \l_siunitx_table_mantissa_dim } - { - \box_use:N \l_siunitx_table_result_box - \tex_hfil:D - } - \box_use:N \l_siunitx_table_result_box - \siunitx_table_print_S_reserved_uncert:n { mantissa } -} -\cs_new_protected_nopar:Npn - \siunitx_table_print_S_reserved_mantissa_aux:n #1 { - \bool_if:NTF \l_siunitx_table_align_comparator_bool - { - \siunitx_table_print_S_measure:Nnn \l_siunitx_table_model_prop - { integer } {#1} - \siunitx_table_print_S_get_integer:Nn - \l_siunitx_number_out_prop {#1} - } - { - \siunitx_table_print_S_measure_comparator_integer:N - \l_siunitx_table_model_prop - \siunitx_table_print_S_measure_comparator_integer_get:N - \l_siunitx_number_out_prop - } - \box_clear:N \l_siunitx_tmp_box - \tl_if_empty:NF \l_siunitx_tmpa_tl - { - \hbox_set:Nn \l_siunitx_tmp_box - { \siunitx_print:nV { number } \l_siunitx_tmpa_tl } - } - \hbox_set_to_wd:Nnn \l_siunitx_table_fill_box - { \l_siunitx_table_integer_dim - \box_wd:N \l_siunitx_tmp_box } - { \tex_hfil:D } - \siunitx_table_print_S_measure:Nnn \l_siunitx_table_model_prop - { decimal } {#1} - \box_clear:N \l_siunitx_tmp_box - \siunitx_table_print_S_get_decimal:Nn - \l_siunitx_number_out_prop {#1} - \tl_if_empty:NF \l_siunitx_tmpa_tl - { - \hbox_set:Nn \l_siunitx_tmp_box - { \siunitx_print:nV { number } \l_siunitx_tmpa_tl } - } - \dim_set:Nn \l_siunitx_table_gap_dim - { - \dim_use:N \l_siunitx_table_decimal_dim - - \box_wd:N \l_siunitx_tmp_box - } -} +\cs_new_protected_nopar:Npn \siunitx_table_print_S_reserved_init: + { + \dim_zero:N \l_siunitx_table_fill_mid_dim + \dim_zero:N \l_siunitx_table_fill_post_dim + \prop_set_eq:NN \l_siunitx_number_in_prop \l_siunitx_table_model_prop + \siunitx_number_process_sign: + \siunitx_number_process_zero_fill: + \siunitx_number_process_mantissa: + \prop_if_in:NnF \l_siunitx_number_in_prop { symbolic } + { \siunitx_number_process_uncertainty: } + \siunitx_number_format: + \prop_get:NnNT \l_siunitx_table_model_prop { mantissa-decimal-raw } + \l_siunitx_tmp_tl + { + \prop_put:NnV \l_siunitx_number_out_prop { mantissa-decimal-raw } + \l_siunitx_tmp_tl + } + \prop_set_eq:NN \l_siunitx_table_model_prop \l_siunitx_number_out_prop + } % \end{macrocode} -%\end{macro} -%\end{macro} +% \end{macro} % -%\begin{macro}{\siunitx_table_print_S_reserved_uncert:n} -%\begin{macro}[aux]{\siunitx_table_print_S_reserved_uncert_aux:n} -% The uncertainty code is generalised for both real and complex parts. -% A lot of the logic is similar to the exponent part (the \cs{pm} -% symbol) or the mantissa (the number measuring). So some of the -% code is shared. +% \begin{macro}{\siunitx_table_print_S_reserved_ends:} +% The end material here is boxed up into the space already reserved. +% That means doing two boxing ups: one for the model, and one for the +% real thing. As in the centred case, if the pre-numeral part has no +% width then the tokens are inserted \enquote{as is}. To avoid any issues +% with people forgetting to reserve space for the pre-numeral part, it is +% boxed up first at natural width so that the measurement is accurate. % \begin{macrocode} -\cs_new_protected_nopar:Npn - \siunitx_table_print_S_reserved_uncert:n #1 { - \bool_if:NT \l_siunitx_uncert_sep_bool - { - \int_compare:nNnTF { \l_siunitx_table_uncert_int } > { 0 } - { \siunitx_table_print_S_reserved_uncert_aux:n {#1} } +\cs_new_protected_nopar:Npn \siunitx_table_print_S_reserved_ends: + { + \hbox_set:Nn \l_siunitx_table_pre_box + { { - \prop_if_in:NnT \l_siunitx_number_out_prop - { #1 -uncertainty } + \l_siunitx_table_collect_pre_tl + \bool_if:NT \l_siunitx_table_math_bool { - \msg_error:nn { siunitx } { table-partial-number } - { an~uncertainty } + \scan_stop: + \c_math_shift_token } } - } -} -\cs_new_protected_nopar:Npn - \siunitx_table_print_S_reserved_uncert_aux:n #1 { - \siunitx_table_print_S_reserved_uncert_pm:n {#1} - \siunitx_table_print_S_reserved_mantissa_aux:n { #1 -uncertainty } - \siunitx_table_print_S_measure:Nnn \l_siunitx_table_model_prop - { uncert } {#1} - \siunitx_table_print_S_get_uncert:Nn \l_siunitx_number_out_prop {#1} - \hbox_set_to_wd:Nnn \l_siunitx_table_result_box - { \l_siunitx_table_uncert_dim } - { - \box_use:N \l_siunitx_table_fill_box - \siunitx_print:nV { number } \l_siunitx_tmpa_tl - \tex_hfil:D - } - \box_use:N \l_siunitx_table_result_box - \bool_if:NF \l_siunitx_table_align_uncert_bool - { - \tex_hskip:D \l_siunitx_table_space_dim - \dim_zero:N \l_siunitx_table_space_dim - } -} -\cs_new_protected_nopar:Npn - \siunitx_table_print_S_reserved_uncert_pm:n #1 { - \tl_clear:N \l_siunitx_tmpb_tl - \siunitx_number_format_join_uncert_pm: - \tl_set:Nx \l_siunitx_tmpb_tl - { { } \exp_not:V \l_siunitx_tmpb_tl { } } - \hbox_set:Nn \l_siunitx_table_result_box - { \siunitx_print:nV { number } \l_siunitx_tmpb_tl } - \prop_if_in:NnF \l_siunitx_number_out_prop { #1 -uncertainty } - { - \hbox_set_to_wd:Nnn \l_siunitx_table_result_box - { \box_wd:N \l_siunitx_table_result_box } { \tex_hfil:D } - } - \bool_if:NF \l_siunitx_table_align_uncert_bool - { \tex_hskip:D -\l_siunitx_table_space_dim } - \box_use:N \l_siunitx_table_result_box -} -% \end{macrocode} -%\end{macro} -%\end{macro} -%\begin{macro}{\siunitx_table_print_S_reserved_exponent:} -%\begin{macro}[aux]{\siunitx_table_print_S_reserved_exponent_product:} -%\begin{macro}[aux] -% {\siunitx_table_print_S_reserved_exponent_product_aux_i:} -%\begin{macro}[aux] -% {\siunitx_table_print_S_reserved_exponent_product_aux_ii:} -% Most of the code for the exponent is concerned with getting the -% product sign correct. Other than that, the exponent result is quite -% easy to handle: just print it with some filling. -% \begin{macrocode} -\cs_new_protected_nopar:Npn \siunitx_table_print_S_reserved_exponent: { - \dim_zero:N \l_siunitx_table_gap_dim - \tl_if_empty:NTF \l_siunitx_output_exponent_tl - { \siunitx_table_print_S_reserved_exponent_product: } - { - \bool_if:NF \l_siunitx_table_align_exp_bool - { \tex_hskip:D -\l_siunitx_table_space_dim } - } - \siunitx_table_print_S_measure:Nnn \l_siunitx_table_model_prop - { exponent } { } - \siunitx_table_print_S_get_exponent:Nn - \l_siunitx_number_out_prop { } - \hbox_set_to_wd:Nnn \l_siunitx_table_result_box - { \l_siunitx_table_exponent_dim } - { - \siunitx_print:nV { number } \l_siunitx_tmpa_tl - \tex_hfil:D - } - \box_use:N \l_siunitx_table_result_box - \bool_if:NF \l_siunitx_table_align_exp_bool - { \tex_hskip:D \l_siunitx_table_space_dim } -} -\cs_new_protected_nopar:Npn - \siunitx_table_print_S_reserved_exponent_product: { - \tl_clear:N \l_siunitx_tmpa_tl - \box_clear:N \l_siunitx_table_result_box - \prop_if_in:NnTF \l_siunitx_table_model_prop { mantissa-result } - { \siunitx_table_print_S_reserved_exponent_product_aux_i: } - { - \prop_if_in:NnT \l_siunitx_table_model_prop { complex-result } - { \siunitx_table_print_S_reserved_exponent_product_aux_i: } - } - \bool_if:NF \l_siunitx_table_align_exp_bool - { \tex_hskip:D -\l_siunitx_table_space_dim } - \box_use:N \l_siunitx_table_result_box -} -\cs_new_protected_nopar:Npn - \siunitx_table_print_S_reserved_exponent_product_aux_i: { - \tl_set_eq:NN \l_siunitx_tmpa_tl \l_siunitx_exponent_product_tl - \bool_if:NT \l_siunitx_tight_bool - { - \tl_set:Nx \l_siunitx_tmpa_tl - { { \exp_not:V \l_siunitx_tmpa_tl } } - } - \tl_set:Nx \l_siunitx_tmpa_tl - { - \exp_not:N \siunitx_ensuremath:n - { { } \exp_not:V \l_siunitx_tmpa_tl { } } - } - \hbox_set:Nn \l_siunitx_table_result_box - { \siunitx_print:nV { number } \l_siunitx_tmpa_tl } - \prop_if_in:NnTF \l_siunitx_number_out_prop { exponent-result } - { - \prop_if_in:NnF \l_siunitx_number_out_prop { mantissa-result } + } + \dim_compare:nNnT + { \box_wd:N \l_siunitx_table_pre_box } = \c_zero_skip + { \l_siunitx_table_collect_pre_tl } + \hbox_set:Nn \l_siunitx_tmp_box { { \l_siunitx_table_pre_tl } } + \hbox_set_to_wd:Nnn \l_siunitx_table_pre_box + { \box_wd:N \l_siunitx_tmp_box } + { + \tex_hfil:D + \hbox_unpack:N \l_siunitx_table_pre_box + } + \hbox_set:Nn \l_siunitx_tmp_box { \l_siunitx_table_post_tl } + \hbox_set_to_wd:Nnn \l_siunitx_table_post_box + { \box_wd:N \l_siunitx_tmp_box } + { { - \prop_if_in:NnF \l_siunitx_number_out_prop { complex-result } + \bool_if:NT \l_siunitx_table_math_bool { - \siunitx_table_print_S_reserved_exponent_product_aux_ii: + \c_math_shift_token + \scan_stop: } + \l_siunitx_table_collect_post_tl } - } - { \siunitx_table_print_S_reserved_exponent_product_aux_ii: } -} -\cs_new_protected_nopar:Npn - \siunitx_table_print_S_reserved_exponent_product_aux_ii: { - \hbox_set_to_wd:Nnn \l_siunitx_table_result_box - { \box_wd:N \l_siunitx_table_result_box } { \tex_hfil:D } -} + \tex_hfil:D + } + } % \end{macrocode} -%\end{macro} -%\end{macro} -%\end{macro} -%\end{macro} +% \end{macro} % -%\begin{macro}{\siunitx_table_print_S_measure:Nnn} -% The measuring code recovers whatever is needed into -% \cs{l_siunitx_tmpa_tl} (as this is internal code, that is okay). -% The content is then boxed up and measured: if there is nothing to do, -% a bit of time can be saved by not boxing up at all. +% \begin{macro}{\siunitx_table_print_S_reserved_round_auto:} +% For auto-rounding, the approach is to find how many decimal digits are +% allowed for, and if there are none to simply set the rounding value to +% zero. % \begin{macrocode} -\cs_new_protected_nopar:Npn \siunitx_table_print_S_measure:Nnn #1#2#3 { - \use:c { siunitx_table_print_S_get_ #2 :Nn } #1 {#3} - \tl_if_empty:NTF \l_siunitx_tmpa_tl - { \dim_set:cn { l_siunitx_table_ #2 _dim } { \c_zero_skip } } - { - \hbox_set:Nn \l_siunitx_tmp_box - { \siunitx_print:nV { number } \l_siunitx_tmpa_tl } - \dim_set:cn { l_siunitx_table_ #2 _dim } - { \box_wd:N \l_siunitx_tmp_box } - } -} +\cs_new_protected_nopar:Npn \siunitx_table_print_S_reserved_round_auto: + { + \prop_get:NnNTF \l_siunitx_table_model_prop { mantissa-decimal-raw } + \l_siunitx_tmpa_tl + { \int_set:Nn \l_siunitx_process_precision_int { \l_siunitx_tmpa_tl } } + { \int_zero:N \l_siunitx_process_precision_int } + \tl_set:Nn \l_siunitx_round_tl { places } + } % \end{macrocode} -%\end{macro} -%\begin{macro}{\siunitx_table_print_S_get_comparator:Nn} -% Getting the comparator part is quite easy. +% \end{macro} +% +% \begin{macro}{\siunitx_table_print_S_reserved_comparator:} +% The comparator is quite simple to deal with. Assuming that there is a +% comparator in the model, this is measured for the reserved width. The +% real comparator can then simply be typeset in a box of the same size. +% If there is no comparator in the real case, then the space added to +% that for filling: this is needed so that any pre-note can be aligned +% freely. % \begin{macrocode} -\cs_new_protected_nopar:Npn - \siunitx_table_print_S_get_comparator:Nn #1#2 { - \prop_get:NnN #1 { comparator } \l_siunitx_tmpa_tl - \quark_if_no_value:NT \l_siunitx_tmpa_tl - { \tl_clear:N \l_siunitx_tmpa_tl } -} +\cs_new_protected_nopar:Npn \siunitx_table_print_S_reserved_comparator: + { + \prop_get:NnNTF \l_siunitx_table_model_prop { comparator } + \l_siunitx_tmpa_tl + { + \hbox_set:Nn \l_siunitx_tmp_box + { \siunitx_print:nV { number } \l_siunitx_tmpa_tl } + \prop_get:NnNTF \l_siunitx_number_out_prop { comparator } + \l_siunitx_tmpa_tl + { + \hbox_set_to_wd:Nnn \l_siunitx_table_result_box + { \box_wd:N \l_siunitx_tmp_box } + { \siunitx_print:nV { number } \l_siunitx_tmpa_tl } + } + { + \dim_add:Nn \l_siunitx_table_fill_pre_dim + { \box_wd:N \l_siunitx_tmp_box } + \cs_set_eq:NN \siunitx_table_print_S_reserved_store_fill:n + \siunitx_table_print_S_reserved_store_fill_pre:n + } + } + { + \cs_set_eq:NN \siunitx_table_print_S_reserved_store_fill:n + \siunitx_table_print_S_reserved_store_fill_pre:n + \prop_if_in:NnT \l_siunitx_number_out_prop { comparator } + { + \msg_error:nnx { siunitx } { table-partial-number } + { a~comparator } + } + } + } % \end{macrocode} -%\end{macro} -%\begin{macro}{\siunitx_table_print_S_get_decimal:Nn} -% Grabbing the decimal part is a simple operation. -% \begin{macrocode} -\cs_new_protected_nopar:Npn - \siunitx_table_print_S_get_decimal:Nn #1#2 { - \prop_get:NnN #1 { #2 -decimal } \l_siunitx_tmpa_tl - \quark_if_no_value:NT \l_siunitx_tmpa_tl - { \tl_clear:N \l_siunitx_tmpa_tl } -} +% \end{macro} +% +% \begin{macro} +% { +% \siunitx_table_print_S_reserved_store_fill_pre:n , +% \siunitx_table_print_S_reserved_store_fill_mid:n +% } +% To allow for the various alignment options, fill is stored in a +% flexible way. +% \begin{macrocode} +\cs_new_protected_nopar:Npn \siunitx_table_print_S_reserved_store_fill_pre:n + { \dim_add:Nn \l_siunitx_table_fill_pre_dim } +\cs_new_protected_nopar:Npn \siunitx_table_print_S_reserved_store_fill_mid:n + { \dim_add:Nn \l_siunitx_table_fill_mid_dim } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\siunitx_table_print_S_reserved_mantissa:} +% \begin{macro}[aux] +% { +% \siunitx_table_print_S_reserved_mantissa_parts: , +% \siunitx_table_print_S_reserved_mantissa_integer: +% } +% The mantissa of a number may contain a sign, an integer part, a +% decimal marker, a decimal part and a non-separated uncertainty. That +% means that there are two ways to deal with the alignment. Each part +% could be done separately, or a correction can be made after setting +% the combined mantissa. Here, the later approach is taken. The first +% step is to deal with the mantissa as a whole: work out show much space +% to reserve, and see if there is anything at all to put in it. The +% complexity only starts if there is a mantissa in the current cell. +% \begin{macrocode} +\cs_new_protected_nopar:Npn \siunitx_table_print_S_reserved_mantissa: + { + \prop_get:NnNTF \l_siunitx_table_model_prop { mantissa } + \l_siunitx_tmpa_tl + { + \hbox_set:Nn \l_siunitx_tmp_box + { \siunitx_print:nV { number } \l_siunitx_tmpa_tl } + \prop_get:NnNTF \l_siunitx_number_out_prop { mantissa } + \l_siunitx_tmpa_tl + { + \dim_set:Nn \l_siunitx_table_mantissa_dim + { \box_wd:N \l_siunitx_tmp_box } + \hbox_set:Nn \l_siunitx_table_mantissa_box + { \siunitx_print:nV { number } \l_siunitx_tmpa_tl } + \siunitx_table_print_S_reserved_mantissa_parts: + } + { + \siunitx_table_print_S_reserved_store_fill:n + { \box_wd:N \l_siunitx_tmp_box } + } + } + { + \prop_if_in:NnT \l_siunitx_number_out_prop { mantissa } + { + \msg_error:nnx { siunitx } { table-partial-number } + { a~mantissa } + } + } + } % \end{macrocode} -%\end{macro} -%\begin{macro}{\siunitx_table_print_S_get_exponent:Nn} -% Getting the exponent part is quite easy. +% The aim here is to deal with the mantissa with as few measurements as +% possible. The integer part is therefore measured, with the real and model +% versions compared. This allows appropriate fill to be calculated to +% add the mantissa to the result box, after any comparator and with +% the appropriate width. Once that is done, the amount of filler needed +% \emph{after} the integer can be calculated: this is the size of the +% model mantissa, minus the size of the real mantissa and the amount of +% filler needed in the integer part. That is stored in the intermediate +% dimension for the present, although it may get moved. +% \begin{macrocode} +\cs_new_protected_nopar:Npn \siunitx_table_print_S_reserved_mantissa_parts: + { + \siunitx_table_print_S_reserved_mantissa_integer: + \hbox_set:Nn \l_siunitx_table_result_box + { + \hbox_unpack:N \l_siunitx_table_result_box + \hbox_to_wd:nn { \l_siunitx_table_fill_mid_dim } { \tex_hfil:D } + \hbox_unpack:N \l_siunitx_table_mantissa_box + } + \dim_set:Nn \l_siunitx_table_fill_mid_dim + { + \l_siunitx_table_mantissa_dim + - \box_wd:N \l_siunitx_table_mantissa_box + - \l_siunitx_table_integer_dim + } + \siunitx_table_print_S_reserved_mantissa_uncert: + } +% \end{macrocode} +% For the integer part, there is a need to measure both the sign and +% the integer itself in the model and in the real number. If there is +% no integer part in the real number, then fill is stored to add either +% before or after any comparator. If there is an integer part, the +% size is measured and the any fill needed is stored for re-insertion. % \begin{macrocode} -\cs_new_protected_nopar:Npn - \siunitx_table_print_S_get_exponent:Nn #1#2 { - \prop_get:NnN #1 { exponent-result } \l_siunitx_tmpa_tl - \quark_if_no_value:NT \l_siunitx_tmpa_tl - { \tl_clear:N \l_siunitx_tmpa_tl } -} +\cs_new_protected_nopar:Npn \siunitx_table_print_S_reserved_mantissa_integer: + { + \prop_get:NnNF \l_siunitx_table_model_prop { mantissa-sign } + \l_siunitx_tmpa_tl + { \tl_clear:N \l_siunitx_tmpa_tl } + \prop_get:NnNT \l_siunitx_table_model_prop { mantissa-integer } + \l_siunitx_tmpb_tl + { \tl_put_right:No \l_siunitx_tmpa_tl \l_siunitx_tmpb_tl } + \siunitx_table_print_S_measure:NN \l_siunitx_tmpa_tl + \l_siunitx_table_integer_dim + \prop_get:NnNF \l_siunitx_number_out_prop { mantissa-sign } + \l_siunitx_tmpa_tl + { \tl_clear:N \l_siunitx_tmpa_tl } + \prop_get:NnNT \l_siunitx_number_out_prop { mantissa-integer } + \l_siunitx_tmpb_tl + { \tl_put_right:No \l_siunitx_tmpa_tl \l_siunitx_tmpb_tl } + \tl_if_empty:NF \l_siunitx_tmpa_tl + { + \siunitx_table_print_S_measure:NN \l_siunitx_tmpa_tl + \l_siunitx_tmp_dim + \dim_sub:Nn \l_siunitx_table_integer_dim { \l_siunitx_tmp_dim } + } + \siunitx_table_print_S_reserved_store_fill:n + { \l_siunitx_table_integer_dim } + } % \end{macrocode} -%\end{macro} -%\begin{macro}{\siunitx_table_print_S_get_integer:Nn} -% Getting the integer part of a number means that the sign also has be -% considered, even if there is no actual integer. This leads to a -% slightly odd approach here. There is also the comparator to -% worry about. +% Here, a separated uncertainty is handled. If there is one, then there must +% be a \cs{pm} part to add. Once the space calculation is done, a flexible +% auxiliary does the spacing and pasting up. % \begin{macrocode} -\cs_new_protected_nopar:Npn - \siunitx_table_print_S_get_integer:Nn #1#2 { - \prop_get:NnN #1 { #2 -sign } \l_siunitx_tmpa_tl - \quark_if_no_value:NT \l_siunitx_tmpa_tl - { \tl_clear:N \l_siunitx_tmpa_tl } - \prop_get:NnN #1 { #2 -integer } \l_siunitx_tmpb_tl - \quark_if_no_value:NT \l_siunitx_tmpb_tl - { \tl_clear:N \l_siunitx_tmpb_tl } - \tl_put_right:NV \l_siunitx_tmpa_tl \l_siunitx_tmpb_tl -} +\cs_new_protected_nopar:Npn \siunitx_table_print_S_reserved_mantissa_uncert: + { + \prop_get:NnNT \l_siunitx_table_model_prop { mantissa-uncertainty } + \l_siunitx_tmpa_tl + { + \siunitx_number_format_join_uncert_pm:N \l_siunitx_tmpa_tl + \hbox_set:Nn \l_siunitx_tmp_box + { \siunitx_print:nV { number } \l_siunitx_tmpa_tl } + \prop_get:NnNTF \l_siunitx_number_out_prop { mantissa-uncertainty } + \l_siunitx_tmpa_tl + { + \dim_set:Nn \l_siunitx_table_uncert_dim + { \box_wd:N \l_siunitx_tmp_box } + \siunitx_number_format_join_uncert_pm:N \l_siunitx_tmpa_tl + \hbox_set:Nn \l_siunitx_tmp_box + { \siunitx_print:nV { number } \l_siunitx_tmpa_tl } + \siunitx_table_print_S_reserved_mantissa_uncert_aux: + } + { + \siunitx_table_print_S_reserved_store_fill:n + { \box_wd:N \l_siunitx_tmp_box } + } + } + } % \end{macrocode} -%\end{macro} -%\begin{macro}{\siunitx_table_print_S_get_mantissa:Nn} -% The mantissa without any uncertainty is needed by the reserved -% space routine. +% Two auxiliaries, one to place the uncertainty directly next to the rest +% of the mantissa, one to maintain alignment. In both cases, any fill ends +% up in the middle fill store, but in the alignment case this also removes +% any previous fill. The temporary box here contains the uncertainty part. % \begin{macrocode} \cs_new_protected_nopar:Npn - \siunitx_table_print_S_get_mantissa:Nn #1#2 { - \prop_get:NnN #1 { mantissa } \l_siunitx_tmpa_tl - \quark_if_no_value:NT \l_siunitx_tmpa_tl - { \tl_clear:N \l_siunitx_tmpa_tl } - \bool_if:NF \l_siunitx_table_align_comparator_bool - { - \prop_get:NnN #1 { comparator } \l_siunitx_tmpb_tl - \quark_if_no_value:NF \l_siunitx_tmpb_tl - { \tl_put_left:NV \l_siunitx_tmpa_tl \l_siunitx_tmpb_tl } - } -} + \siunitx_table_print_S_reserved_mantissa_uncert_aligned: + { + \hbox_set:Nn \l_siunitx_table_result_box + { + \hbox_unpack:N \l_siunitx_table_result_box + \hbox_to_wd:nn { \l_siunitx_table_fill_mid_dim } { \tex_hfil:D } + \hbox_unpack:N \l_siunitx_tmp_box + } + \dim_set:Nn \l_siunitx_table_fill_mid_dim + { \l_siunitx_table_uncert_dim - \box_wd:N \l_siunitx_tmp_box } + } +\cs_new_protected_nopar:Npn + \siunitx_table_print_S_reserved_mantissa_uncert_not_aligned: + { + \hbox_set:Nn \l_siunitx_table_result_box + { + \hbox_unpack:N \l_siunitx_table_result_box + \hbox_unpack:N \l_siunitx_tmp_box + } + \dim_add:Nn \l_siunitx_table_fill_mid_dim + { + \l_siunitx_table_uncert_dim + - \box_wd:N \l_siunitx_tmp_box + } + } % \end{macrocode} -%\end{macro} -%\begin{macro}{\siunitx_table_print_S_get_marker:Nn} -% The decimal marker is always going to be boxed up using the -% standard version, not any possible copied value. So the code can be -% kept quite clear. -% \begin{macrocode} -\cs_new_protected_nopar:Npn \siunitx_table_print_S_get_marker:Nn #1#2 { - \tl_set:Nx \l_siunitx_tmpa_tl - { - \exp_not:N \siunitx_ensuremath:n - { \exp_not:V \l_siunitx_output_decimal_tl } - } -} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\siunitx_table_print_S_reserved_exponent:} +% \begin{macro}[aux] +% { +% \siunitx_table_print_S_reserved_exponent_product: , +% \siunitx_table_print_S_reserved_exponent_product_correction: , +% \siunitx_table_print_S_reserved_exponent_aligned: , +% \siunitx_table_print_S_reserved_exponent_not_aligned: +% } +% Printing the exponent needs to deal with the exponent product. This +% is easiest to do by simply re-checking for a mantissa. If there is no +% exponent, then any space which needs to be added must be moved from +% the mid space to the post space at this stage. +% \begin{macrocode} +\cs_new_protected_nopar:Npn \siunitx_table_print_S_reserved_exponent: + { + \prop_get:NnNTF \l_siunitx_table_model_prop { exponent-result } + \l_siunitx_tmpa_tl + { + \prop_if_in:NnT \l_siunitx_table_model_prop { mantissa } + { \siunitx_table_print_S_reserved_exponent_product: } + \hbox_set:Nn \l_siunitx_tmp_box + { \siunitx_print:nV { number } \l_siunitx_tmpa_tl } + \prop_get:NnNTF \l_siunitx_number_out_prop { exponent-result } + \l_siunitx_tmpa_tl + { + \dim_set:Nn \l_siunitx_table_exponent_dim + { \box_wd:N \l_siunitx_tmp_box } + \prop_if_in:NnTF \l_siunitx_number_out_prop { mantissa } + { \siunitx_table_print_S_reserved_exponent_product: } + { \siunitx_table_print_S_reserved_exponent_product_correction: } + \hbox_set:Nn \l_siunitx_tmp_box + { \siunitx_print:nV { number } \l_siunitx_tmpa_tl } + \siunitx_table_print_S_reserved_exponent_aux: + } + { + \dim_set:Nn \l_siunitx_table_fill_post_dim + { \l_siunitx_table_fill_mid_dim + \box_wd:N \l_siunitx_tmp_box } + } + } + { + \prop_if_in:NnT \l_siunitx_number_out_prop { exponent-result } + { + \msg_error:nnx { siunitx } { table-partial-number } + { an~exponent } + } + \dim_set_eq:NN \l_siunitx_table_fill_post_dim + \l_siunitx_table_fill_mid_dim + } + } % \end{macrocode} -%\end{macro} -%\begin{macro}{\siunitx_table_print_S_get_result:Nn} -% Getting the result values is easy. +% A short sub-function to deal with the appearance of the exponent product +% for both the real number and the model. % \begin{macrocode} -\cs_new_protected_nopar:Npn \siunitx_table_print_S_get_result:Nn #1#2 { - \prop_get:NnN #1 { result } \l_siunitx_tmpa_tl - \quark_if_no_value:NT \l_siunitx_tmpa_tl - { \tl_clear:N \l_siunitx_tmpa_tl } -} +\cs_new_protected_nopar:Npn \siunitx_table_print_S_reserved_exponent_product: + { + \tl_set_eq:NN \l_siunitx_tmpb_tl \l_siunitx_exponent_product_tl + \bool_if:NT \l_siunitx_tight_bool + { \tl_set:Nx \l_siunitx_tmpb_tl { { \exp_not:o \l_siunitx_tmpb_tl } } } + \tl_set:Nx \l_siunitx_tmpa_tl + { + \exp_not:N \siunitx_ensuremath:n + { { } \exp_not:o \l_siunitx_tmpb_tl { } } + \exp_not:o \l_siunitx_tmpa_tl + } + } % \end{macrocode} -%\end{macro} -%\begin{macro}{\siunitx_table_print_S_get_uncert:Nn} +% If there is no mantissa, then some additional space is needed for the +% location where the product symbol would have been. % \begin{macrocode} -\cs_new_protected_nopar:Npn \siunitx_table_print_S_get_uncert:Nn #1#2 { - \prop_get:NnN #1 { #2 -uncertainty } \l_siunitx_tmpa_tl - \quark_if_no_value:NT \l_siunitx_tmpa_tl - { \tl_clear:N \l_siunitx_tmpa_tl } -} +\cs_new_protected_nopar:Npn + \siunitx_table_print_S_reserved_exponent_product_correction: + { + \group_begin: + \tl_clear:N \l_siunitx_tmpa_tl + \siunitx_table_print_S_reserved_exponent_product: + \tl_set:Nx \l_siunitx_tmpa_tl + { { } \exp_not:o \l_siunitx_tmpa_tl { } } + \siunitx_table_print_S_measure:NN \l_siunitx_tmpa_tl \l_siunitx_tmp_dim + \exp_args:NNNo \group_end: + \dim_set:Nn \l_siunitx_tmp_dim { \dim_use:N \l_siunitx_tmp_dim } + \siunitx_table_print_S_reserved_store_fill:n { \l_siunitx_tmp_dim } + \dim_sub:Nn \l_siunitx_table_exponent_dim { \l_siunitx_tmp_dim } + } % \end{macrocode} -%\end{macro} -% -%\begin{macro}{\siunitx_table_print_S_measure_comparator_integer:N} -%\begin{macro}{\siunitx_table_print_S_measure_comparator_integer_get:N} -% A special-case macro when the comparator is also needed in -% measuring up the integer part of the mantissa. +% There are two cases for adding the exponent to the result box, one +% with additional space to maintain alignment, and one with no space. +% The space needed after the exponent then can be set to either include +% or exclude the mid fill space. Doing that here avoids one extra assignment +% (to clear the mid fill in the aligned case). % \begin{macrocode} -\cs_new_protected_nopar:Npn - \siunitx_table_print_S_measure_comparator_integer:N #1 +\cs_new_protected_nopar:Npn \siunitx_table_print_S_reserved_exponent_aligned: { - \siunitx_table_print_S_measure_comparator_integer_get:N #1 - \tl_if_empty:NTF \l_siunitx_tmpa_tl - { \dim_set:Nn \l_siunitx_table_integer_dim { \c_zero_skip } } + \hbox_set:Nn \l_siunitx_table_result_box { - \hbox_set:Nn \l_siunitx_tmp_box - { \siunitx_print:nV { number } \l_siunitx_tmpa_tl } - \dim_set:Nn \l_siunitx_table_integer_dim - { \box_wd:N \l_siunitx_tmp_box } + \hbox_unpack:N \l_siunitx_table_result_box + \hbox_to_wd:nn { \l_siunitx_table_fill_mid_dim } { \tex_hfil:D } + \hbox_unpack:N \l_siunitx_tmp_box + } + \dim_set:Nn \l_siunitx_table_fill_post_dim + { + \l_siunitx_table_exponent_dim + - \box_wd:N \l_siunitx_tmp_box } } \cs_new_protected_nopar:Npn - \siunitx_table_print_S_measure_comparator_integer_get:N #1 + \siunitx_table_print_S_reserved_exponent_not_aligned: { - \prop_get:NnN #1 { comparator } \l_siunitx_tmpa_tl - \quark_if_no_value:NT \l_siunitx_tmpa_tl - { \tl_clear:N \l_siunitx_tmpa_tl } - \prop_get:NnN #1 { mantissa-sign } \l_siunitx_tmpb_tl - \quark_if_no_value:NF \l_siunitx_tmpb_tl - { \tl_put_right:NV \l_siunitx_tmpa_tl \l_siunitx_tmpb_tl } - \prop_get:NnN #1 { mantissa-integer } \l_siunitx_tmpb_tl - \quark_if_no_value:NT \l_siunitx_tmpb_tl - { \tl_clear:N \l_siunitx_tmpb_tl } - \tl_put_right:NV \l_siunitx_tmpa_tl \l_siunitx_tmpb_tl + \hbox_set:Nn \l_siunitx_table_result_box + { + \hbox_unpack:N \l_siunitx_table_result_box + \hbox_unpack:N \l_siunitx_tmp_box + } + \dim_set:Nn \l_siunitx_table_fill_post_dim + { + \l_siunitx_table_fill_mid_dim + + \l_siunitx_table_exponent_dim + - \box_wd:N \l_siunitx_tmp_box + } } % \end{macrocode} -%\end{macro} -%\end{macro} +% \end{macro} +% \end{macro} % -%\subsection{Direct printing in \texttt{S} columns} +% \subsection{Direct printing in \texttt{S} columns} % % When number parsing is turned off the usual approach to printing % tabular material is not suitable. Instead, the strategy used by % \pkg{dcolumn} can be applied, which requires the decimal marker to % be made active in math mode. % -%\begin{macro}{\siunitx_table_direct:} -% The main part of the system simply makes a choice about the -% methods to use. -% \begin{macrocode} -\cs_new_protected_nopar:Npn \siunitx_table_direct: { - \m@th - \bool_if:NTF \l_siunitx_table_center_decimal_bool - { \siunitx_table_direct_centered: } - { \siunitx_table_direct_reserved: } -} -% \end{macrocode} -%\end{macro} -% -%\begin{macro}{\siunitx_table_direct_centered:} -%\begin{macro}[aux]{\siunitx_table_direct_centered_aux:N} -%\begin{macro}{\siunitx_table_direct_centered_end:} -% When centring the content about a decimal marker, the trick is -% to collect everything into two boxes and then compare the sizes. -% In that sense this is very similar to the normal method, except that -% it will work with non-numerical input. -% \begin{macrocode} -\char_make_active:N \@ -\cs_new_protected_nopar:Npn \siunitx_table_direct_centered: { - \cs_set_eq:NN \siunitx_table_print: - \siunitx_table_direct_centered_end: - \hbox_set:Nn \l_siunitx_tmp_box - { \siunitx_ensuremath:n { \l_siunitx_output_decimal_tl } } - \hbox_set_to_wd:Nnn \l_siunitx_table_post_box - { \box_wd:N \l_siunitx_tmp_box } - { \tex_hfil:D } - \hbox_set:Nn \l_siunitx_table_pre_box - \c_group_begin_token - \c_math_shift_token - \tl_map_function:NN \l_siunitx_input_decimal_tl - \siunitx_table_direct_centered_aux:N -} -\cs_new_protected_nopar:Npn \siunitx_table_direct_centered_aux:N #1 { - \char_set_lccode:nn { `\@ } { `#1 } - \char_set_mathcode:nn { `#1 } { 32768 } - \tl_to_lowercase:n { \cs_set_nopar:Npn @ } - { +% \begin{macro}{\siunitx_table_print_S_direct:} +% The main part of the system simply does the appropriate math work +% then calls the main function, which will be assigned by the +% key--value system. +% \begin{macrocode} +\cs_new_protected_nopar:Npn \siunitx_table_print_S_direct: + { + \m@th + \siunitx_table_print_S_direct_main: + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro} +% { +% \siunitx_table_print_S_direct_centered: , +% \siunitx_table_print_S_direct_centered_end: +% } +% \begin{macro}[aux]{\siunitx_table_print_S_direct_centered_aux:N} +% When centring the content about a decimal marker, the trick is +% to collect everything into two boxes and then compare the sizes. +% In that sense this is very similar to the normal method, except that +% it will work with non-numerical input. +% \begin{macrocode} +\char_set_catcode_active:N \@ +\cs_new_protected_nopar:Npn \siunitx_table_print_S_direct_centered: + { + \cs_set_eq:NN \siunitx_table_print: + \siunitx_table_print_S_direct_centered_end: + \hbox_set:Nn \l_siunitx_tmp_box + { \siunitx_ensuremath:n { \l_siunitx_output_decimal_tl } } + \hbox_set_to_wd:Nnn \l_siunitx_table_post_box + { \box_wd:N \l_siunitx_tmp_box } + { \tex_hfil:D } + \hbox_set:Nn \l_siunitx_table_pre_box + \c_group_begin_token + \c_math_shift_token + \tl_map_function:NN \l_siunitx_input_decimal_tl + \siunitx_table_print_S_direct_centered_aux:N + } +\cs_new_protected_nopar:Npn \siunitx_table_print_S_direct_centered_aux:N #1 + { + \char_set_lccode:nn { `\@ } { `#1 } + \char_set_mathcode:nn { `#1 } { 32768 } + \tl_to_lowercase:n { \cs_set_nopar:Npn @ } + { + \c_math_shift_token + \c_group_end_token + \hbox_set:Nn \l_siunitx_table_post_box + \c_group_begin_token + \c_math_shift_token + \l_siunitx_output_decimal_tl + } + } +\char_set_catcode_letter:N \@ +\cs_new_protected_nopar:Npn \siunitx_table_print_S_direct_centered_end: + { \c_math_shift_token - \c_group_end_token - \hbox_set:Nn \l_siunitx_table_post_box - \c_group_begin_token - \c_math_shift_token - \l_siunitx_output_decimal_tl - } -} -\char_make_letter:N \@ -\cs_new_protected_nopar:Npn \siunitx_table_direct_centered_end: { - \c_math_shift_token - \c_group_end_token - \dim_compare:nNnTF - { \box_wd:N \l_siunitx_table_pre_box } > - { \box_wd:N \l_siunitx_table_post_box } - { - \hbox_set_to_wd:Nnn \l_siunitx_table_post_box - { \box_wd:N \l_siunitx_table_pre_box } - { - \hbox_unpack:N \l_siunitx_table_post_box - \tex_hfil:D - } - } - { - \hbox_set_to_wd:Nnn \l_siunitx_table_pre_box + \c_group_end_token + \dim_compare:nNnTF + { \box_wd:N \l_siunitx_table_pre_box } > { \box_wd:N \l_siunitx_table_post_box } - { - \tex_hfil:D - \hbox_unpack:N \l_siunitx_table_pre_box - } - } - \box_use:N \l_siunitx_table_pre_box - \box_use:N \l_siunitx_table_post_box -} + { + \hbox_set_to_wd:Nnn \l_siunitx_table_post_box + { \box_wd:N \l_siunitx_table_pre_box } + { + \hbox_unpack:N \l_siunitx_table_post_box + \tex_hfil:D + } + } + { + \hbox_set_to_wd:Nnn \l_siunitx_table_pre_box + { \box_wd:N \l_siunitx_table_post_box } + { + \tex_hfil:D + \hbox_unpack:N \l_siunitx_table_pre_box + } + } + \box_use:N \l_siunitx_table_pre_box + \box_use:N \l_siunitx_table_post_box + } % \end{macrocode} -%\end{macro} -%\end{macro} -%\end{macro} -% -%\begin{macro}{\siunitx_table_direct_reserved:} -%\begin{macro}[aux]{\siunitx_table_direct_reserved_aux:N} -%\begin{macro}{\siunitx_table_direct_reserved_end:} -% The plan here is to box up the entire number using the information -% available about the size of the two parts. Relatively easy, -% but needs a bit of measuring. The first box here does need to use -% \cs{tex_hill:D} as \texttt{fil} glue will not work. -% \begin{macrocode} -\char_make_active:N \@ -\cs_new_protected_nopar:Npn \siunitx_table_direct_reserved: { - \cs_set_eq:NN \siunitx_table_print: - \siunitx_table_direct_reserved_end: - \tl_set:Nx \l_siunitx_tmpa_tl - { \prg_replicate:nn { \l_siunitx_table_integer_int } { 8 } } - \hbox_set:Nn \l_siunitx_tmp_box - { - \siunitx_ensuremath:n - { - \bool_if:NT \l_siunitx_table_sign_mantissa_bool { - } - \l_siunitx_tmpa_tl - } - } - \dim_set:Nn \l_siunitx_table_integer_dim - { \box_wd:N \l_siunitx_tmp_box } - \tl_set:Nx \l_siunitx_tmpa_tl - { \prg_replicate:nn { \l_siunitx_table_decimal_int } { 8 } } - \hbox_set:Nn \l_siunitx_tmp_box - { - \siunitx_ensuremath:n - { - \l_siunitx_output_decimal_tl - \l_siunitx_tmpa_tl - } - } - \hbox_set_to_wd:Nnn \l_siunitx_table_post_box - { \box_wd:N \l_siunitx_tmp_box } - { \tex_hfil:D } - \hbox_set_to_wd:Nnn \l_siunitx_table_pre_box - { \l_siunitx_table_integer_dim } - \c_group_begin_token - \c_math_shift_token - \tl_map_function:NN \l_siunitx_input_decimal_tl - \siunitx_table_direct_reserved_aux:N - \tex_hfill:D -} -\cs_new_protected_nopar:Npn \siunitx_table_direct_reserved_aux:N #1 { - \char_set_lccode:nn { `\@ } { `#1 } - \char_set_mathcode:nn { `#1 } { 32768 } - \tl_to_lowercase:n { \cs_set_nopar:Npn @ } - { +% \end{macro} +% \end{macro} +% +% \begin{macro} +% { +% \siunitx_table_print_S_direct_reserved: , +% \siunitx_table_print_S_direct_reserved_end: +% } +% \begin{macro}[aux]{\siunitx_table_print_S_direct_reserved_aux:N} +% The plan here is to box up the entire number using the information +% available about the size of the two parts. Relatively easy, +% but needs a bit of measuring. The first box here does need to use +% \cs{tex_hill:D} as \texttt{fil} glue will not work. +% \begin{macrocode} +\char_set_catcode_active:N \@ +\cs_new_protected_nopar:Npn \siunitx_table_print_S_direct_reserved: + { + \cs_set_eq:NN \siunitx_table_print: + \siunitx_table_print_S_direct_reserved_end: + \prop_get:NnNF \l_siunitx_table_model_prop { mantissa-integer } + \l_siunitx_tmpa_tl + { \tl_clear:N \l_siunitx_tmpa_tl } + \hbox_set:Nn \l_siunitx_tmp_box + { + \siunitx_ensuremath:n + { + \prop_get:NnNT \l_siunitx_table_model_prop { mantissa-sign } + \l_siunitx_tmpb_tl + { \l_siunitx_tmpb_tl } + \l_siunitx_tmpa_tl + } + } + \dim_set:Nn \l_siunitx_table_integer_dim + { \box_wd:N \l_siunitx_tmp_box } + \prop_get:NnNF \l_siunitx_table_model_prop { mantissa-decimal } + \l_siunitx_tmpa_tl + { \tl_clear:N \l_siunitx_tmpa_tl } + \hbox_set:Nn \l_siunitx_tmp_box + { + \siunitx_ensuremath:n + { + \l_siunitx_output_decimal_tl + \l_siunitx_tmpa_tl + } + } + \hbox_set_to_wd:Nnn \l_siunitx_table_post_box + { \box_wd:N \l_siunitx_tmp_box } + { \tex_hfil:D } + \hbox_set_to_wd:Nnn \l_siunitx_table_pre_box + { \l_siunitx_table_integer_dim } + \c_group_begin_token \c_math_shift_token - \c_group_end_token - \hbox_set_to_wd:Nnn \l_siunitx_table_post_box - { \box_wd:N \l_siunitx_tmp_box } - \c_group_begin_token + \tl_map_function:NN \l_siunitx_input_decimal_tl + \siunitx_table_print_S_direct_reserved_aux:N + \tex_hfill:D + } +\cs_new_protected_nopar:Npn \siunitx_table_print_S_direct_reserved_aux:N #1 + { + \char_set_lccode:nn { `\@ } { `#1 } + \char_set_mathcode:nn { `#1 } { 32768 } + \tl_to_lowercase:n { \cs_set_nopar:Npn @ } + { \c_math_shift_token - \l_siunitx_output_decimal_tl - } -} -\char_make_letter:N \@ -\cs_new_protected_nopar:Npn \siunitx_table_direct_reserved_end: { - \c_math_shift_token - \tex_hfil:D - \c_group_end_token - \siunitx_table_align_left:n { \l_siunitx_table_number_align_skip } - \box_use:N \l_siunitx_table_pre_box - \box_use:N \l_siunitx_table_post_box - \siunitx_table_align_right:n { \l_siunitx_table_number_align_skip } -} + \c_group_end_token + \hbox_set_to_wd:Nnn \l_siunitx_table_post_box + { \box_wd:N \l_siunitx_tmp_box } + \c_group_begin_token + \c_math_shift_token + \l_siunitx_output_decimal_tl + } + } +\char_set_catcode_letter:N \@ +\cs_new_protected_nopar:Npn \siunitx_table_print_S_direct_reserved_end: + { + \c_math_shift_token + \tex_hfil:D + \c_group_end_token + \siunitx_table_align_left:n { \l_siunitx_table_number_align_skip } + \box_use:N \l_siunitx_table_pre_box + \box_use:N \l_siunitx_table_post_box + \siunitx_table_align_right:n { \l_siunitx_table_number_align_skip } + } +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \subsection{Table settings} +% +% To allow for the construction above, the table settings are given here. +% +% \begin{macrocode} +\keys_set:nn { siunitx } + { + table-align-comparator = true, + table-align-exponent = true, + table-align-text-pre = true, + table-align-text-post = true, + table-align-uncertainty = true, + table-omit-exponent = false, + table-parse-only = false, + table-number-alignment = center-decimal-marker, + table-text-alignment = center, + table-figures-decimal = 2, + table-figures-integer = 3 + } % \end{macrocode} -%\end{macro} -%\end{macro} -%\end{macro} % %\subsection{Symbols} % @@ -14589,15 +14854,8 @@ This work consists of the file siunitx.dtx set~thousands~separator = { \exp_not:V \l_siunitx_group_sep_tl } } - \bool_if:NTF \l_siunitx_group_four_bool - { - \clist_put_right:Nn \l_siunitx_pgf_link_clist - { min~exponent~for~1000~sep = 3 } - } - { - \clist_put_right:Nn \l_siunitx_pgf_link_clist - { min~exponent~for~1000~sep = 4 } - } + \clist_put_right:Nn \l_siunitx_pgf_link_clist + { min~exponent~for~1000~sep = \int_use:N \l_siunitx_group_min_int } \bool_if:nF { \l_siunitx_group_decimal_bool || @@ -14644,154 +14902,148 @@ This work consists of the file siunitx.dtx % Lots of messages, all of them together in one block to make life % easier. % \begin{macrocode} -\msg_set:nnnn { siunitx } { bad-arc-sign } +\msg_new:nnnn { siunitx } { bad-arc-sign } { Incorrect~use~of~sign~in~degree-minute-second~angle. } { Only~the~highest~value~part~of~an~angle~can~have~a~sign. } -\msg_set:nnnn { siunitx } { duplicate-complex-root-token } +\msg_new:nnnn { siunitx } { duplicate-complex-root-token } { Duplicate~complex~root~token~'#1'~in~input. } { Only~one~complex~root~token~can~appear~in~a~single~number. } -\msg_set:nnnn { siunitx } { duplicate-decimal-token } +\msg_new:nnnn { siunitx } { duplicate-decimal-token } { Duplicate~decimal~marker~token~'#1'~in~input. } { Only~one~decimal~marker~token~can~appear~in~a~single~number. } -\msg_set:nnnn { siunitx } { duplicate-exponent-token } +\msg_new:nnnn { siunitx } { duplicate-exponent-token } { Duplicate~exponent~marker~token~'#1'~in~input. } { Only~one~exponent~marker~token~can~appear~in~a~single~number. } -\msg_set:nnnn { siunitx } { duplicate-quotient-token } +\msg_new:nnnn { siunitx } { duplicate-quotient-token } { Duplicate~quotient~token. } { Only~one~quotient~token~can~appear~in~a~single~number. } -\msg_set:nnnn { siunitx } { duplicate-sticky-per } +\msg_new:nnnn { siunitx } { duplicate-sticky-per } { Duplicate~\token_to_str:N \per. } { When~the~'sticky-per'~option~is~active,~only~one - \token_to_str:N \per \\ - may~appear~in~a~unit. + \token_to_str:N \per may~appear~in~a~unit. } -\msg_set:nnnn { siunitx } { empty-arc } +\msg_new:nnnn { siunitx } { empty-arc } { Empty~degree-minute-second~angle. } { The~angle~given~does~not~contain~any~numbers. } -\msg_set:nnnn { siunitx } { empty-uncertainty } +\msg_new:nnnn { siunitx } { empty-uncertainty } { Empty~uncertainty~given~in~'#1'. } { The~number~given~contains~an~empty~uncertainty. } -\msg_set:nnnn { siunitx } { ending-product-token } +\msg_new:nnnn { siunitx } { ending-product-token } { Misplaced~product~token. } { A~number~cannot~end~with~a~product~token. } -\msg_set:nnnn { siunitx } { ending-quotient-token } +\msg_new:nnnn { siunitx } { ending-quotient-token } { Misplaced~quotient~token. } { A~number~cannot~end~with~a~quotient~token. } -\msg_set:nnnn { siunitx } { invalid-arc-format } +\msg_new:nnnn { siunitx } { invalid-arc-format } { Invalid~degree-minute-second angle~'#1'. } { - Angles~given~in~degree-minute-second~format~should~contain~two~';'\\ - symbols~to~divide~up~the~parts~of~the~input.\\ + Angles~given~in~degree-minute-second~format~should~contain~two~';' + symbols~to~divide~up~the~parts~of~the~input. } -\msg_set:nnnn { siunitx } { invalid-number } +\msg_new:nnnn { siunitx } { invalid-number } { Invalid~numerical~input~'#1'. } { - The~input given~as~a~number~does~not~make~logical~sense.\\ + The~input given~as~a~number~does~not~make~logical~sense.~ This~happens,~for example,~if~a~number~only~contains~a~sign. } -\msg_set:nnnn { siunitx } { invalid-token-in-exponent } +\msg_new:nnnn { siunitx } { invalid-token-in-exponent } { Invalid~exponent~in~numerical~input~'#1'. } { - The~exponent`part~of~a~number~cannot~contain~an~uncertainty~or~ - complex~part.\\ - The~input~given~appears~to~contain~one~of~these~in~the~exponent. + The~exponent~part~of~a~number~cannot~contain~an~uncertainty~or~ + complex~part: \\ + the~input~given~appears~to~contain~one~of~these~in~the~exponent. } -\msg_set:nnnn { siunitx } { invalid-token-in-number } +\msg_new:nnnn { siunitx } { invalid-token-in-number } { Invalid~token~'#1'~in~numerical~input. } { Numbers~can~only~contain~tokens~defined~using~the~ 'input-...'~options:\\ the~token~'#1'~is~not~set~up~as~a~valid~part~of~a~number. } -\msg_set:nnnn { siunitx } { invalid-token-in-uncertainty } +\msg_new:nnnn { siunitx } { invalid-token-in-uncertainty } { Invalid~uncertainty~in~numerical~input~'#1'. } { The~uncertainty~part~of~a~number~may~only~contain~digits~or~ symbols. } -\msg_set:nnnn { siunitx } { literal-unit } +\msg_new:nnnn { siunitx } { literal-unit } { Literal~units~disabled. } { - You~gave~the~literal~input~'#1'\\ + You~gave~the~literal~input~'#1'~ but~literal~unit~output~is~disabled. } -\msg_set:nnnn { siunitx } { misplaced-sign-token } +\msg_new:nnnn { siunitx } { misplaced-sign-token } { Misplaced~sign~token~'#1'. } { Sign~tokens~can~only~come~at~the~beginning~of~a~number. } -\msg_set:nnnn { siunitx } { misplaced-complex-root-token } +\msg_new:nnnn { siunitx } { misplaced-complex-root-token } { Misplaced~complex~token~in~numerical~input~'#1'. } { - The~root~token~must~come~either~before~or~after~the~real~digits\\ + The~root~token~must~come~either~before~or~after~the~real~digits~ of~the~complex~part. } -\msg_set:nnnn { siunitx } { misplaced-uncertainty-token } +\msg_new:nnnn { siunitx } { misplaced-uncertainty-token } { Misplaced~uncertainty~token~'#1'. } { The~uncertainty~in~a~number~must~be~given~between~a~set~of~ delimiters~as~defined~by~the\\ - \c_space_tl \c_space_tl - 'input-open-uncertainty'~and~'input-close-uncertainty'\\ + \ \ 'input-open-uncertainty'~and~'input-close-uncertainty'~ options. } -\msg_set:nnnn { siunitx } { multi-part-range } +\msg_new:nnnn { siunitx } { multi-part-range } { Numerical~range~with~multiple~parts. } { - The~input~'#1'~is~a~number~which~has~more~than~one~part.\\ - Ranges~can~only~contain~one~number~in~each~part. + The~input~'#1'~is~a~number~which~has~more~than~one~part: \\ + ranges~can~only~contain~one~number~in~each~part. } -\msg_set:nnn { siunitx } { option-not-available } +\msg_new:nnn { siunitx } { option-not-available } { Option~'#1'~not~available~in~strict~mode. } -\msg_set:nnn { siunitx } { option-preamble-only } +\msg_new:nnn { siunitx } { option-preamble-only } { Option~'#1'~only~available~in~the~preamble. } -\msg_set:nnnn { siunitx } { prefix-base-mismatch } +\msg_new:nnnn { siunitx } { prefix-base-mismatch } { Prefix~bases~do~not~match. } { - You~have~asked~for~prefixes~to~be~converted~into~a~power,\\ + You~have~asked~for~prefixes~to~be~converted~into~a~power,~ but~the~bases~do~not~match. } -\msg_set:nnn { siunitx } { prefix-only } +\msg_new:nnn { siunitx } { prefix-only } { Prefix~with~no~unit. } -\msg_set:nnnn { siunitx } { qualifier-before-unit } +\msg_new:nnnn { siunitx } { qualifier-before-unit } { Qualifier~before~unit. } { Unit~qualifiers~have~to~follow~after~units,~not~before~them. } -\msg_set:nnnn { siunitx } { restricted-number } +\msg_new:nnnn { siunitx } { restricted-number } { Token~'#1'~forbidden~in~restricted~numerical~input. } { The~current~input~must~be~a~real~number~and~cannot~contain: \\ - \c_space_tl -~an~exponent; \\ - \c_space_tl -~an~uncertainty; \\ - \c_space_tl -~a~complex~part. + \ -~an~exponent; \\ + \ -~an~uncertainty; \\ + \ -~a~complex~part. } -\msg_set:nnnn { siunitx } { starting-product-token } +\msg_new:nnnn { siunitx } { starting-product-token } { Misplaced~product~token. } { A~number~cannot~begin~with~a~product~token. } -\msg_set:nnnn { siunitx } { starting-quotient-token } +\msg_new:nnnn { siunitx } { starting-quotient-token } { Misplaced~quotient~token. } { A~number~cannot~begin~with~a~quotient~token. } -\msg_set:nnnn { siunitx } { table-partial-number } +\msg_new:nnnn { siunitx } { table-partial-number } { No~space~reserved~for~#1~\msg_line_context:. } { - The~number~in~the~current~table~cell~contains~#1~part, \\ + The~number~in~the~current~table~cell~contains~#1~part, but~you~did~not~reserve~any~space~to~print~it: \\ it~will~be~missing~in~the~output. } -\msg_set:nnnn { siunitx } { unknown-configuration-file } - { Unknown~configuration~'#1'. } - { The~configuration~file~'siunitx-#1.cfg'~was~not~found. } -\msg_set:nnnn { siunitx } { unknown-option } +\msg_new:nnnn { siunitx } { unknown-option } { Unknown~option~'#1'. } { - The~option~file~'#1'~is~not~known~by~siunitx: \\ + The~option~file~'#1'~is~not~known~by~siunitx: perhaps~it~is~spelled~incorrectly. } -\msg_set:nnnn { siunitx } { version-1-option } +\msg_new:nnnn { siunitx } { version-1-option } { Version~1~option~'#1'~detected. } { Use: \\ - \c_space_tl \c_space_tl - \token_to_str:N \usepackage[load-configurations = version-1] - \token_to_str:N { siunitx \token_to_str:N } \\ + \ \ \token_to_str:N \usepackage [ version-1-compatibility ] + \iow_char:N \{ siunitx \token_to_str:N \iow_char:N \} \\ in~the~preamble~to~load~the~appropriate~code. } % \end{macrocode} @@ -14917,7 +15169,7 @@ This work consists of the file siunitx.dtx % %\begin{macro}{ % \SIlist , -% \SIrange , +% \SIrange %} % Lists and range of values are handled in a very similar way. % Everything is kept relatively simple, and so there is not too much @@ -14989,7 +15241,7 @@ This work consists of the file siunitx.dtx \bool_set_false:N \l_siunitx_table_collect_pre_bool \siunitx_table_print_S: } - { \siunitx_table_direct: #2 \siunitx_table_print: } + { \siunitx_table_print_S_direct: #2 \siunitx_table_print: } } % \end{macrocode} %\end{macro} @@ -15020,73 +15272,75 @@ This work consists of the file siunitx.dtx % \pkg{hyperref}, and ensure that everything works cleanly and with % no unnecessary warnings. % -%\begin{macro}{\siunitx_contents_add:N} -% An updated version of \cs{addtocontents} which will ensure that -% everything works properly. Using \cs{token_to_str:N} means that -% there is no problem with the asynchronous nature of \TeX's writing -% mechanism. +% \begin{macro}{\siunitx_contents_add:N} +% An updated version of \cs{addtocontents} which will ensure that +% everything works properly. Using \cs{token_to_str:N} means that +% there is no problem with the asynchronous nature of \TeX{}'s writing +% mechanism. % \begin{macrocode} -\AtBeginDocument { - \cs_set:Npn \addtocontents #1#2 - { - \protected@write \@auxout - { - \cs_set_eq:NN \label \use_none:n - \cs_set_eq:NN \index \use_none:n - \cs_set_eq:NN \glossary\use_none:n - \tl_map_function:NN \l_siunitx_declare_list_tl - \siunitx_contents_add:N - } - { \token_to_str:N \@writefile {#1} {#2} } - } -} -\cs_new_protected_nopar:Npn \siunitx_contents_add:N #1 { - \cs_set_nopar:Npn #1 { \token_to_str:N #1 } -} +\AtBeginDocument + { + \cs_set:Npn \addtocontents #1#2 + { + \protected@write \@auxout + { + \cs_set_eq:NN \label \use_none:n + \cs_set_eq:NN \index \use_none:n + \cs_set_eq:NN \glossary \use_none:n + \tl_map_function:NN \l_siunitx_declare_list_tl + \siunitx_contents_add:N + } + { \token_to_str:N \@writefile {#1} {#2} } + } + } +\cs_new_protected_nopar:Npn \siunitx_contents_add:N #1 + { \cs_set_nopar:Npn #1 { \token_to_str:N #1 } } % \end{macrocode} -%\end{macro} +% \end{macro} % -%\begin{macro}{\siunitx_contents_bookmarks:} -% The idea here is two-fold. First, all of the unit macros are set -% up to simply print their literal interpretation: this is hopefully -% good enough for most bookmark situations. Secondly, the document -% commands are made expandable. This allows a bit of re-arrangement -% of the input, removes any set up options (which are being ignored) -% and stops \pkg{hyperref} issuing a warning. +% \begin{macro}{\siunitx_contents_bookmarks:} +% The idea here is two-fold. First, all of the unit macros are set +% up to simply print their literal interpretation: this is hopefully +% good enough for most bookmark situations. Secondly, the document +% commands are made expandable. This allows a bit of re-arrangement +% of the input, removes any set up options (which are being ignored) +% and stops \pkg{hyperref} issuing a warning. % \begin{macrocode} -\cs_new_protected_nopar:Npn \siunitx_contents_bookmarks: { - \tl_map_function:NN \l_siunitx_declare_list_tl - \siunitx_unit_print_literal_aux:N - \msg_redirect_name:nnn { LaTeX / xparse } { redefine-command } - { none } - \cs_set_eq:NN \num \siunitx_bookmark_num:w - \cs_set_eq:NN \numrange \siunitx_bookmark_numrange:w - \cs_set_eq:NN \si \siunitx_bookmark_si:w - \cs_set_eq:NN \SI \siunitx_bookmark_SI:w - \cs_set_eq:NN \SIrange \siunitx_bookmark_SIrange:w - \cs_set_eq:NN \si \siunitx_bookmark_si:w - \cs_set_nopar:Npn \SIUnitSymbolAngstrom { \AA } - \cs_set_nopar:Npn \SIUnitSymbolArcminute { ' } - \cs_set_nopar:Npn \SIUnitSymbolArcsecond { '' } - \cs_set_nopar:Npn \SIUnitSymbolCelsius { \textcelsius } - \cs_set_nopar:Npn \SIUnitSymbolDegree { \textdegree } - \cs_set_nopar:Npn \SIUnitSymbolMicro { \textmu } - \cs_set_nopar:Npn \SIUnitSymbolOhm { [ohm] } -} +\cs_new_protected_nopar:Npn \siunitx_contents_bookmarks: + { + \tl_map_function:NN \l_siunitx_declare_list_tl + \siunitx_unit_print_literal_aux:N + \msg_redirect_name:nnn { xparse } { redefine-command } { none } + \cs_set_eq:NN \num \siunitx_bookmark_num:w + \cs_set_eq:NN \numrange \siunitx_bookmark_numrange:w + \cs_set_eq:NN \si \siunitx_bookmark_si:w + \cs_set_eq:NN \SI \siunitx_bookmark_SI:w + \cs_set_eq:NN \SIrange \siunitx_bookmark_SIrange:w + \cs_set_eq:NN \si \siunitx_bookmark_si:w + \cs_set_eq:NN \siunitx_textsuperscript:n \use:n + \cs_set_nopar:Npn \SIUnitSymbolAngstrom { \AA } + \cs_set_nopar:Npn \SIUnitSymbolArcminute { ' } + \cs_set_nopar:Npn \SIUnitSymbolArcsecond { '' } + \cs_set_nopar:Npn \SIUnitSymbolCelsius { \textcelsius } + \cs_set_nopar:Npn \SIUnitSymbolDegree { \textdegree } + \cs_set_nopar:Npn \SIUnitSymbolMicro { \textmu } + \cs_set_nopar:Npn \SIUnitSymbolOhm { [ohm] } + } % \end{macrocode} -%\end{macro} -% -%\begin{macro}{ -% \siunitx_bookmark_num:w , -% \siunitx_bookmark_numrange:w , -% \siunitx_bookmark_SIlist:w , -% \siunitx_bookmark_SIrange:w , -% \siunitx_bookmark_SI:w , -% \siunitx_bookmark_si:w , -%} -% To keep things fast, expandable versions of the document commands -% are created only once. These are then used if necessary to remove -% and re-order arguments in an expandable fashion. +% \end{macro} +% +% \begin{macro} +% { +% \siunitx_bookmark_num:w , +% \siunitx_bookmark_numrange:w , +% \siunitx_bookmark_SIlist:w , +% \siunitx_bookmark_SIrange:w , +% \siunitx_bookmark_SI:w , +% \siunitx_bookmark_si:w +% } +% To keep things fast, expandable versions of the document commands +% are created only once. These are then used if necessary to remove +% and re-order arguments in an expandable fashion. % \begin{macrocode} \DeclareExpandableDocumentCommand \siunitx_bookmark_num:w { o m } {#2} \DeclareExpandableDocumentCommand \siunitx_bookmark_numrange:w { o m m } @@ -15099,7 +15353,7 @@ This work consists of the file siunitx.dtx { o m m m } { #2 ~ #4 \l_siunitx_range_phrase_tl #3 ~ #4 } \DeclareExpandableDocumentCommand \siunitx_bookmark_si:w { o m } {#2} % \end{macrocode} -%\end{macro} +% \end{macro} % %\begin{macro}{\siunitx_bookmark_SIlist_map:nn} %\begin{macro}[aux]{\siunitx_bookmark_SIlist_map_aux:nw} @@ -15381,7 +15635,7 @@ This work consists of the file siunitx.dtx % \begin{macrocode} \group_begin: \char_set_lccode:nn { `\@ } { `\_ } - \char_make_math_subscript:N \@ + \char_set_catcode_math_subscript:N \@ \tl_to_lowercase:n { \group_end: \DeclareSIUnit \clight { \text { \ensuremath { c @ { 0 } } } } @@ -15402,7 +15656,7 @@ This work consists of the file siunitx.dtx \group_begin: \char_set_lccode:nn { `\@ } { `\_ } \char_set_lccode:nn { `\E } { `\E } - \char_make_math_subscript:N \@ + \char_set_catcode_math_subscript:N \@ \tl_to_lowercase:n { \group_end: \DeclareSIUnit \bohr { \text { \ensuremath { a @ { 0 } } } } @@ -15474,6 +15728,7 @@ This work consists of the file siunitx.dtx \keys_set:nn { siunitx } { bracket-numbers = true, + detect-family = false, detect-mode = false, detect-shape = false, detect-weight = false, @@ -15485,6 +15740,7 @@ This work consists of the file siunitx.dtx \siunitx_strict_option:n { bracket-numbers , + detect-family , detect-italic , detect-mode , detect-shape , @@ -15584,51 +15840,90 @@ This work consists of the file siunitx.dtx } % \end{macrocode} % -%\subsection{Loading additional configurations} +% \subsection{Loading additional configurations} % -% There is only only option for loading files: keeps things simple. +% \begin{variable}{\c_siunitx_configuration_ext_tl} +% Logical mark-up for the file extension. % \begin{macrocode} -\keys_define:nn { siunitx } { - load-configurations .code:n = - { \siunitx_load_configuration:n {#1} } -} +\tl_const:Nn \c_siunitx_configuration_ext_tl { cfg } % \end{macrocode} +% \end{variable} % -%\begin{macro}{\siunitx_load_configuration:n} -%\begin{macro}[aux]{\siunitx_load_configuration_aux:n} -%\begin{macro}{\c_siunitx_configuration_ext_tl} -% Loading configuration files is made slightly complex by the need -% to remove spaces in the file names (none of the files contain any at -% all, so this is easy). Secondly, the \LaTeXe{} \cs{@onefilewithoptions} -% function is used for file loading, as \LaTeX3 currently needs the -% \LaTeXe{} category code stack to keep things sane. +% \begin{macro}{\siunitx_load_abbreviations:} +% \begin{macro}{\siunitx_load_binary:} +% Loading abbreviations is on by default, which therefore requires a bit +% of juggling. The idea here is that the abbreviations will be loaded unless +% specifically turned off. This can occur anywhere in the preamble. % \begin{macrocode} -\cs_new_protected:Npn \siunitx_load_configuration:n #1 { - \tl_set_rescan:Nnn \l_siunitx_tmpa_tl - { \char_make_ignore:N \ } {#1} - \clist_map_function:NN \l_siunitx_tmpa_tl - \siunitx_load_configuration_aux:n -} -\cs_new_protected:Npn \siunitx_load_configuration_aux:n #1 { - \tl_if_empty:nF {#1} - { - \file_if_exist:nTF - { siunitx- #1 . \c_siunitx_configuration_ext_tl } +\keys_define:nn { siunitx } + { + abbreviations .choice:, + abbreviations / + true .code:n = { \siunitx_load_abbreviations: }, + abbreviations / + false .code:n = + { \cs_set_eq:NN \siunitx_load_abbreviations: \prg_do_nothing: } , + abbreviations .default:n = true , + binary-units .choice:, + binary-units / + true .code:n = { \siunitx_load_binary: }, + binary-units / + false .code:n = { } , + binary-units .default:n = true + } +\cs_new_protected_nopar:Npn \siunitx_load_abbreviations: + { + \@onefilewithoptions { siunitx-abbreviations } [ ] [ ] + \c_siunitx_configuration_ext_tl + } +\cs_new_protected_nopar:Npn \siunitx_load_binary: + { + \@onefilewithoptions { siunitx-binary } [ ] [ ] + \c_siunitx_configuration_ext_tl + } +\AtBeginDocument + { + \siunitx_load_abbreviations: + \siunitx_load_binary: + } +\siunitx_option_deactivate:n { abbreviations , binary } +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% The version 1 options are not loaded as standard. +% \begin{macrocode} +\keys_define:nn { siunitx } + { + version-1-compatibility .choice: , + version-1-compatibility / + true .code:n = { - \@onefilewithoptions { siunitx- #1 } [ ] [ ] - \c_siunitx_configuration_ext_tl - } + \@onefilewithoptions { siunitx-version-1 } [ ] [ ] + \c_siunitx_configuration_ext_tl + }, + version-1-compatibility / + false .code:n = { } , + version-1-compatibility .default:n = true + } +\siunitx_option_deactivate:n { version-1-compatibility } +% \end{macrocode} +% +% Dealing with the old \opt{load-configurations} option is pretty easy, as +% only one choice is important. +% \begin{macrocode} +\keys_define:nn { siunitx } { + load-configurations .code:n = + { + \clist_if_in:nnT {#1} { version-1 } { - \msg_error:nnx { siunitx } { unknown-configuration-file } {#1} + \@onefilewithoptions { siunitx-version-1 } [ ] [ ] + \c_siunitx_configuration_ext_tl } } } -\tl_new:N \c_siunitx_configuration_ext_tl -\tl_set:Nn \c_siunitx_configuration_ext_tl { cfg } +\siunitx_option_deactivate:n { load-configurations } % \end{macrocode} -%\end{macro} -%\end{macro} -%\end{macro} % % Load any local configuration file. % \begin{macrocode} @@ -15651,18 +15946,12 @@ This work consists of the file siunitx.dtx %\subsection{Support for version one} % % \begin{macrocode} -%<*version-1> -% \end{macrocode} -% -% \begin{macrocode} -\ProvidesExplFile {siunitx-version-1.cfg} {2011/06/15} {2.2i} - {siunitx: Version 1 settings} +%<*version-1> % \end{macrocode} % -% The abbreviations are loaded by default by version one. % \begin{macrocode} -\keys_set:nn { siunitx } - { load-configurations = { abbreviations , binary } } +\ProvidesExplFile {siunitx-version-1.cfg} {2011/07/09} {2.3a} + {siunitx: Version 1 settings} % \end{macrocode} % % The re-arrangements made to the code in version two, and in particular @@ -16296,7 +16585,7 @@ This work consists of the file siunitx.dtx %\begin{macro}{ % \newunit , % \renewunit , -% \provideunit , +% \provideunit %} % The functions for creating units from version one are easy to create. % \begin{macrocode} @@ -16309,7 +16598,7 @@ This work consists of the file siunitx.dtx %\begin{macro}{ % \newpower , % \renewpower , -% \providepower , +% \providepower %} % Slightly more complex: an optional argument to check. A simple % assumption is made that it will be \texttt{post}: anything else @@ -16336,7 +16625,7 @@ This work consists of the file siunitx.dtx %\begin{macro}{ % \newprefix , % \renewprefix , -% \provideprefix , +% \provideprefix %} % Slightly more complex: an optional argument to check. A simple % assumption is made that it will be \texttt{post}: anything else @@ -16363,7 +16652,7 @@ This work consists of the file siunitx.dtx %\begin{macro}{ % \newqualifier , % \renewqualifier , -% \providequalifier , +% \providequalifier %} % The functions for creating qualifiers are easy to create again. % \begin{macrocode} @@ -16377,7 +16666,7 @@ This work consists of the file siunitx.dtx % %\begin{macro}{ % \Square , -% \ssquare , +% \ssquare %} % In version 1, \cs{square} is not used with these two alternatives % preferred. @@ -16393,7 +16682,7 @@ This work consists of the file siunitx.dtx % \Day , % \dday , % \Gray , -% \ggray , +% \ggray %} % Units which are given awkward names in version one. % \begin{macrocode} @@ -16409,7 +16698,7 @@ This work consists of the file siunitx.dtx %\begin{macro}{ % \atomicmass , % \arcmin , -% \arcsec , +% \arcsec %} % Slightly different: given more complete names in version two. % \begin{macrocode} @@ -16426,7 +16715,7 @@ This work consists of the file siunitx.dtx % \millibar , % \rad , % \rem , -% \roentgen , +% \roentgen %} % Units which were defined in version one but are no longer listed % by the \textsc{bipm} as acceptable. @@ -16454,7 +16743,7 @@ This work consists of the file siunitx.dtx % \mics , % \cmc , % \dmc , -% \cms , +% \cms %} % A few abbreviations which have been renamed. % \begin{macrocode} @@ -16481,7 +16770,7 @@ This work consists of the file siunitx.dtx % \cubicdecimetre , % \squarecentimetre , % \squaremetre , -% \squarekilometre , +% \squarekilometre %} % Units from version one that did not seem like a good idea to retain. % \begin{macrocode} @@ -16497,7 +16786,7 @@ This work consists of the file siunitx.dtx % %\begin{macro}{ % \parsec , -% \lightyear , +% \lightyear %} % A few units for astronomy that version 1 provided. % \begin{macrocode} @@ -16509,7 +16798,7 @@ This work consists of the file siunitx.dtx %\begin{macro}{ % \gmol , % \kgmol , -% \lbmol , +% \lbmol %} % Slightly odd chemical engineering units, again provided in version 1. % \begin{macrocode} @@ -16522,7 +16811,7 @@ This work consists of the file siunitx.dtx %\begin{macro}{ % \molar , % \Molar , -% \torr , +% \torr %} % A few common units for chemistry from version 1. \cs{molar} is % simply a handy abbreviation: \cs{Molar} is common but rather @@ -16563,7 +16852,7 @@ This work consists of the file siunitx.dtx % \pb , % \fb , % \ab , -% \zb , +% \zb %} % High-energy physics units from version one. % \begin{macrocode} @@ -16586,35 +16875,27 @@ This work consists of the file siunitx.dtx % \end{macrocode} %\end{macro} % -%\begin{macro}{\requiresiconfigs} -%\begin{macro}[aux]{\siunitx_requireconfig:n} -% Version one provides this, and it might pop up so should not -% cause errors. +% \begin{macro}{\requiresiconfigs} +% Version one provides this, and it might pop up so should not +% cause errors. % \begin{macrocode} -\NewDocumentCommand \requiresiconfigs { m } { - \keys_set:nn { siunitx } { load-configurations = version-1 } - \clist_map_function:nN {#1} \siunitx_requireconfig:n -} -\cs_new_protected_nopar:Npn \siunitx_requireconfig:n #1 { - \str_if_eq:nnT {#1} { synchem } - { \keys_set:nn { siunitx } { load-configurations = chemistry } } -} +\NewDocumentCommand \requiresiconfigs { m } + { \keys_set:nn { siunitx } { version-1-compatibility } } % \end{macrocode} -%\end{macro} -%\end{macro} +% \end{macro} % % \begin{macrocode} %</version-1> % \end{macrocode} % -%\subsection{Abbreviated units} +% \subsection{Abbreviated units} % % \begin{macrocode} %<*abbreviations> % \end{macrocode} % % \begin{macrocode} -\ProvidesExplFile {siunitx-abbreviations.cfg} {2010/08/12} {2.0s} +\ProvidesExplFile {siunitx-abbreviations.cfg} {2011/07/09} {2.3a} {siunitx: Abbreviated units} % \end{macrocode} % @@ -16623,15 +16904,8 @@ This work consists of the file siunitx.dtx % into related groups, mainly to avoid an overly long list in one % place. % -%\begin{macro}{ -% \A , -% \pA , -% \nA , -% \uA , -% \mA , -% \kA , -%} -% Currents. +% \begin{macro}{\A, \pA, \nA, \uA, \mA, \kA} +% Currents. % \begin{macrocode} \DeclareSIUnit \A { \ampere } \DeclareSIUnit \pA { \pico \ampere } @@ -16640,16 +16914,9 @@ This work consists of the file siunitx.dtx \DeclareSIUnit \mA { \milli \ampere } \DeclareSIUnit \kA { \kilo \ampere } % \end{macrocode} -%\end{macro} -%\begin{macro}{ -% \Hz , -% \mHz , -% \kHz , -% \MHz , -% \GHz , -% \THz , -%} -% Then frequencies. +% \end{macro} +% \begin{macro}{\Hz, \mHz, \kHz, \MHz, \GHz, \THz} +% Then frequencies. % \begin{macrocode} \DeclareSIUnit \Hz { \hertz } \DeclareSIUnit \mHz { \milli \hertz } @@ -16658,17 +16925,9 @@ This work consists of the file siunitx.dtx \DeclareSIUnit \GHz { \giga \hertz } \DeclareSIUnit \THz { \tera \hertz } % \end{macrocode} -%\end{macro} -%\begin{macro}{ -% \mol , -% \fmol , -% \pmol , -% \nmol , -% \umol , -% \mmol , -% \kmol , -%} -% Amounts of substance (moles). +% \end{macro} +% \begin{macro}{\mol, \fmol, \pmol, \nmol, \umol, \mmol, \kmol} +% Amounts of substance (moles). % \begin{macrocode} \DeclareSIUnit \mol { \mole } \DeclareSIUnit \fmol { \femto \mole } @@ -16678,16 +16937,9 @@ This work consists of the file siunitx.dtx \DeclareSIUnit \mmol { \milli \mole } \DeclareSIUnit \kmol { \kilo \mole } % \end{macrocode} -%\end{macro} -%\begin{macro}{ -% \V , -% \pV , -% \nV , -% \uV , -% \mV , -% \kV , -%} -% Potentials. +% \end{macro} +% \begin{macro}{\V, \pV, \nV, \uV, \mV, \kV} +% Potentials. % \begin{macrocode} \DeclareSIUnit \V { \volt } \DeclareSIUnit \pV { \pico \volt } @@ -16696,36 +16948,22 @@ This work consists of the file siunitx.dtx \DeclareSIUnit \mV { \milli \volt } \DeclareSIUnit \kV { \kilo \volt } % \end{macrocode} -%\end{macro} -%\begin{macro}{ -% \l , -% \ml , -% \ul , -% \L , -% \mL , -% \uL , -%} -% Volumes. +% \end{macro} +% \begin{macro}{\hl, \l, \ml, \ul, \hL, \L, \mL, \uL} +% Volumes. % \begin{macrocode} +\DeclareSIUnit \hl { \hecto \litre } \DeclareSIUnit \l { \litre } \DeclareSIUnit \ml { \milli \litre } \DeclareSIUnit \ul { \micro \litre } +\DeclareSIUnit \hL { \hecto \liter } \DeclareSIUnit \L { \liter } \DeclareSIUnit \mL { \milli \liter } \DeclareSIUnit \uL { \micro \liter } % \end{macrocode} -%\end{macro} -%\begin{macro}{ -% \fg , -% \pg , -% \ng , -% \ug , -% \mg , -% \g , -% \kg , -% \amu , -%} -% Masses. +% \end{macro} +% \begin{macro}{\fg, \pg, \ng, \ug, \mg, \g, \kg, \amu} +% Masses. % \begin{macrocode} \DeclareSIUnit \fg { \femto \gram } \DeclareSIUnit \pg { \pico \gram } @@ -16736,24 +16974,10 @@ This work consists of the file siunitx.dtx \DeclareSIUnit \kg { \kilo \gram } \DeclareSIUnit \amu { \atomicmassunit } % \end{macrocode} -%\end{macro} -%\begin{macro}{ -% \W , -% \mW , -% \kW , -% \MW , -% \GW , -% \kJ , -% \J , -% \eV , -% \meV , -% \keV , -% \MeV , -% \GeV , -% \TeV , -% \kWh , -%} -% Energies. +% \end{macro} +% \begin{macro} +% {\W, \mW, \kW,\MW , \GW, \kJ, \J, \eV, \meV, \keV, \MeV, \GeV, \TeV, \kWh} +% Energies. % \begin{macrocode} \DeclareSIUnit \W { \watt } \DeclareSIUnit \mW { \milli \watt } @@ -16770,18 +16994,9 @@ This work consists of the file siunitx.dtx \DeclareSIUnit \TeV { \tera \electronvolt } \DeclareSIUnit [ inter-unit-product = ] \kWh { \kilo \watt \hour } % \end{macrocode} -%\end{macro} -%\begin{macro}{ -% \m , -% \pm , -% \nm , -% \um , -% \mm , -% \cm , -% \dm , -% \km , -%} -% Lengths. +% \end{macro} +% \begin{macro}{\m, \pm, \nm, \um, \mm, \cm, \dm, \km} +% Lengths. % \begin{macrocode} \DeclareSIUnit \m { \metre } \DeclareSIUnit \pm { \pico \metre } @@ -16792,99 +17007,69 @@ This work consists of the file siunitx.dtx \DeclareSIUnit \dm { \deci \metre } \DeclareSIUnit \km { \kilo \metre } % \end{macrocode} -%\end{macro} -%\begin{macro}{\K} -% Temperatures. +% \end{macro} +% \begin{macro}{\K} +% Temperatures. % \begin{macrocode} \DeclareSIUnit \K { \kelvin } % \end{macrocode} -%\end{macro} -%\begin{macro}{ -% \N , -% \mN , -% \kN , -% \MN , -%} -% Forces. +% \end{macro} +% \begin{macro}{\N, \mN, \kN, \MN} +% Forces. % \begin{macrocode} \DeclareSIUnit \N { \newton } \DeclareSIUnit \mN { \milli \newton } \DeclareSIUnit \kN { \kilo \newton } \DeclareSIUnit \MN { \mega \newton } % \end{macrocode} -%\end{macro} -%\begin{macro}{ -% \Pa , -% \kPa , -% \MPa , -% \GPa , -%} -% Pressures. +% \end{macro} +% \begin{macro}{\Pa, \kPa, \MPa, \GPa} +% Pressures. % \begin{macrocode} \DeclareSIUnit \Pa { \pascal } \DeclareSIUnit \kPa { \kilo \pascal } \DeclareSIUnit \MPa { \mega \pascal } \DeclareSIUnit \GPa { \giga \pascal } % \end{macrocode} -%\end{macro} -%\begin{macro}{ -% \mohm , -% \kohm , -% \Mohm , -%} -% Resistances. +% \end{macro} +% \begin{macro}{\mohm, \kohm, \Mohm} +% Resistances. % \begin{macrocode} \DeclareSIUnit \mohm { \milli \ohm } \DeclareSIUnit \kohm { \kilo \ohm } \DeclareSIUnit \Mohm { \mega \ohm } % \end{macrocode} -%\end{macro} -%\begin{macro}{ -% \s , -% \as , -% \fs , -% \ps , -% \ns , -% \us , -% \ms , -%} -% Finally, times. +% \end{macro} +% \begin{macro}{\s, \as, \fs, \ps, \ns, \us, \ms} +% Finally, times. % \begin{macrocode} -\DeclareSIUnit \s { \second }\DeclareSIUnit \as { \atto \second } +\DeclareSIUnit \s { \second } +\DeclareSIUnit \as { \atto \second } \DeclareSIUnit \fs { \femto \second } \DeclareSIUnit \ps { \pico \second } \DeclareSIUnit \ns { \nano \second } \DeclareSIUnit \us { \micro \second } \DeclareSIUnit \ms { \milli \second } % \end{macrocode} -%\end{macro} +% \end{macro} % % \begin{macrocode} %</abbreviations> % \end{macrocode} % -%\subsection{Binary units} +% \subsection{Binary units} % % \begin{macrocode} %<*binary> % \end{macrocode} % % \begin{macrocode} -\ProvidesExplFile {siunitx-binary.cfg} {2011/06/15} {2.2i} +\ProvidesExplFile {siunitx-binary.cfg} {2011/07/09} {2.3a} {siunitx: Binary units} % \end{macrocode} % -%\begin{macro}{ -% \kibi , -% \mebi , -% \gibi , -% \tebi , -% \pebi , -% \exbi , -% \zebi , -% \yobi , -%} -% The binary units as specified by the IEC. +% \begin{macro}{\kibi, \mebi, \gibi, \tebi, \pebi, \exbi, \zebi, \yobi} +% The binary units as specified by the IEC. % \begin{macrocode} \DeclareBinaryPrefix \kibi { Ki } { 10 } \DeclareBinaryPrefix \mebi { Mi } { 20 } @@ -16895,67 +17080,64 @@ This work consists of the file siunitx.dtx \DeclareBinaryPrefix \zebi { Zi } { 70 } \DeclareBinaryPrefix \yobi { Yi } { 80 } % \end{macrocode} -%\end{macro} -%\begin{macro}{ -% \bit , -% \byte , -%} -% Now the units. +% \end{macro} +% \begin{macro}{\bit, \byte} +% Now the units. % \begin{macrocode} \DeclareSIUnit \bit { bit } \DeclareSIUnit \byte { B } % \end{macrocode} -%\end{macro} +% \end{macro} % % \begin{macrocode} %</binary> % \end{macrocode} % -%\end{implementation} +% \end{implementation} % -%\begin{thebibliography}{1} +% \begin{thebibliography}{1} % -% \bibitem{BIPM} -% \emph{The International System of Units (SI)}, -% \url{http://www.bipm.org/en/si/}. +% \bibitem{BIPM} +% \emph{The International System of Units (SI)}, +% \url{http://www.bipm.org/en/si/}. % -% \bibitem{NIST} -% \emph{International System of Units from NIST}, -% \url{http://physics.nist.gov/cuu/Units/index.html}. +% \bibitem{NIST} +% \emph{International System of Units from NIST}, +% \url{http://physics.nist.gov/cuu/Units/index.html}. % -% \bibitem{SI:2.1} -% \emph{SI base units}, -% \url{http://www.bipm.org/en/si/si_brochure/chapter2/2-1/}. +% \bibitem{SI:2.1} +% \emph{SI base units}, +% \url{http://www.bipm.org/en/si/si_brochure/chapter2/2-1/}. % -% \bibitem{SI:2.2.2} -% \emph{Units with special names and symbols; units that -% incorporate special names and symbols}, -% \url{http://www.bipm.org/en/si/si_brochure/chapter2/2-2/2-2-2.html}. +% \bibitem{SI:2.2.2} +% \emph{Units with special names and symbols; units that +% incorporate special names and symbols}, +% \url{http://www.bipm.org/en/si/si_brochure/chapter2/2-2/2-2-2.html}. % -% \bibitem{SI:3.1} -% \emph{SI Prefixes}, -% \url{http://www.bipm.org/en/si/si_brochure/chapter3/prefixes.html}. +% \bibitem{SI:3.1} +% \emph{SI Prefixes}, +% \url{http://www.bipm.org/en/si/si_brochure/chapter3/prefixes.html}. % -% \bibitem{SI:4.1.T6} -% \emph{Non-SI units accepted for use with the International -% System of Units}, -% \url{http://www.bipm.org/en/si/si_brochure/chapter4/table6.html}. +% \bibitem{SI:4.1.T6} +% \emph{Non-SI units accepted for use with the International +% System of Units}, +% \url{http://www.bipm.org/en/si/si_brochure/chapter4/table6.html}. % -% \bibitem{SI:4.1.T7} -% \emph{Non-SI units whose values in SI units must be obtained -% experimentally}, -% \url{http://www.bipm.org/en/si/si_brochure/chapter4/table7.html}. +% \bibitem{SI:4.1.T7} +% \emph{Non-SI units whose values in SI units must be obtained +% experimentally}, +% \url{http://www.bipm.org/en/si/si_brochure/chapter4/table7.html}. % -% \bibitem{SI:4.1.T8} -% \emph{Other non-SI units}, -% \url{http://www.bipm.org/en/si/si_brochure/chapter4/table8.html}. +% \bibitem{SI:4.1.T8} +% \emph{Other non-SI units}, +% \url{http://www.bipm.org/en/si/si_brochure/chapter4/table8.html}. % -% \bibitem{SI:5.3.3} -% \emph{Formatting the value of a quantity}, -% \url{http://www.bipm.org/en/si/si_brochure/chapter5/5-3-2.html#5-3-3}. +% \bibitem{SI:5.3.3} +% \emph{Formatting the value of a quantity}, +% \url{http://www.bipm.org/en/si/si_brochure/chapter5/5-3-2.html#5-3-3}. % -%\end{thebibliography} +% \end{thebibliography} % -%\PrintChanges +% \PrintChanges % -%\PrintIndex
\ No newline at end of file +% \PrintIndex
\ No newline at end of file diff --git a/Master/texmf-dist/source/latex/siunitx/siunitx.ins b/Master/texmf-dist/source/latex/siunitx/siunitx.ins index 6ece6097a03..a57f66aca5a 100644 --- a/Master/texmf-dist/source/latex/siunitx/siunitx.ins +++ b/Master/texmf-dist/source/latex/siunitx/siunitx.ins @@ -35,6 +35,7 @@ the LaTeX Project Public License (LPPL), either version 1.3c of this license or (at your option) any later version. The latest version of this license is in the file: http://www.latex-project.org/lppl.txt + This work is "maintained" (as per LPPL maintenance status) by Joseph Wright. @@ -42,7 +43,6 @@ This work consists of the file siunitx.dtx and the derived files siunitx.pdf, siunitx.sty and siunitx.ins. - \endpostamble \usedir{tex/latex/siunitx} \generate{ @@ -64,6 +64,7 @@ This work consists of the file siunitx.dtx %% this license or (at your option) any later version. The latest %% version of this license is in the file: %% http://www.latex-project.org/lppl.txt +%% %% This work is "maintained" (as per LPPL maintenance status) by %% Joseph Wright. %% @@ -71,6 +72,5 @@ This work consists of the file siunitx.dtx %% and the derived files siunitx.pdf, %% siunitx.sty and %% siunitx.ins. -%% %% %% End of file `siunitx.ins'. |