Text FormattingBest Practice for typesetting physical Quantities

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
User avatar
svend_tveskaeg
Posts: 478
Joined: Sun Jul 12, 2009 5:31 am

Best Practice for typesetting physical Quantities

Post by svend_tveskaeg »

Consider the following example.

Code: Select all

\documentclass{article}

\usepackage{amsmath}
\usepackage[
  locale=DE
]{siunitx}

\begin{document}

\noindent Should I use
\[
  \SI{38.0}{\cm} + 2 \cdot \SI{26.2}{\cm} + \SI{32.6}{\cm}
  = \SI[parse-numbers=false]{(38{,}0 + 52{,}4 + 32{,}6)}{\cm}
  = \SI{123.0}{\cm}.
\]
or
\[
  \SI{38.0}{\cm} + 2 \cdot \SI{26.2}{\cm} + \SI{32.6}{\cm}
  = (\num{38.0} + \num{52.4} + \num{32.6})\,\si{\cm}
  = \SI{123.0}{\cm}.
\]
when typing physical units?

\end{document}
The question is in the attached screenshot of the output.
Attachments
The output.
The output.
output.png (14.39 KiB) Viewed 7873 times
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Re: Best Practice for typesetting physical Quantities

Post by cgnieder »

This is rather subjective I think. I would prefer the second version but I can't tell you why, exactly. This is just a feeling.

Best
site moderator & package author
User avatar
svend_tveskaeg
Posts: 478
Joined: Sun Jul 12, 2009 5:31 am

Re: Best Practice for typesetting physical Quantities

Post by svend_tveskaeg »

Okay. Thank you, Clemens.
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Best Practice for typesetting physical Quantities

Post by cgnieder »

BTW: one could think of a third way:

Code: Select all

\documentclass{article}

\usepackage{amsmath}
\usepackage[
  locale=DE
]{siunitx}

\begin{document}

\[
  \SI{38.0}{\cm} + 2 \cdot \SI{26.2}{\cm} + \SI{32.6}{\cm}
  = \SIlist[list-separator=+,list-final-separator=+,list-units=brackets]{38;52.4;32.6}{\cm}
  = \SI{123.0}{\cm}.
\]

\end{document}
But I'm still not entirely sure which one I'd choose in the end.

Regards
site moderator & package author
User avatar
svend_tveskaeg
Posts: 478
Joined: Sun Jul 12, 2009 5:31 am

Best Practice for typesetting physical Quantities

Post by svend_tveskaeg »

This is really nice. I'll use the following:

Code: Select all

\documentclass{article}

\usepackage{amsmath}
\usepackage[
  locale=DE
]{siunitx}

\newcommand*\horse[3]{
  \SIlist[
    list-separator=#1,
    list-final-separator=#1,
    list-units=brackets
  ]{#2}{#3}
}

\begin{document}

\[
  \SI{38.0}{\cm} + 2 \cdot \SI{26.2}{\cm} + \SI{32.6}{\cm}
  = \horse{+}{100; 38; 52.4; 32.6}{\cm}
  = \SI{123.0}{\cm}.
\]

\end{document}
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)
Post Reply