summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/mandi/mandi.dtx
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2022-01-28 03:00:39 +0000
committerNorbert Preining <norbert@preining.info>2022-01-28 03:00:39 +0000
commitaef84c3078da1ba1bad9754ea0555ac9bc1c0aac (patch)
tree504157331610369440808936658f31b027731b5f /macros/latex/contrib/mandi/mandi.dtx
parentb5deca5ab245af14ca010a3e61225189e9c860f9 (diff)
CTAN sync 202201280300
Diffstat (limited to 'macros/latex/contrib/mandi/mandi.dtx')
-rw-r--r--macros/latex/contrib/mandi/mandi.dtx886
1 files changed, 495 insertions, 391 deletions
diff --git a/macros/latex/contrib/mandi/mandi.dtx b/macros/latex/contrib/mandi/mandi.dtx
index f78128d1a4..d3313fc5b4 100644
--- a/macros/latex/contrib/mandi/mandi.dtx
+++ b/macros/latex/contrib/mandi/mandi.dtx
@@ -1,7 +1,7 @@
% \iffalse meta-comment
% !TEX program = lualatexmk
%
-% Copyright (C) 2021 by Paul J. Heafner <heafnerj@gmail.com>
+% Copyright (C) 2021,2022 by Paul J. Heafner <heafnerj@gmail.com>
% ---------------------------------------------------------------------------
% This work may be distributed and/or modified under the conditions of the
% LaTeX Project Public License, either version 1.3 of this license or (at
@@ -53,7 +53,14 @@
%
%<*driver>
\ProvidesFile{mandi.dtx}
-\documentclass[10pt]{ltxdoc}
+% As of 2021-12-02 ltxdoc.cls picks up ltxdoc.cfg and sets
+% the default paper size to a4paper rather than letter.
+% This can be changed in a local ltxdoc.cfg file but it is
+% easier to just use the article class and the doc package
+% instead and force letterpaper size.
+% \documentclass[10pt]{ltxdoc}
+\documentclass[10pt,letterpaper]{article}
+\usepackage{doc}
\PassOptionsToPackage{listings,documentation}{tcolorbox} % prevent option clash
\usepackage{\jobname} % load mandi.sty
\usepackage{mandistudent} % load mandistudent.sty
@@ -79,45 +86,72 @@
colback = gray!10!white,sidebyside,lefthand ratio = 0.5,center},%
listing style = vpython,%
}%
-% Redefine tcolorbox's \tcbdocnew and \tcbdocupdated defaults.
-\renewcommand*{\tcbdocnew}[1]
- {\textcolor{green!50!black}{\sffamily\bfseries N} #1}
-\renewcommand*{\tcbdocupdated}[1]
- {\textcolor{blue!75!black}{\sffamily\bfseries U} #1}
-\hypersetup{colorlinks=true} % colored links; no borders
% See https://tex.stackexchange.com/q/156383/218142
\newcommand*{\pkg}[1]{\textsf{#1}} % typeset package names
\newcommand*{\mandi}{\textsf{mandi}} % typeset mandi
\newcommand*{\mandistudent}{\textsf{mandistudent}} % typeset mandistudent
\newcommand*{\mandiexp}{\textsf{mandiexp}} % typeset mandiexp
-\newcommand*{\GlowScript}{\texttt{GlowScript}} % typeset GlowScript
-\newcommand*{\GlowScriptorg}{\texttt{GlowScript.org}} % typeset GlowScript.org
+\newcommand*{\WebVPython}{\texttt{Web VPython}} % typeset Web VPython
+\newcommand*{\WebVPythonorg}{\texttt{WebVPython.org}} % typeset WebVPython.org
\newcommand*{\VPython}{\texttt{VPython}} % typeset VPython
\newcommand*{\VPythonorg}{\texttt{VPython.org}} % typeset VPython.org
-\newcommand*{\gsurl}{glowscript.org} % GlowScript URL
+\newcommand*{\gsurl}{webvpython.org} % Web VPython URL
\newcommand*{\vpurl}{vpython.org} % VPython URL
\newcommand*{\lualatex}{Lua\LaTeX} % typeset LuaLaTeX
+%%%%% Some local hacks to make things better.
+% Redefine tcolorbox's \tcbdocnew and \tcbdocupdated defaults.
+\renewcommand*{\tcbdocnew}[1]
+ {\textcolor{green!50!black}{\sffamily\bfseries N} #1}
+\renewcommand*{\tcbdocupdated}[1]
+ {\textcolor{blue!75!black}{\sffamily\bfseries U} #1}
+\hypersetup{colorlinks=true} % colored links; no borders
+
% A customized internal hyperref tool to mimic that in tcolorbox.
% In fact, I borrowed it from tcolorbox.
-\NewDocumentCommand{\setplace}{ s m }{%
- \IfBooleanTF {#1}%
- {\phantomsection}%
- {}%
- \label{#2}%
-}%
-\NewDocumentCommand{\linktoplace}{ m m }{%
- \hyperref[#1]{\texttt{#2}%
- \ifnum\getpagerefnumber{#1}=\thepage\relax%
- \else%
- %\textsuperscript{\ding{213}\,{P.}\,\pageref*{#1}}%
- % Changed with tcolorbox 4.51
- \textsuperscript{{\fontfamily{pzd}\fontencoding{U}\fontseries{m}\fontshape{n}\selectfont\char213}
- \,{P.}\,\pageref*{#1}}%
- \fi%
+\NewDocumentCommand{\setplace}{ s m }%
+ {%
+ \IfBooleanTF {#1}%
+ {\phantomsection}%
+ {}%
+ \label{#2}%
+ }%
+\NewDocumentCommand{\linktoplace}{ m m }%
+ {%
+ \hyperref[#1]{\texttt{#2}%
+ \ifnum\getpagerefnumber{#1}=\thepage\relax%
+ \else%
+ %\textsuperscript{\ding{213}\,{P.}\,\pageref*{#1}}%
+ % Changed with tcolorbox 4.51
+ \textsuperscript{{\fontfamily{pzd}\fontencoding{U}\fontseries{m}\fontshape{n}\selectfont\char213}
+ \,{P.}\,\pageref*{#1}}%
+ \fi%
+ }%
}%
+
+% Clean up the Change History entries to get rid of General:
+% and add dates.
+% See https://tex.stackexchange.com/a/283894/218142
+\renewcommand{\generalname}{} % gets rid of General
+\makeatletter
+\renewcommand*{\changes@}[3]{%
+ \protected@edef\@tempa{%
+ \noexpand\glossary{#1 (#2)\levelchar
+ \ifx\saved@macroname\@empty
+ \space\actualchar\generalname
+ \else
+ \expandafter\@gobble\saved@macroname
+ \actualchar
+ \string\verb\quotechar*\verbatimchar\saved@macroname\verbatimchar
+ \fi
+ #3}}% gets rid of colon and adjusts spacing
+ \@tempa
+ \endgroup
+ \@esphack
}%
+\makeatother
+%%%%% End local hacks.
% We need a new command for in-line listings to prevent overfull boxes.
% Anything in |...| will be in small plain text.
@@ -142,7 +176,7 @@
% \IndexPrologue{\section{Index}Page numbers refer to page where the
% corresponding entry is documented and/or referenced.}
%
-% \CheckSum{2171}
+% \CheckSum{2156}
%
% \CharacterTable
% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
@@ -184,29 +218,29 @@
% \phantomsection
% \addcontentsline{toc}{section}{Acknowledgements}
% \section*{Acknowledgements}
-% To all of the students who have learned \LaTeX\ in my introductory
+% To all of the students who have learned \LaTeXe\ in my introductory
% physics courses over the years, I say a heartfelt thank you. You
% have contributed directly to the state of this software and to its
% use in introductory physics courses and to innovating how physics
% is taught.
%
-% I also acknowledge the \LaTeX\ developers who inhabit the
+% I also acknowledge the \LaTeXe\ developers who inhabit the
% \href{https://tex.stackexchange.com/}{\TeX\ StackExchange} site.
% Entering a new culture is daunting for anyone, especially for
-% newcomers. The \LaTeX\ development culture is no exception. We all
+% newcomers; the \LaTeXe\ development culture is no exception. We all
% share a passion for creating beautiful documents and I have learned
-% much over the past year that improved my ability to do just that.
-% There are too many of you to list individually, and I would surely
-% accidentally omit some were I to try. Collectively, I thank you all
-% for your patience and advice.
+% much over the summers of 2020 and 2021 that improved my ability to
+% do just that. There are too many of you to list individually, and I
+% would surely accidentally omit some were I to try. Collectively, I
+% thank you all for your patience and advice.
% \newpage
% \phantomsection
% \addcontentsline{toc}{section}{Change History}
% \PrintChanges
% \newpage
% \phantomsection
-% \addcontentsline{toc}{section}{List of \texttt{GlowScript} Programs}
-% \listofglowscriptprograms
+% \addcontentsline{toc}{section}{List of \texttt{Web VPython} Programs}
+% \listofwebvpythonprograms
% \phantomsection
% \addcontentsline{toc}{section}{List of \texttt{VPython} Programs}
% \listofvpythonprograms
@@ -215,9 +249,12 @@
% \listoffigures
% \restoregeometry
%
-% \changes{v3.0.0}{2021-08-22}{\mandi\ initial release}
-% \changes{v3.0.0}{2021-08-22}{\mandistudent\ initial release}
-% \changes{v3.0.0}{2021-08-22}{\mandiexp\ initial release}
+% \changes{v3.0.0}{2021-08-22}{\linktoplace{sec:mandipkg}{mandi} Initial release}
+% \changes{v3.0.0}{2021-08-22}{\linktoplace{sec:mandistudentpkg}{mandistudent} Initial release}
+% \changes{v3.0.0}{2021-08-22}{\linktoplace{sec:mandiexppkg}{mandiexp} Initial release}
+% \changes{v3.0.1}{2021-08-24}{\linktoplace{sec:mandipkg}{mandi} Minor doc changes}
+% \changes{v3.0.1}{2021-08-24}{\linktoplace{sec:mandistudentpkg}{mandistudent} Minor doc changes}
+% \changes{v3.0.1}{2021-08-24}{\linktoplace{sec:mandiexppkg}{mandiexp} Minor doc changes}
%
% \section{Introduction}
%
@@ -249,10 +286,21 @@
% as well as new, users is to treat this as a brand new experience. I think
% the most important thing to keep in mind is that I assume users,
% expecially new users, will have a relatively recent TeX distribution
-% (like TeX Live) that includes a recently updated \LaTeX\ kernel. If users
+% (like TeX Live) that includes a recently updated \LaTeXe\ kernel. If users
% report that this is a major problem, I can provide some degree of
-% backwards compatibility.
+% backwards compatibility. However, I use a fully updated TeX Live distribution.
%
+% \changes{v3.1.0}{2022-01-27}
+% {\linktoplace{sec:mandipkg}{mandi} Added GitHub links to code}
+% \section{Code Availability}
+% The \mandi\ source repository's \texttt{main} branch is at
+% \url{https://github.com/heafnerj/mandi}. This code will usually coincide
+% with that found on \href{https://ctan.org/pkg/mandi}{CTAN}. The very latest
+% build can be found on the \texttt{dev} branch found at
+% \url{https://github.com/heafnerj/mandi/tree/dev}. Students and other academic
+% academic users should probably get the \texttt{dev} branch code since it is
+% stable and may contain improvements over the \texttt{main} branch code.
+%
% \newpage
% \section{Student/Instructor Quick Guide}
%
@@ -266,7 +314,7 @@
%\iffalse
%<*example>
%\fi
-\begin{dispExample*}{lefthand ratio=0.80}
+\begin{dispExample*}{lefthand ratio = 0.80}
\( \vec{p} \) or \( \vec*{p} \) \\
\( \vec{p}_{\symup{final}} \) or \( \vec*{p}_{\symup{final}} \) \\
\( \magnitude{\vec{p}} \) or \( \magnitude*{\vec{p}_{\symup{final}}} \) \\
@@ -306,7 +354,7 @@
%\iffalse
%<*example>
%\fi
-\begin{dispExample*}{lefthand ratio=0.70}
+\begin{dispExample*}{lefthand ratio = 0.70}
\( \vacuumpermittivitymathsymbol = \vacuumpermittivity \)
\end{dispExample*}
%\iffalse
@@ -314,12 +362,12 @@
%\fi
%
% Use \refCom{mivector} to typeset symbolic vectors with components.
-% Use the aliases \refCom{direction} to typeset a direction or unit
+% Use the alias \refCom{direction} to typeset a direction or unit
% vector.
%\iffalse
%<*example>
%\fi
-\begin{dispExample*}{sidebyside=false}
+\begin{dispExample*}{sidebyside = false}
\( \mivector{\slot,\slot,\slot} \) or \( \mivector{p_x,p_y,p_z} \) \\
\( \direction{\frac{1}{\sqrt{3}},\frac{1}{\sqrt{3}},\frac{1}{\sqrt{3}}} \) or
\end{dispExample*}
@@ -329,8 +377,8 @@
%
% Use \refEnv{physicsproblem} and \refEnv{parts} and \refCom{problempart}
% for problems. For step-by-step mathematical solutions use
-% \refEnv{physicssolution}. Use \refEnv{glowscriptblock} to typeset
-% \href{https://\gsurl}{\GlowScript} programs. Use \refCom{vpythonfile} to
+% \refEnv{physicssolution}. Use \refEnv{webvpythonblock} to typeset
+% \href{https://\gsurl}{\WebVPython} programs. Use \refCom{vpythonfile} to
% typeset \href{https://\vpurl}{VPython} program files.
%
% \newpage
@@ -341,7 +389,7 @@
%\iffalse
%<*example>
%\fi
-\begin{dispListing*}{sidebyside=false,listing only}
+\begin{dispListing*}{sidebyside = false,listing only}
\usepackage[options]{mandi}
\end{dispListing*}
%\iffalse
@@ -354,7 +402,7 @@
\begin{docCommand}{mandiversion}{}
Typesets the current version and build date.
\end{docCommand}
-\begin{dispExample*}{sidebyside=false}
+\begin{dispExample*}{sidebyside = false}
The version is \mandiversion\ and is a stable build.
\end{dispExample*}
%\iffalse
@@ -391,7 +439,7 @@
%</example>
%\fi
%
-% \subsection{The \texttt{mandisetup} Command}
+% \subsection{The \texttt{\small mandisetup} Command}
%
%\iffalse
%<*example>
@@ -401,14 +449,14 @@
can be done in the preamble or inside the
|\begin{document}...\end{document}| environment.
\end{docCommand}
-\begin{dispListing*}{sidebyside=false,listing only}
+\begin{dispListing*}{sidebyside = false,listing only}
\mandisetup{units=base}
\end{dispListing*}
-\begin{dispListing*}{sidebyside=false,listing only}
+\begin{dispListing*}{sidebyside = false,listing only}
\mandisetup{preciseconstants}
\end{dispListing*}
-\begin{dispListing*}{sidebyside=false,listing only}
- \mandisetup{preciseconstants=false}
+\begin{dispListing*}{sidebyside = false,listing only}
+ \mandisetup{preciseconstants = false}
\end{dispListing*}
%\iffalse
%</example>
@@ -442,11 +490,11 @@
{%
doc new = 2021-02-24,%
doc name = momentumvector,%
- doc parameter = \marg{\ensuremath{c_1,\dots,c_n}},%
+ doc parameter = \marg{\( c_1,\dots,c_n \)},%
},%
{%
doc name = vectormomentum,%
- doc parameter = \marg{\ensuremath{c_1,\dots,c_n}},%
+ doc parameter = \marg{\( c_1,\dots,c_n \)},%
},%
}%
Command for momentum and its vector variants. The default units will depend
@@ -455,7 +503,7 @@
take more than three components. Note the other variants for the quantity's
value and units.
\end{docCommands}
-\begin{dispExample*}{lefthand ratio=0.60}
+\begin{dispExample*}{lefthand ratio = 0.60}
\( \momentum{5} \) \\
\( \momentumvalue{5} \) \\
\( \momentumbaseunits{5} \) \\
@@ -496,7 +544,7 @@
%\iffalse
%<*example>
%\fi
-\begin{docCommand}[doc new = 2021-02-16]{checkquantity}{\marg{name}}
+\begin{docCommand}[doc updated = 2022-01-27]{checkquantity}{\marg{name}}
Command to check and typeset the command, base units,
derived units, and alternate units of a defined physical
quantity.
@@ -527,11 +575,11 @@
{%
doc new = 2021-02-24,%
doc name = accelerationvector,%
- doc parameter = \marg{\ensuremath{c_1,\dots,c_n}},%
+ doc parameter = \marg{\( c_1,\dots,c_n \)},%
},%
{%
doc name = vectoracceleration,%
- doc parameter = \marg{\ensuremath{c_1,\dots,c_n}},%
+ doc parameter = \marg{\( c_1,\dots,c_n \)},%
},%
}%
\end{docCommands}
@@ -548,11 +596,11 @@
{%
doc new = 2021-02-24,%
doc name = angularaccelerationvector,%
- doc parameter = \marg{\ensuremath{c_1,\dots,c_n}},%
+ doc parameter = \marg{\( c_1,\dots,c_n \)},%
},%
{%
doc name = vectorangularacceleration,%
- doc parameter = \marg{\ensuremath{c_1,\dots,c_n}},%
+ doc parameter = \marg{\( c_1,\dots,c_n \)},%
},%
}%
\end{docCommands}
@@ -569,11 +617,11 @@
{%
doc new = 2021-02-24,%
doc name = angularimpulsevector,%
- doc parameter = \marg{\ensuremath{c_1,\dots,c_n}},%
+ doc parameter = \marg{\( c_1,\dots,c_n \)},%
},%
{%
doc name = vectorangularimpulse,%
- doc parameter = \marg{\ensuremath{c_1,\dots,c_n}},%
+ doc parameter = \marg{\( c_1,\dots,c_n \)},%
},%
}%
\end{docCommands}
@@ -587,11 +635,11 @@
{%
doc new = 2021-02-24,%
doc name = angularmomentumvector,%
- doc parameter = \marg{\ensuremath{c_1,\dots,c_n}},%
+ doc parameter = \marg{\( c_1,\dots,c_n \)},%
},%
{%
doc name = vectorangularmomentum,%
- doc parameter = \marg{\ensuremath{c_1,\dots,c_n}},%
+ doc parameter = \marg{\( c_1,\dots,c_n \)},%
},%
}%
\end{docCommands}
@@ -605,11 +653,11 @@
{%
doc new = 2021-02-24,%
doc name = angularvelocityvector,%
- doc parameter = \marg{\ensuremath{c_1,\dots,c_n}},%
+ doc parameter = \marg{\( c_1,\dots,c_n \)},%
},%
{%
doc name = vectorangularvelocity,%
- doc parameter = \marg{\ensuremath{c_1,\dots,c_n}},%
+ doc parameter = \marg{\( c_1,\dots,c_n \)},%
},%
}%
\end{docCommands}
@@ -638,11 +686,11 @@
{%
doc new = 2021-02-24,%
doc name = cmagneticfieldvector,%
- doc parameter = \marg{\ensuremath{c_1,\dots,c_n}},%
+ doc parameter = \marg{\( c_1,\dots,c_n \)},%
},%
{%
doc name = vectorcmagneticfield,%
- doc parameter = \marg{\ensuremath{c_1,\dots,c_n}},%
+ doc parameter = \marg{\( c_1,\dots,c_n \)},%
},%
}%
\end{docCommands}
@@ -668,11 +716,11 @@
{%
doc new = 2021-02-24,%
doc name = currentdensityvector,%
- doc parameter = \marg{\ensuremath{c_1,\dots,c_n}},%
+ doc parameter = \marg{\( c_1,\dots,c_n \)},%
},%
{%
doc name = vectorcurrentdensity,%
- doc parameter = \marg{\ensuremath{c_1,\dots,c_n}},%
+ doc parameter = \marg{\( c_1,\dots,c_n \)},%
},%
}%
\end{docCommands}
@@ -689,11 +737,11 @@
},%
{%
doc name = directionvector,%
- doc parameter = \marg{\ensuremath{c_1,\dots,c_n}},%
+ doc parameter = \marg{\( c_1,\dots,c_n \)},%
},%
{%
doc name = vectordirection,%
- doc parameter = \marg{\ensuremath{c_1,\dots,c_n}},%
+ doc parameter = \marg{\( c_1,\dots,c_n \)},%
},%
}%
\end{docCommands}
@@ -707,11 +755,11 @@
{%
doc new = 2021-02-24,%
doc name = displacementvector,%
- doc parameter = \marg{\ensuremath{c_1,\dots,c_n}},%
+ doc parameter = \marg{\( c_1,\dots,c_n \)},%
},%
{%
doc name = vectordisplacement,%
- doc parameter = \marg{\ensuremath{c_1,\dots,c_n}},%
+ doc parameter = \marg{\( c_1,\dots,c_n \)},%
},%
}%
\end{docCommands}
@@ -728,10 +776,10 @@
{%
doc new = 2021-02-24,%
doc name = electricdipolemomentvector,%
- doc parameter = \marg{\ensuremath{c_1,\dots,c_n}},%
+ doc parameter = \marg{\( c_1,\dots,c_n \)},%
},%
{ doc name = vectorelectricdipolemoment,%
- doc parameter = \marg{\ensuremath{c_1,\dots,c_n}},%
+ doc parameter = \marg{\( c_1,\dots,c_n \)},%
},%
}%
\end{docCommands}
@@ -745,11 +793,11 @@
{%
doc new = 2021-02-24,%
doc name = electricfieldvector,%
- doc parameter = \marg{\ensuremath{c_1,\dots,c_n}},%
+ doc parameter = \marg{\( c_1,\dots,c_n \)},%
},%
{%
doc name = vectorelectricfield,%
- doc parameter = \marg{\ensuremath{c_1,\dots,c_n}},%
+ doc parameter = \marg{\( c_1,\dots,c_n \)},%
},%
}%
\end{docCommands}
@@ -793,11 +841,11 @@
{%
doc new = 2021-02-24,%
doc name = energyfluxvector,%
- doc parameter = \marg{\ensuremath{c_1,\dots,c_n}},%
+ doc parameter = \marg{\( c_1,\dots,c_n \)},%
},%
{%
doc name = vectorenergyflux,%
- doc parameter = \marg{\ensuremath{c_1,\dots,c_n}},%
+ doc parameter = \marg{\( c_1,\dots,c_n \)},%
},%
}%
\end{docCommands}
@@ -814,11 +862,11 @@
{%
doc new = 2021-02-24,%
doc name = forcevector,%
- doc parameter = \marg{\ensuremath{c_1,\dots,c_n}},%
+ doc parameter = \marg{\( c_1,\dots,c_n \)},%
},%
{%
doc name = vectorforce,%
- doc parameter = \marg{\ensuremath{c_1,\dots,c_n}},%
+ doc parameter = \marg{\( c_1,\dots,c_n \)},%
},%
}%
\end{docCommands}
@@ -835,11 +883,11 @@
{%
doc new = 2021-02-24,%
doc name = gravitationalfieldvector,%
- doc parameter = \marg{\ensuremath{c_1,\dots,c_n}},%
+ doc parameter = \marg{\( c_1,\dots,c_n \)},%
},%
{%
doc name = vectorgravitationalfield,%
- doc parameter = \marg{\ensuremath{c_1,\dots,c_n}},%
+ doc parameter = \marg{\( c_1,\dots,c_n \)},%
},%
}%
\end{docCommands}
@@ -859,11 +907,11 @@
{%
doc new = 2021-02-24,%
doc name = impulsevector,%
- doc parameter = \marg{\ensuremath{c_1,\dots,c_n}},%
+ doc parameter = \marg{\( c_1,\dots,c_n \)},%
},%
{%
doc name = vectorimpulse,%
- doc parameter = \marg{\ensuremath{c_1,\dots,c_n}},%
+ doc parameter = \marg{\( c_1,\dots,c_n \)},%
},%
}%
\end{docCommands}
@@ -880,6 +928,9 @@
\begin{docCommand}{linearmassdensity}{\marg{magnitude}}
\end{docCommand}
\checkquantity{linearmassdensity}
+\begin{docCommand}[doc new = 2022-01-27]{lorentzfactor}{\marg{magnitude}}
+\end{docCommand}
+\checkquantity{lorentzfactor}
\begin{docCommand}[doc updated = 2021-05-02]{luminousintensity}{\marg{magnitude}}
\end{docCommand}
\checkquantity{luminousintensity}
@@ -895,11 +946,11 @@
{%
doc new = 2021-02-24,%
doc name = magneticdipolemomentvector,%
- doc parameter = \marg{\ensuremath{c_1,\dots,c_n}},%
+ doc parameter = \marg{\( c_1,\dots,c_n \)},%
},%
{%
doc name = vectormagneticdipolemoment,%
- doc parameter = \marg{\ensuremath{c_1,\dots,c_n}},%
+ doc parameter = \marg{\( c_1,\dots,c_n \)},%
},%
}%
\end{docCommands}
@@ -913,11 +964,11 @@
{%
doc new = 2021-02-24,%
doc name = magneticfieldvector,%
- doc parameter = \marg{\ensuremath{c_1,\dots,c_n}},%
+ doc parameter = \marg{\( c_1,\dots,c_n \)},%
},%
{%
doc name = vectormagneticfield,%
- doc parameter = \marg{\ensuremath{c_1,\dots,c_n}},%
+ doc parameter = \marg{\( c_1,\dots,c_n \)},%
},%
}%
\end{docCommands}
@@ -945,12 +996,12 @@
doc new = 2021-02-24,%
doc name = momentumvector,%
doc label = momentumvectordemo,%
- doc parameter = \marg{\ensuremath{c_1,\dots,c_n}},%
+ doc parameter = \marg{\( c_1,\dots,c_n \)},%
},%
{%
doc name = vectormomentum,%
doc label = vectormomentumdemo,%
- doc parameter = \marg{\ensuremath{c_1,\dots,c_n}} },%
+ doc parameter = \marg{\( c_1,\dots,c_n \)} },%
}%
\end{docCommands}
\checkquantity{momentum}
@@ -963,11 +1014,11 @@
{%
doc new = 2021-02-24,%
doc name = momentumfluxvector,%
- doc parameter = \marg{\ensuremath{c_1,\dots,c_n}},%
+ doc parameter = \marg{\( c_1,\dots,c_n \)},%
},%
{%
doc name = vectormomentumflux,%
- doc parameter = \marg{\ensuremath{c_1,\dots,c_n}},%
+ doc parameter = \marg{\( c_1,\dots,c_n \)},%
},%
}%
\end{docCommands}
@@ -999,11 +1050,11 @@
{%
doc new = 2021-02-24,%
doc name = poyntingvector,%
- doc parameter = \marg{\ensuremath{c_1,\dots,c_n}},%
+ doc parameter = \marg{\( c_1,\dots,c_n \)},%
},%
{%
doc name = vectorpoynting,%
- doc parameter = \marg{\ensuremath{c_1,\dots,c_n}},%
+ doc parameter = \marg{\( c_1,\dots,c_n \)},%
},%
}%
\end{docCommands}
@@ -1053,11 +1104,11 @@
{%
doc new = 2021-02-24,%
doc name = torquevector,%
- doc parameter = \marg{\ensuremath{c_1,\dots,c_n}},%
+ doc parameter = \marg{\( c_1,\dots,c_n \)},%
},%
{%
doc name = vectortorque,%
- doc parameter = \marg{\ensuremath{c_1,\dots,c_n}},%
+ doc parameter = \marg{\( c_1,\dots,c_n \)},%
},%
}%
\end{docCommands}
@@ -1071,12 +1122,17 @@
{%
doc new = 2021-02-24,%
doc name = velocityvector,%
- doc parameter = \marg{\ensuremath{c_1,\dots,c_n}},%
+ doc parameter = \marg{\( c_1,\dots,c_n \)},%
},%
{%
doc name = vectorvelocity,%
- doc parameter = \marg{\ensuremath{c_1,\dots,c_n}},%
+ doc parameter = \marg{\( c_1,\dots,c_n \)},%
},%
+ }%
+\end{docCommands}
+\checkquantity{velocity}
+\begin{docCommands}
+ {%
{%
doc name = velocityc,%
doc parameter = \marg{magnitude},%
@@ -1084,15 +1140,14 @@
{%
doc new = 2021-02-24,%
doc name = velocitycvector,%
- doc parameter = \marg{\ensuremath{c_1,\dots,c_n}},%
+ doc parameter = \marg{\( c_1,\dots,c_n \)},%
},%
{%
doc name = vectorvelocityc,%
- doc parameter = \marg{\ensuremath{c_1,\dots,c_n}},%
+ doc parameter = \marg{\( c_1,\dots,c_n \)},%
},%
}%
\end{docCommands}
-\checkquantity{velocity}
\checkquantity{velocityc}
\begin{docCommand}{volume}{\marg{magnitude}}
\end{docCommand}
@@ -1115,11 +1170,11 @@
{%
doc new = 2021-02-24,%
doc name = wavenumbervector,%
- doc parameter = \marg{\ensuremath{c_1,\dots,c_n}},%
+ doc parameter = \marg{\( c_1,\dots,c_n \)},%
},%
{%
doc name = vectorwavenumber,%
- doc parameter = \marg{\ensuremath{c_1,\dots,c_n}},%
+ doc parameter = \marg{\( c_1,\dots,c_n \)},%
},%
}%
\end{docCommands}
@@ -1148,7 +1203,7 @@
doc name = newscalarquantity,%
},%
{%
- doc new=2021-02-21,%
+ doc new = 2021-02-21,%
doc name = renewscalarquantity,%
},%
}%
@@ -1175,7 +1230,7 @@
doc name = newvectorquantity,%
},%
{%
- doc new=2021-02-21,%
+ doc new = 2021-02-21,%
doc name = renewvectorquantity,%
},%
}%
@@ -1349,10 +1404,10 @@
%\iffalse
%<*example>
%\fi
-\begin{docCommand}[doc updated = 2021-02-26]{checkconstant}{\marg{name}}
- Command to check and typeset the constant's name, base units, derived
- units, alternate units, mathematical symbol, approximate value, and
- precise value.
+\begin{docCommand}[doc updated = 2022-01-27]{checkconstant}{\marg{name}}
+ Command to check and typeset the constant's name, mathematical symbol,
+ approximate value, precise value, base units, derived units, and
+ alternate units.
\end{docCommand}
%\iffalse
%</example>
@@ -1360,14 +1415,14 @@
%
% \subsubsection{Predefined Physical Constants}
%
-% Every other defined physical constant can be treated similarly. Just
-% replace |oofpez| with the constant's name. Unfortunately, there is no
-% universal agreement on the names of every constant so don't fret if
-% the names used here vary from other sources. Here are all the physical
-% constants, with all their units, defined in \mandi.
-% The constants \refCom{coulombconstant} and \refCom{biotsavartconstant} are
-% defined as semantic aliases for, respectively, \refCom{oofpez} and
-% \refCom{mzofp}.
+% Every other defined physical constant can be treated similarly to
+% \refCom{oofpez}. Just replace |oofpez| with the constant's name.
+% Unfortunately, there is no universal agreement on the names of every
+% constant so don't fret if the names used here vary from other sources.
+% Here are all the physical constants, with all their units, defined in
+% \mandi. The constants \refCom{coulombconstant} and
+% \refCom{biotsavartconstant} are defined as semantic aliases for,
+% respectively, \refCom{oofpez} and \refCom{mzofp}.
%
%\iffalse
%<*example>
@@ -1504,7 +1559,7 @@
doc name = newphysicalconstant,%
},%
{%
- doc new=2021-02-21,%
+ doc new = 2021-02-21,%
doc name = renewphysicalconstant,%
},%
}%
@@ -1820,6 +1875,19 @@
%\iffalse
%<*example>
%\fi
+\begin{docCommand}[doc new = 2022-01-27,]{hbar}{}%
+ A better glyph for Planck's constant over \( 2\pi \).
+\end{docCommand}
+\begin{dispExample}
+ \( \hbar \)
+\end{dispExample}
+%\iffalse
+%</example>
+%\fi
+%
+%\iffalse
+%<*example>
+%\fi
\begin{docCommands}[%
doc parameter = \marg{number},%
]%
@@ -1848,22 +1916,23 @@
%\iffalse
%<*example>
%\fi
-\begin{docCommand}{mivector}{%
- \oarg{delimiter}\marg{\ensuremath{c_1,\dots,c_n}}\oarg{units}
+\begin{docCommand}[doc updated = 2022-01-27]{mivector}{%
+ \oarg{delimiter}\marg{\( c_1,\dots,c_n \)}\oarg{units}
}%
Typesets a vector as either numeric or symbolic components with an
- optional unit (for numerical components only). There can be more
- than three components. The delimiter used in the list of components
- can be specified; the default is a comma. The notation mirrors that of
+ optional unit (for numerical components only). There must be more
+ than one component, and there can be more than three components.
+ The delimiter used in the list of components can be specified;
+ the default is a comma. The notation mirrors that of
\emph{Matter \& Interactions}.
\end{docCommand}
-\begin{dispExample*}{lefthand ratio=0.65}
- \( \mivector{p_0,p_1,p_2,p_3} \) \\
- \( \mivector{\gamma m v_x,\gamma m v_y,\gamma m v_z} \) \\
- \( \mivector{\frac{Q_1Q_2}{x^2},0,0} \) \\
- \( \mivector{-1,0,0} \) \\
- \( \mivector{-1,0,0}[\velocityonlyderivedunits] \) \\
- \( \mivector{-1,0,0}[\meter\per\second] \) \\
+\begin{dispExample*}{lefthand ratio = 0.70}
+ \( \mivector{p_0,p_1,p_2,p_3} \) \\
+ \( \mivector{\gamma mc,\gamma mv_x,\gamma mv_y,\gamma mv_z} \) \\
+ \( \mivector{\frac{Q_1Q_2}{x^2},0,0} \) \\
+ \( \mivector{-1,0,0} \) \\
+ \( \mivector{-1,0,0}[\velocityonlyderivedunits] \) \\
+ \( \mivector{-1,0,0}[\meter\per\second] \) \\
\( \velocity{\mivector{-1,0,0}} \)
\end{dispExample*}
%\iffalse
@@ -1883,11 +1952,13 @@
% |\makeatother|. This simplifies defining internal commands (with |@|
% in the name) that are not for the user to know about.
%
+% \changes{v3.1.0}{2022-01-27}
+% {\linktoplace{sec:mandipkg}{mandi} Code formatted for better readability}
% \begin{macrocode}
-\def\mandi@version{3.0.0}
-\def\mandi@date{2021-08-22}
+\def\mandi@version{3.1.0}
+\def\mandi@date{2022-01-27}
\NeedsTeXFormat{LaTeX2e}[2020-02-02]
-\DeclareRelease{v3.0.0}{2021-08-22}{mandi.sty}
+\DeclareRelease{v3.1.0}{2022-01-27}{mandi.sty}
\DeclareCurrentRelease{v\mandi@version}{\mandi@date}
\ProvidesPackage{mandi}
[\mandi@date\space v\mandi@version\space Macros for physical quantities]
@@ -1902,16 +1973,24 @@
% Load third party packages, documenting why each one is needed.
%
% \begin{macrocode}
-\RequirePackage{pgfopts} % needed for key-value interface
-\RequirePackage{array} % needed for \checkquantity and \checkconstant
-\RequirePackage{iftex} % needed for requiring LuaLaTeX
-\RequirePackage{unicode-math} % needed for Unicode support
-\RequireLuaTeX % require this engine
+\RequirePackage{pgfopts} % needed for key-value interface
+\RequirePackage{array} % needed for \checkquantity and \checkconstant
+\RequirePackage{iftex} % needed for requiring LuaLaTeX
+\RequirePackage{unicode-math} % needed for Unicode support
+% \end{macrocode}
+%
+% \changes{v3.1.0}{2022-01-27}
+% {\linktoplace{sec:mandipkg}{mandi} \pkg{xparse} is loaded for older formats}
+% \begin{macrocode}
+\IfFormatAtLeastTF {2020-10-01} % load xparse if necessary
+ {}%
+ {\RequirePackage{xparse}}%
+\RequireLuaTeX % require this engine
% \end{macrocode}
%
% Parts of the unit engine have been rewritten with
% \href{https://www.ctan.org/pkg/xparse}{\pkg{xparse}} for both clarity
-% and power. Note that \pkg{xparse} is now part of the \LaTeX\ kernel.
+% and power. Note that \pkg{xparse} is now part of the \LaTeXe\ kernel.
% Other parts have been rewriten in
% \href{https://www.ctan.org/pkg/expl}{\pkg{expl}} with a look to the
% future.
@@ -1981,6 +2060,8 @@
% First, define the keys. The key handlers require certain commands defined
% by the unit engine.
%
+% \changes{v3.1.0}{2022-01-27}
+% {\linktoplace{sec:mandipkg}{mandi} Unknown package options handled safely}
% \begin{macrocode}
\newif\ifusingpreciseconstants
\pgfkeys{%
@@ -1995,6 +2076,10 @@
units/alternate/.style={/mandi/options/buffered@units=alternate},%
units/base/.style={/mandi/options/buffered@units=base},%
units/derived/.style={/mandi/options/buffered@units=derived},%
+ .unknown/.code={%
+ \typeout{}%
+ \typeout{mandi: You used unknown option '\pgfkeyscurrentname'.}%
+ },%
}%
% \end{macrocode}
%
@@ -2037,14 +2122,16 @@
% when called with new options. A new banner is written to the console.
%
% \begin{macrocode}
-\NewDocumentCommand{\mandisetup}{ m }{%
- \IfValueT{#1}{%
- \pgfqkeys{/mandi/options}{#1}
- \typeout{}%
- \typeout{mandi: mandisetup options...}
- \mandi@do@setup
+\NewDocumentCommand{\mandisetup}{ m }%
+ {%
+ \IfValueT{#1}%
+ {%
+ \pgfqkeys{/mandi/options}{#1}
+ \typeout{}%
+ \typeout{mandi: mandisetup options...}
+ \mandi@do@setup
+ }%
}%
-}%
% \end{macrocode}
%
% Define units and related constructs to be used with the unit engine.
@@ -2053,6 +2140,8 @@
% \href{https://ctan.org/pkg/siunits}{\pkg{SIunits}} package.
% We make use of |\symup{...}| from the \pkg{unicode-math} package.
%
+% \changes{v3.1.0}{2022-01-27}
+% {\linktoplace{sec:mandipkg}{mandi} Added a negative space to \refCom{lightspeed}}
% \begin{macrocode}
\NewDocumentCommand{\per}{}{/}
\NewDocumentCommand{\usk}{}{\cdot}
@@ -2072,7 +2161,7 @@
\NewDocumentCommand{\kev}{}{\kiloelectronvolt}
\NewDocumentCommand{\kiloelectronvolt}{}{\symup{keV}}
\NewDocumentCommand{\kilogram}{}{\symup{kg}}
-\NewDocumentCommand{\lightspeed}{}{\symup{c}}
+\NewDocumentCommand{\lightspeed}{}{\!\symup{c}}
\NewDocumentCommand{\megaelectronvolt}{}{\symup{MeV}}
\NewDocumentCommand{\meter}{}{\symup{m}}
\NewDocumentCommand{\metre}{}{\meter}
@@ -2102,23 +2191,25 @@
\NewDocumentCommand{\xtento}{ m }{\times\tento{#1}}
% \end{macrocode}
%
+% \changes{v3.1.0}{2022-01-27}
+% {\linktoplace{sec:mandipkg}{mandi} \LaTeX3 code now conforms to formatting standards}
% \begin{macrocode}
\ExplSyntaxOn
-\cs_new:Npn \mandi_newscalarquantity #1#2#3#4
-{%
- \cs_new:cpn {#1} ##1 {\unit{##1}{\mandi@selectunits{#2}{#3}{#4}}}%
- \cs_new:cpn {#1value} ##1 {##1}%
- \cs_new:cpn {#1baseunits} ##1 {\unit{##1}{\mandi@selectbaseunits{#2}{#3}{#4}}}%
- \cs_new:cpn {#1derivedunits} ##1 {\unit{##1}{\mandi@selectderivedunits{#2}{#3}{#4}}}%
- \cs_new:cpn {#1alternateunits} ##1 {\unit{##1}{\mandi@selectalternateunits{#2}{#3}{#4}}}%
- \cs_new:cpn {#1onlybaseunits} {\mandi@selectbaseunits{#2}{#3}{#4}}%
- \cs_new:cpn {#1onlyderivedunits} {\mandi@selectderivedunits{#2}{#3}{#4}}%
- \cs_new:cpn {#1onlyalternateunits} {\mandi@selectalternateunits{#2}{#3}{#4}}%
-}%
-\NewDocumentCommand{\newscalarquantity}{ m m O{#2} O{#2} }%
-{%
- \mandi_newscalarquantity { #1 }{ #2 }{ #3 }{ #4 }%
-}%
+\cs_new:Npn \__mandi_newscalarquantity:nnnn #1#2#3#4
+ {
+ \cs_new:cpn {#1} ##1 {\unit{##1}{\mandi@selectunits{#2}{#3}{#4}}}
+ \cs_new:cpn {#1value} ##1 {##1}
+ \cs_new:cpn {#1baseunits} ##1 {\unit{##1}{\mandi@selectbaseunits{#2}{#3}{#4}}}
+ \cs_new:cpn {#1derivedunits} ##1 {\unit{##1}{\mandi@selectderivedunits{#2}{#3}{#4}}}
+ \cs_new:cpn {#1alternateunits} ##1 {\unit{##1}{\mandi@selectalternateunits{#2}{#3}{#4}}}
+ \cs_new:cpn {#1onlybaseunits} {\mandi@selectbaseunits{#2}{#3}{#4}}
+ \cs_new:cpn {#1onlyderivedunits} {\mandi@selectderivedunits{#2}{#3}{#4}}
+ \cs_new:cpn {#1onlyalternateunits} {\mandi@selectalternateunits{#2}{#3}{#4}}
+ }
+\NewDocumentCommand{\newscalarquantity}{ m m O{#2} O{#2} }
+ {
+ \__mandi_newscalarquantity:nnnn { #1 }{ #2 }{ #3 }{ #4 }
+ }
\ExplSyntaxOff
% \end{macrocode}
%
@@ -2126,21 +2217,21 @@
%
% \begin{macrocode}
\ExplSyntaxOn
-\cs_new:Npn \mandi_renewscalarquantity #1#2#3#4
-{%
- \cs_set:cpn {#1} ##1 {\unit{##1}{\mandi@selectunits{#2}{#3}{#4}}}%
- \cs_set:cpn {#1value} ##1 {##1}%
- \cs_set:cpn {#1baseunits} ##1 {\unit{##1}{\mandi@selectbaseunits{#2}{#3}{#4}}}%
- \cs_set:cpn {#1derivedunits} ##1 {\unit{##1}{\mandi@selectderivedunits{#2}{#3}{#4}}}%
- \cs_set:cpn {#1alternateunits} ##1 {\unit{##1}{\mandi@selectalternateunits{#2}{#3}{#4}}}%
- \cs_set:cpn {#1onlybaseunits} {\mandi@selectbaseunits{#2}{#3}{#4}}%
- \cs_set:cpn {#1onlyderivedunits} {\mandi@selectderivedunits{#2}{#3}{#4}}%
- \cs_set:cpn {#1onlyalternateunits} {\mandi@selectalternateunits{#2}{#3}{#4}}%
-}%
-\NewDocumentCommand{\renewscalarquantity}{ m m O{#2} O{#2} }%
-{%
- \mandi_renewscalarquantity { #1 }{ #2 }{ #3 }{ #4 }%
-}%
+\cs_new:Npn \__mandi_renewscalarquantity:nnnn #1#2#3#4
+ {
+ \cs_set:cpn {#1} ##1 {\unit{##1}{\mandi@selectunits{#2}{#3}{#4}}}
+ \cs_set:cpn {#1value} ##1 {##1}
+ \cs_set:cpn {#1baseunits} ##1 {\unit{##1}{\mandi@selectbaseunits{#2}{#3}{#4}}}
+ \cs_set:cpn {#1derivedunits} ##1 {\unit{##1}{\mandi@selectderivedunits{#2}{#3}{#4}}}
+ \cs_set:cpn {#1alternateunits} ##1 {\unit{##1}{\mandi@selectalternateunits{#2}{#3}{#4}}}
+ \cs_set:cpn {#1onlybaseunits} {\mandi@selectbaseunits{#2}{#3}{#4}}
+ \cs_set:cpn {#1onlyderivedunits} {\mandi@selectderivedunits{#2}{#3}{#4}}
+ \cs_set:cpn {#1onlyalternateunits} {\mandi@selectalternateunits{#2}{#3}{#4}}
+ }
+\NewDocumentCommand{\renewscalarquantity}{ m m O{#2} O{#2} }
+ {
+ \__mandi_renewscalarquantity:nnnn { #1 }{ #2 }{ #3 }{ #4 }
+ }
\ExplSyntaxOff
% \end{macrocode}
%
@@ -2148,30 +2239,30 @@
%
% \begin{macrocode}
\ExplSyntaxOn
-\cs_new:Npn \mandi_newvectorquantity #1#2#3#4
-{%
- \mandi_newscalarquantity { #1 }{ #2 }{ #3 }{ #4 }%
- \cs_new:cpn {vector#1} ##1 {\unit{\mivector{##1}}{\mandi@selectunits{#2}{#3}{#4}}}%
- \cs_new:cpn {#1vector} ##1 {\unit{\mivector{##1}}{\mandi@selectunits{#2}{#3}{#4}}}%
- \cs_new:cpn {vector#1value} ##1 {\mivector{##1}}%
- \cs_new:cpn {#1vectorvalue} ##1 {\mivector{##1}}%
- \cs_new:cpn {vector#1baseunits} ##1 {\unit{\mivector{##1}}{\mandi@selectbaseunits{#2}{#3}{#4}}}%
- \cs_new:cpn {#1vectorbaseunits} ##1 {\unit{\mivector{##1}}{\mandi@selectbaseunits{#2}{#3}{#4}}}%
- \cs_new:cpn {vector#1derivedunits} ##1 {\unit{\mivector{##1}}{\mandi@selectderivedunits{#2}{#3}{#4}}}%
- \cs_new:cpn {#1vectorderivedunits} ##1 {\unit{\mivector{##1}}{\mandi@selectderivedunits{#2}{#3}{#4}}}%
- \cs_new:cpn {vector#1alternateunits} ##1 {\unit{\mivector{##1}}{\mandi@selectalternateunits{#2}{#3}{#4}}}%
- \cs_new:cpn {#1vectoralternateunits} ##1 {\unit{\mivector{##1}}{\mandi@selectalternateunits{#2}{#3}{#4}}}%
- \cs_new:cpn {vector#1onlybaseunits} {\mandi@selectbaseunits{#2}{#3}{#4}}%
- \cs_new:cpn {#1vectoronlybaseunits} {\mandi@selectbaseunits{#2}{#3}{#4}}%
- \cs_new:cpn {vector#1onlyderivedunits} {\mandi@selectderivedunits{#2}{#3}{#4}}%
- \cs_new:cpn {#1vectoronlyderivedunits} {\mandi@selectderivedunits{#2}{#3}{#4}}%
- \cs_new:cpn {vector#1onlyalternateunits} {\mandi@selectalternateunits{#2}{#3}{#4}}%
- \cs_new:cpn {#1vectoronlyalternateunits} {\mandi@selectalternateunits{#2}{#3}{#4}}%
-}%
-\NewDocumentCommand{\newvectorquantity}{ m m O{#2} O{#2} }%
-{%
- \mandi_newvectorquantity { #1 }{ #2 }{ #3 }{ #4 }%
-}%
+\cs_new:Npn \__mandi_newvectorquantity:nnnn #1#2#3#4
+ {
+ \__mandi_newscalarquantity:nnnn { #1 }{ #2 }{ #3 }{ #4 }
+ \cs_new:cpn {vector#1} ##1 {\unit{\mivector{##1}}{\mandi@selectunits{#2}{#3}{#4}}}
+ \cs_new:cpn {#1vector} ##1 {\unit{\mivector{##1}}{\mandi@selectunits{#2}{#3}{#4}}}
+ \cs_new:cpn {vector#1value} ##1 {\mivector{##1}}
+ \cs_new:cpn {#1vectorvalue} ##1 {\mivector{##1}}
+ \cs_new:cpn {vector#1baseunits} ##1 {\unit{\mivector{##1}}{\mandi@selectbaseunits{#2}{#3}{#4}}}
+ \cs_new:cpn {#1vectorbaseunits} ##1 {\unit{\mivector{##1}}{\mandi@selectbaseunits{#2}{#3}{#4}}}
+ \cs_new:cpn {vector#1derivedunits} ##1 {\unit{\mivector{##1}}{\mandi@selectderivedunits{#2}{#3}{#4}}}
+ \cs_new:cpn {#1vectorderivedunits} ##1 {\unit{\mivector{##1}}{\mandi@selectderivedunits{#2}{#3}{#4}}}
+ \cs_new:cpn {vector#1alternateunits} ##1 {\unit{\mivector{##1}}{\mandi@selectalternateunits{#2}{#3}{#4}}}
+ \cs_new:cpn {#1vectoralternateunits} ##1 {\unit{\mivector{##1}}{\mandi@selectalternateunits{#2}{#3}{#4}}}
+ \cs_new:cpn {vector#1onlybaseunits} {\mandi@selectbaseunits{#2}{#3}{#4}}
+ \cs_new:cpn {#1vectoronlybaseunits} {\mandi@selectbaseunits{#2}{#3}{#4}}
+ \cs_new:cpn {vector#1onlyderivedunits} {\mandi@selectderivedunits{#2}{#3}{#4}}
+ \cs_new:cpn {#1vectoronlyderivedunits} {\mandi@selectderivedunits{#2}{#3}{#4}}
+ \cs_new:cpn {vector#1onlyalternateunits} {\mandi@selectalternateunits{#2}{#3}{#4}}
+ \cs_new:cpn {#1vectoronlyalternateunits} {\mandi@selectalternateunits{#2}{#3}{#4}}
+ }
+\NewDocumentCommand{\newvectorquantity}{ m m O{#2} O{#2} }
+ {
+ \__mandi_newvectorquantity:nnnn { #1 }{ #2 }{ #3 }{ #4 }
+ }
\ExplSyntaxOff
% \end{macrocode}
%
@@ -2179,30 +2270,30 @@
%
% \begin{macrocode}
\ExplSyntaxOn
-\cs_new:Npn \mandi_renewvectorquantity #1#2#3#4
-{%
- \mandi_renewscalarquantity { #1 }{ #2 }{ #3 }{ #4 }%
- \cs_set:cpn {vector#1} ##1 {\unit{\mivector{##1}}{\mandi@selectunits{#2}{#3}{#4}}}%
- \cs_set:cpn {#1vector} ##1 {\unit{\mivector{##1}}{\mandi@selectunits{#2}{#3}{#4}}}%
- \cs_set:cpn {vector#1value} ##1 {\mivector{##1}}%
- \cs_set:cpn {#1vectorvalue} ##1 {\mivector{##1}}%
- \cs_set:cpn {vector#1baseunits} ##1 {\unit{\mivector{##1}}{\mandi@selectbaseunits{#2}{#3}{#4}}}%
- \cs_set:cpn {#1vectorbaseunits} ##1 {\unit{\mivector{##1}}{\mandi@selectbaseunits{#2}{#3}{#4}}}%
- \cs_set:cpn {vector#1derivedunits} ##1 {\unit{\mivector{##1}}{\mandi@selectderivedunits{#2}{#3}{#4}}}%
- \cs_set:cpn {#1vectorderivedunits} ##1 {\unit{\mivector{##1}}{\mandi@selectderivedunits{#2}{#3}{#4}}}%
- \cs_set:cpn {vector#1alternateunits} ##1 {\unit{\mivector{##1}}{\mandi@selectalternateunits{#2}{#3}{#4}}}%
- \cs_set:cpn {#1vectoralternateunits} ##1 {\unit{\mivector{##1}}{\mandi@selectalternateunits{#2}{#3}{#4}}}%
- \cs_set:cpn {vector#1onlybaseunits} {\mandi@selectbaseunits{#2}{#3}{#4}}%
- \cs_set:cpn {#1vectoronlybaseunits} {\mandi@selectbaseunits{#2}{#3}{#4}}%
- \cs_set:cpn {vector#1onlyderivedunits} {\mandi@selectderivedunits{#2}{#3}{#4}}%
- \cs_set:cpn {#1vectoronlyderivedunits} {\mandi@selectderivedunits{#2}{#3}{#4}}%
- \cs_set:cpn {vector#1onlyalternateunits} {\mandi@selectalternateunits{#2}{#3}{#4}}%
- \cs_set:cpn {#1vectoronlyalternateunits} {\mandi@selectalternateunits{#2}{#3}{#4}}%
-}%
-\NewDocumentCommand{\renewvectorquantity}{ m m O{#2} O{#2} }%
-{%
- \mandi_renewvectorquantity { #1 }{ #2 }{ #3 }{ #4 }%
-}%
+\cs_new:Npn \__mandi_renewvectorquantity:nnnn #1#2#3#4
+ {
+ \__mandi_renewscalarquantity:nnnn { #1 }{ #2 }{ #3 }{ #4 }
+ \cs_set:cpn {vector#1} ##1 {\unit{\mivector{##1}}{\mandi@selectunits{#2}{#3}{#4}}}
+ \cs_set:cpn {#1vector} ##1 {\unit{\mivector{##1}}{\mandi@selectunits{#2}{#3}{#4}}}
+ \cs_set:cpn {vector#1value} ##1 {\mivector{##1}}
+ \cs_set:cpn {#1vectorvalue} ##1 {\mivector{##1}}
+ \cs_set:cpn {vector#1baseunits} ##1 {\unit{\mivector{##1}}{\mandi@selectbaseunits{#2}{#3}{#4}}}
+ \cs_set:cpn {#1vectorbaseunits} ##1 {\unit{\mivector{##1}}{\mandi@selectbaseunits{#2}{#3}{#4}}}
+ \cs_set:cpn {vector#1derivedunits} ##1 {\unit{\mivector{##1}}{\mandi@selectderivedunits{#2}{#3}{#4}}}
+ \cs_set:cpn {#1vectorderivedunits} ##1 {\unit{\mivector{##1}}{\mandi@selectderivedunits{#2}{#3}{#4}}}
+ \cs_set:cpn {vector#1alternateunits} ##1 {\unit{\mivector{##1}}{\mandi@selectalternateunits{#2}{#3}{#4}}}
+ \cs_set:cpn {#1vectoralternateunits} ##1 {\unit{\mivector{##1}}{\mandi@selectalternateunits{#2}{#3}{#4}}}
+ \cs_set:cpn {vector#1onlybaseunits} {\mandi@selectbaseunits{#2}{#3}{#4}}
+ \cs_set:cpn {#1vectoronlybaseunits} {\mandi@selectbaseunits{#2}{#3}{#4}}
+ \cs_set:cpn {vector#1onlyderivedunits} {\mandi@selectderivedunits{#2}{#3}{#4}}
+ \cs_set:cpn {#1vectoronlyderivedunits} {\mandi@selectderivedunits{#2}{#3}{#4}}
+ \cs_set:cpn {vector#1onlyalternateunits} {\mandi@selectalternateunits{#2}{#3}{#4}}
+ \cs_set:cpn {#1vectoronlyalternateunits} {\mandi@selectalternateunits{#2}{#3}{#4}}
+ }
+\NewDocumentCommand{\renewvectorquantity}{ m m O{#2} O{#2} }
+ {
+ \__mandi_renewvectorquantity:nnnn { #1 }{ #2 }{ #3 }{ #4 }
+ }
\ExplSyntaxOff
% \end{macrocode}
%
@@ -2210,26 +2301,26 @@
%
% \begin{macrocode}
\ExplSyntaxOn
-\cs_new:Npn \mandi_newphysicalconstant #1#2#3#4#5#6#7
-{%
- \cs_new:cpn {#1} {\unit{\mandi@selectprecision{#3}{#4}}{\mandi@selectunits{#5}{#6}{#7}}}%
- \cs_new:cpn {#1mathsymbol} {#2}%
- \cs_new:cpn {#1approximatevalue} {#3}%
- \cs_new:cpn {#1precisevalue} {#4}%
- \cs_new:cpn {#1baseunits}
- {\unit{\mandi@selectprecision{#3}{#4}}{\mandi@selectbaseunits{#5}{#6}{#7}}}%
- \cs_new:cpn {#1derivedunits}
- {\unit{\mandi@selectprecision{#3}{#4}}{\mandi@selectderivedunits{#5}{#6}{#7}}}%
- \cs_new:cpn {#1alternateunits}
- {\unit{\mandi@selectprecision{#3}{#4}}{\mandi@selectalternateunits{#5}{#6}{#7}}}%
- \cs_new:cpn {#1onlybaseunits} {\mandi@selectbaseunits{#5}{#6}{#7}}%
- \cs_new:cpn {#1onlyderivedunits} {\mandi@selectderivedunits{#5}{#6}{#7}}%
- \cs_new:cpn {#1onlyalternateunits} {\mandi@selectalternateunits{#5}{#6}{#7}}%
-}%
-\NewDocumentCommand{\newphysicalconstant}{ m m m m m O{#5} O{#5} }%
-{%
- \mandi_newphysicalconstant { #1 }{ #2 }{ #3 }{ #4 }{ #5 }{ #6 }{ #7 }%
-}%
+\cs_new:Npn \__mandi_newphysicalconstant:nnnnnnn #1#2#3#4#5#6#7
+ {
+ \cs_new:cpn {#1} {\unit{\mandi@selectprecision{#3}{#4}}{\mandi@selectunits{#5}{#6}{#7}}}
+ \cs_new:cpn {#1mathsymbol} {#2}
+ \cs_new:cpn {#1approximatevalue} {#3}
+ \cs_new:cpn {#1precisevalue} {#4}
+ \cs_new:cpn {#1baseunits}
+ {\unit{\mandi@selectprecision{#3}{#4}}{\mandi@selectbaseunits{#5}{#6}{#7}}}
+ \cs_new:cpn {#1derivedunits}
+ {\unit{\mandi@selectprecision{#3}{#4}}{\mandi@selectderivedunits{#5}{#6}{#7}}}
+ \cs_new:cpn {#1alternateunits}
+ {\unit{\mandi@selectprecision{#3}{#4}}{\mandi@selectalternateunits{#5}{#6}{#7}}}
+ \cs_new:cpn {#1onlybaseunits} {\mandi@selectbaseunits{#5}{#6}{#7}}
+ \cs_new:cpn {#1onlyderivedunits} {\mandi@selectderivedunits{#5}{#6}{#7}}
+ \cs_new:cpn {#1onlyalternateunits} {\mandi@selectalternateunits{#5}{#6}{#7}}
+ }
+\NewDocumentCommand{\newphysicalconstant}{ m m m m m O{#5} O{#5} }
+ {
+ \__mandi_newphysicalconstant:nnnnnnn { #1 }{ #2 }{ #3 }{ #4 }{ #5 }{ #6 }{ #7 }
+ }
\ExplSyntaxOff
% \end{macrocode}
%
@@ -2237,26 +2328,26 @@
%
% \begin{macrocode}
\ExplSyntaxOn
-\cs_new:Npn \mandi_renewphysicalconstant #1#2#3#4#5#6#7
-{%
- \cs_set:cpn {#1} {\unit{\mandi@selectprecision{#3}{#4}}{\mandi@selectunits{#5}{#6}{#7}}}%
- \cs_set:cpn {#1mathsymbol} {#2}%
- \cs_set:cpn {#1approximatevalue} {#3}%
- \cs_set:cpn {#1precisevalue} {#4}%
- \cs_set:cpn {#1baseunits}
- {\unit{\mandi@selectprecision{#3}{#4}}{\mandi@selectbaseunits{#5}{#6}{#7}}}%
- \cs_set:cpn {#1derivedunits}
- {\unit{\mandi@selectprecision{#3}{#4}}{\mandi@selectderivedunits{#5}{#6}{#7}}}%
- \cs_set:cpn {#1alternateunits}
- {\unit{\mandi@selectprecision{#3}{#4}}{\mandi@selectalternateunits{#5}{#6}{#7}}}%
- \cs_set:cpn {#1onlybaseunits} {\mandi@selectbaseunits{#5}{#6}{#7}}%
- \cs_set:cpn {#1onlyderivedunits} {\mandi@selectderivedunits{#5}{#6}{#7}}%
- \cs_set:cpn {#1onlyalternateunits} {\mandi@selectalternateunits{#5}{#6}{#7}}%
-}%
-\NewDocumentCommand{\renewphysicalconstant}{ m m m m m O{#5} O{#5} }%
-{%
- \mandi_renewphysicalconstant { #1 }{ #2 }{ #3 }{ #4 }{ #5 }{ #6 }{ #7 }%
-}%
+\cs_new:Npn \__mandi_renewphysicalconstant:nnnnnnn #1#2#3#4#5#6#7
+ {
+ \cs_set:cpn {#1} {\unit{\mandi@selectprecision{#3}{#4}}{\mandi@selectunits{#5}{#6}{#7}}}
+ \cs_set:cpn {#1mathsymbol} {#2}
+ \cs_set:cpn {#1approximatevalue} {#3}
+ \cs_set:cpn {#1precisevalue} {#4}
+ \cs_set:cpn {#1baseunits}
+ {\unit{\mandi@selectprecision{#3}{#4}}{\mandi@selectbaseunits{#5}{#6}{#7}}}
+ \cs_set:cpn {#1derivedunits}
+ {\unit{\mandi@selectprecision{#3}{#4}}{\mandi@selectderivedunits{#5}{#6}{#7}}}
+ \cs_set:cpn {#1alternateunits}
+ {\unit{\mandi@selectprecision{#3}{#4}}{\mandi@selectalternateunits{#5}{#6}{#7}}}
+ \cs_set:cpn {#1onlybaseunits} {\mandi@selectbaseunits{#5}{#6}{#7}}
+ \cs_set:cpn {#1onlyderivedunits} {\mandi@selectderivedunits{#5}{#6}{#7}}
+ \cs_set:cpn {#1onlyalternateunits} {\mandi@selectalternateunits{#5}{#6}{#7}}
+ }
+\NewDocumentCommand{\renewphysicalconstant}{ m m m m m O{#5} O{#5} }
+ {
+ \__mandi_renewphysicalconstant:nnnnnnn { #1 }{ #2 }{ #3 }{ #4 }{ #5 }{ #6 }{ #7 }
+ }
\ExplSyntaxOff
% \end{macrocode}
%
@@ -2290,14 +2381,14 @@
% [\kilogram\usk\meter\tothetwo\per(\second\usk\radian)]%
% [\newton\usk\meter\usk\second\per\radian]%
%\else
- \newvectorquantity{angularimpulse}%
- {\kilogram\usk\meter\tothetwo\usk\second\inverse}%
- [\kilogram\usk\meter\tothetwo\per\second]% % also \joule\usk\second
- [\kilogram\usk\meter\tothetwo\per\second]% % also \newton\usk\meter\usk\second
- \newvectorquantity{angularmomentum}%
- {\kilogram\usk\meter\tothetwo\usk\second\inverse}%
- [\kilogram\usk\meter\tothetwo\per\second]% % also \joule\usk\second
- [\kilogram\usk\meter\tothetwo\per\second]% % also \newton\usk\meter\usk\second
+\newvectorquantity{angularimpulse}%
+ {\kilogram\usk\meter\tothetwo\usk\second\inverse}%
+ [\kilogram\usk\meter\tothetwo\per\second]% % also \joule\usk\second
+ [\kilogram\usk\meter\tothetwo\per\second]% % also \newton\usk\meter\usk\second
+\newvectorquantity{angularmomentum}%
+ {\kilogram\usk\meter\tothetwo\usk\second\inverse}%
+ [\kilogram\usk\meter\tothetwo\per\second]% % also \joule\usk\second
+ [\kilogram\usk\meter\tothetwo\per\second]% % also \newton\usk\meter\usk\second
%\fi
\newvectorquantity{angularvelocity}%
{\radian\usk\second\inverse}%
@@ -2439,6 +2530,13 @@
{\kilogram\usk\meter\inverse}%
[\kilogram\per\meter]%
[\kilogram\per\meter]%
+% \end{macrocode}
+%
+% \changes{v3.1.0}{2022-01-27}
+% {\linktoplace{sec:mandipkg}{mandi} Added \refCom{lorentzfactor}}
+% \begin{macrocode}
+\newscalarquantity{lorentzfactor}%
+ {}%
\newscalarquantity{luminousintensity}%
{\candela}%
\newscalarquantity{magneticcharge}%
@@ -2584,53 +2682,70 @@
[\newton\per\meter\tothetwo]%
% \end{macrocode}
%
+% We need a better glyph for Planck's constant over \( 2\pi \).
+%
+% \changes{v3.1.0}{2022-01-27}
+% {\linktoplace{sec:mandipkg}{mandi} Added \refCom{hbar}}
+% \begin{macrocode}
+\AtBeginDocument{%
+ \DeclareRobustCommand{\hbar}{{\mathpalette\hbar@\relax\symup{h}}}%
+}%
+\newcommand*{\hbar@}[2]{%
+ \makebox[0pt][l]{\raisebox{-0.07\height}{\(\m@th#1\mkern-2mu\mathchar"AF\)}}%
+ % optional line to make the bar thicker; must use -0.11
+ \makebox[0pt][l]{\raisebox{-0.11\height}{\(\m@th#1\mkern-2mu\mathchar"AF\)}}%
+}%
+% \end{macrocode}
+%
% Define physical constants for introductory physics, again alphabetically
% for convenience.
%
+% \changes{v3.1.0}{2022-01-27}
+% {\linktoplace{sec:mandipkg}{mandi} Constants' values now use only \cs{times}}
% \begin{macrocode}
\newphysicalconstant{avogadro}%
{\symup{N_A}}%
- {6\timestento{23}}{6.02214076\timestento{23}}% % exact 2019 value
+ {6\times10^{23}}{6.02214076\times10^{23}}% % exact 2019 value
{\mole\inverse}%
[\per\mole]%
[\per\mole]%
\newphysicalconstant{biotsavartconstant}% % alias for \mzofp
{\symup{\frac{\mu_o}{4\pi}}}%
- {\tento{-7}}{\tento{-7}}%
+ {10^{-7}}{10^{-7}}%
{\kilogram\usk\meter\usk\ampere\totheinversetwo\usk\second\totheinversetwo}%
[\henry\per\meter]%
[\tesla\usk\meter\per\ampere]%
\newphysicalconstant{bohrradius}%
{\symup{a_o}}%
- {5.3\timestento{-11}}{5.29177210903\timestento{-11}}%
+ {5.3\times10^{-11}}{5.29177210903\times10^{-11}}%
{\meter}%
\newphysicalconstant{boltzmann}%
{\symup{k_B}}%
- {1.4\timestento{-23}}{1.380649\timestento{-23}}% % exact 2019 value
+ {1.4\times10^{-23}}{1.380649\times10^{-23}}% % exact 2019 value
{\kilogram\usk\meter\tothetwo\usk\second\totheinversetwo\usk\kelvin\inverse}%
[\joule\per\kelvin]%
[\joule\per\kelvin]%
\newphysicalconstant{coulombconstant}% % alias for \oofpez
{\symup{\frac{1}{4\pi\epsilon_o}}}%
- {9\timestento{9}}{8.9875517923\timestento{9}}%
+ {9\times10^{9}}{8.9875517923\times10^{9}}%
{\kilogram\usk\meter\tothethree\usk\ampere\totheinversetwo\usk\second\totheinversefour}%
[\meter\per\farad]%
[\newton\usk\meter\tothetwo\per\coulomb\tothetwo]%
\newphysicalconstant{earthmass}%
{\symup{M_{Earth}}}%
- {6.0\timestento{24}}{5.9722\timestento{24}}%
+ {6.0\times10^{24}}{5.9722\times10^{24}}%
{\kilogram}%
\newphysicalconstant{earthmoondistance}%
{\symup{d_{EM}}}%
- {3.8\timestento{8}}{3.81550\timestento{8}}%
+ {3.8\times10^{8}}{3.81550\times10^{8}}%
{\meter}%
\newphysicalconstant{earthradius}%
{\symup{R_{Earth}}}%
- {6.4\timestento{6}}{6.3781\timestento{6}}%
+ {6.4\times10^{6}}{6.3781\times10^{6}}%
{\meter}%
\newphysicalconstant{earthsundistance}%
{\symup{d_{ES}}}%
- {1.5\timestento{11}}{1.496\timestento{11}}%
+ {1.5\times10^{11}}{1.496\times10^{11}}%
{\meter}%
\newphysicalconstant{electroncharge}%
{\symup{q_e}}%
@@ -2646,77 +2761,76 @@
[\coulomb]%
\newphysicalconstant{electronmass}%
{\symup{m_e}}%
- {9.1\timestento{-31}}{9.1093837015\timestento{-31}}%
+ {9.1\times10^{-31}}{9.1093837015\times10^{-31}}%
{\kilogram}%
\newphysicalconstant{elementarycharge}%
{\symup{e}}%
- {1.6\timestento{-19}}{1.602176634\timestento{-19}}% % exact 2019 value
+ {1.6\times10^{-19}}{1.602176634\times10^{-19}}% % exact 2019 value
{\ampere\usk\second}%
[\coulomb]%
[\coulomb]%
\newphysicalconstant{finestructure}%
{\symup{\alpha}}%
- {\frac{1}{137}}{7.2973525693\timestento{-3}}%
+ {\frac{1}{137}}{7.2973525693\times10^{-3}}%
{}%
\newphysicalconstant{hydrogenmass}%
{\symup{m_H}}%
- {1.7\timestento{-27}}{1.6737236\timestento{-27}}%
+ {1.7\times10^{-27}}{1.6737236\times10^{-27}}%
{\kilogram}%
\newphysicalconstant{moonearthdistance}%
{\symup{d_{ME}}}%
- {3.8\timestento{8}}{3.81550\timestento{8}}%
+ {3.8\times10^{8}}{3.81550\times10^{8}}%
{\meter}%
\newphysicalconstant{moonmass}%
{\symup{M_{Moon}}}%
- {7.3\timestento{22}}{7.342\timestento{22}}%
+ {7.3\times10^{22}}{7.342\times10^{22}}%
{\kilogram}%
\newphysicalconstant{moonradius}%
{\symup{R_{Moon}}}%
- {1.7\timestento{6}}{1.7371\timestento{6}}%
+ {1.7\times10^{6}}{1.7371\times10^{6}}%
{\meter}%
\newphysicalconstant{mzofp}%
{\symup{\frac{\mu_o}{4\pi}}}%
- {\tento{-7}}{\tento{-7}}%
+ {10^{-7}}{10^{-7}}%
{\kilogram\usk\meter\usk\ampere\totheinversetwo\usk\second\totheinversetwo}%
[\henry\per\meter]%
[\tesla\usk\meter\per\ampere]%
\newphysicalconstant{neutronmass}%
{\symup{m_n}}%
- {1.7\timestento{-27}}{1.67492749804\timestento{-27}}%
+ {1.7\times10^{-27}}{1.67492749804\times10^{-27}}%
{\kilogram}%
\newphysicalconstant{oofpez}%
{\symup{\frac{1}{4\pi\epsilon_o}}}%
- {9\timestento{9}}{8.9875517923\timestento{9}}%
+ {9\times10^{9}}{8.9875517923\times10^{9}}%
{\kilogram\usk\meter\tothethree\usk\ampere\totheinversetwo\usk\second\totheinversefour}%
[\meter\per\farad]%
[\newton\usk\meter\tothetwo\per\coulomb\tothetwo]%
\newphysicalconstant{oofpezcs}%
{\symup{\frac{1}{4\pi\epsilon_o c^2}}}%
- {\tento{-7}}{\tento{-7}}%
+ {10^{-7}}{10^{-7}}%
{\kilogram\usk\meter\usk\ampere\totheinversetwo\usk\second\totheinversetwo}%
[\tesla\usk\meter\tothetwo]%
[\newton\usk\second\tothetwo\per\coulomb\tothetwo]%
\newphysicalconstant{planck}%
{\symup{h}}%
- {6.6\timestento{-34}}{6.62607015\timestento{-34}}% % exact 2019 value
+ {6.6\times10^{-34}}{6.62607015\times10^{-34}}% % exact 2019 value
{\kilogram\usk\meter\tothetwo\usk\second\inverse}%
[\joule\usk\second]%
[\joule\usk\second]%
% \end{macrocode}
%
% See \url{https://tex.stackexchange.com/a/448565/218142}.
-%
%
% \begin{macrocode}
\newphysicalconstant{planckbar}%
- {\symup{\lower0.18ex\hbox{\mathchar"AF}\mkern-7mu h}}%
- {1.1\timestento{-34}}{1.054571817\timestento{-34}}%
+ {\hbar}%
+ {1.1\times10^{-34}}{1.054571817\times10^{-34}}%
{\kilogram\usk\meter\tothetwo\usk\second\inverse}%
[\joule\usk\second]%
[\joule\usk\second]
\newphysicalconstant{planckc}%
{\symup{hc}}%
- {2.0\timestento{-25}}{1.98644586\timestento{-25}}%
+ {2.0\times10^{-25}}{1.98644586\times10^{-25}}%
{\kilogram\usk\meter\tothethree\usk\second\totheinversetwo}%
[\joule\usk\meter]%
[\joule\usk\meter]%
@@ -2734,35 +2848,35 @@
[\coulomb]%
\newphysicalconstant{protonmass}%
{\symup{m_p}}%
- {1.7\timestento{-27}}{1.672621898\timestento{-27}}%
+ {1.7\times10^{-27}}{1.672621898\times10^{-27}}%
{\kilogram}%
\newphysicalconstant{rydberg}%
{\symup{R_{\infty}}}%
- {1.1\timestento{7}}{1.0973731568160\timestento{7}}%
+ {1.1\times10^{7}}{1.0973731568160\times10^{7}}%
{\meter\inverse}%
\newphysicalconstant{speedoflight}%
{\symup{c}}%
- {3\timestento{8}}{2.99792458\timestento{8}}% % exact value
+ {3\times10^{8}}{2.99792458\times10^{8}}% % exact value
{\meter\usk\second\inverse}%
[\meter\per\second]%
[\meter\per\second]
\newphysicalconstant{stefanboltzmann}%
{\symup{\sigma}}%
- {5.7\timestento{-8}}{5.670374\timestento{-8}}%
+ {5.7\times10^{-8}}{5.670374\times10^{-8}}%
{\kilogram\usk\second\totheinversethree\usk\kelvin\totheinversefour}%
[\watt\per\meter\tothetwo\usk\kelvin\tothefour]%
[\watt\per\meter\tothetwo\usk\kelvin\tothefour]
\newphysicalconstant{sunearthdistance}%
{\symup{d_{SE}}}%
- {1.5\timestento{11}}{1.496\timestento{11}}%
+ {1.5\times10^{11}}{1.496\times10^{11}}%
{\meter}%
\newphysicalconstant{sunmass}%
{\symup{M_{Sun}}}%
- {2.0\timestento{30}}{1.98855\timestento{30}}%
+ {2.0\times10^{30}}{1.98855\times10^{30}}%
{\kilogram}%
\newphysicalconstant{sunradius}%
{\symup{R_{Sun}}}%
- {7.0\timestento{8}}{6.957\timestento{8}}%
+ {7.0\times10^{8}}{6.957\times10^{8}}%
{\meter}%
\newphysicalconstant{surfacegravfield}%
{\symup{g}}%
@@ -2772,19 +2886,19 @@
[\newton\per\kilogram]%
\newphysicalconstant{universalgrav}%
{\symup{G}}%
- {6.7\timestento{-11}}{6.67430\timestento{-11}}%
+ {6.7\times10^{-11}}{6.67430\times10^{-11}}%
{\meter\tothethree\usk\kilogram\inverse\usk\second\totheinversetwo}%
[\newton\usk\meter\tothetwo\per\kilogram\tothetwo]% % also \joule\usk\meter\per\kilogram\tothetwo
[\newton\usk\meter\tothetwo\per\kilogram\tothetwo]%
\newphysicalconstant{vacuumpermeability}%
{\symup{\mu_o}}%
- {4\pi\timestento{-7}}{4\pi\timestento{-7}}% % as of 2018 no longer 4\pi\timestento{-7}
+ {4\pi\times10^{-7}}{4\pi\times10^{-7}}% % as of 2018 no longer 4\pi\times10^{-7}
{\kilogram\usk\meter\usk\ampere\totheinversetwo\usk\second\totheinversetwo}%
[\henry\per\meter]%
[\tesla\usk\meter\per\ampere]%
\newphysicalconstant{vacuumpermittivity}%
{\symup{\epsilon_o}}%
- {9\timestento{-12}}{8.854187817\timestento{-12}}%
+ {9\times10^{-12}}{8.854187817\times10^{-12}}%
{\ampere\tothetwo\usk\second\tothefour\usk\kilogram\inverse\usk\meter\totheinversethree}%
[\farad\per\meter]%
[\coulomb\tothetwo\per\newton\usk\meter\tothetwo]%
@@ -2793,94 +2907,84 @@
% Diagnostic commands to provide sanity checks on commands that
% represent physical quantities and constants.
%
+% \changes{v3.1.0}{2022-01-27}
+% {\linktoplace{sec:mandipkg}{mandi} Improved \refCom{checkquantity}}
+% \changes{v3.1.0}{2022-01-27}
+% {\linktoplace{sec:mandipkg}{mandi} Improved \refCom{checkconstant}}
% \begin{macrocode}
\ExplSyntaxOn
-\NewDocumentCommand{\checkquantity}{ m }%
-{%
- % Works for both scalar and vector quantities (without vector in the name!).
- \begin{center}
- \begin{tabular}{%
- >{\bfseries\small}
- p{0.5\linewidth}
- p{0.1\linewidth}
- p{0.1\linewidth}
- p{0.1\linewidth}
- }%
- name & & & \tabularnewline
- \ttfamily\footnotesize{\token_to_str:c {#1}} & & & \tabularnewline
- \end{tabular}~ % This nonbreaking space is important!
- \begin{tabular}{%
- >{\bfseries\small}p{0.25\linewidth}
- >{\bfseries\small}p{0.25\linewidth}
- >{\bfseries\small}p{0.25\linewidth}
- }%
- base & derived & alternate \tabularnewline
- \footnotesize{\( \use:c {#1onlybaseunits} \)} &
- \footnotesize{\( \use:c {#1onlyderivedunits} \)} &
- \footnotesize{\( \use:c {#1onlyalternateunits} \)}
- \end{tabular}
- \end{center}
-}%
-\NewDocumentCommand{\checkconstant}{ m }%
-{%
- \begin{center}
- \begin{tabular}{%
- >{\bfseries\small}
- p{0.5\linewidth}
- p{0.1\linewidth}
- p{0.1\linewidth}
- p{0.1\linewidth}
- }%
- name & & & \tabularnewline
- \ttfamily\footnotesize{\token_to_str:c {#1}} & & & \tabularnewline
- \end{tabular}~ % This nonbreaking space is important!
- \begin{tabular}{%
- >{\bfseries\small}p{0.25\linewidth}
- >{\bfseries\small}p{0.25\linewidth}
- >{\bfseries\small}p{0.25\linewidth}
- }%
- symbol & approximate & precise \tabularnewline
- \footnotesize{\( \use:c {#1mathsymbol} \)} &
- \footnotesize{\( \use:c {#1approximatevalue} \)} &
- \footnotesize{\( \use:c {#1precisevalue} \)}
- \end{tabular}~ % This nonbreaking space is important!
- \begin{tabular}{%
- >{\bfseries\small}p{0.25\linewidth}
- >{\bfseries\small}p{0.25\linewidth}
- >{\bfseries\small}p{0.25\linewidth}
- }%
- base & derived & alternate \tabularnewline
- \footnotesize{\( \use:c {#1onlybaseunits} \)} &
- \footnotesize{\( \use:c {#1onlyderivedunits} \)} &
- \footnotesize{\( \use:c {#1onlyalternateunits} \)}
- \end{tabular}
- \end{center}
-}%
+\NewDocumentCommand{\@aux}{ m }
+ {
+ \use:c { #1 }
+ }
+\NewDocumentCommand{\@auy}{ m }
+ {
+ \normalfont\ttfamily\token_to_str:c { #1 }
+ }
\ExplSyntaxOff
+\newcolumntype{M}{>{\(}p{0.25\linewidth}<{\)}}
+\NewDocumentCommand{\checkquantity}{ m }
+ {%
+ \begin{center}
+ \begin{tabular}{MMM}
+ \textbf{command} & \multicolumn{2}{l}{\@auy{#1}} \tabularnewline
+ \text{\textbf{base}} & \text{\textbf{derived}} & \text{\textbf{alternate}} \tabularnewline
+ \@aux{#1onlybaseunits} & \@aux{#1onlyderivedunits} & \@aux{#1onlyalternateunits} \tabularnewline
+ \end{tabular}
+ \end{center}
+ }%
+\NewDocumentCommand{\checkconstant}{ m }
+ {%
+ \begin{center}
+ \begin{tabular}{MMM}
+ \textbf{command} & \multicolumn{2}{l}{\@auy{#1}} \tabularnewline
+ \text{\textbf{symbol}} & \text{\textbf{approximate}} & \text{\textbf{precise}} \tabularnewline
+ \@aux{#1mathsymbol} & \@aux{#1approximatevalue} & \@aux{#1precisevalue} \tabularnewline
+ \text{\textbf{base}} & \text{\textbf{derived}} & \text{\textbf{alternate}} \tabularnewline
+ \@aux{#1onlybaseunits} & \@aux{#1onlyderivedunits} & \@aux{#1onlyalternateunits} \tabularnewline
+ \end{tabular}
+ \end{center}
+ }%
% \end{macrocode}
%
-% \refCom{mivector} is a workhorse command.
-% Orginal code provided by |@egreg|.\newline
+% \refCom{mivector} is a workhorse command.\newline
% See \url{https://tex.stackexchange.com/a/39054/218142}.
-%
%
+% \changes{v3.1.0}{2022-01-27}
+% {\linktoplace{sec:mandipkg}{mandi} \refCom{mivector} now
+% requires more than one component}
% \begin{macrocode}
\ExplSyntaxOn
-\NewDocumentCommand{\mivector}{ O{,} m o }%
- {%
- \mi_vector:nn { #1 } { #2 }%
- \IfValueT{#3}{\,{#3}}%
- }%
-\seq_new:N \l__mi_list_seq
-\cs_new_protected:Npn \mi_vector:nn #1 #2
-{%
- \ensuremath{%
- \seq_set_split:Nnn \l__mi_list_seq { , } { #2 }
- \int_compare:nF { \seq_count:N \l__mi_list_seq = 1 } { \left\langle }
- \seq_use:Nnnn \l__mi_list_seq { #1 } { #1 } { #1 }
- \int_compare:nF { \seq_count:N \l__mi_list_seq = 1 } { \right\rangle }
- }%
-}%
+\NewDocumentCommand{\mivector}{ O{,} m o }
+ {
+ \__mandi_vector:nn { #1 } { #2 }
+ \IfValueT{#3}{\,{#3}}
+ }
+\seq_new:N \l__mandi_list_seq
+\cs_new_protected:Npn \__mandi_vector:nn #1#2
+ {
+ \seq_set_split:Nnn \l__mandi_list_seq { , } { #2 }
+ \int_compare:nT { \seq_count:N \l__mandi_list_seq = 1 }
+ {
+ \msg_new:nnnn { mandi } { onecomponent }
+ {
+ More~than~one~component~expected. \iow_newline:
+ You~provided~one~component~to~a~command \iow_newline:
+ that~expects~a~vector.~Either~you~don't \iow_newline:
+ need~a~vector~here~or~you~didn't~supply \iow_newline:
+ all~the~components.
+ }
+ {
+ Decide~whether~or~not~you~really~need~a~vector~command~here. \iow_newline:
+ \msg_see_documentation_text:n { mandi }
+ }
+ \msg_fatal:nn { mandi } { onecomponent }
+
+ }
+ \left\langle
+ \seq_use:Nnnn \l__mandi_list_seq { #1 } { #1 } { #1 }
+ \right\rangle
+ }
\ExplSyntaxOff
% \end{macrocode}
% \restoregeometry