Giter Club home page Giter Club logo

siunitx's Introduction

siunitx - A comprehensive (SI) units package

Description

Physical quantities have both numbers and units, and each physical quantity should be expressed as the product of a number and a unit. Typesetting physical quantities requires care to ensure that the combined mathematical meaning of the number-unit combination is clear. In particular, the SI units system lays down a consistent set of units with rules on how these are to be used. However, different countries and publishers have differing conventions on the exact appearance of numbers (and units). The siunitx package provides a set of tools for authors to typeset quantities in a consistent way. The package has an extended set of configuration options which make it possible to follow varying typographic conventions with the same input syntax. The package includes automated processing of numbers and units, and the ability to control tabular alignment of numbers.

Author

This package is maintained by Joseph Wright: [email protected]

License

Released under the LaTeX Project Public License v1.3c or later. See https://www.latex-project.org/lppl.txt

siunitx's People

Contributors

crparedes avatar dbitouze avatar dependabot[bot] avatar e-kwsm avatar gusbrs avatar jakubkaczor avatar jan-glx avatar janniklasrose avatar jeremy-engel avatar josephshen avatar josephwright avatar koppor avatar lbaeni avatar muzimuzhi avatar pjanck avatar septatrix avatar texhackse avatar tijssen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

siunitx's Issues

Material before number in table not processed unless using centre-decimal-marker alignment

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.

Convert fractions to decimals

As siunitx recognises fractions in numerical input it would be possible to have

\num{1 / 2}

print the same output as

\num{0.5}

Scientific notation (force exponent) option

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}

Flexible presets (locales)

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.?

Fixed exponent printing in tables

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}

Converting output of \num macro using oolatex inserts formulas

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.

"output-decimal-marker" and "group-digits=true" don't work for \SendSettingsToPgf

[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}

Errors in physical measurements

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.

Allow table notes to "close up" to numbers

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).

Uncertainty numbers

[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}

Omit exponent in tables when exponents are fixed

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}

Allow "maths" as well as "math" in options

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?

Detect and use LuaTeX if available

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.

Add function for periods of time

A function which can typeset periods of time, such as "2 d 3 h 4 min 5 s". This could also cover the somewhat unusual formatting using in astronomy (see the attached picture).
exampleHMS

multi-part-units=single when use-brackets=false?

[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}

Failure to parse v1 options correctly

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}

\SendSettingsToPgf doesn't do anything

[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}

If requirements change throughout the document, \SendSettingsToPgf should work not only in the preamble

[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}

Review number formatting logic

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.

Various options give bad results for complex numbers

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.

\kWh fails to work correctly when combined with other units

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}

table-align-numbers, etc. are the wrong way around

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.

Choice of methods for rounding exactly half

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).

Multi-part uncertainties for numbers

[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)}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.