Skip to content

Commit

Permalink
Replace deprecated siunitx commands with new versions
Browse files Browse the repository at this point in the history
Essentially sed with:

\SI      -> \qty
\SIlist  -> \qtylist
\SIrange -> \qtyrange
\si      -> \unit

The new commands provide more clarity.
  • Loading branch information
alexpovel committed Oct 11, 2021
1 parent 2e3a582 commit 82977ce
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 57 deletions.
12 changes: 6 additions & 6 deletions bib/glossaries/symbols/greek.bib
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,36 @@
@symbol{ratio_of_specific_heats,
name={\ensuremath{\kappa}},
description={Ratio of specific heats},
unit={\si{-}},
unit={\unit{-}},
}
@symbol{celsius_temperature,
name={\ensuremath{\vartheta}},
description={(relative) Temperature},
unit={\si{\degreeCelsius}},
unit={\unit{\degreeCelsius}},
}
@symbol{relative_humidity,
name={\ensuremath{\varphi}},
description={Relative Humidity},
unit={\si{\degreeCelsius}},
unit={\unit{\degreeCelsius}},
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Fluid Mechanics
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@symbol{drag_coefficient,
name={\ensuremath{\zeta}},
description={Drag Coefficient},
unit={\si{-}},
unit={\unit{-}},
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Other
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@symbol{mass_fraction,
name={\ensuremath{\gamma}},
description={Mass fraction},
unit={\si{-}},
unit={\unit{-}},
}
@symbol{angle_one,
name={\ensuremath{\alpha}},
description={Angle},
unit={\si{\radian}},
unit={\unit{\radian}},
}
6 changes: 3 additions & 3 deletions bib/glossaries/symbols/other.bib
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ @entry{difference
@entry{flow,
name={\flowfmt{\symbolplaceholder}},
description={\symbolplaceholder{} as a flow quantity},
unit={\si{\symbolplaceholder\per\second}},
unit={\unit{\symbolplaceholder\per\second}},
}
@entry{nabla,
name={\nablaoperatorfmt{\symbolplaceholder}},
description={Vector of partial derivatives (Nabla operator) of \symbolplaceholder},
unit={\si{-}},
unit={\unit{-}},
}
@entry{mean,
name={\meanfmt{\symbolplaceholder}},
Expand All @@ -43,7 +43,7 @@ @entry{logmean
@entry{vector,
name={\ensuremath{\vectfmt{x}}},
description={Vector},
unit={\si{-}},
unit={\unit{-}},
}
@entry{abs,
name={\ensuremath{\absfmt*{\symbolplaceholder}}},
Expand Down
48 changes: 24 additions & 24 deletions bib/glossaries/symbols/roman.bib
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,34 @@
@symbol{pressure,
name={\ensuremath{p}},
description={Pressure},
unit={\si{\pascal}},
unit={\unit{\pascal}},
}
@symbol{abs_temperature,
name={\ensuremath{T}},
description={(absolute) Temperature},
unit={\si{\kelvin}},
unit={\unit{\kelvin}},
}
@symbol{volume,
name={\ensuremath{V}},
specific={\ensuremath{v}},
description={Volume},
unit={\si{\meter\cubed}},
unit={\unit{\meter\cubed}},
}
@symbol{gas_constant,
name={\ensuremath{R}},
specific={\ensuremath{R}},
description={(specific) Gas Constant},
unit={\si{\joule\per\kilogram\per\kelvin}},
unit={\unit{\joule\per\kilogram\per\kelvin}},
}
@symbol{mass,
name={\ensuremath{m}},
description={Mass},
unit={\si{\kilogram}},
unit={\unit{\kilogram}},
}
@symbol{density,
name={\ensuremath{\rho}},
description={Density},
unit={\si{\kilogram\per\meter\cubed}},
unit={\unit{\kilogram\per\meter\cubed}},
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Thermodynamic change of state / energy
Expand All @@ -40,12 +40,12 @@ @symbol{enthalpy
name={\ensuremath{H}},
specific={\ensuremath{h}},
description={Enthalpy},
unit={\si{\joule}},
unit={\unit{\joule}},
}
@symbol{velocity,
name={\ensuremath{c}},
description={Velocity/Speed},
unit={\si{\meter\per\second}},
unit={\unit{\meter\per\second}},
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Air conditioning
Expand All @@ -54,7 +54,7 @@ @symbol{moisture_content
name={\ensuremath{x}},
description={Moisture Content},
unit={%
\si{
\unit{
\gram_{\glsfmtname{sub.water}}
\per
\kilogram_{\glsfmtname{sub.dry}\glsfmtname{sub.air}}
Expand All @@ -68,13 +68,13 @@ @symbol{heating_value
name={\ensuremath{H_{\glsentryname{sub.inferior}}}},
specific={\ensuremath{H_{\glsentryname{sub.inferior}}}},
description={(specific) Heating Value},
unit={\si{\joule\per\kilogram}},
unit={\unit{\joule\per\kilogram}},
}
@symbol{heat_capacity,
name={\ensuremath{C}},
specific={\ensuremath{c}},
description={Heat capacity},
unit={\si{\joule\per\kelvin}},
unit={\unit{\joule\per\kelvin}},
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Coordinates etc.
Expand All @@ -83,51 +83,51 @@ @symbol{heat_capacity
@symbol{first_cart_coord,
name={\ensuremath{x}},
description={First Cartesian coordinate (length)},
unit={\si{\meter}},
unit={\unit{\meter}},
}
@symbol{second_cart_coord,
name={\ensuremath{y}},
description={Second Cartesian coordinate (width)},
unit={\si{\meter}},
unit={\unit{\meter}},
}
@symbol{third_cart_coord,
name={\ensuremath{z}},
description={Third Cartesian coordinate (height)},
unit={\si{\meter}},
unit={\unit{\meter}},
}
@symbol{radius,
name={\ensuremath{r}},
description={Radius},
unit={\si{\meter}},
unit={\unit{\meter}},
}
@symbol{area,
name={\ensuremath{A}},
description={Area},
unit={\si{\meter\squared}},
unit={\unit{\meter\squared}},
}
% REQUIRED for built-in \timederiv to work:
@symbol{time,
name={\ensuremath{t}},
description={Time},
unit={\si{\second}},
unit={\unit{\second}},
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Electrical
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@symbol{voltage,
name={\ensuremath{U_{\glsentryname{sub.electric}}}},
description={Voltage},
unit={\si{\volt}},
unit={\unit{\volt}},
}
@symbol{electric_current,
name={\ensuremath{J_{\glsentryname{sub.electric}}}},
description={Electric current},
unit={\si{\ampere}},
unit={\unit{\ampere}},
}
@symbol{electrical_resistance,
name={\ensuremath{R_{\glsentryname{sub.electric}}}},
description={Electrical resistance},
unit={\si{\ohm}},
unit={\unit{\ohm}},
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Dimensionless Quantities
Expand All @@ -137,23 +137,23 @@ @symbol{electrical_resistance
@symbol{mach_number,
name={\ensuremath{\operatorname{M}}},
description={\glsfmtname{name.ernst_mach} number},
unit={\si{-}},
unit={\unit{-}},
}
@symbol{reynolds_number,
name={\ensuremath{\operatorname{Re}}},
description={\glsfmtname{name.osborne_reynolds} number},
unit={\si{-}},
unit={\unit{-}},
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Other
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@symbol{component,
name={\ensuremath{n}},
description={Component},
unit={\si{-}},
unit={\unit{-}},
}
@symbol{count,
name={\ensuremath{k}},
description={Count/Quantity},
unit={\si{-}},
unit={\unit{-}},
}
22 changes: 11 additions & 11 deletions chapters/mainmatter/base-features.tex
Original file line number Diff line number Diff line change
Expand Up @@ -473,25 +473,25 @@ \subsubsection{Physical Units}
number needs to be typeset, \verb|\num| is also required.
In this document, it will use the math font: \num{1234567890}.

Physical units are output using \verb|\si|.
Physical units are output using \verb|\unit|.
It also has parsing capabilities:
\begin{minted}[linenos=false]{latex}
\si{\meter\cubed\kelvin\per\kilogram\squared\per\giga\watt\per\degreeCelsius}
\unit{\meter\cubed\kelvin\per\kilogram\squared\per\giga\watt\per\degreeCelsius}
\end{minted}
will print
\si{\meter\cubed\kelvin\per\kilogram\squared\per\giga\watt\per\degreeCelsius}.
\unit{\meter\cubed\kelvin\per\kilogram\squared\per\giga\watt\per\degreeCelsius}.
The mode in which units with negative exponents are displayed can be changed,
\iecfeg{e.g.}\ fractions can be used:
\si[per-mode=fraction]{\meter\cubed\kelvin\per\kilogram\squared\per\giga\watt\per\degreeCelsius}.
\unit[per-mode=fraction]{\meter\cubed\kelvin\per\kilogram\squared\per\giga\watt\per\degreeCelsius}.
You can also use \verb|\DeclareSIQualifier| to create textual subscripts for units,
further specifying them, or create entirely custom units using \verb|\DeclareSIUnit|.
An example for both combined is: \si[per-mode=fraction]{\mega\watthour\thermal\per\meter\cubed}.
An example for both combined is: \unit[per-mode=fraction]{\mega\watthour\thermal\per\meter\cubed}.

The \verb|\SI{<quantity>}{<unit>}| command essentially combines \verb|\num| and
\verb|\si|, inserting a small space in between, for correct typesetting.
The \verb|\qty{<quantity>}{<unit>}| command essentially combines \verb|\num| and
\verb|\unit|, inserting a small space in between, for correct typesetting.
No or full spaces are wrong and painful to read.

There are also commands to print ranges: \SIrange{20}{50}{\meter}.
There are also commands to print ranges: \qtyrange{20}{50}{\meter}.
Refer to the package documentation for more.

\subsubsection{Chemistry}
Expand Down Expand Up @@ -711,7 +711,7 @@ \section{Language}
% However, that command can break due to macro expansion stuff,
% if it contains macros and not just plain text.
\begin{english}\enquote{Quote!}\end{english} &
\begin{english}\SI{100.2}{\meter}\end{english} &
\begin{english}\qty{100.2}{\meter}\end{english} &
% polyglossia \begin{<language>} environment seems to introduce
% empty lines in paragraph columns; remove them manually.
\vspace{-\baselineskip}% This is guesswork; haven't figured this out yet
Expand All @@ -735,7 +735,7 @@ \section{Language}
\\
German &
\begin{german}\enquote{Zitat!}\end{german} &
\begin{german}\SI{100.2}{\meter}\end{german} &
\begin{german}\qty{100.2}{\meter}\end{german} &
\vspace{-\baselineskip}% This is guesswork; haven't figured this out yet
\begin{german}
\glossaryname{},
Expand Down Expand Up @@ -1226,7 +1226,7 @@ \subsection{bib2gls}
name={\ensuremath{T}},
description={absolute temperature},
group={roman},
unit={\si{\kelvin}},
unit={\unit{\kelvin}},
}
\end{minted}

Expand Down
10 changes: 5 additions & 5 deletions chapters/mainmatter/floats.tex
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,8 @@ \subsubsection{Large Floats}
\\
&
\multicolumn{7}{c}{{[--]}} &
\(\brackets*{\si{\kilogram\per\meter\cubed}}\) &
\(\brackets*{\si{\mega\joule\per\kilogram}}\)
\(\brackets*{\unit{\kilogram\per\meter\cubed}}\) &
\(\brackets*{\unit{\mega\joule\per\kilogram}}\)
\\
\cmidrule(lr){2-8}% truncate left and right
&
Expand Down Expand Up @@ -993,7 +993,7 @@ \subsubsection{Directly in \LaTeX{}}
\pgfkeys{/pgf/fpu/output format=fixed}
\pgfmathparse{AmbientPressure/1e5}
%
For \SI[round-mode=figures, round-precision=1]{\pgfmathresult}{\bar}
For \qty[round-mode=figures, round-precision=1]{\pgfmathresult}{\bar}
air pressure.%
%
\pgfkeys{/pgf/fpu=false}
Expand Down Expand Up @@ -1116,7 +1116,7 @@ \subsubsection{Directly in \LaTeX{}}
%
\addlegendimage{color=rdylbu2, ultra thick, dashdotted}
\addlegendentry{%
Specific Enthalpy in \si{\kilo\joule\per\kilogram\dryair}%
Specific Enthalpy in \unit{\kilo\joule\per\kilogram\dryair}%
}

% Add nodes and connect them. Connect the one we are currently
Expand Down Expand Up @@ -1436,7 +1436,7 @@ \subsubsection{Using MATLAB2Ti\textit{k}Z}
% use this special command version, see also
% https://tex.stackexchange.com/a/317015/120853
\addlegendentryexpanded{
\SI{\pressure}{\bar}/\SI{\temperature}{\degreeCelsius}
\qty{\pressure}{\bar}/\qty{\temperature}{\degreeCelsius}
}
}
\end{axis}%
Expand Down
4 changes: 2 additions & 2 deletions chapters/mainmatter/usage.tex
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ \subsection{More on Docker}
\item The \textbf{image} is then built according to the \texttt{Dockerfile} instructions,
resulting in a large\-/ish file that contains an executable environment.
For example, if we install a comprehensive TeXLive distribution, the image can be
more than \SI{2}{\giga\byte} in size.
more than \qty{2}{\giga\byte} in size.
Note that you will never interact with that \enquote{file} directly.
Docker manages it for you, and all interaction occurs through the \texttt{docker} command.

Expand Down Expand Up @@ -390,7 +390,7 @@ \subsection{Editor}
try \href{https://www.texstudio.org/}{TeXStudio}.
Like VSCode, it is also
\href{https://github.com/texstudio-org/texstudio}{open source}.
TeXStudio will cater to \SI{90}{\percent} of your \LaTeX{} needs, but nothing else (Markdown, \dots{}).
TeXStudio will cater to \qty{90}{\percent} of your \LaTeX{} needs, but nothing else (Markdown, \dots{}).

\subsubsection{Visual Studio Code}

Expand Down
Loading

0 comments on commit 82977ce

Please sign in to comment.