josephwright / siunitx Goto Github PK
View Code? Open in Web Editor NEWA comprehensive (SI) units package for LaTeX
License: LaTeX Project Public License v1.3c
A comprehensive (SI) units package for LaTeX
License: LaTeX Project Public License v1.3c
Some parts of siunitx
(for example number parsing) could usefully be handled in Lua where this is available. At the user level, this should not be visible other than in terms of performance.
Several combinations of options give bad results when numbers contain a complex part. Looking at these, many seem to be outside of the scope of siunitx
(as complex numbers cannot be measured in a physical sense and come up in limited circumstances).
The plan is therefore to limit things at the input step to those types of complex number where I know what to do with them in the output. Basically, this means things like
\SI{1+2i}{\per\centi\metre}
should work, but not much else.
[Reported by Stefan Pinnow]
\documentclass{article}
\usepackage{siunitx}
\begin{document}
\noindent
\emph{10 \num{10}} \\
% \emph{10 \num[detect-italic=true]{10}} \\ % <-- produces an error
\end{document}
When reading things like rulers, it is conventional to give the error in the measurement as a fraction of the minimal division, usually quarters. This is different to the type of s.u. that siunitx
understands, but could be considered as an addition to the package.
\documentclass{article}
\usepackage{siunitx}
\begin{document}
\sisetup{mode = math}
\SI{1234}{\metre\per\second}
\end{document}
There should be an option to force scientific notation even when the input does not use it. Thus for example
\num[scientific-notation]{0.010}
would be the same as
\num{1.0e-2}
[Reported by daleif]
It seems to be handly to be able to do something like
\SI{>5}{\percent}
\SI{<<5}{\percent}
To get
$>5\,\%$
and
$\ll5\,\%$
\documentclass{article}
\usepackage{cellspace}
\usepackage{siunitx}
\begin{document}
bla
\end{document}
[Reported by Stefan Pinnow]
\documentclass{article}
\usepackage{siunitx}
\newcommand*\option[1]{\texttt{#1}}
\begin{document}
numbers with uncertainties over the decimal separator \\
% \num{8.2(1.3)}
which should result in $\num{8.2} \pm \num{1.3}$.\\
This is a real life example.\\
The question is how to show it when \option{separate-uncertainty=false}.
Simply by \num{8.2}(\num{1.3})?
\end{document}
It would be useful to have an option that when a value is rounded below a fixed limit it is printed as less than the limit, rather than whatever the rounding output results in.
[Slightly edited from an e-mail from Roberrt Riemann]
In physics you use sometimes the following syntax to indicate different types of errors: 2149 ± 46 ± 51. It would be nice to get that behaviour with something like
\num{10.55(18)(16)}
[Reported by Stefan Pinnow]
The reason for that is that the output of
\si[per-mode=symbol,per-symbol=/]{\per\mole}
gives "/mol" which is not what one wants. In this case the output should be "1/mol" to be
consistent with the other outputs when "per-mode" is set to reciprocal and fraction.
As discussed on c.t.t., producing output such as "1.2 %, 3.4 %, 5.6 %" with an input syntax such as
\SIlist{{1.2}{3.4}{5.6}}{\percent}
or some similar variant could be a desirable addition.
Processing the minimal example
\documentclass{article}
\usepackage{siunitx}
\usepackage{numprint}
\begin{document}
\num{123456}
\numprint{123456}
\end{document}
using
mk4ht oolatex <filename>.tex
will print the siunitx
number as formulas but the numprint
one as text.
Should
\documentclass{article}
\usepackage{siunitx}
\begin{document}
\num{1 x -2 x 3}
\end{document}
add brackets?
These got forgotten entirely: they should be in the v1 stuff and in the discussion of emulation of these units.
As siunitx
recognises fractions in numerical input it would be possible to have
\num{1 / 2}
print the same output as
\num{0.5}
Example
\documentclass{article}
\usepackage{siunitx}
\DeclareSIUnit\test{m\per\second}
\begin{document}
\si{\test}
\end{document}
siunitx
version 1 includes a set of "locales" which contain a list of settings following the typographic traditions for different locations. Should version 2 retain something similar? If so, would a better approach to the interface look more like Tikz styles? Something like
\sisetup{
preset / UK = { ... }
use-preset = UK
}
If so, how would they be added to, etc.?
Based on the fixed exponent
concept as described in issue #9, it should be possible to omit the exponent of a number entirely when the exponent level is fixed:
\begin{tabular}{S[fixed-exponent = 10,table-omit-exponent]}
1e9 \\
2.0e10 \\
\end{tabular}
would then be the same as
\begin{tabular}{S}
0.1 \\
2.0 \\
\end{tabular}
Rather than printing the sign for negative numbers, print the absolute value in bracket.
Based on the \ang
function, a method to typeset geographical co-ordinates (e.g. 01°05'04.34" W) would be a potential enhancement to siunitx
.
Example
\documentclass{article}
\usepackage{etoolbox,siunitx}
\robustify\bfseries
\begin{document}
\sisetup{detect-all,output-decimal-marker={,},mode=text}
\begin{tabular}{S}
1.23 \\
4.56 \\
\bfseries 7.89 \\
\end{tabular}
\begin{tabular}{S[table-format = 1.2]}
1.23 \\
4.56 \\
\bfseries 7.89 \\
\end{tabular}
\end{document}
but see issue with any other combination also.
[Reported by Steafn Pinnow]
\documentclass{article}
\usepackage{siunitx}
\sisetup{
output-decimal-marker={,},
}
\usepackage{tikz}
\usepackage{pgfplots}
\SendSettingsToPgf
\begin{document}
\begin{tikzpicture}
\begin{axis}
\addplot coordinates { (0,0) (1,1) };
\node at (axis cs:0.25,0.75) {\SI{10.5}{\metre}};
\end{axis}
\end{tikzpicture}
\sisetup{
output-decimal-marker={.},
}
% \SendSettingsToPgf <--- not possible right now
\begin{tikzpicture}
\begin{axis}
\addplot coordinates { (0,0) (1,1) };
\node at (axis cs:0.25,0.75) {\SI{10.5}{\metre}};
\end{axis}
\end{tikzpicture}
\end{document}
Example:
\documentclass{article}
\usepackage{siunitx}
\begin{document}
\sisetup{parse-numbers = false}
\begin{tabular}{SS}
\multicolumn{1}{c}{Some values} & {Some values} \\
2.35 & 2.35 \\
\sqrt{2} & \sqrt{2} \\
\end{tabular}
\end{document}
Conversion for example from '0.012' to '1.2e-2' and so forth.
The current bracket interface is still not clear enough, see for example #22. More thought is needed prior to release.
The back-compatibility code is broken: \newunit
does not allow optional arguments.
Minimal example:
\documentclass{article}
\usepackage{siunitx}
\begin{document}
\begin{tabular}
{S[table-format=3.3,table-space-text-post={a},table-parse-only]}
77.698 \\
378\textsuperscript{f} \\
\end{tabular}
\end{document}
There are a number of methods for breaking the "tie break" when rounding (see http://en.wikipedia.org/wiki/Rounding). Currently, siunitx
uses "half up". Another choice used in the US is "half to even". Potential syntax:
\sisetup{round-precision = 3,round-mode = figures}
\num[round-half = up]{4.125} % Gives 4.13
\num[round-half = even]{4.125} % Gives 4.12
\num[round-half = up]{4.135} % Gives 4.14
\num[round-half = even]{4.135} % Gives 4.14
(there are alternative names, for example round-tie-mode
).
[Reported by Stefan Pinnow]
Have a look at this example
\documentclass{article}
\usepackage{siunitx}
\sisetup{
output-decimal-marker={,},
% group-digits=true,
}
\usepackage{tikz}
\usepackage{pgfplots}
% \pgfkeys{
% /pgf/number format/set decimal separator={{{,}}}, % use comma as decimal sep
% /pgf/number format/set thousands separator={\,}, % small skip for thousands sep
% /pgf/number format/min exponent for 1000 sep=4, % group-four-digits=false
% }
\pgfplotsset{
scale ticks above exponent={9},
}
\SendSettingsToPgf
\begin{document}
\begin{tikzpicture}
\begin{axis}
\addplot coordinates { (0,0) (1,1) };
\end{axis}
\end{tikzpicture}
\begin{tikzpicture}
\begin{axis}
\addplot coordinates { (0,0) (10000,10000) };
\end{axis}
\end{tikzpicture}
\SI{10.5}{\metre}, \num{10000}
\end{document}
[Reported by Stefan Pinnow]
This makes it hard to find misspelled options. In my case it was colour=blue
which doesn't work any more because only the US English spelling is used now. Please bring up errors again for unknown options.
Example
\documentclass{article}
\usepackage{siunitx}
\begin{document}
\num[separate-uncertainty=true]{1e4 x 2(3) x 3/4}
\end{document}
Options such as table-align-numbers
sound like they are true/false. On the other hand, table-number-alignment
sounds like it requires a position. This shows up in the context of bug #2, where an additional option such as table-align-notes
or table-align-post-text
is needed, and which is a Boolean.
[Reported by Stefan Pinnow]
\documentclass{article}
\usepackage{siunitx}
\begin{document}
\sisetup{
round-mode = figures,
round-precision = 3
}%
\ang{1;2;3456789} \\
\ang{1;2;3} \\
\ang{;2;} \\
\end{document}
Probably the error message for unknown options could be cleverer, particularly when loading the package. Perhaps do some auto-detection?
Example
\documentclass{article}
\usepackage{siunitx}
\sisetup{load-configurations=abbreviations}
\DeclareSIUnit\KWH{kWh}
\begin{document}
\si{\kilo\watt\hour\per\second}
\si{\kWh\per\s} \\
\si{\kg\per\kWh} \\
\\
\si{\KWH\per\s} \\
\si{\kg\per\KWH} \\
\end{document}
Version one of siunitx
uses both UK and US spellings. Following some discussion within the LaTeX Project, version 2 of siunitx
only provides US spellings. Should UK spellings (at least for "maths") be available, even if not documented?
The current number formatting logic probably needs checking over to make sure that things are as efficient as possible. There are some places where it is likely that steps can be saved by carefully adjusting the output flags. Not one for the immediate future, but should be done as part of the post-v2.0 work.
There are occasions where it would be useful to "level" the exponent of numbers, particularly in tables, so that all are given with the same exponent. For example
\begin{tabular}{S[fixed-exponent = 10]}
1e9 \\
2.0e10 \\
\end{tabular}
might then give the same output as
\begin{tabular}{S}
0.1e10 \\
2e10 \\
\end{tabular}
[Reported by Stefan Pinnow]
\documentclass{article}
\usepackage{siunitx}
\usepackage{tikz}
\SendSettingsToPgf
\begin{document}
bla
\end{document}
The cancel
package allows striking through material in formulae. To show simplification in units, the \cancel
function would need to be added to the unit processor.
[Reported by Stefan Pinnow]
\documentclass{article}
\usepackage{siunitx}
\sisetup{
output-decimal-marker={,}, % leads to wrong results (left plot)
% output-decimal-marker={{,}}, % works fine (left plot)
group-digits=true, % doesn't work (right plot)
% group-four-digits=true,
}
\usepackage{tikz}
\usepackage{pgfplots}
% \pgfkeys{
% /pgf/number format/set decimal separator={{{,}}}, % use comma as decimal sep
% /pgf/number format/set thousands separator={\,}, % small skip for thousands sep
% /pgf/number format/min exponent for 1000 sep=4, % group-four-digits=false
% } %% everything works fine with these and commenting out \SendSettingsToPgf
\pgfplotsset{
scale ticks above exponent={9},
}
\SendSettingsToPgf
\begin{document}
\begin{tikzpicture}
\begin{axis}
\addplot coordinates { (0,0) (1,1) };
\end{axis}
\end{tikzpicture}
\begin{tikzpicture}
\begin{axis}
\addplot coordinates { (0,0) (10000,10000) };
\end{axis}
\end{tikzpicture}
\num{0.5}; \num{10000}; \num{1000}
\end{document}
Example
\documentclass{article}
\usepackage{siunitx}
\begin{document}
\SI[separate-uncertainty,multi-part-units=repeat]{1.234(5)e-4}{\metre}
\end{document}
[Reported Stefan Pinnow]
\documentclass{article}
\usepackage{siunitx}
\newcommand*\option[1]{\texttt{#1}}
\begin{document}
should \option{multi-part-units} be set to \option{single}
when \option{use-brackets} is set to \option{false} for consistency? \\
\sisetup{separate-uncertainty}
\noindent%
\num{1.234(5)e-4} \\
\SI{1.234(5)e-4}{\metre} \\
\sisetup{separate-uncertainty,use-brackets=false}
\noindent%
\num{1.234(5)e-4} \\
\SI{1.234(5)e-4}{\metre} $\leftarrow$ not consistent \\
\SI[multi-part-units=single]{1.234(5)e-4}{\metre} \\
\end{document}
Example
\documentclass{article}
\pagestyle{empty}
\usepackage[load-configurations=version-1]{siunitx}
\usepackage{booktabs}
\begin{document}
\begin{tabular}{
S[digitsep=none,decimalsymbol={\,\pm\,},
numdigits={0123456789.},numdecimal=+]}\toprule
\emph{Zahlenwerte}\\\midrule
2.3456 + 0.02 \\
34.2345 + 0.001 \\
56.7835 + 0.067 \\
90.473 + 0.021 \\\bottomrule
\end{tabular}
\end{document}
With the following example
\documentclass{article}
\usepackage{siunitx}
\begin{document}
\begin{tabular}
{S[table-format=3.3,table-space-text-post={a}]}
77.698 \\
378\textsuperscript{f} \\
\end{tabular}
\end{document}
the text is separated out from the number. There should be an option to "close up" the space (which would probably mean that table-space-test-post would not be needed here).
Doesn't seem to be working at all: test and sort.
As reported by Stefan Pinnow, these need proper documentation
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.