% \iffalse meta-comment
% File: thermodynamics.dtx Copyright (C) 2022-2023 Karl D. Hammond
%
% Karl D. Hammond
% Chemical Engineering Program
% University of Missouri
% Contact: hammondkd@missouri.edu
%
% 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 your option) any later version.
% The latest version of this license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
% This work has the LPPL maintenance status `maintained'.
%
% The Current Maintainer of this work is K. D. Hammond.
%
% This work consists of the files thermodynamics.dtx and thermodynamics.ins
% and the derived files thermodynamics.sty, thermodynamics.pdf,
% thermodynamics-examples.tex, and thermodynamics-examples.pdf.
% \fi
%
% \iffalse
%^^A FIXME: need correct date of release once you update this
%^^X\GetIdInfo $Id: thermodynamics.dtx 2.00 2023/11/16 Karl D. Hammond <hammondkd@missouri.edu> $
%^^X    {thermodynamics notation}
%<*driver>
%^^X\ProvidesFile{\ExplFileName}
\ProvidesFile{thermodynamics.dtx}
%</driver>
%
%<package>\NeedsTeXFormat{LaTeX2e}
%<package>\RequirePackage{expl3}
%<package>\ProvidesPackage{thermodynamics}
%<*package>
    [2023/11/16 v2.00 thermodynamics notation]
%</package>
%^^X    {\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription}
%<*driver>
\documentclass[11pt,letterpaper]{ltxdoc}
%^^X\bool_set_false:N \l__codedoc_allow_indexing_bool
\usepackage[margin=0.80in,left=2.05in]{geometry}
\usepackage[T1]{fontenc}
\usepackage{textcomp}
\usepackage{amsmath}
\usepackage{pxfonts}
\usepackage{array}
\usepackage{booktabs}
\usepackage{footmisc}
\usepackage[labelfont=bf,labelsep=period,font=small]{caption}
\GetFileInfo{thermodynamics.dtx}
\usepackage{thermodynamics}[\filedate\space\fileversion]
\DisableCrossrefs
\CodelineIndex
\PageIndex
\CodelineNumbered
\RecordChanges
%^^X Preparing to use l3doc.cls, but it's not quite mature yet....
%^^A\DisableDocumentation
%^^A\DisableImplementation
%^^X\ExplSyntaxOff
\let\tn\cs
\let\env\texttt
\let\pkg\textsf
\begin{document}
  \DocInput{thermodynamics.dtx}
\end{document}
%</driver>
% \fi
%
% \CheckSum{2387}
%
% \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
%  Lower-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
%  Digits       \0\1\2\3\4\5\6\7\8\9
%  Exclamation     \!      Double quote    \"      Hash (number)   \#
%  Dollar          \$      Percent         \%      Ampersand       \&
%  Acute accent    \'      Left paren      \(      Right paren     \)
%  Asterisk        \*      Plus            \+      Comma           \,
%  Minus           \-      Point           \.      Solidus         \/
%  Colon           \:      Semicolon       \;      Less than       \<
%  Equals          \=      Greater than    \>      Question mark   \?
%  Commercial at   \@      Left bracket    \[      Backslash       \\
%  Right bracket   \]      Circumflex      \^      Underscore      \_
%  Grave accent    \`      Left brace      \{      Vertical bar    \|
%  Right brace     \}      Tilde           \~}
%
% \changes{v1.00}{2022/04/29}{Initial public release}
% \changes{v2.00}{2023/11/16}{Revision to use \LaTeX3
%       (\pkg{expl3}/\pkg{xparse}) syntax layer}
%
% \newcommand*{\setmarginparsize}[1]
% {\bgroup
% \RenewExpandableDocumentCommand{\MacroFont}{}{\fontencoding\encodingdefault
%    \fontfamily\ttdefault
%    \fontseries\mddefault
%    \fontshape\shapedefault
%    #1}
% }
% \newcommand*{\restoremarginparsize}{\egroup}
%
% \GetFileInfo{thermodynamics.dtx}
%^^X \title{The \textsf{thermodynamics} package\thanks{This document
%^^X   corresponds to \textsf{thermodynamics}~\ExplFileVersion,
%^^X   dated \ExplFileDate.}}
% \title{The \textsf{thermodynamics} package\thanks{This document
%   corresponds to \textsf{thermodynamics}~\fileversion,
%   dated \filedate.}}
% \author{Karl D. Hammond \\ \texttt{hammondkd@missouri.edu}}
%^^X \date{\ExplFileDate}
% \date{\filedate}
% \maketitle
%
% \begin{abstract}
% A package, \textsf{thermodynamics}, is defined that makes typesetting
% quantities found in thermodynamics texts relatively simple. The commands are
% flexible and intended to be relatively intuitive. It handles several sets
% of notation for total, specific, and molar quantities; allows changes between
% symbols (e.g., $A$ vs.\ $F$ for Helmholtz free energy); and greatly
% simplifies the typesetting of symbols and partial derivatives commonly
% encountered in mixture thermodynamics. Changes of one's notes from one
% textbook to another can be achieved relatively easily by changing package
% options.
% \end{abstract}
%
%^^X \begin{documentation}
% \section{Introduction}
% The purpose of this package is to simplify the typesetting of equations in
% thermodynamics, particularly chemical engineering thermodynamics, which are
% often cumbersome to enter. For example, consider the following equation:
% \begin{equation}
%   d\Ut = \Partial*{\Ut}{\St}{\Vt,\allNs} \,d\St
%         + \Partial*{\Ut}{\Vt}{\St,\allNs} \,d\Vt
%         + \sumall_i \Partial*{\Ut}{\Nt_i}{\St,\Vt,\allNsbut{i}} d\Nt_i.
%   \label{eq:chain-rule-U}
% \end{equation}
% This equation is pretty basic, and equations like it occur all the time in
% thermodynamics. Without this package, you might typeset it like this:
% \begin{verbatim}
% \[ d\underline{U} =
%    \left(\frac{\partial\underline{U}}
%               {\partial\underline{S}}\right)_{\underline{V},\vec{n}}
%    d\underline{S}
%  + \left(\frac{\partial\underline{U}}
%               {\partial\underline{V}}\right)_{\underline{S},\vec{n}}
%    d\underline{V}
%  + \sum_{i=1}^C \left(\frac{\partial\underline{U}}
%       {\partial n_i}\right)_{\underline{S},\underline{V},n_{j\neq i}}
%    dn_i. \]
%\end{verbatim}
% This is a lot of code, and even then the output is slightly clunky:
% \[ d\underline{U} =
%     \left(\frac{\partial\underline{U}}
%                {\partial\underline{S}}\right)_{\underline{V},\vec{n}}
%     d\underline{S}
%   + \left(\frac{\partial\underline{U}}
%                {\partial\underline{V}}\right)_{\underline{S},\vec{n}}
%     d\underline{V}
%   + \sum_{i=1}^C \left(\frac{\partial\underline{U}}
%                {\partial n_i}\right)_{\underline{S},\underline{V},n_{j\neq i}}
%     dn_i.
% \]
% It is also frustratingly difficult to change one's notes or handouts from one
% textbook that uses, say, $n_1$ to denote moles of component 1 to another
% textbook that uses $N_1$ for the same quantity, or perhaps denotes the
% total internal energy as $U$ or $U^t$ rather than $\Ut$.
% For example, if you wanted it to be
% \[\begin{thermomolesrange}
%   \begin{thermoextensiveplain}
%   \RenewExpandableDocumentCommand{\Nt}{}{N}
%   \RenewExpandableDocumentCommand{\ncomponents}{}{\mathcal{C}}
%   d\Ut = \Partial*{\Ut}{\St}{\Vt,\allNs} \,d\St
%         + \Partial*{\Ut}{\Vt}{\St,\allNs} \,d\Vt
%         + \sumall_i \Partial*{\Ut}{\Nt_i}{\St,\Vt,\allNsbut{i}} d\Nt_i.
%   \end{thermoextensiveplain}
%   \end{thermomolesrange}
% \]
% without changing any of your code---to update it across all handouts, exams,
% and homework sets after changing textbooks, say---you would be out of luck
% (or in for a lot of work).
%
% With this package, you could reduce the code to typeset this equation to
% \begin{verbatim}
%  \begin{equation}
%     d\Ut = \Partial*{\Ut}{\St}{\Vt,\allNs} d\St
%       + \Partial*{\Ut}{\Vt}{\St,\allNs} d\Vt
%       + \sumall_i \Partial*{\Ut}{\Nt_i}{\St,\Vt,\allNsbut{i}} d\Nt_i
%  \end{equation}
%\end{verbatim}
% and it will render similarly to Equation~\eqref{eq:chain-rule-U}, including
% the shortened underscores and negative kerning.
% If you later decide to change the notation such that extensive properties are
% not underlined, you can do that without changing any of your code (just
% change a package option). Similarly, if you want $\vec{n}$ replaced by
% $n_1,\dots,n_C$, you can do that with a package option, too.
%
% The package handles second derivatives, too. For example,
% \begin{verbatim}
%  \[ \Partial*{\Hm}{T}{P} = T\Partial*{\Sm}{T}{P}
%                          = -T\PartialSecond*{\Gm}{T}{P} = \cP \]
%\end{verbatim}
% renders (using the default options)
%  \[ \Partial*{\Hm}{T}{P} = T\Partial*{\Sm}{T}{P}
%                          = -T\PartialSecond*{\Gm}{T}{P} = \cP. \]
% Similarly, macros are defined for mixed second partial derivatives that allow
% things like
% \begin{verbatim}
%  \[ \Partial*{\Gpm_i}{P}{T,\allNs}
%    = \PartialMixSecond*{\Gt}{P}{\Nt_i}{T,\allNsbut{i}}
%    = \PartialMixSecond*{\Gt}{\Nt_i}{P}{T,\allNsbut{i}}
%    = \Partial*{\Vt}{\Nt_i}{T,P,\allNsbut{i}} = \Vpm_i \],
%\end{verbatim}
% which renders
% \[ \Partial*{\Gpm_i}{P}{T,\allNs}
%   = \PartialMixSecond*{\Gt}{P}{\Nt_i}{T,\allNsbut{i}}
%   = \PartialMixSecond*{\Gt}{\Nt_i}{P}{T,\allNsbut{i}}
%   = \Partial*{\Vt}{\Nt_i}{T,P,\allNsbut{i}} = \Vpm_i
% \]
% using the defaults.
%
%^^A-------------------------------------------------------------------------
%
% \section{Using the Package} \label{sec:using}
% There are three categories of macros defined in this package: macros
% that produce symbols (or groups of them), macros that typeset derivatives,
% and macros that are used internally that the user need not know about.
% There are also several environments that allow the user to change notation
% temporarily.
%
% \subsection{Predefined Symbols}
% The macros used to produce symbols fall into five categories: extensive
% properties, molar properties, specific properties (i.e., per unit mass),
% partial molar properties, and shortcut macros (e.g., macros for the heat
% capacities, saturation pressure, and so forth). The macros corresponding to
% extensive, molar, and specific properties are shown in
% Table~\ref{table:symbols}. Examples using the enthalpy are
% \DescribeMacro{\Ht}
% \DescribeMacro{\Hm}
% \DescribeMacro{\Hs}
% \DescribeMacro{\Hpm}
% \begin{verbatim}
%   \[ \Ht \quad \Hm \quad \Hs \quad \Hpm_i. \]
%\end{verbatim}
% Using the default package options, the above renders as
%   \[ \Ht \quad \Hm \quad \hat H \quad \Hpm{i}. \]
% In addition, the properties in
% Table~\ref{table:conveniences} are defined for convenience.
%
% \DescribeMacro{\Ut}
% \DescribeMacro{\Um}
% How these symbols are rendered can be customized by package options. As long
% as the user consistently uses \cs{Ut} to render the total internal energy,
% \cs{Um} to render the molar internal energy, and so forth, switching notation
% from, say, $\Ut$ to $U^t$ for extensive properties is trivial.
%
% \DescribeMacro{\cP}
% \DescribeMacro{\cV}
% \DescribeMacro{\cPt}
% \DescribeMacro{\cVt}
% \DescribeMacro{\cPs}
% \DescribeMacro{\cVs}
% \DescribeMacro{\cPpm}
% \DescribeMacro{\cVpm}
% The heat capacities (see Table~\ref{table:conveniences}) are generally
% assumed to be molar (e.g., \cs{cP} is interpreted to be the molar heat
% capacity). To get the specific heat capacities, the macros \cs{cPs} and
% \cs{cVs} are provided, which by default render as $\cPs$ and $\cVs$,
% respectively. There are also extensive versions, so \cs{cPt} and \cs{cVt}
% will render as $\cPt$ and $\cVt,$
% respectively.  Note that \cs{cP} and friends require you to surround
% \cs{text} with brackets.  For example, \verb"\cP_i^\text{A}" will not work,
% nor will \verb"\cP^\text{A}_i"; you need to use \verb"\cP_i^{\text{A}}" and
% \verb"\cP^{\text{A}}_i". Using \verb"\cP^\IG_i" will work as expected.
%
% You can also get partial molar heat capacities via \cs{cPpm} and \cs{cVpm},
% though the latter's mathematical definition is a bit hard to wrap one's head
% around:
% \begin{verbatim}
%   \[ \cVpm_i = \Partial*{\cVt}{\Nt_i}{T,P,\allNsbut{i}}
%              = \frac{\partial}{\partial\Nt_i}
%                \left[ -T\PartialSecond{\Ft}{T}{\Vt,\allNs}
%                \right]_{T,P,\allNsbut{i}} \]
%\end{verbatim}
% yields
%   \[ \cVpm{i} = \Partial*{\cVt}{\Nt_i}{T,P,\allNsbut{i}}
%               = \frac{\partial}{\partial\Nt_i}
%                 \left[ -T\PartialSecond{\Ft}{T}{\Vt,\allNs}
%                 \right]_{T,P,\allNsbut{i}}. \]
%
% \begin{table}
%   \caption{Commands defined in this package to represent extensive
%       thermodynamic quantities and their molar and specific analogs.
%       These macros should be used even if the symbol the user
%       wishes to use does not match the command used (e.g., \cs{Ft}
%       for total Helmholtz free energy even if it ends up being set as
%       $\Ft$)\@.
%   }
%   \label{table:symbols}
%^^A TODO The \leavevmode macro here is to prevent whitespace from building
%^^A      up due to a bug in old versions of hypdoc. It should be harmless to
%^^A      leave it in there, but consider removing it at some point.
%   \leavevmode
%   \SpecialMacroIndex{\Qt}\relax
%   \SpecialMacroIndex{\Qm}\relax
%   \SpecialMacroIndex{\Qs}\relax
%   \SpecialMacroIndex{\Wt}\relax
%   \SpecialMacroIndex{\Wm}\relax
%   \SpecialMacroIndex{\Ws}\relax
%   \SpecialMacroIndex{\Et}\relax
%   \SpecialMacroIndex{\Em}\relax
%   \SpecialMacroIndex{\Es}\relax
%   \SpecialMacroIndex{\Epm}\relax
%   \SpecialMacroIndex{\EEt}\relax
%   \SpecialMacroIndex{\EE}\relax
%   \SpecialMacroIndex{\EEs}\relax
%   \SpecialMacroIndex{\EEpm}\relax
%   \SpecialMacroIndex{\ERt}\relax
%   \SpecialMacroIndex{\ER}\relax
%   \SpecialMacroIndex{\ERs}\relax
%   \SpecialMacroIndex{\ERpm}\relax
%   \SpecialMacroIndex{\Ut}\relax
%   \SpecialMacroIndex{\Um}\relax
%   \SpecialMacroIndex{\Us}\relax
%   \SpecialMacroIndex{\Upm}\relax
%   \SpecialMacroIndex{\UEt}\relax
%   \SpecialMacroIndex{\UE}\relax
%   \SpecialMacroIndex{\UEs}\relax
%   \SpecialMacroIndex{\UEpm}\relax
%   \SpecialMacroIndex{\URt}\relax
%   \SpecialMacroIndex{\UR}\relax
%   \SpecialMacroIndex{\URs}\relax
%   \SpecialMacroIndex{\URpm}\relax
%   \SpecialMacroIndex{\Ht}\relax
%   \SpecialMacroIndex{\Hm}\relax
%   \SpecialMacroIndex{\Hs}\relax
%   \SpecialMacroIndex{\Hpm}\relax
%   \SpecialMacroIndex{\HEt}\relax
%   \SpecialMacroIndex{\HE}\relax
%   \SpecialMacroIndex{\HEs}\relax
%   \SpecialMacroIndex{\HEpm}\relax
%   \SpecialMacroIndex{\HRt}\relax
%   \SpecialMacroIndex{\HR}\relax
%   \SpecialMacroIndex{\HRs}\relax
%   \SpecialMacroIndex{\HRpm}\relax
%   \SpecialMacroIndex{\St}\relax
%   \SpecialMacroIndex{\Sm}\relax
%   \SpecialMacroIndex{\Ss}\relax
%   \SpecialMacroIndex{\Spm}\relax
%   \SpecialMacroIndex{\SEt}\relax
%   \SpecialMacroIndex{\SE}\relax
%   \SpecialMacroIndex{\SEs}\relax
%   \SpecialMacroIndex{\SEpm}\relax
%   \SpecialMacroIndex{\SRt}\relax
%   \SpecialMacroIndex{\SR}\relax
%   \SpecialMacroIndex{\SRs}\relax
%   \SpecialMacroIndex{\SRpm}\relax
%   \SpecialMacroIndex{\Ft}\relax
%   \SpecialMacroIndex{\Fm}\relax
%   \SpecialMacroIndex{\Fs}\relax
%   \SpecialMacroIndex{\Fpm}\relax
%   \SpecialMacroIndex{\FEt}\relax
%   \SpecialMacroIndex{\FE}\relax
%   \SpecialMacroIndex{\FEs}\relax
%   \SpecialMacroIndex{\FEpm}\relax
%   \SpecialMacroIndex{\FRt}\relax
%   \SpecialMacroIndex{\FR}\relax
%   \SpecialMacroIndex{\FRs}\relax
%   \SpecialMacroIndex{\FRpm}\relax
%   \SpecialMacroIndex{\Gt}\relax
%   \SpecialMacroIndex{\Gm}\relax
%   \SpecialMacroIndex{\Gs}\relax
%   \SpecialMacroIndex{\Gpm}\relax
%   \SpecialMacroIndex{\GEt}\relax
%   \SpecialMacroIndex{\GE}\relax
%   \SpecialMacroIndex{\GEs}\relax
%   \SpecialMacroIndex{\GEpm}\relax
%   \SpecialMacroIndex{\GRt}\relax
%   \SpecialMacroIndex{\GR}\relax
%   \SpecialMacroIndex{\GRs}\relax
%   \SpecialMacroIndex{\GRpm}\relax
%   \SpecialMacroIndex{\At}\relax
%   \SpecialMacroIndex{\Am}\relax
%   \SpecialMacroIndex{\As}\relax
%   \SpecialMacroIndex{\Apm}\relax
%   \SpecialMacroIndex{\Nt}\relax
%   \SpecialMacroIndex{\Lt}\relax
%   \SpecialMacroIndex{\Lm}\relax
%   \SpecialMacroIndex{\Ls}\relax
%   \SpecialMacroIndex{\Lpm}\relax
%   \SpecialMacroIndex{\LEt}\relax
%   \SpecialMacroIndex{\LE}\relax
%   \SpecialMacroIndex{\LEs}\relax
%   \SpecialMacroIndex{\LEpm}\relax
%   \SpecialMacroIndex{\LRt}\relax
%   \SpecialMacroIndex{\LR}\relax
%   \SpecialMacroIndex{\LRs}\relax
%   \SpecialMacroIndex{\LRpm}\relax
%   \centering
%   \begin{minipage}{\linewidth}\renewcommand*{\footnoterule}{\vskip-1.75ex}%
%   \centering\scriptsize\setlength{\tabcolsep}{0.05in}
%   \begin{tabular}{l l l l l l l l l l l l l}
%   \toprule
%     & & & & & \multicolumn{4}{c}{Excess}
%       & \multicolumn{4}{c}{Residual (Departure)} \\
%   \cmidrule(r{0.5ex}){6-9}
%   \cmidrule(l{0.5ex}){10-13}
%     Property & Total & Molar & Specific & \parbox[b]{0.45in}{Partial Molar}
%     & T & M & S & PM & T & M & S & PM \\
%   \midrule
%     Heat            & \cs{Qt}  & \cs{Qm} & \cs{Qs}  & \\
%     Work            & \cs{Wt}  & \cs{Wm} & \cs{Ws}  & \\
%     Total energy    & \cs{Et}  & \cs{Em} & \cs{Es}  & \cs{Epm}
%                     & \cs{EEt} & \cs{EE} & \cs{EEs} & \cs{EEpm}
%                     & \cs{ERt} & \cs{ER} & \cs{ERs} & \cs{ERpm} \\
%     Internal energy & \cs{Ut} & \cs{Um} & \cs{Us} & \cs{Upm}
%                     & \cs{UEt} & \cs{UE} & \cs{UEs} & \cs{UEpm}
%                     & \cs{URt} & \cs{UR} & \cs{URs} & \cs{URpm} \\
%     Enthalpy        & \cs{Ht} & \cs{Hm} & \cs{Hs} & \cs{Hpm}
%                     & \cs{HEt} & \cs{HE} & \cs{HEs} & \cs{HEpm}
%                     & \cs{HRt} & \cs{HR} & \cs{HRs} & \cs{HRpm} \\
%     Entropy         & \cs{St} & \cs{Sm} & \cs{Ss} & \cs{Spm}
%                     & \cs{SEt} & \cs{SE} & \cs{SEs} & \cs{SEpm} 
%                     & \cs{SRt} & \cs{SR} & \cs{SRs} & \cs{SRpm} \\
%     Volume          & \cs{Vt} & \cs{Vm} & \cs{Vs} & \cs{Vpm}
%                     & \cs{VEt} & \cs{VE} & \cs{VEs} & \cs{VEpm}
%                     & \cs{VRt} & \cs{VR} & \cs{VRs} & \cs{VRpm} \\
%     Helmholtz free energy & \cs{Ft} & \cs{Fm} & \cs{Fs} & \cs{Fpm}
%                     & \cs{FEt} & \cs{FE} & \cs{FEs} & \cs{FEpm}
%                     & \cs{FRt} & \cs{FR} & \cs{FRs} & \cs{FRpm} \\
%     Gibbs free energy & \cs{Gt} & \cs{Gm} & \cs{Gs} & \cs{Gpm}
%                     & \cs{GEt} & \cs{GE} & \cs{GEs} & \cs{GEpm}
%                     & \cs{GRt} & \cs{GR} & \cs{GRs} & \cs{GRpm} \\
%     Surface area    & \cs{At} & \cs{Am} & \cs{As} & \cs{Apm} \\
%     Grand potential\footnote{The grand potential,
%       $\begin{thermomolesrange}\Lt(T,\Vt,\allmus)\end{thermomolesrange}
%           = \Ut - T\St - \sumall_i \mu_i \Nt_i,$
%       is also called the Landau free energy by some authors.}
%                     & \cs{Lt} & \cs{Lm} & \cs{Ls} & \cs{Lpm}
%                     & \cs{LEt} & \cs{LE} & \cs{LEs} & \cs{LEpm}
%                     & \cs{LRt} & \cs{LR} & \cs{LRs} & \cs{LRpm} \\
%     Moles           & \cs{Nt} & \\
%   \bottomrule
%   \end{tabular}
%   \end{minipage}
% \end{table}
%
% \begin{table}
%   \caption{Convenience macros and their default symbols.
%       These are generally ``smart'': for example,
%       \texttt{\textbackslash cP\_i} renders as $C_{P,i}$, as expected, and
%       \texttt{\textbackslash cP\_i\^{}\textbackslash std} renders as
%       $C_{P,i}^\circ$, also as expected. You can also reverse it:
%       \texttt{\textbackslash cP\^{}\textbackslash std\_i} becomes
%       $C^\circ_{P,i}$.}
%   \label{table:conveniences}
%^^A TODO The \leavevmode macro here is to prevent whitespace from building
%^^A      up due to a bug in old versions of hypdoc. It should be harmless to
%^^A      leave it in there, but consider removing it at some point.
%   \leavevmode
%   \SpecialMacroIndex{\cP}\relax
%   \SpecialMacroIndex{\cV}\relax
%   \SpecialMacroIndex{\kappaT}\relax
%   \SpecialMacroIndex{\kappaS}\relax
%   \SpecialMacroIndex{\alphaP}\relax
%   \SpecialMacroIndex{\alphaS}\relax
%   \SpecialMacroIndex{\muJT}\relax
%   \SpecialMacroIndex{\heatcapacitysymbol}\relax
%   \SpecialMacroIndex{\compressibilitysymbol}\relax
%   \SpecialMacroIndex{\expansivitysymbol}\relax
%   \SpecialMacroIndex{\amix}\relax
%   \SpecialMacroIndex{\fpure}\relax
%   \SpecialMacroIndex{\fmix}\relax
%   \SpecialMacroIndex{\fsat}\relax
%   \SpecialMacroIndex{\phipure}\relax
%   \SpecialMacroIndex{\phimix}\relax
%   \SpecialMacroIndex{\phisat}\relax
%   \SpecialMacroIndex{\Psat}\relax
%   \SpecialMacroIndex{\Pvap}\relax
%   \SpecialMacroIndex{\sat}\relax
%   \SpecialMacroIndex{\Henryrat}\relax
%   \SpecialMacroIndex{\Henrymol}\relax
%   \SpecialMacroIndex{\gammarat}\relax
%   \SpecialMacroIndex{\gammamol}\relax
%   \SpecialMacroIndex{\Deltamix}\relax
%   \SpecialMacroIndex{\Deltarxn}\relax
%   \SpecialMacroIndex{\Deltavap}\relax
%   \SpecialMacroIndex{\Deltasub}\relax
%   \SpecialMacroIndex{\Deltafus}\relax
%   \SpecialMacroIndex{\mixing}\relax
%   \SpecialMacroIndex{\reaction}\relax
%   \SpecialMacroIndex{\fusion}\relax
%   \SpecialMacroIndex{\vaporization}\relax
%   \SpecialMacroIndex{\sublimation}\relax
%   \begin{minipage}{\linewidth}
%   \small
%   \addtolength{\tabcolsep}{-2.75pt}\relax
%   \addtolength{\extrarowheight}{0.75ex}\relax
%   \renewcommand*{\footnoterule}{\vskip-1.5ex}\relax
%   \begin{tabular}{l l l l l}
%   \toprule
%   \\[-1.5\normalbaselineskip]
%     Name & Macro & Sym. & Definition & Base Symbol Macro \\
%   \midrule
%     Isobaric heat capacity & \cmd\cP\footnote{\relax
%         Extensive and specific (per-unit-mass) versions are available
%         as \cs{cPt} and \cmd\cPs, respectively, with similar macros for the
%         isochoric heat capacity.\label{fn:cP}}
%     & \(cP\) & \(\displaystyle T\Partial{\Sm}{T}{P}\)
%     & \cmd\heatcapacitysymbol \\[2.0ex]
%     Isochoric heat capacity & \verb"\cV"\footref{fn:cP} & \(\cV\)
%     & \(\displaystyle T\Partial{\Sm}{T}{\Vm}\)
%     & \cmd\heatcapacitysymbol \\[2.0ex]
%     Isothermal compressibility & \cmd\kappaT & $\kappaT$
%       & \(\displaystyle -\frac{1}{\Vm} \Partial{\Vm}{P}{T} \)
%       & \cmd\compressibilitysymbol \\[2.0ex]
%     Isentropic compressibility & \cmd\kappaS & $\kappaS$
%       & \(\displaystyle -\frac{1}{\Vm} \Partial{\Vm}{P}{\Sm}\)
%       & \cmd\compressibilitysymbol \\[2.0ex]
%     Isobaric expansivity & \cmd\alphaP & $\alphaP$
%       & \(\displaystyle \frac{1}{\Vm} \Partial{\Vm}{T}{P}\)
%       & \cmd\expansivitysymbol \\[2.0ex]
%     Isentropic expansivity & \cmd\alphaS & $\alphaS$
%       & \(\displaystyle \frac{1}{\Vm} \Partial{\Vm}{T}{\Sm}\)
%       & \cmd\expansivitysymbol \\[2.0ex]
%     Joule--Thomson coeff. & \cmd\muJT & $\muJT$
%       & \(\displaystyle \Partial{T}{P}{\Hm}\) & \cmd\JTsymbol \\
%     Pure fugacity & \cmd\fpure & $f$ & $\phi P$ \\
%     Mixture fugacity & \cmd\fmix & $\fmix$
%       & $\fmix_i = x_i\phimix_i P$ \\[0.5ex]
%     Saturation fugacity & \cmd\fsat & $\fsat$
%       & $\phisat \Psat$ & \cmd\sat \\
%     Pure fugacity coefficient & \cmd\phipure & $\phipure$ &
%       \multicolumn{2}{l}{\( \phipure_i
%         = \exp\left(\frac{1}{RT}\int_0^P \Vm_i(T,p)
%               - \frac{RT}{p}\,dp\right) \)} \\
%     Mixture fugacity coeff.\ & \cmd\phimix & $\phimix$
%       & \multicolumn{2}{l}{\( \phimix_i
%          = \exp\left(\frac{1}{RT}\int_0^P \Vpm{i}(T,p,\allXs)
%                - \frac{RT}{p}\,dp\right) \)} \\
%     Henry's constant (rational) & \cmd\Henryrat & $\Henryrat$
%       & $\gamma_i^\infty f_i$ \\
%     Henry's constant (molal) & \cmd\Henrymol & $\Henrymol$ 
%       & $M_s \gamma_i^\infty f_i$ \\
%     Rational activity coeff.\ & \cmd\gammarat & $\gammarat$
%       & $\gamma/\gamma^\infty$ \\
%     Molal activity coeff.\ & \cmd\gammamol & $\gammamol$
%       & $x_s \gamma/\gamma^\infty$ \\
%     Saturation fugacity coeff.\ & \cmd\phisat & $\phisat$
%       & $\phipure(T,\Psat)$ & \cmd\sat \\
%     Saturation pressure & \cmd\Psat & $\Psat$ && \cmd\sat \\
%     Vapor pressure & \cmd\Pvap & \multicolumn{3}{l}{Currently a synonym
%       for \cs{Psat}\footnote{If you want \cs{Pvap} to produce $P^\text{vap}$
%       instead of $\Psat$, you should redefine the \cs{sat} macro.}} \\
%     Standard state & \cmd\std\footnote{Typical usage would be
%       \texttt{\$\cs{mu}\_i = \cs{mu}\textasciicircum\cs{std}\_i
%         + RT \cs{log} a\_i\$},
%       yielding $\mu_i = \mu_i^\std + RT \log a_i$.} & $\std$ \\
%     Standard pressure & \cmd\Pstd & $\Pstd$ & & \cs{std} \\
%     Standard fugacity & \cmd\fstd & $\fstd$ & $\fpure(T,\Pstd)$ & \cs{std}
%     \\
%     Change on mixing & \cmd\Deltamix\footnote{The usual usage would be
%         something like
%         \texttt{\$\cs{Deltamix}\cs{Vm}\textasciicircum\cs{IGM} = 0\$}.\relax
%       \label{fn:Deltausage}}
%       & $\Delta M$\textsubscript{mix}
%       & $M - \sumall_i x_i M_i$ & \cmd\mixing \\
%     Change on reaction & \cmd\Deltarxn\footref{fn:Deltausage}
%       & $\Deltarxn M$
%       & $\sumall_i \nu_i M_i$ & \cmd\reaction \\
%     Change on melting & \cmd\Deltafus\footref{fn:Deltausage}
%       & $\Deltafus M$ & $M^L - M^S$ & \cmd\fusion \\
%     Change on boiling & \cmd\Deltavap\footref{fn:Deltausage}
%       & $\Deltavap M$ & $M^V - M^L$ & \cmd\vaporization \\
%     Change on subliming & \cmd\Deltasub\footref{fn:Deltausage}
%       & $\Deltasub M$ & $M^V - M^S$ & \cmd\sublimation \\
%   \bottomrule
%   \end{tabular}
%   \end{minipage}
% \end{table}
%
% \subsection{Partial Molar Properties}
% \DescribeMacro{\Upm}
% \DescribeMacro{\Vpm}
% Partial molar quantities are defined with the suffix \verb"pm".
% For example, \cs{Upm} refers to the partial molar internal energy. There
% are two options for how to enter partial molar quantities: as commands or
% as super/subscripts. For example,
% \begin{verbatim}
%  \[ \Upm{i} \quad \Upm[\IG]{i} \quad \Vpm_i \quad \Vpm^\IG_i \]
%\end{verbatim}
% will typeset as
% \[ \Upm{i} \quad \Upm[\text{IG}]{i} \quad \Vpm{i} \quad \Vpm^{\text{IG}}_i.\]
% There are also partial molar heat capacities available via the macros
%  \cs{cPpm} and \cs{cVpm}.
% \textbf{Important}: The \tn{text} command defined by the \pkg{amstext}
% package is usually robust enough that something like \verb"\Um^\text{L}" will
% work as expected, without additional braces. This does \emph{not} work for
% partial molar properties; for example, \verb"\Hpm^\text{L}_i" will produce an
% error, as will \verb"\Hpm_i^\text{L}". The expression
% \verb"\Hpm_i^{\text{L}}" will work as expected.
%
% \DescribeMacro{\partialmolar}
% New partial molar properties can be defined for any ``simple'' symbol using
% the \cs{partialmolar} macro. ``Simple'' means it has no subscripts or
% superscripts. For example, the macro for the partial molar Gibbs free energy
% is effectively defined via the macro
% \DescribeMacro{\Gpm}
% \begin{verbatim}
%   \NewDocumentCommand{\Gpm}{}{\partialmolar{G}}.
%\end{verbatim}
% A list of pre-defined macros for total, molar, specific, and partial molar
% quantities commonly used in thermodynamics is included in
% Table~\ref{table:symbols}.
%
% \subsection{Defining New Properties}
% \DescribeMacro{\NewExtensiveProperty}
% Users can create new properties using a family of commands. Typically, a
% user would want to define at least the total, molar, and specific properties,
% which can be accomplished by the \cs{NewExtensiveProperty} command.
% For example,
% \begin{verbatim}
%  \NewExtensiveProperty{J}{K}
%\end{verbatim}
% \NewExtensiveProperty{J}{K}\relax
% would define the commands \cs{Jt}, \cs{Jm}, and \cs{Js}, which would produce
% (using the default package options) the symbols $\Jt$, $K$, and $\hat{K}$,
% respectively.
%
% \DescribeMacro{\NewPartialMolarProperty}%
% Partial molar properties can be created either with the \cs{partialmolar}
% macro directly as described above or with \cs{NewPartialMolarProperty}, which
% has the same argument style as \cs{NewExtensiveProperty}.
%
% \DescribeMacro{\NewExcessProperty}%
% \DescribeMacro{\NewResidualProperty}%
% Similarly, one can define commands for the total, molar, and specific excess
% properties using \cs{NewExcessProperty} in a similar manner, and similar
% commands for the residual properties with \cs{NewResidualProperty}.
%
% \setmarginparsize{\footnotesize}
% \DescribeMacro{\NewThermodynamicProperty}\relax
% \restoremarginparsize
% \NewThermodynamicProperty{B}{B}\relax
% \NewExtensiveProperty{M}{M}\relax
% It is common that a user wants the total, molar, specific, and partial molar
% commands for a new symbol, as well as excess and residual (departure)
% properties for each case.  Users can define such properties---common examples
% are $\Bt$ and $\Mt$ to represent uncommon or arbitrary properties---by using
% \cs{NewThermodynamicProperty}, which calls all four of the aforementioned
% declarations on the same command/\allowbreak{}symbol combinations. For
% example,
% \begin{verbatim}
%  \NewThermodynamicProperty{B}{B}
%\end{verbatim}
% defines the commands \cs{Bt}, \cs{Bm}, \cs{Bs}, and \cs{Bpm}, which define
% the total, molar, specific, and partial molar properties, respectively.
% It also defines \cs{BEt}, \cs{BE}, \cs{BEs}, and \cs{BEpm} for the
% corresponding excess properties, and \cs{BRt}, \cs{BR}, \cs{BRs}, and
% \cs{BRpm} for residual (departure) properties. These produce, respectively,
% $\Bt, \Bm, \Bs, \Bpm{i}, \BEt, \BE, \BEs, \BEpm{i}, \BRt, \BR, \BRs,$ and
% $\BRpm{i}$ using the defaults.
%
% \subsection{Other Predefined Symbols and Modifiers}
% There are a number of predefined symbols and modifiers.
% While these symbols could be defined or used without these macros, such use
% is not recommended: changing package options will result in inconsistencies
% if these macros are not used.
%
% \subsubsection{Heat Capacities, Compressibilities, and Expansivities}
% \DescribeMacro{\cP}
% \DescribeMacro{\cV}
% \DescribeMacro{\kappaS}
% \DescribeMacro{\kappaT}
% \DescribeMacro{\alphaP}
% \DescribeMacro{\alphaS}
% The isobaric and isochoric heat capacities are produced with \cs{cP} and
% \cs{cV}, respectively. Four other measurable quantities are defined: the
% isothermal and isentropic compressibilities, \cs{kappaT} and \cs{kappaS},
% respectively; and the isobaric and isentropic volume expansivities,
% \cs{alphaP} and \cs{alphaS}, respectively. Some textbooks use $\beta$ instead
% of $\alpha$ for the volume expansivity to differentiate it from the
% \emph{linear} expansivity; this can be changed by redefining
% \cs{expansivitysymbol}, which is done automatically by some of the
% package options that create notation specific to a particular textbook.
%
% \subsubsection{Joule--Thomson Coefficients}
% \changes{v2.00}{2023/11/16}{Added \cs{muJT} to represent Joule--Thomson
%   coefficients (which have different notation across textbooks).}
% \DescribeMacro{\muJT}
% The Joule--Thomson coefficient is produced with \cs{muJT}, which be default
% is rendered $\muJT$. Some books call this coefficient $\alpha_H$; this is
% handled automatically for books of which the package author is aware.
%
% \subsubsection{Fugacities and Fugacity Coefficients}
% \DescribeMacro{\fpure}
% \DescribeMacro{\fmix}
% \DescribeMacro{\phipure}
% \DescribeMacro{\phimix}
% Different textbooks use different variations on the symbol $f$ for
% fugacity, so it is recommended to use the macro \cs{fpure} to denote the
% pure-component fugacity and \cs{fmix} to denote the mixture fugacity.
% Similarly, the pure-component fugacity coefficient should be generated with
% \cs{phipure}, and that in the mixture should be \cs{phimix}.
%
% For example, the following markup is an example of a common equation in
% mixture thermodynamics:
% \begin{verbatim}
%   \[ \fmix_j = x_j \phimix_j P = x_j \gamma_j \fpure_j
%       = x_j \gamma_j \phipure_j P. \]
%\end{verbatim}
% With the default package options, this produces
%   \[ \fmix_j = x_j \phimix_j P = x_j \gamma_j \fpure_j
%       = x_j \gamma_j \phipure_j P. \]
% With the |Thompson| package option, however, the same markup produces
%   \[ \hat f_j = x_j \hat\phi_j P = x_j \gamma_j f^\bullet_j
%       = x_j \gamma_j \phi^\bullet_j P. \]
% Similarly, the |Prausnitz| package option causes it to generate
%   \[ f_j = x_j \phi_j P = x_j \gamma_j f_{\text{pure},j}
%          = x_j \gamma_j \phi_{\text{pure},j} P, \]
% and the |Sandler| option causes it to generate
%   \[ \bar f_j = x_j \bar \phi_j P = x_j \gamma_j f_j
%          = x_j \gamma_j \phi_j  P. \]
%
% \subsubsection{Activity Coefficients and Henry's Constants}
% \DescribeMacro{\gammarat}
% \DescribeMacro{\gammamol}
% \DescribeMacro{\Henryrat}
% \DescribeMacro{\Henrymol}
% The activity coefficient based on the Lewis--Randall rule can be generated
% with \cs{gamma}, as usual. The Henry's Law activity coefficients should be
% produced with \cs{gammarat} (rational basis) and \cs{gammamol} (molal basis).
% There are also macros to generate the Henry's law constants for both the
% rational basis (\cs{Henryrat}) and the molal basis (\cs{Henrymol}).
% These are interrelated:
% \begin{verbatim}
% \[ \fmix_i = x_i \gamma_i \fpure_i = x_i \gammarat_i \Henryrat_i
%            = C_i \gammamol_i \Henrymol_i \]
%\end{verbatim}
% produces
% \[ \fmix_i = x_i \gamma_i \fpure_i = x_i \gammarat_i \Henryrat_i
%            = C_i \gammamol_i \Henrymol_i \]
% using the default options.
% These symbols can be customized either directly or by using package options.
% For example, the |TesterModell| package option changes the equation
% above to
% \[ \hat f_i = x_i \gamma_i f_i = x_i \gamma_i^{**} f_i^{**}
%   = C_i \gamma_i^* f_i^* \]
% without any changes in markup.
%
% Note that some books (e.g., |ElliottLira|) prefer the atmospheric chemistry
% convention for the molal basis, namely
% \[ \fmix_i = x_i \gamma_i \fpure_i = x_i \gammarat_i \Henryrat_i
%%^^A            = C_i \gammamol_i \Henrymol_i
%            = C_i \gammamol_i / K_{H,i} \]
% (that is, using $1/K_{H,i}$ in place of $\Henrymol_i$).
% Unfortunately, this makes it impossible to change symbols without any edits
% to markup, so this convention is \emph{not} supported by this package.
%
% \subsubsection{Saturation Properties}
% \DescribeMacro{\Psat}
% \DescribeMacro{\Pvap}
% \DescribeMacro{\fsat}
% \DescribeMacro{\phisat}
% The saturation pressure is generated with \cs{Psat}. The macro \cs{Pvap} is
% an alias for \cs{Psat}. The fugacity and fugacity coefficient at saturation
% are accessed via \cs{fsat} and \cs{phisat}, respectively. Package options
% can be used to change some of these to match the notation of specific
% textbooks.
%
% \DescribeMacro{\sat}
% The \cs{sat} macro is used ``behind the scenes'' as part of
% \cs{Psat}, \cs{fsat}, and \cs{phisat}, which produce $\Psat$,
% $\fsat$, and $\phisat$, respectively (using the defaults). If you wanted to
% redefine them to be $P^\text{vap}$, $f^\text{vap}$, and $\phi^\text{vap}$,
% you could simply redefine \cs{sat} with
% \verb"\RenewDocumentCommand{\sat}{}{{\text{vap}}}".
% This is done automatically using package option |Sandler|.
%
% \subsubsection{Standard States}
% \DescribeMacro{\std}
% \DescribeMacro{\Pstd}
% \DescribeMacro{\fstd}
% The symbol $\circ$ (\cs{circ}) is used by default for standard states.
% This is intended to be easy to change should the user want to replace
% $P^\circ$ with $P^\ominus$, say. This is accessed via the \cs{std} macro.
% The macro \cs{Pstd} is defined as |P^\std| for convenience to denote
% standard pressures, and \cs{fstd} is defined for standard fugacities so as
% to ease implementation across textbooks.
%
% The usual usage would be something like this:
% \begin{verbatim}
% \[ \Deltarxn\Gm = \sumall_i \nu_i \mu_i = \sumall_i \left[ \nu_i \mu^\std_i
%    + \nu_i RT \log\left(\frac{\fmix_i}{\fstd_i}\right) \right]
%    = \Deltarxn\Gm^\std + RT \log\left[\prodall_i a_i^{\nu_i} \right] \],
%\end{verbatim}
% which produces
% \[ \Deltarxn\Gm = \sumall_i \nu_i \mu_i = \sumall_i \left[ \nu_i \mu^\std_i
%    + \nu_i RT \log\left(\frac{\fmix_i}{\fstd_i}\right) \right]
%    = \Deltarxn\Gm^\std + RT \log\left[\prodall_i a_i^{\nu_i} \right] \]
% with the default settings.
%
% \subsubsection{Changes on Mixing, Reaction, Fusion, Vaporization, and
%   Sublimation}
% \DescribeMacro{\Deltamix}
% Mixing properties are handled via the \cs{Deltamix} macro, and are used as in
% the following example:
% \begin{verbatim}
% \[ \Deltamix\Gm = \Gm - \sumall_i x_i \Gm_i
%                 = \Deltamix\Hm - T\Deltamix\Sm \],
%\end{verbatim}
% which yields, using the default options,
% \[ \Deltamix\Gm = \Gm - \sumall_i x_i \Gm_i = \Deltamix\Hm - T\Deltamix\Sm \]
% Some textbooks (|Sandler|, |Thompson|) choose to typeset these with the word
% ``mix'' \emph{before} the symbol, which is handled automatically by this
% package.
% \DescribeMacro{\mixing}
% The macro \cs{mixing} determines how the change in mixing label is rendered;
% the default is \verb"{\text{mix}}".
%
% \DescribeMacro{\Deltafus}
% \DescribeMacro{\Deltasub}
% \DescribeMacro{\Deltavap}
% The commands \cs{Deltafus}, \cs{Deltasub}, and \cs{Deltavap}
% typeset changes due to fusion (melting), sublimation (subliming), and
% vaporization (boiling), respectively. Their use is straightforward, viz.,
% \begin{verbatim}
%  \[ \Deltasub\Hm = \Hm^V - \Hm^S = \Hm^V - \Hm^L + (\Hm^L - \Hm^S)
%                  = \Deltafus\Hm + \Deltavap\Hm \],
%\end{verbatim}
% yielding
%  \[ \Deltasub\Hm = \Hm^V - \Hm^S = \Hm^V - \Hm^L + (\Hm^L - \Hm^S)
%                  = \Deltafus\Hm + \Deltavap\Hm \]
% with the default options. Note that some textbooks (e.g., |Sandler|) typeset
% these quantities quite differently; this is handled automatically. Other
% textbooks (e.g., |Koretsky|) typeset them as subscripts; this is also
% handled automatically.
%
% \DescribeMacro{\Deltaf}
% \DescribeMacro{\Deltarxn}
% The macros \cs{Deltaf} and \cs{Deltarxn} are intended to typeset the enthalpy
% or free energy of formation and reaction, respectively. For example,
% \begin{verbatim}
%  \[ \Deltarxn\Hm^\std = \sumall_i \nu_i \Deltaf\Hm_i^\std \]
%\end{verbatim}
% results in
% \[ \Deltarxn\Hm^\std = \sumall_i \nu_i \Deltaf\Hm_i^\std. \]
% It is not anticipated that this command will be combined with something like
% a heat capacity, which already has a (potentially double) subscript, but as
% there is no ``formation'' heat capacity, that should not present a problem.
%
% \subsection{Residual and Excess Properties}
% \DescribeMacro{\UR}
% \DescribeMacro{\URt}
% \DescribeMacro{\URs}
% \DescribeMacro{\URpm}
% \DescribeMacro{\UE}
% \DescribeMacro{\UEt}
% \DescribeMacro{\UEs}
% \DescribeMacro{\UEpm}
% Additional macros are defined that make it easy to typeset the residual
% (also called ``departure'') and excess total, molar, specific, and partial
% molar properties. These macros follow the same pattern: \cs{UR}, \cs{URt},
% \cs{URs}, and \cs{URpm} typeset the molar, total, specific, and partial molar
% residual internal energies, respectively, and by default expand to $U^R,$
% $\URt,$ $\URs, $ and $\smash[t]{\URpm{i}}$ (the last
% is called as \verb"\URpm{i}" or \verb"\URpm_i"). Similarly, \cs{UE},
% \cs{UEt}, \cs{UEs}, and \cs{UEpm} typeset the corresponding excess
% properties. The first character of the macros for other properties follow the
% same pattern as in Table~\ref{table:symbols}.
%
% The $R$ and $E$ characters are generated by the macros \cs{residual} and
% \cs{excess}, respectively. These macros can be redefined; for example, if you
% \DescribeMacro{\excess}
% \DescribeMacro{\residual}
% want \cs{SE}, which normally produces $\SE$, to give you $S^{EX}$---and let's
% be honest, who doesn't want that?\footnote{You knew that joke was
% coming.}---then you can redefine it with
% \begin{verbatim}
%   \RenewDocumentCommand{\excess}{}{{EX}},
%\end{verbatim}
% or possibly
% \begin{verbatim}
%   \RenewDocumentCommand{\excess}{}{{\mathrm{EX}}}
%\end{verbatim}
% or even
% \begin{verbatim}
%   \RenewDocumentCommand{\excess}{}{\text{EX}},
%\end{verbatim}
% which cause \cs{SE} to expand to $S^{EX},$ $S^\mathrm{EX},$ and
% $S^\text{EX},$ respectively.
%
% It is generally possible to use superscripts with the excess or residual
% properties; in the event this fails, the \cs{excess} and \cs{residual} macros
% can be used directly, viz.,
% \begin{verbatim}
%   \begin{gather*}
%     \HE^\std = \Hm^{\excess,\std} = \HE(T,\Pstd)
%       = \HR(T,\Pstd) - \HR^\IS(T,\Pstd) = \HR^\std - \HR^{\IS,\std} \\
%   \RenewDocumentCommand{\excess}{{EX}}
%     \HE^\std = \Hm^{\excess,\std} = \HE(T,\Pstd)
%       = \HR(T,\Pstd) - \HR^\IS(T,\Pstd)
%   \end{gather*},
%\end{verbatim}
% which yields
% \begin{gather*}
%     \HE^\std = \Hm^{\excess,\std} = \HE(T,\Pstd)
%       = \HR(T,\Pstd) - \HR^\IS(T,\Pstd) = \HR^\std - \HR^{\IS,\std} \\
%   \RenewDocumentCommand{\excess}{}{{EX}}
%     \HE^\std = \Hm^{\excess,\std} = \HE(T,\Pstd)
%       = \HR(T,\Pstd) - \HR^\IS(T,\Pstd)
% \end{gather*}
% using the default options.
%
% \subsection{Partial Derivatives}
% \DescribeMacro{\Partial}%
% \DescribeMacro{\Partial*}%
% Partial derivatives are easily rendered using the \cs{Partial} command.
% There is a starred form (\cs{Partial*}) that additionally adjusts the
% spacing after the closing symbol to remove some of the space, anticipating
% that the following binary operator will overhang the subscripts.
% Compare the following:
% \begin{verbatim}
%  \[ \Partial{\Hm}{T}{P} = \cP \qquad \Partial*{\Hm}{T}{P} = \cP \],
%\end{verbatim}
% which yields
%  \[ \Partial{\Hm}{T}{P} = \cP \qquad \Partial*{\Hm}{T}{P} = \cP. \]
%
% \DescribeMacro{\Partialinline}%
% Inline first derivatives\footnote{The ``inline'' versions of
%   partial derivatives are ``sticky'': if you issue \cs{Partialinline} or
%   its second-order equivalents anywhere in a line, all subsequent
%   \cs{Partial} and \cs{Partial[Mix]Second} macros on the same line
%    (technically, anywhere in the same \TeX\ ``group'') will
%   expand inline as well. To prevent this, enclose your \cs{Partialinline} and
%   associated arguments in its own group (i.e.,
%   \texttt{\{\cs{Partialinline}\dots\}}).%
%   \label{fn:inline}}
% can be entered the same way; compare:
% \begin{verbatim}
%  \[ \Partial*{\Hm}{T}{P} = \Partialinline{\Hm}{T}{P}
%       = T\Partial{\Sm}{T}{P} \],
%\end{verbatim}
% which results in
%   \[ \Partial*{\Hm}{T}{P} = \Partialinline{\Hm}{T}{P}
%       = T\Partial{\Sm}{T}{P}. \]
% There is no need for an inline starred form, as the subscripts do not
% extend far enough below the baseline.
%
% \subsubsection{Second-Order Partial Derivatives}
% \DescribeMacro{\PartialSecond}%
% \DescribeMacro{\PartialSecond*}%
% \DescribeMacro{\PartialMixSecond}%
% \DescribeMacro{\PartialMixSecond*}%
% Second partial derivatives and mixed-second partial derivatives are typeset
% with the commands \cs{PartialSecond} and \cs{PartialMixSecond}, respectively.
% Like the first-order variety, these also have starred versions that remove
% the space immediately following the closing symbols, anticipating that the
% equals sign or other binary operator following the derivative will overhang
% the elements held constant. For example,
% \begin{verbatim}
%   \[ \Vpm_i = \Partial*{\Vt}{\Nt_i}{T,P,\allNsbut{i}}
%             = \PartialMixSecond*{\Gt}{\Nt_i}{P}{T,\allNsbut{i}}
%             = \PartialMixSecond*{\Gt}{P}{\Nt_i}{T,\allNsbut{i}}
%             = \Partial{\Gpm_i}{P}{T,\allNs} \]
%\end{verbatim}
% looks like
%   \[ \Vpm_i = \Partial*{\Vt}{\Nt_i}{T,P,\allNsbut{i}}
%             = \PartialMixSecond*{\Gt}{\Nt_i}{P}{T,\allNsbut{i}}
%             = \PartialMixSecond*{\Gt}{P}{\Nt_i}{T,\allNsbut{i}}
%             = \Partial{\Gpm_i}{P}{T,\allNs}. \]
% \DescribeMacro{\PartialSecondinline}%
% \DescribeMacro{\PartialMixSecondinline}%
% Inline versions\footref{fn:inline} of second-order derivatives are handled
% with \cs{PartialSecondinline} and \cs{PartialMixSecondinline}, viz.,
% \begin{verbatim}
% \begin{equation}
%   \Vpm_i = \Partialinline{\Vt}{\Nt_i}{T,P,\allNsbut{i}}
%          = \PartialMixSecondinline{\Gt}{\Nt_i}{P}{T,\allNsbut{i}}
%          = \PartialMixSecondinline{\Gt}{P}{\Nt_i}{T,\allNsbut{i}}
%          = \Partialinline{\Gpm_i}{P}{T,\allNs} \]
% \end{equation}
%\end{verbatim}
% looks like
% \begin{equation}
%     \Vpm_i = \Partialinline{\Vt}{\Nt_i}{T,P,\allNsbut{i}}
%            = \PartialMixSecondinline{\Gt}{\Nt_i}{P}{T,\allNsbut{i}}
%            = \PartialMixSecondinline{\Gt}{P}{\Nt_i}{T,\allNsbut{i}}
%            = \Partialinline{\Gpm_i}{P}{T,\allNs}.
%   \label{eq:Vpm-inline}
% \end{equation}
% \pagebreak[0]%
%
% \subsubsection{Delimiter Sizing}
% \DescribeMacro{\PartialBigg}%
% \DescribeMacro{\PartialSecondBigg}%
% \DescribeMacro{\PartialMixSecondBigg}%
% \DescribeMacro{\Partialbigg}%
% \DescribeMacro{\PartialSecondbigg}%
% \DescribeMacro{\PartialMixSecondbigg}%
% There are instances (such as the line above) when \cs{Partial} causes
% parentheses that are slightly
% too tall but do not need to be---particularly when partial molar properties,
% specific quantities, or fugacities are involved. The macro \cs{PartialBigg}
% uses \pkg{amsmath}'s \tn{Biggl} and \tn{Biggr} macros in place of \tn{left}
% and \tn{right} to size the delimiters accordingly; \cs{Partialbigg} uses
% \tn{biggl} and \tn{biggr} in a similar fashion. For example, compare the
% following:
% \begin{verbatim}
%  \[ \Vpm_i = \Partial*{\Vt}{\Nt_i}{T,P,\allNsbut{i}}
%            = \Partial*{\Gpm_i}{P}{T,\allNs}
%            = \PartialBigg*{\Gpm_i}{P}{T,\allNs}
%            = RT\Partial*{\log\fmix_i}{P}{T,\allNs}
%            = RT\,\PartialBigg*{\log\fmix_i}{P}{T,\allNs}
%            = RT\,\Partialbigg{\log\fmix_i}{P}{T,\allNs} \],
%\end{verbatim}
% which typesets as
%  \[ \Vpm{i} = \Partial*{\Vt}{\Nt_i}{T,P,\allNsbut{i}}
%            = \Partial*{\Gpm{i}}{P}{T,\allNs}
%            = \PartialBigg*{\Gpm{i}}{P}{T,\allNs}
%            = RT\Partial*{\log\fmix_i}{P}{T,\allNs}
%            = RT\,\PartialBigg*{\log\fmix_i}{P}{T,\allNs}
%            = RT\,\Partialbigg{\log\fmix_i}{P}{T,\allNs}. \]
% Note that a similar effect---possibly with other side effects---can be
% achieved with \pkg{amsmath}'s \tn{smash} command, which has the effect of
% removing all vertical space associated with a particular character.
% Observe:
% \begin{verbatim}
%  \[ \Vpm_i = \Partial*{\Vt}{\Nt_i}{T,P,\allNsbut{i}}
%            = \Partial{\smash{\Gpm_i}}{P}{T,\allNs} \]
%\end{verbatim}
% produces
%  \[ \Vpm_i = \Partial*{\Vt}{\Nt_i}{T,P,\allNsbut{i}}
%            = \Partial{\smash{\Gpm_i}}{P}{T,\allNs}. \]
%
% \setmarginparsize{\footnotesize}%
% \DescribeMacro{\Partialinlinetext}%
% \DescribeMacro{\PartialSecondinlinetext}%
% \restoremarginparsize
% \setmarginparsize{\scriptsize}
% \DescribeMacro{\PartialMixSecondinlinetext}%
% \restoremarginparsize
% Similarly, there are times when \cs{Partialinline} causes parentheses that
% are too big for inline text, and they do not need to be---particularly for
% symbols with overlines, underlines, or other decorations. In this case, the
% macros \cs{Partialinlinetext}, \cs{PartialSecondinlinetext}, and
% \cs{PartialMixSecondinlinetext} come in handy; using these macros like so,
% \begin{verbatim}
% \[ \Vpm_i = \Partialinlinetext{\Vt}{\Nt_i}{T,P,\allNsbut{i}}
%           = \PartialMixSecondinlinetext{\Gt}{\Nt_i}{P}{T,\allNsbut{i}}
%           = \PartialMixSecondinlinetext{\Gt}{P}{\Nt_i}{T,\allNsbut{i}}
%           = \Partialinlinetext{\Gpm_i}{P}{T,\allNs} \],
%\end{verbatim}
% Equation~\eqref{eq:Vpm-inline} looks like
% \[ \Vpm{i} = \Partialinlinetext{\Vt}{\Nt_i}{T,P,\allNsbut{i}}
%           = \PartialMixSecondinlinetext{\Gt}{\Nt_i}{P}{T,\allNsbut{i}}
%           = \PartialMixSecondinlinetext{\Gt}{P}{\Nt_i}{T,\allNsbut{i}}
%           = \Partialinlinetext{\Gpm{i}}{P}{T,\allNs}. \]
%
% \subsubsection{Higher-Order Derivatives}
% It is possible to ``fake'' higher-order derivatives via some trickery.
% For example,
% \begin{verbatim}
% \[ \cPpm_i = T\Partial*{\Spm_i}{T}{P,\allXs}
%            = T\PartialMixSecond*{\St}{T}{\Nt_i}{P,\allNsbut{i}}
%            = -T\Partial{^3\Gt}{T^2\partial\Nt_i}{P,\allNsbut{i}} \]
%\end{verbatim}
% gives
% \[ \cPpm{i} = T\Partial*{\Spm{i}}{T}{P,\allXs}
%             = T\PartialMixSecond*{\St}{T}{\Nt_i}{P,\allNsbut{i}}
%             = -T\Partial{^3\Gt}{T^2\partial\Nt_i}{P,\allNsbut{i}}, \]
% which is probably pretty close to what you wanted. Using this trickery with
% the package option \verb"nosubscripts" will not work, and the use of
% third- and higher-order derivatives with this package should generally be
% considered unsupported.
%
% \subsection{Holding Constant the Number of Moles of Several Species}
% \DescribeMacro{\allNs}%
% \DescribeMacro{\allNsbut}%
% \DescribeMacro{\allmus}%
% \DescribeMacro{\allmusbut}%
% \DescribeMacro{\allXs}%
% \DescribeMacro{\allXsbut}%
% \DescribeMacro{\allYs}%
% \DescribeMacro{\allYsbut}%
% \DescribeMacro{\allMs}%
% \DescribeMacro{\allMsbut}%
% \DescribeMacro{\allWs}%
% \DescribeMacro{\allWsbut}%
% It is common in thermodynamics to use notation such as
% \[ \Vpm_k = \Partial{\Vt}{\Nt_k}{T,P,\allNsbut{k}}, \]
% or perhaps
% \begin{thermomolesrange}
% \[ \Vpm{k} = \Partial{\Vt}{\Nt_k}{T,P,\allNsbut{k}} \]
% \end{thermomolesrange}
% or
% \[ \Vpm{k} = \left(\frac{\partial\Vt}{\partial\Nt_k}\right)_{T,P,\Nt_j[k]} \]
% to mean partial derivatives that hold the number of moles of each species
% constant \emph{except} the one being changed.
% Similarly, a property determined with all mole fractions held
% constant might be written
% \[ \cP = \Partial{\Hm}{T}{P,\allXs}, \]
% or perhaps
% \begin{thermomolesrange}\relax
% \[ \cP = \Partial{\Hm}{T}{P,\allXs}. \]
% \end{thermomolesrange}\relax
% There are several macros that standardize such constructs.
% The \cs{allNs} macro expands to something meaning the number of moles of all
% species; by default, this is $\vec{n}$ (package option
% \verb"moles-index"), but can be changed to $n_1,\dotsc,n_C$ using the package
% option \verb"moles-range". Similarly, the macros \cs{allmus} and
% \cs{allmusbut} do the same but with $n$ replaced by $\mu$, and \cs{allMsbut}
% is the same with $m$ instead of $n$. There are analogous macros for mole
% fractions, namely \cs{allXs} and \cs{allXsbut} for $x$ and \cs{allYs} and
% \cs{allYsbut} for $y$, as well as \cs{allWs} and \cs{allWsbut} for mass
% fractions---these implicitly assume that all mole or mass fractions
% \emph{except} the last are used as variables.
% These macros all take an optional argument; for example,
% \begin{verbatim}
% \[ \Partial{\Ht}{\Nt_1}{T,P,\allNsbut{1}} =
%    \Partial{\Ht}{\Nt_1}{T,P,\allNsbut[m]{1}} = \Hpm_1 \]
%\end{verbatim}
% typesets as
% \[ \Partial{\Ht}{\Nt_1}{T,P,\allNsbut{1}} =
%    \Partial{\Ht}{\Nt_1}{T,P,\allNsbut[m]{1}} = \Hpm{1}. \]
% Similarly,
% \begin{verbatim}
% \[ \Partial{\Hm}{x_i}{T,P,\allXsbut{i}}
%   = \Partial{\Hm}{x_i}{T,P,\allXsbut[m]{i}}
%   = \Hpm_i - \Hpm_\ncomponents \]
%\end{verbatim}
% becomes
% \[ \Partial{\Hm}{x_i}{T,P,\allXsbut{i}}
%  = \Partial{\Hm}{x_i}{T,P,\allXsbut[m]{i}}
%  = \Hpm{i} - \Hpm{\ncomponents}. \]
% Users must supply their own redefinitions if they wish to hold something
% other than \cs{ncomponents} constant in addition to the argument for mole
% and mass fractions.
% Using the \verb"moles-range" package option, for which \verb"\allXsbut{k}"
% expands to
% \( \begin{thermomolesrange}\allXsbut{k}\end{thermomolesrange} \)
% rather than \( \allXsbut{k} \), the optional argument is ignored.
%
% The optional argument to \cs{allNs} and similar commands is ignored when
% using the default options; it is relevant for package options that redefine
% \cs{allNs} to make $N_i$, for example; in this case, one can enter
% \cs{allNs[j]} to make \TeX\ render $N_j$ instead of $N_i$. This is useful
% if you are using $i$ somewhere else in the equation.
%
% \DescribeMacro{\allbut}
% \DescribeMacro{\allbutlastand}
% Users can define new ``all but'' macros using the \cs{allbut} and
% \cs{allbutlastand} commands. For example,
% \begin{verbatim}
%   \NewDocumentCommand{\allNsbut}{O{j} m}{\allbut[#1]{#2}{\Nt}}
%   \NewDocumentCommand{\allXsbut}{O{j} m}{\allbutlastand[#1]{#2}{x}}
%\end{verbatim}
% are the definitions of \cs{allNsbut} and \cs{allXsbut}, respectively.
%
% \subsection{Jacobians}
% \DescribeMacro{\Jacobian}%
% \DescribeMacro{\Jacobiandet}%
% The Jacobian determinant is often denoted with Leibnitz-like notation, viz.,
% \begin{verbatim}
% \[ \Jacobian{K,L}{X,Y} = \Jacobiandet{K,L}{X,Y} \],
%\end{verbatim}
% which produces (assuming the \pkg{amsmath} package has been loaded)
% \[ \Jacobian{K,L}{X,Y} = \Jacobiandet{K,L}{X,Y}. \]
% There are two optional arguments to \cs{Jacobiandet}. The first will be
% pre-pended before every element of the matrix (typically \cs{textstyle} or
% \cs{displaystyle}); the second is the extra spacing added between rows
% (default is 1.25~ex for text-style fractions and 2.75~ex for display-style
% fractions).  More than two variables can be specified, viz.,
% \begin{verbatim}
% \[ \Jacobian{K,L,M}{X,Y,Z}
%   = \Jacobiandet[\displaystyle][3ex]{K,L,M}{X,Y,Z} \]
%\end{verbatim}
% will produce
% \[ \Jacobian{K,L,M}{X,Y,Z} = \Jacobiandet[\displaystyle][3ex]{K,L,M}{X,Y,Z}.
% \]
% The \cs{Jacobiandet} macro will understand implied multicomponent Jacobians,
% too, namely,
% \begin{verbatim}
% \[ \Jacobian{f_1,\dots,f_m}{x_1,\dots,x_m} =
%    \Jacobiandet{f_1,\dots,f_m}{x_1,\dots,x_m} \]
%\end{verbatim}
% typesets as
% \[ \Jacobian{f_1,\dots,f_m}{x_1,\dots,x_m} =
%    \Jacobiandet{f_1,\dots,f_m}{x_1,\dots,x_m}. \]
% If the option |moles-range| or the \env{thermomolesrange} environment is
% used, the same code produces
% \begin{thermomolesrange}
% \[ \Jacobian{f_1,\dots,f_m}{x_1,\dots,x_m} =
%    \Jacobiandet{f_1,\dots,f_m}{x_1,\dots,x_m}. \]
% \end{thermomolesrange}
%
% \subsection{Sums and Products}
% \DescribeMacro{\sumall}
% \DescribeMacro{\sumallbutlast}
% \DescribeMacro{\prodall}
% It is common to require sums and products such as
% \[ \sumall_i x_i = 1 \quad \text{or} \quad
%    x_\ncomponents = 1 - \sumallbutlast_i x_i \quad \text{or} \quad
%    \Gt = \sumall_j \mu_j\Nt_j \quad \text{and} \quad
%    K = \prodall_k a_k^{\nu_k}. \]
% This package defines shortcuts to typeset such terms thus:
% \begin{verbatim}
% \[ \sumall_i x_i = 1 \quad \text{or} \quad
%    x_\ncomponents = 1 - \sumallbutlast_i x_i \quad \text{or} \quad
%    \Gt = \sumall_j \mu_j\Nt_j \quad \text{and} \quad
%    K = \prodall_k a_k^{\nu_k} \].
%\end{verbatim}
% The symbol $C$ can be changed by redefining the expandable macro
% \cs{ncomponents}. This is done automatically by some package options (e.g.,
% |TesterModell| changes it to $n$; |Sandler| changes it to $\mathcal{C}$;
% |Thompson| changes it to $c$).
%
% \section{Loading the Package} \label{sec:loading}
% To load the package with the defaults enabled, load it the usual way:
% \begin{verbatim}
%   \usepackage{thermodynamics}
%\end{verbatim}
% The package options loaded by default are \verb"EUAGHan", \verb"subscripts",
% \verb"parentheses", \verb"intensive-plain", and \verb"moles-index".
% These define, respectively, the default symbols to use for total energy,
% internal energy, Helmholtz free energy, and so forth; the manner of writing
% partial derivatives; the delimiters around partial derivatives; the
% manner of denoting extensive, molar, and specific properties; and the
% manner of writing the number of moles of all or most species in partial
% derivatives. The default behavior can be altered by options in the following
% section.
%
% \subsection{Package Options}
% There are three categories of options: options that affect which symbols are
% used, options that affect how symbols are decorated, and options that affect
% how partial derivatives are displayed. These are presented in turn.
%
% \subsubsection{Options that Change Symbol Sets}
% There are several options that choose the set of symbols to use for total
% energy, internal energy, Helmholtz free energy, and so forth. These are
% summarized in Table~\ref{table:symbol-sets}. The default is \verb"EUAGHan".
%
% \NewExtensiveProperty{f}{F}
% \NewExtensiveProperty{a}{A}
% \NewExtensiveProperty{ee}{\mathcal{E}}
% \NewExtensiveProperty{aa}{\mathcal{A}}
% \begin{table}
%   \caption{Options controlling which symbols to use by default. The
%       macros \cs{Et}, \cs{Ut}, \cs{Ft}, \cs{Gt}, \cs{Ht}, \cs{At}, and
%       \cs{Nt} represent the total energy, internal energy,
%       Helmholtz free energy, Gibbs free energy, enthalpy, surface area,
%       and number of moles, respectively. Symbols are shown as they would
%       appear with the (default) option \texttt{intensive-plain}.
%   }
%   \label{table:symbol-sets}
%   \centering\small
%   \begin{tabular}{l l l l l l l l l}
%   \toprule
%   Option & \verb"\Et" & \verb"\Ut" & \verb"\Ft" & \verb"\Gt" & \verb"\Ht"
%          & \verb"\At" & \verb"\Nt" \\
%   \midrule
%     |EUAGHan| & $\Et$ & $\Ut$ & $\Ft$ & $\Gt$ & $\Ht$ & $\At$ & $n$ \\
%     |EUAGHaN| & $\Et$ & $\Ut$ & $\Ft$ & $\Gt$ & $\Ht$ & $\At$ & $N$ \\
%     |EUHAGan| & \multicolumn{7}{l}{(synonym for \texttt{EUAGHan})} \\
%     |EUHAGaN| & \multicolumn{7}{l}{(synonym for \texttt{EUAGHaN})} \\
%     |EUFGHAn| & $\Et$ & $\Ut$ & $\ft$ & $\Gt$ & $\Ht$ & $\at$ & $n$ \\
%     |EUFGHAN| & $\Et$ & $\Ut$ & $\ft$ & $\Gt$ & $\Ht$ & $\at$ & $N$ \\
%     |EEFGHAn| & $\eet$ & $\Et$ & $\ft$ & $\Gt$ & $\Ht$ & $\at$ & $n$ \\
%     |EEFGHAN| & $\eet$ & $\Et$ & $\ft$ & $\Gt$ & $\Ht$ & $\at$ & $N$ \\
%     |EEFGHan| & $\eet$ & $\Et$ & $\ft$ & $\Gt$ & $\Ht$ & $\At$ & $n$ \\
%     |EEFGHaN| & $\eet$ & $\Et$ & $\ft$ & $\Gt$ & $\Ht$ & $\At$ & $N$ \\
%     |EEAGHaN| & $\eet$ & $\Et$ & $\Ft$ & $\Gt$ & $\Ht$ & $\At$ & $N$ \\
%     |EEAGHAN| & $\eet$ & $\Et$ & $\Ft$ & $\Gt$ & $\Ht$ & $\aat$ & $n$ \\
%     |EUAGHAN| & $\Et$ & $\Ut$ & $\Ft$ & $\Gt$ & $\Ht$ & $\aat$ & $N$ \\
%     |EUFGHan| & $\Et$ & $\Ut$ & $\ft$ & $\Gt$ & $\Ht$ & $\At$ & $n$ \\
%     |EUFGHaN| & $\Et$ & $\Ut$ & $\ft$ & $\Gt$ & $\Ht$ & $\At$ & $N$ \\
%   \bottomrule
%   \end{tabular}
% \end{table}
%
% Using \verb"EUAGHan" (the default), we might use the following markup:
% \begin{verbatim}
%   \[ \Ft = \Ut - T\St = -P\Vt + \sumall_i \mu_i \Nt_i + \sigma \At
%      \qquad \Hm = \Um + P\Vm \qquad \Et = \Ut + \frac12 mv^2 \],
%\end{verbatim}
% which would look like
%   \[ \Ft = \Ut - T\St = -P\Vt + \sumall_i \mu_i \Nt_i + \sigma \At
%      \qquad \Hm = \Um + P\Vm \qquad \Et = \Ut + \frac12 mv^2 \]
% Using the \verb"EEFGHAN" option, the same markup would yield
% \[ \ft
%    = \Et - T\St
%    = -P\Vt + \sumall_i \mu_i N_i + \sigma \at
%    \qquad H = U + PV
%    \qquad \eet = \Et + \frac12 mv^2. \]
%
% \subsubsection{Options for Extensive vs.\ Molar Properties}
% There are four sets of notation that define how extensive properties are
% represented, as shown in Table~\ref{table:extensive}.
% The default is \verb"intensive-plain", which (using the volume as an
% example) represents the total, molar, specific, and partial molar volumes,
% respectively, as $\Vt,$ $\Vm,$ $\Vs,$ and $\Vpm{j},$
% respectively.
%
% For example, the definition of the partial molar enthalpy would be different
% depending on which set of notation is used. The markup
% \begin{verbatim}
% \[ \Hpm_i = \Partial*{\Ht}{\Nt_i}{T,P,\allNsbut{i}}
%           = \Partial{\Nt\Hm}{\Nt_i}{T,P,\allNsbut{i}} \]
%\end{verbatim}
% yields the following, depending on the package option loaded:
% \begin{align*}
%   \Hpm_i &= \Partial*{\Ht}{\Nt_i}{T,P,\allNsbut{i}}
%           = \Partial{\Nt\Hm}{\Nt_i}{T,P,\allNsbut{i}}
%       && \text{\texttt{intensive-plain}} \\
%   \Hpm_i &=
% \begin{thermoextensiveplain}
%             \Partial*{\Ht}{\Nt_i}{T,P,\allNsbut{i}}
%           = \Partial{\Nt\Hm}{\Nt_i}{T,P,\allNsbut{i}}
% \end{thermoextensiveplain}
%       && \text{\texttt{extensive-plain}} \\
%   \Hpm_i &=
% \begin{thermoextensivesuperscript}
%             \Partial*{\Ht}{\Nt_i}{T,P,\allNsbut{i}}
%           = \Partial{\Nt\Hm}{\Nt_i}{T,P,\allNsbut{i}}
% \end{thermoextensivesuperscript}
%       && \text{\texttt{extensive-superscript}} \\
% \begin{thermointensivelowercase}
%   \Hpm_i
% \end{thermointensivelowercase}
%          &=
% \begin{thermointensivelowercase}
%             \Partial*{\Ht}{\Nt_i}{T,P,\allNsbut{i}}
%           = \Partial{\Nt\Hm}{\Nt_i}{T,P,\allNsbut{i}}
% \end{thermointensivelowercase}
%       && \text{\texttt{intensive-lowercase}}
% \end{align*}
% The use of \verb"intensive-lowercase" is strongly discouraged.
%
% Note that the number of moles can be changed from $n$ to $N$ via the
% options in the previous section.
%
% \begin{table}
%   \caption{Notation sets that can be set using the options
%       \texttt{intensive-plain} (the default), \texttt{extensive-plain},
%       \texttt{extensive-superscript}, and \texttt{intensive-lowercase}.}
%   \label{table:extensive}
%   \centering\small
%   \begin{tabular}{l l l l l l}
%   \toprule
%     Option & \verb"\Vt" & \verb"\Vm" & \verb"\Vs" & \verb"\Vpm_i" \\
%   \midrule
%     \verb"intensive-plain" & $\Vt$ & $\Vm$ & $\Vs$ & $\Vpm{i}$ \\[2ex]
%     \verb"extensive-plain" &
%       \begin{thermoextensiveplain}$\Vt$\end{thermoextensiveplain} &
%       \begin{thermoextensiveplain}$\Vm$\end{thermoextensiveplain} &
%       \begin{thermoextensiveplain}$\Vs$\end{thermoextensiveplain} &
%       \begin{thermoextensiveplain}$\Vpm{i}$\end{thermoextensiveplain}
%     \\[2ex]
%     \verb"extensive-superscript" &
%       \begin{thermoextensivesuperscript}$\Vt$\end{thermoextensivesuperscript} &
%       \begin{thermoextensivesuperscript}$\Vm$\end{thermoextensivesuperscript} &
%       \begin{thermoextensivesuperscript}$\Vs$\end{thermoextensivesuperscript} &
%       \begin{thermoextensivesuperscript}$\Vpm{i}$\end{thermoextensivesuperscript} \\[2ex]
%     \verb"intensive-lowercase" &
%       \begin{thermointensivelowercase}$\Vt$\end{thermointensivelowercase} &
%       \begin{thermointensivelowercase}$\Vm$\end{thermointensivelowercase} &
%       \begin{thermointensivelowercase}$\Vs$\end{thermointensivelowercase} &
%       \begin{thermointensivelowercase}$\Vpm{i}$\end{thermointensivelowercase} 
%     \\
%   \bottomrule
%   \end{tabular}
% \end{table}
%
% \pagebreak[1]\relax
% \setmarginparsize{\footnotesize}
% \DescribeEnv{thermointensiveplain}
% \DescribeEnv{thermoextensiveplain}
% \DescribeEnv{thermoextensivesuperscript}
% \DescribeEnv{thermointensivelowercase}
% \restoremarginparsize
% It is possible to change notation locally, though there are very, very few
% good reasons why you would want to do this in a regular document---normally,
% one would use the corresponding package options. The environment
% \env{thermointensiveplain} means \cs{St} will become $\St$ and \cs{Sm} will
% become $\Sm$ in the text. Similarly, inside \env{thermoextensiveplain},
% \cs{St} will become $S$ and \cs{Sm} will become $\St$.
% Inside \env{thermoextensivesuperscript}, \cs{St} will become $S^t$ and
% \cs{Sm} will be $S$; and inside \env{thermointensivesubscript},
% \cs{St} will be $S$ and \cs{Sm} will be $s$.
%
% \subsubsection{Options Affecting Partial Derivatives}
% There are several options that change how partial derivatives are rendered.
% First are the options that affect the delimiters. We will use the following
% code as an example:
% \begin{verbatim}
%   \[ \Partial*{\Vm}{T}{P} = \PartialMixSecond{\Gm}{T}{P}{}
%                           = \PartialMixSecond{\Gm}{P}{T}{}
%                           = -\Partial{\Sm}{P}{T}. \]
%\end{verbatim}
% Using the |parentheses| option (the default), this gives
%   \[ \Partial*{\Vm}{T}{P} = \PartialMixSecond{\Gm}{T}{P}{}
%                           = \PartialMixSecond{\Gm}{P}{T}{}
%                           = -\Partial{\Sm}{P}{T}. \]
% The option |brackets| changes the output to
% \begin{thermobrackets}
%   \[ \Partial*{\Vm}{T}{P} = \PartialMixSecond{\Gm}{T}{P}{}
%                           = \PartialMixSecond{\Gm}{P}{T}{}
%                           = -\Partial{\Sm}{P}{T}. \]
% \end{thermobrackets}\relax
% The option \verb"bar" changes the output to
% \begin{thermobar}
%   \[ \Partial*{\Vm}{T}{P} = \PartialMixSecond{\Gm}{T}{P}{}
%                           = \PartialMixSecond{\Gm}{P}{T}{}
%                           = -\Partial{\Sm}{P}{T}. \]
% \end{thermobar}\relax
% The option \verb"plain-derivatives" eliminates all delimiters; this forces
% the \verb"nosubscripts" option. The output in this case is
% \begin{thermoplain}%
%   \[ \Partial*{\Vm}{T}{P} = \PartialMixSecond{\Gm}{T}{P}{}
%                           = \PartialMixSecond{\Gm}{P}{T}{}
%                           = -\Partial{\Sm}{P}{T}. \]
% \end{thermoplain}\relax
% Accompanying the \verb"plain-derivatives" option is the \verb"nosubscripts"
% option, which overrides the default option \verb"subscripts". This option
% makes partial derivatives such as
% \[ \begin{thermosubscripts}
%      \Partial{\Vm}{P}{T} \qquad \text{(\texttt{subscripts} option)},
%     \end{thermosubscripts}\relax \]
% and instead renders them
% \[ \begin{thermoNOsubscripts}
%       \Partial{\Vm}{P}{T} \qquad \text{(\texttt{nosubscripts} option)},
%    \end{thermoNOsubscripts} \]
% Combined with \verb"plain-derivatives", this would give
% \[ \begin{thermoplain}
%      \Partial{\Vm}{P}{T} \qquad \text{(\texttt{nosubscripts} and
%                                        \texttt{plain-derivatives} options)}.
%    \end{thermoplain} \]
% The variables are sorted into an order defined by an internal constant,
% meaning $T$ will always be listed before $P$. The order by default is in
% the order that terms appear in the fundamental equations, that is,
% \begin{gather*}
%   d\Ut = T \,d\St - P \,d\Vt + \mu \,d\Nt \\
%   d\Ht = T \,d\St + \Vt \,dP + \mu \,d\Nt \\
%   d\Ft = -\St\,dT - P \,d\Vt + \mu \,d\Nt \\
%   \vdots \\
%   d\Lt = -\St\,dT - P \,d\Vt - \Nt\,d\mu,
% \end{gather*}
% with the exception that subscripted variables are (currently) not sortable.
% If \verb"\Nt_i" or some similar construct appears as a variable and
% \verb"\allNsbut{i}" appears in the held-constant list, the package will
% assume that the argument list \emph{should} contain all of the mole numbers.
% Symbols without subscripts that are not in the fundamental equation or one of
% its variants are sorted in alphabetical order.
%
% \DescribeEnv{thermoparentheses}
% \DescribeEnv{thermobrackets}
% \DescribeEnv{thermobar}
% \DescribeEnv{thermoplain}
% If you want to use parentheses \emph{locally}, even though your overall
% document uses another delimiter, the \env{thermoparentheses} environment will
% do that. Similarly, \env{thermobrackets} will temporarily switch to brackets,
% \env{thermobar} will temporarily switch to a tailing vertical bar, and
% \env{thermoplain} will remove delimiters altogether.
%
% \DescribeEnv{thermosubscripts}
% \DescribeEnv{thermoNOsubscripts}
% The environments \env{thermosubscripts} and \env{thermoNOsubscripts}
% force the use or disuse of subscripts, respectively.
%
% \subsubsection{Options Regarding the Number of Moles}
% \DescribeMacro{\allNs}%
% \DescribeMacro{\allNsbut}%
% The default option \verb"moles-index" defines the macro \cs{allNs} to expand
% to $\allNs$ and the macro \verb"\allNsbut{i}" to expand to $\allNsbut{i}$.
% You can change the dummy index: \verb"\allNsbut[k]{i}" expands to
% $\allNsbut[k]{i}$ by default. This is typically not necessary, however: if
% you type \verb"\allNsbut{j}", the package will figure out that you want
% $\allNsbut{j}$ rather than $\Nt_{j\neq j}$. The time to use the optional
% argument is in situations such as
% \[ \Partial{\mu_j}{\Nt_k}{\allNsbut[i]{k}}, \]
% which is incorrect if the dummy index $j$ is used in place of the $i$.
%
% You can change these to expand to ranges using the \verb"moles-range"
% option, which renders \cs{allNs} as
% $\begin{thermomolesrange}\allNs\end{thermomolesrange}$ and
% \verb"\allNsbut{i}" as
% $\begin{thermomolesrange}\allNsbut{i}\end{thermomolesrange}.$
% The optional argument is ignored in this set of notation. Examples of these
% options are shown in Table~\ref{table:allNs}.
%
% \DescribeEnv{thermomolesrange}
% The environment \env{thermomolesrange} temporarily redefines \cs{allNs} and
% other range-oriented macros as though the |moles-range| package option had
% been invoked.
%
% \DescribeMacro{\ncomponents}%
% You can change the symbol for the number of components (default: $C$) by
% redefining the macro \cs{ncomponents}. This is done for you by some package
% options that define notation for particular textbooks.
%
% \begin{table}
%   \caption{Illustration of the \texttt{moles-index} and \texttt{moles-range}
%       options and their effects on \cs{allNs} and \cs{allNsbut}.}
%   \label{table:allNs}
%^^A TODO The \leavevmode macro here is to prevent whitespace from building
%^^A      up due to a bug in old versions of hypdoc. It should be harmless to
%^^A      leave it in there, but consider removing it at some point.
%   \leavevmode
%   \SpecialMacroIndex{\allNs}\relax
%   \SpecialMacroIndex{\allNsbut}\relax
%   \SpecialMacroIndex{\allXs}\relax
%   \SpecialMacroIndex{\allXsbut}\relax
%   \centering
%   \begin{minipage}{4.49in}\renewcommand*{\footnoterule}{\vskip-1.5ex}%
%   \small
%     \begin{tabular}{l l l}
%     \toprule
%       Macro\footnote{You may use $C$ directly instead of \cs{ncomponents}
%         here, but then it will not change to another symbol if you want to
%         switch to an option that redefines \cs{ncomponents} later.}
%       & \verb"moles-index" & \verb"moles-range" \\
%     \midrule
%       \verb"\allNs" & $\allNs$
%           & $\begin{thermomolesrange}\allNs\end{thermomolesrange}$ \\
%       \verb"\allNsbut{1}" & $\allNsbut{1}$
%           & $\begin{thermomolesrange}\allNsbut{1}\end{thermomolesrange}$ \\
%       \verb"\allNsbut{i}" & $\allNsbut{i}$
%           & $\begin{thermomolesrange}\allNsbut{i}\end{thermomolesrange}$ \\
%       \verb"\allNsbut{j}" & $\allNsbut{j}$
%           & $\begin{thermomolesrange}\allNsbut{j}\end{thermomolesrange}$ \\
%       \verb"\allNsbut{\ncomponents}" & $\allNsbut{\ncomponents}$
%  & $\begin{thermomolesrange}\allNsbut{\ncomponents}\end{thermomolesrange}$\\
%       \verb"\allNsbut[k]{i}" & $\allNsbut[k]{i}$
%           & $\begin{thermomolesrange}\allNsbut[k]{i}\end{thermomolesrange}$\\
%       \verb"\allXs" & $\allXs$
%           & $\begin{thermomolesrange}\allXs\end{thermomolesrange}$ \\
%       \verb"\allXsbut{1}" & $\allXsbut{1}$
%           & $\begin{thermomolesrange}\allXsbut{1}\end{thermomolesrange}$ \\
%       \verb"\allXsbut{i}" & $\allXsbut{i}$
%           & $\begin{thermomolesrange}\allXsbut{i}\end{thermomolesrange}$ \\
%       \verb"\allXsbut{j}" & $\allXsbut{j}$
%           & $\begin{thermomolesrange}\allXsbut{j}\end{thermomolesrange}$ \\
%       \verb"\allXsbut{\ncomponents-1}" & $\allXsbut{\ncomponents-1}$
%           & $\begin{thermomolesrange}\allXsbut{\ncomponents-1}
%               \end{thermomolesrange}$ \\
%       \verb"\allXsbut[k]{\ncomponents-1}" & $\allXsbut[k]{\ncomponents-1}$
%           & $\begin{thermomolesrange}\allXsbut[k]{\ncomponents-1}
%               \end{thermomolesrange}$ \\
%       \verb"\allXsbut{\ncomponents}"\footnote{This would typically be used
%           to denote something like
%           \( \begin{thermomolesrange}
%                \Gt(T,P,\Nt,\allXsbut{\ncomponents})
%               \end{thermomolesrange}
%           \) rather than in a subscript, but it looks silly if we do not
%           handle this case this way.}
%           & $\allXsbut{\ncomponents}$
%           & $\begin{thermomolesrange}\allXsbut{\ncomponents}
%              \end{thermomolesrange}$ \\
%     \bottomrule
%     \end{tabular}
%   \end{minipage}
% \end{table}
%
% \subsubsection{Other Options}
% \DescribeMacro{\dbar}%
% The default for path-dependent one-forms (often called ``inexact
% differentials'') is \cs{dbar}, which looks like $\dbar$. This can be changed,
% if desired, to a delta ($\delta$) with the \verb"delta" option to the
% package.
%
% It should be noted that the \cs{dbar} macro is context-dependent: changing
% the typeface to something not supported will probably ruin it, as the kerning
% is very font-specific. This package currently supports Computer Modern,
% Times, Palatino, Bitstream Charter, Garamond, and Utopia, but other typefaces
% may require a manual redefinition.
%
% \subsubsection{Options for Particular Textbooks}
% There are several options that load package options and/or redefine
% particular commands to match the notation in a particular textbook. So far
% the following textbooks are supported:
% \begin{description}
%   \item[Bejan] Notation used by Bejan, \emph{Advanced Engineering
%     Thermodynamics}, Third Edition. Wiley: Hoboken, 2006. Loads non-default
%     package options \verb"EUFGHAN", \verb"intensive-lowercase", and
%     \verb"delta". Also swaps the notation for specific and
%     intensive properties and redefines \cs{cV}, \cs{cVs}, \cs{cVt},
%     \cs{expansivitysymbol}, and \cs{ncomponents} to match his notation.
%   \item[CBK] Notation used by \c Cengel, Boles, and Kano\u glu,
%     \emph{Thermodynamics: An Engineering Approach}, Ninth Edition.
%     McGraw Hill: Singapore, 2020. Loads the non-default package options
%     \verb"EUAGHAN" and \verb"intensive-lowercase"; also redefines
%     partial molar, specific, and molar properties' notation to fit theirs,
%     and redefines the internal symbol for pressure, \cs{Deltarxn},
%     \cs{compressibilitysymbol}, and \cs{expansivitysymbol} to fit their
%     usage. Their prodigal symbols for specific and total volume, which appear
%     to be from the font ITC Benguiat Gothic Standard Book Oblique, are not
%     supported.
%   \item[ElliottLira] Notation used by Elliott and Lira, \emph{Introductory
%     Chemical Engineering Thermodynamics}, Second Edition. Prentice Hall:
%     Upper Saddle River, 2012. Loads the default package options and
%     redefines \cs{IG}, \cs{IGM}, \cs{allcomponents}, and \cs{Deltarxn} to fit
%     their notation.
%   \item[Koretsky] Notation used by Koretsky, \emph{Engineering and Chemical
%     Thermodynamics}, Second Edition, Wiley: New Caledonia, 2013.
%     Loads the non-default package options \verb"EUAGHAn", \verb"brackets",
%     \verb"intensive-lowercase", and \verb"delta"; modifies the
%     \verb"intensive-lowercase" defaults to make uppercase partial molar
%     properties to match Koretsky's notation and redefines
%     \cs{expansivitysymbol}, \cs{IS}, \cs{residual}, \cs{IG}, \cs{IGM},
%     \cs{Deltafus}, \cs{Deltasub}, \cs{Deltavap}, \cs{Henryrat},
%     \cs{gammarat}, \cs{Deltafus}, \cs{Deltavap}, and \cs{Deltasub} to match
%     his use. Also redefines the fugacity coefficients to use $\varphi$
%     instead of $\phi$.
%   \item[MSBB] Notation used by Moran, Shapiro, Boettner, and Bailey,
%     \emph{Fundamentals of Engineering Thermodynamics}, Eighth Edition.
%     Wiley: Kendallville, 2014. Loads the non-default package options
%     \verb"EUFGHAn", \verb"intensive-lowercase", and \verb"delta"; removes the
%     left parenthesis in partial derivatives and redefines \cs{IGM}, \cs{IG},
%     \cs{expansitivitysymbol}, \cs{allcomponents}, \cs{allbut}, \cs{Ft},
%     \cs{fmix}, and \cs{phimix}, as well as symbols for the Helmholtz free
%     energy and pressure, intensive and specific property notation, and
%     partial molar notation to fit their somewhat ill-advised notation.
%   \item[Prausnitz] Notation used by Prausnitz, Lichtenthaler, and de Azevedo,
%     \emph{Molecular Thermodynamics of Fluid-Phase Equilibria}, Third Edition,
%     Pearson, 1998. Loads the non-default package option
%     \verb"intensive-lowercase" and redefines \cs{fmix}, \cs{phimix},
%     \cs{fpure}, \cs{phipure}, \cs{Henryrat}, \cs{residual},
%     \cs{allcomponents}, and \cs{allbut} to fit their notation.
%   \item[Sandler] Notation used by Sandler, \emph{Chemical, Biochemical, and
%     Engineering Thermodynamics}, Fifth Edition. Wiley: Hoboken, 2017.
%     Loads non-default package options \verb"EUAGHaN" and
%     \verb"extensive-plain"; also redefines \cs{sat}, \cs{excess},
%     \cs{residual}, \cs{ncomponents}, \cs{fmix}, \cs{fstd}, \cs{phimix},
%     \cs{allcomponents}, \cs{IS}, \cs{Deltamix}, \cs{Deltarxn}, \cs{Deltasub},
%     \cs{Deltafus}, \cs{Deltavap}, and \cs{Henryrat}. Also redefines \cs{cV},
%     \cs{cP}, \cs{cVt}, and \cs{cPt}.
%   \item[SVNAS] Notation used by Smith, Van Ness, Abbott, and Swihart,
%     \emph{Introduction to Chemical Engineering Thermodynamics}, Ninth
%     Edition. McGraw-Hill: Boston, 2021. Loads the non-default package option
%     \verb"extensive-superscript" and redefines \cs{allcomponents},
%     \cs{allbut}, \cs{IG}, \cs{IGM}, \cs{IS}, \cs{expansivitysymbol}, and
%     \cs{Deltarxn} to fit their notation.  The extensive heat capacities are
%     also redefined, as they do not use such an entity.
%   \item[TesterModell] Notation used by Tester and Modell,
%     \emph{Thermodynamics and Its Applications}, Third Edition, Prentice Hall:
%     Upper Saddle River, 1997. Loads the non-default package options
%     \verb"EUAGHaN" and \verb"delta"; also redefines \cs{ncomponents} to be
%     $n$ and redefines \cs{allcomponents}, \cs{allbut}, and \cs{allbutlastand}
%     to fit their (somewhat inconsistent) notation. Also redefines \cs{IG},
%     \cs{IGM}, \cs{IS}, \cs{excess}, \cs{reaction}, \cs{Henryrat},
%     \cs{Henrymol}, \cs{gammarat}, and \cs{gammamol} to fit their style.
%   \item[Thompson] Notation used by Thompson, \emph{A Unified Introduction to
%     Chemical Engineering Thermodynamics}, Stillwater Press: Orono, 2000.
%     Loads the non-default package options |EUAGHAn| and |delta|;
%     also redefines \cs{excess}, \cs{residual}, \cs{Henryrat}, \cs{Henrymol},
%     \cs{allcomponents}, \cs{ncomponents}, \cs{IS}, \cs{IG}, \cs{IGM},
%     \cs{fpure}, \cs{phipure}, \cs{mix}, \cs{Deltamix}, \cs{Deltarxn}, and
%     \cs{allbut} to match his notation, plus adjustments to intensive (molar)
%     properties.  Note that he uses $c$, $\mathrm{c}$, $n_C$, and 
%     $\mathrm{n}$ for the number of components in various places in the book;
%     I chose $c$ for the definition of \cs{ncomponents}, but it is impossible
%     to be completely consistent with his notation.
% \end{description}
% There may well be some inconsistencies between the notation in these books
% and the symbols used here. I will fix such inconsistencies as I become aware
% of them.
%^^X \end{documentation}
%
% \setcounter{IndexColumns}{2}
% \StopEventually{\PrintChanges\PrintIndex}
%
% ^^A--------------------------------------------------------------------------
% \iffalse
%<*package>
%<@@=thermodynamics>
% \fi
%
%^^X\begin{implementation}
% \section{Implementation}
% We set up some non-standard token comparison variants; these are designed
% to catch both \cs{ncomponents}=\cs{ncomponents} and \cs{ncomponents}=$C$
% (using the default options); we have to define \cs{ncomponents} to be
% expandable to make these work at all.
%    \begin{macrocode}
\ExplSyntaxOn
\cs_generate_variant:Nn \tl_if_eq:nnTF { xxTF }
%    \end{macrocode}
%
% This package requires the \pkg{amstext} package, as \tn{text} is used to
% handle \cs{sat}, \cs{IS}, \cs{IG}, \cs{IGM}, \cs{Henrymol}, \cs{fusion},
% \cs{reaction}, \cs{vaporization}, and \cs{sublimation} by default, as well
% as several other macros defined by package options.
%    \begin{macrocode}
\RequirePackage{amstext}
%    \end{macrocode}
%
% \subsection{Symbols Controlled by Package Options}
% We set some symbols prior to declaring the package options. The default
% symbols follow package option |EUAGHan|, even though the macros follow
% the option |EUFGHAN|.
%
% \begin{macro}{\dbar}
% The way \cs{dbar} is defined depends on the typeface you are using.
% We try to determine, at \verb"\begin{document}", which typeface you chose
% based on the packages that are loaded and some of their internal definitions.
% The \textsf{thermodynamics} package currently supports
% Computer Modern (the default or through \pkg{lmodern}),
% Palatino (through \pkg{pxfonts} or \pkg{newpxmath}),
% Times (through \pkg{txfonts}, \pkg{mathptmx}, or \pkg{newtxmath}),
% Utopia (through \pkg{mathdesign}),
% Bitstream Charter (through \pkg{mathdesign}), and
% Garamond (through \pkg{mathdesign}).
% Definitions of \cs{dbar} (with \cs{newcommand*}, \cs{providecommand*},
% \cs{NewDocumentCommand}, or \cs{ProvideDocumentCommand})
% in the preamble will override the ones here.
%    \begin{macrocode}
\AtBeginDocument{
    \@ifpackageloaded{pxfonts}{%
        \ProvideDocumentCommand{\dbar}{}
            {\mkern5mu\mathchar'26\mkern-10mu d}
    }{}
    \@ifpackageloaded{newpxmath}{%
        \ProvideDocumentCommand{\dbar}{}
            {\mkern5mu\mathchar'26\mkern-10mu d}
    }{}
    \@ifpackageloaded{txfonts}{%
        \ProvideDocumentCommand{\dbar}{}
            {\mkern5mu\mathchar'26\mkern-11mu d}
    }{}
    \@ifpackageloaded{mathptmx}{%
        \ProvideDocumentCommand{\dbar}{}
            {\mkern5mu\mathchar'26\mkern-10mu d}
    }{}
    \@ifpackageloaded{newtxmath}{%
        \ProvideDocumentCommand{\dbar}{}
            {\mkern5mu\mathchar'26\mkern-11mu d}
    }{}
    \@ifpackageloaded{mathdesign}{%
        \tl_const:Nn \c_@@_charter_tl {mdbch}
        \tl_const:Nn \c_@@_utopia_tl {mdput}
        \tl_const:Nn \c_@@_garamond_tl {mdugm}
        \tl_if_eq:NNT \MD@default@family \c_@@_utopia_tl
        { \ProvideDocumentCommand{\dbar}{}
            {\mkern5mu\mathchar'26\mkern-20mu d}
        }
        \tl_if_eq:NNT \MD@default@family \c_@@_charter_tl
        { \ProvideDocumentCommand{\dbar}{}
            {\mkern5mu\mathchar'26\mkern-15mu d}
        }
        \tl_if_eq:NNT \MD@default@family \c_@@_garamond_tl
        { \ProvideDocumentCommand{\dbar}{}
            {\mkern5mu\mathchar'26\mkern-17mu d}
        }
    }{}
    % Defaults to Computer Modern
    \ProvideDocumentCommand{\dbar}{}
        {\mkern3mu\mathchar'26\mkern-12mu d}
}
%    \end{macrocode}
% \end{macro}
%
% Symbols are defined for the total energy, internal energy, Helmholtz free
% energy, Gibbs free energy, enthalpy, entropy, surface area, volume, number
% of moles, heat, and work; these are $E$, $U$, $A$, $G$, $H$, $S$, $a$,
% $V$, $n$, $Q$, and $W$, respectively. These commands should not be used on
% their own, but rather accessed through the macros \cs{Ut}, \cs{Um}, and
% \cs{Us} (using the internal energy as an example).
%
% The default symbols are not intended to be easy to change---the intended
% mechanism is through package options. If you want to use a non-standard
% symbol that is not available through one of the package options, you can
% redefine the internal token lists inside
% \cs{ExplSyntaxOn}\dots\cs{ExplSyntaxOff}. For example,
% \begin{verbatim}
%    \ExplSyntaxOn
%       \tl_gset:Nn \g__thermodynamics_Helmholtz_symbol {H}
%       \tl_gset:Nn \g__thermodynamics_enthalpy_symbol {h}
%    \ExplSyntaxOff
%\end{verbatim}
% would define the ill-advised notation that I have nonetheless heard of
% that uses $H$ for Helmholtz free energy and $h$ for enthalpy.
% Note that the macros for temperature and pressure are only used inside
% the definitions of the compressibilities, expansivitites, and heat
% capacities; there is no user-level macro for the temperature or the pressure,
% so it is up to the user to use consistent symbols for those properties.
%    \begin{macrocode}
\tl_new:N \g_@@_total_energy_symbol
\tl_new:N \g_@@_internal_energy_symbol
\tl_new:N \g_@@_Helmholtz_symbol
\tl_new:N \g_@@_Gibbs_symbol
\tl_new:N \g_@@_Landau_symbol
\tl_new:N \g_@@_enthalpy_symbol
\tl_new:N \g_@@_entropy_symbol
\tl_new:N \g_@@_area_symbol
\tl_new:N \g_@@_volume_symbol
\tl_new:N \g_@@_mole_symbol
\tl_new:N \g_@@_heat_symbol
\tl_new:N \g_@@_work_symbol
\tl_new:N \g_@@_temperature_symbol
\tl_new:N \g_@@_pressure_symbol

\tl_gset:Nn \g_@@_total_energy_symbol E
\tl_gset:Nn \g_@@_internal_energy_symbol U
\tl_gset:Nn \g_@@_Helmholtz_symbol A
\tl_gset:Nn \g_@@_Gibbs_symbol G
\tl_gset:Nn \g_@@_Landau_symbol \Omega
\tl_gset:Nn \g_@@_enthalpy_symbol H
\tl_gset:Nn \g_@@_entropy_symbol S
\tl_gset:Nn \g_@@_area_symbol a
\tl_gset:Nn \g_@@_volume_symbol V
\tl_gset:Nn \g_@@_mole_symbol n
\tl_gset:Nn \g_@@_heat_symbol Q
\tl_gset:Nn \g_@@_work_symbol W
\tl_gset:Nn \g_@@_temperature_symbol T
\tl_gset:Nn \g_@@_pressure_symbol P
%    \end{macrocode}
%
% We then define two functions and several lengths that we shall use when
% drawing rules above or below a symbol. The default is to use underlined
% symbols for extensive quantities, plain symbols for molar quantities, and
% carets for specific quantities, but this can be changed using package
% options.
%^^A TODO these might work better as kern 0.1*width, symbol, kern 0.2*width
%    \begin{macrocode}
\cs_new:Nn \@@_underline:n
{ \mkern1mu\underline{\mkern-1mu #1\mkern-4mu}\mkern4mu }
\cs_new:Nn \@@_overline:n
{ \mkern2mu\overline{\mkern-2mu #1\mkern-1mu}\mkern1mu }
%    \end{macrocode}
%
% \begin{macro}{\PartialOpen,\PartialClose,\PartialEmptyClose}
% We define three commands to use to denote the beginning and end of partial
% derivatives. These symbols can be customized by package options. Default
% is |parentheses|, meaning that \verb"\[ \Partial{f}{x}{y} \]" renders as
% \[ \left(\frac{\partial f}{\partial x}\right)_y \]
% with the defaults. The macro \cs{PartialEmptyClose} is used when the last
% argument to \cs{Partial} is empty, which is important for the |bar|
% option to the document class or inside the \env{thermobar} environment.
%    \begin{macrocode}
\tl_new:N \l_@@_PartialOpen_tl
\tl_new:N \l_@@_PartialEmptyClose_tl
\tl_new:N \l_@@_PartialClose_tl

\tl_set:Nn \l_@@_PartialOpen_tl {(}
\tl_set:Nn \l_@@_PartialClose_tl {)}
\tl_set:Nn \l_@@_PartialEmptyClose_tl {)}
%    \end{macrocode}
% \end{macro}
%
% \subsection{Package Options}
% We declare a bunch of options for which sets of symbols to use.
% These are summarized in Table~\ref{table:symbol-sets}.
% \changes{v1.01}{2023/09/15}{Changed options with two $E$ or two $A$
%    variables to use calligraphic letters for the less-common of the two.}
%    \begin{macrocode}
\DeclareOption{EUAGHan}{}% the default
\DeclareOption{EUAGHaN}{\tl_gset:Nn \g_@@_mole_symbol N}%
\DeclareOption{EUHAGan}{\ExecuteOptions{EUAGHan}}
\DeclareOption{EUHAGaN}{\ExecuteOptions{EUAGHaN}}
\DeclareOption{EUFGHAn}{%
  \tl_gset:Nn \g_@@_Helmholtz_symbol F
  \tl_gset:Nn \g_@@_area_symbol A
}
\DeclareOption{EUFGHAN}{%
  \tl_gset:Nn \g_@@_Helmholtz_symbol F
  \tl_gset:Nn \g_@@_area_symbol A
  \tl_gset:Nn \g_@@_mole_symbol N
}
\DeclareOption{EEFGHAn}{%
  \tl_gset:Nn \g_@@_total_energy_symbol {\mathcal{E}}
  \tl_gset:Nn \g_@@_internal_energy_symbol E
  \tl_gset:Nn \g_@@_Helmholtz_symbol F
  \tl_gset:Nn \g_@@_area_symbol A
}
\DeclareOption{EEFGHAN}{%
  \tl_gset:Nn \g_@@_total_energy_symbol {\mathcal{E}}
  \tl_gset:Nn \g_@@_internal_energy_symbol E
  \tl_gset:Nn \g_@@_Helmholtz_symbol F
  \tl_gset:Nn \g_@@_area_symbol A
  \tl_gset:Nn \g_@@_mole_symbol N
}
\DeclareOption{EEFGHan}{%
  \tl_gset:Nn \g_@@_total_energy_symbol {\mathcal{E}}
  \tl_gset:Nn \g_@@_internal_energy_symbol E
  \tl_gset:Nn \g_@@_Helmholtz_symbol F
}
\DeclareOption{EEFGHaN}{%
  \tl_gset:Nn \g_@@_total_energy_symbol {\mathcal{E}}
  \tl_gset:Nn \g_@@_internal_energy_symbol E
  \tl_gset:Nn \g_@@_Helmholtz_symbol F
  \tl_gset:Nn \g_@@_mole_symbol N
}
\DeclareOption{EEAGHan}{%
  \tl_gset:Nn \g_@@_total_energy_symbol {\mathcal{E}}
  \tl_gset:Nn \g_@@_internal_energy_symbol E
}
\DeclareOption{EEAGHaN}{%
  \tl_gset:Nn \g_@@_total_energy_symbol {\mathcal{E}}
  \tl_gset:Nn \g_@@_internal_energy_symbol E
  \tl_gset:Nn \g_@@_mole_symbol N
}
\DeclareOption{EUAGHAn}{%
  \tl_gset:Nn \g_@@_area_symbol {\mathcal{A}}
}
\DeclareOption{EUAGHAN}{%
  \tl_gset:Nn \g_@@_area_symbol {\mathcal{A}}
  \tl_gset:Nn \g_@@_mole_symbol N
}
\DeclareOption{EUFGHan}{%
  \tl_gset:Nn \g_@@_Helmholtz_symbol F
}
\DeclareOption{EUFGHaN}{%
  \tl_gset:Nn \g_@@_Helmholtz_symbol F
  \tl_gset:Nn \g_@@_mole_symbol N
}
%    \end{macrocode}
% The |delta| option redefines \cs{dbar} to produce the symbol $\delta$.
% The default is to use a $d$ with a slash through it ($\dbar$) for inexact
% differentials unless the user overrides it with this option. The macro could
% also be redefined manually, of course.
%    \begin{macrocode}
\DeclareOption{delta}{ \cs_set_eq:NN \dbar \delta }
%    \end{macrocode}
%
% Next, we define options for the set of notation. The default is
% |intensive-plain|, which produces things like $V$ for molar volume,
% $\Vt$ for total volume, and $\hat V$ for specific volume.
% The symbols themselves are produced via internal (non-user-facing) macros.
%    \begin{macrocode}
\cs_new:Nn \@@_extensive:n {#1}
\cs_new:Nn \@@_intensive:n {#1}
\cs_new:Nn \@@_specific:n {\hat{#1}}

\cs_new:Npn \@@_set_intensive_plain
{
  \cs_set:Nn \@@_extensive:n {\@@_underline:n{##1}}
  \cs_set:Nn \@@_intensive:n {##1}
}
\cs_new:Npn \@@_set_extensive_plain
{
  \cs_set:Nn \@@_extensive:n {##1}
  \cs_set:Nn \@@_intensive:n {\@@_underline:n{##1}}
}
\cs_new:Npn \@@_set_lowercase_pms
{
  \RenewDocumentCommand{\partialmolar}{m}
  {
    \tl_set:Nn \l_@@_pm_symbol_tl {\text_lowercase:n {##1}}
    \@@_generic_pm:
  }
}
\cs_new:Npn \@@_set_intensive_lowercase
{
  \cs_set:Nn \@@_extensive:n {\text_uppercase:n {##1}}
  \cs_set:Nn \@@_intensive:n {\text_lowercase:n {##1}}
  \cs_set:Nn \@@_specific:n {\hat{\text_lowercase:n {##1}}}
}
\cs_new:Npn \@@_set_extensive_superscripts
{
  \cs_set:Nn \@@_extensive:n {{##1}\c_math_superscript_token t}
  \cs_set:Nn \@@_intensive:n {##1}
}
\DeclareOption{extensive-plain}{\@@_set_extensive_plain}
\DeclareOption{intensive-plain}{\@@_set_intensive_plain} % the default
\DeclareOption{intensive-lowercase}{% PLEASE don't use this!
  \@@_set_intensive_lowercase
  \AtEndOfPackage{
    \@@_set_lowercase_pms
    \RenewDocumentCommand{\heatcapacitysymbol}{}{c}
  }
}
\DeclareOption{extensive-superscript}{%
  \@@_set_extensive_superscripts
  \AtEndOfPackage{%
    \RenewDocumentCommand{\URt}{}{\g_@@_internal_energy_symbol
      \c_math_superscript_token{\residual,t}}
    \RenewDocumentCommand{\HRt}{}{\g_@@_enthalpy_symbol
      \c_math_superscript_token{\residual,t}}
    \RenewDocumentCommand{\FRt}{}{\g_@@_Helmoholtz_symbol
      \c_math_superscript_token{\residual,t}}
    \RenewDocumentCommand{\GRt}{}{\g_@@_Gibbs_symbol
      \c_math_superscript_token{\residual,t}}
    \RenewDocumentCommand{\VRt}{}{\g_@@_volume_symbol
      \c_math_superscript_token{\residual,t}}
    \RenewDocumentCommand{\SRt}{}{\g_@@_entropy_symbol
      \c_math_superscript_token{\residual,t}}
    \RenewDocumentCommand{\UEt}{}{\g_@@_internal_energy_symbol
      \c_math_superscript_token{\excess,t}}
    \RenewDocumentCommand{\HEt}{}{\g_@@_enthalpy_symbol
      \c_math_superscript_token{\excess,t}}
    \RenewDocumentCommand{\FEt}{}{\g_@@_Helmoholtz_symbol
      \c_math_superscript_token{\excess,t}}
    \RenewDocumentCommand{\GEt}{}{\g_@@_Gibbs_symbol
      \c_math_superscript_token{\excess,t}}
    \RenewDocumentCommand{\VEt}{}{\g_@@_volume_symbol
      \c_math_superscript_token{\excess,t}}
    \RenewDocumentCommand{\SEt}{}{\g_@@_entropy_symbol
      \c_math_superscript_token{\excess,t}}
  }
}
%    \end{macrocode}
%
% The next two options choose whether variables held constant are subscripted
% (the default) or placed next to the function. The difference is
%%^^A \[ \left(\frac{\partial U}{\partial S}\right)_V \quad\text{versus}\quad
%%^^A    \left(\frac{\partial U(S,V)}{\partial S}\right) \]
%  \[ \Partial{\Um}{\Sm}{\Vm} \quad\text{versus}\quad
%     \begin{thermoNOsubscripts}
%       \Partial{\Um}{\Sm}{\Vm}
%     \end{thermoNOsubscripts} \]
% for \verb"subscripts" and \verb"nosubscripts", respectively.
%    \begin{macrocode}
\bool_new:N \l_@@_subscripted_bool
\bool_set_true:N \l_@@_subscripted_bool
\DeclareOption{subscripts}{\bool_set_true:N \l_@@_subscripted_bool}
\DeclareOption{nosubscripts}{\bool_set_false:N \l_@@_subscripted_bool}
%    \end{macrocode}
% These options change how \cs{Partial} and friends render derivatives.
% The default is parentheses, but other options include brackets, braces,
% a vertical bar on the right side, or plain (undecorated) derivatives.
%    \begin{macrocode}
\DeclareOption{parentheses}{}
\DeclareOption{brackets}{%
  \tl_set:Nn \l_@@_PartialOpen_tl {[}
  \tl_set:Nn \l_@@_PartialClose_tl {]}
  \tl_set:Nn \l_@@_PartialEmptyClose_tl {]}
}
\DeclareOption{braces}{%
  \tl_set:Nn \l_@@_PartialOpen_t1 {\{}
  \tl_set:Nn \l_@@_PartialClose_t1 {\}}
  \tl_set:Nn \l_@@_PartialEmptyClose_tl {\}}
}
\DeclareOption{bar}{%
  \tl_set:Nn \l_@@_PartialOpen_tl {.}
  \tl_set:Nn \l_@@_PartialClose_tl {\rvert}
  \tl_set:Nn \l_@@_PartialEmptyClose_tl {.}
}
\DeclareOption{plain-derivatives}{% This implies dU(S,V,N)/dS notation
  \tl_set:Nn \l_@@_PartialOpen_tl {.}
  \tl_set:Nn \l_@@_PartialClose_tl {.}
  \tl_set:Nn \l_@@_PartialEmptyClose_tl {.}
  \ExecuteOptions{nosubscripts}
}
%    \end{macrocode}
% \subsection{The Number of Moles Macros}
% \begin{macro}{\ncomponents}
% We define the number of components, default $C$, for use in the ``all moles''
% and related macros. The command is expandable so we can perform comparisons
% to user-entered values.
%    \begin{macrocode}
\NewExpandableDocumentCommand \ncomponents {} {C}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\allNs,\allXs,\allYs,\allmus,\allMs,\allWs}
% Several macros define a shorthand for ``moles of all species'' (\cs{allNs})
% and ``moles of all species except'' (\cs{allNsbut}), as well as similar
% quantities for masses (\cs{allMs}, \cs{allMsbut}) and chemical potentials
% (\cs{allmus}, \cs{allmusbut}), which occur frequently in mixture
% thermodynamics. The default is for \cs{allNs} to become $\vec{n}$ and
% \verb"allNsbut{i}" to become $n_{j\neq i}$. The optional argument changes
% which index (default: $j$) to use in the left side of the inequality.\relax
% \footnote{The index \!$j$ is automatically replaced with $k$ if the user
%   issues \texttt{\textbackslash allNsbut\{j\}}.}
% Essentially identical commands are defined for chemical potentials and
% masses: \cs{allmus} and \cs{allmusbut} and \cs{allMs} and \cs{allMsbut},
% respectively.
%    \begin{macrocode}
\NewDocumentCommand{\allNs}{O{i}}{\allcomponents[#1]{\Nt}}
\NewDocumentCommand{\allXs}{O{i}}{\allcomponents[#1]{x}}
\NewDocumentCommand{\allYs}{O{i}}{\allcomponents[#1]{y}}
\NewDocumentCommand{\allmus}{O{i}}{\allcomponents[#1]{\mu}}
\NewDocumentCommand{\allMs}{O{i}}{\allcomponents[#1]{m}}
\NewDocumentCommand{\allWs}{O{i}}{\allcomponents[#1]{w}}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\allNsbut,\allXsbut,\allYsbut,\allMsbut,\allWsbut}
% Similar commands are defined for mole fractions (\cs{allXs}, \cs{allYs},
% etc.), but these assume the last mole fraction is \emph{not} one of the
% variables---that is, \cs{allXsbut} and \cs{allYsbut} assume the argument
% \emph{and} \cs{ncomponents} are held constant. For example,
% \begin{verbatim}
%   \[ \Partial{\Gm}{T}{P,\allXs} = -\Sm \qquad
%      \Partial{\Gm}{x_i}{T,P,\allXsbut{i}} \neq \Gpm_i \]
%\end{verbatim}
% yields
% \[ \Partial{G}{T}{P,\allXs} = -S \qquad
%    \Partial{G}{x_i}{T,P,x_{j\neq i,C}} \neq \Gpm{i}. \]
%    \begin{macrocode}
\NewDocumentCommand{\allNsbut}{O{j} m} {\allbut[#1]{#2}{\Nt}}
\NewDocumentCommand{\allXsbut}{O{j} m} {\allbutlastand[#1]{#2}{x}}
\NewDocumentCommand{\allYsbut}{O{j} m} {\allbutlastand[#1]{#2}{y}}
\NewDocumentCommand{\allmusbut}{O{j} m} {\allbut[#1]{#2}{\mu}}
\NewDocumentCommand{\allMsbut}{O{j} m} {\allbut[#1]{#2}{m}}
\NewDocumentCommand{\allWsbut}{O{j} m} {\allbutlastand[#1]{#2}{w}}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\allbutlastand,\allbut,\allcomponents}
% \changes{v1.01}{10/04/2023}{Updated \cs{allcomponents} to include an
%   optional argument that changes $N_i$ to $N_j$, say, when using
%   TesterModell or other options that denote moles of all components that
%   way. Similar updates to \cs{allNs} and friends.}
% The \cs{allcomponents}, \cs{allbut}, and \cs{allbutlastand} macros can be
% used to define new entities; say, if you want to use $z_i$ as a mole
% fraction, then use
% \begin{verbatim}
%   \NewDocumentCommand{\allZsbut}{O{j} m}{\allbutlastand[#1]{#2}{z}}
%\end{verbatim}
% Similarly, something meaning the concentrations of every species could be
% defined via
% \begin{verbatim}
%   \NewDocumentCommand{\allCs}{O{}}{\allcomponents{C}}
%\end{verbatim}
%    \begin{macrocode}
\NewDocumentCommand{\allcomponents}{O{} m}{\vec{#2}}
\NewDocumentCommand{\allbut}{O{j} m m}
{ \tl_if_eq:nnTF {#1} {#2}
  { {#3}\c_math_subscript_token{k \neq #2} }
  { {#3}\c_math_subscript_token{#1 \neq #2} }
}
\NewDocumentCommand{\allbutlastand}{O{j} m m}
{ \tl_if_eq:xxTF {#2} {\ncomponents}
  { {#3}\c_math_subscript_token{#1 \neq #2} }
  { \tl_if_eq:nnTF {#1} {#2}
    { {#3}\c_math_subscript_token{k \neq #2,\ncomponents} }
    { {#3}\c_math_subscript_token{#1 \neq #2,\ncomponents} }
  }
}
%    \end{macrocode}
% \end{macro}
%
% We then define two package options that change how to render \cs{allNs} and
% friends.\relax
% \changes{v1.01}{2022/05/04}{Fixed bug in \cs{allbutlastand} when using the
%   |moles-range| option ($C$ should have been $C-1$ in the last option).}
%    \begin{macrocode}
\DeclareOption{moles-index}{}
\DeclareOption{moles-range}{ \@@_set_moles_range }
\cs_new:Npn \@@_set_moles_range {%
  \RenewDocumentCommand{\allcomponents}{O{} m}
  { {##2}\c_math_subscript_token 1,\dots,
        {##2}\c_math_subscript_token{\ncomponents} }
  \RenewDocumentCommand{\allbut}{O{j} m m}
  { \tl_if_eq:nnTF {##2} {1}
    { {##3}\c_math_subscript_token 2,\dots,
        {##3}\c_math_subscript_token{\ncomponents} }
    { \tl_if_eq:xxTF {##2} {\ncomponents}
      { {##3}\c_math_subscript_token 1,\dots,
          {##3}\c_math_subscript_token{\ncomponents-1} }
      { {##3}\c_math_subscript_token 1,\dots,
            [{##3}\c_math_subscript_token{##2}],
            \dots,{##3}\c_math_subscript_token{\ncomponents} }
    }
  }
  \RenewDocumentCommand{\allbutlastand}{O{j} m m}
  { \tl_if_eq:nnTF {##2} {1}
    { {##3}\c_math_subscript_token 2,\dots,
        {##3}\c_math_subscript_token{\ncomponents-1} }
    { \tl_if_eq:xxTF {##2} {\ncomponents}
      { {##3}\c_math_subscript_token 1,\dots,
        {##3}\c_math_subscript_token{\ncomponents-1}
      }
      { \tl_if_eq:xxTF {##2} {\ncomponents-1}
        { {##3}\c_math_subscript_token 1,\dots,
          {##3}\c_math_subscript_token{\ncomponents-2} }
        {
          {##3}\c_math_subscript_token 1,\dots,
          [{##3}\c_math_subscript_token{##2}],\dots,
           {##3}\c_math_subscript_token{\ncomponents-1}
        }
      }
    }
  }
}
%    \end{macrocode}
% The remaining options define textbook-specific notation.
%    \begin{macrocode}
\DeclareOption{Bejan}{
  \ExecuteOptions{EUFGHAN,intensive-lowercase,delta}
  \cs_set:Nn \@@_specific:n {\text_lowercase:n {#1}}
  \cs_set:Nn \@@_intensive:n {\bar{\text_lowercase:n {#1}}}
  \tl_gset:Nn \g_@@_volume_symbol v
}
\DeclareOption{CBK}{
  \ExecuteOptions{EUAGHAN,intensive-lowercase}
  \AtEndOfPackage{
    \cs_set:Nn \@@_overline:n {\widetilde{#1}}
    \cs_set:Nn \@@_specific:n {\text_lowercase:n {#1}}
    \cs_set:Nn \@@_intensive:n {\bar{\text_lowercase:n{#1}}}
    \tl_gset:Nn \g_@@_pressure_symbol p
    \RenewDocumentCommand{\Deltarxn}{m}{{#1}\c_math_subscript_token R}
    \RenewDocumentCommand{\compressibilitysymbol}{}{\beta}
    \RenewDocumentCommand{\expansivitysymbol}{}{\alpha}
  }
}
\DeclareOption{ElliottLira}{
  \AtEndOfPackage{
    \RenewDocumentCommand{\allcomponents}{O{} m}{#2}
    \RenewDocumentCommand{\Deltarxn}{m}{\Delta #1}
    \RenewDocumentCommand{\IG}{}{{\text{ig}}}
    \RenewDocumentCommand{\IGM}{}{{\text{ig}}}
    \RenewDocumentCommand{\IS}{}{{\text{is}}}
  }
}
\DeclareOption{Koretsky}{
  \ExecuteOptions{EUAGHAn,brackets,intensive-lowercase,delta}
  \AtEndOfPackage{
    %^^A Undo part of intensive-lowercase
    \RenewDocumentCommand{\partialmolar}{m}
    { \tl_set:Nn \l_@@_pm_symbol_tl {#1}
      \@@_generic_pm:
    }
    \RenewDocumentCommand{\expansivitysymbol}{}{\beta}
    \RenewDocumentCommand{\IS}{}{{\text{ideal}}}
    \RenewDocumentCommand{\residual}{}{{\text{dep}}}
    \RenewDocumentCommand{\IG}{}{{\text{ideal}}}
    \RenewDocumentCommand{\IGM}{}{{\text{ideal}}}
    \RenewDocumentCommand{\Henryrat}{}{{\mathcal{H}}}
    \RenewDocumentCommand{\gammarat}{}
        {\gamma\c_math_superscript_token\text{Henry's}}
    \RenewDocumentCommand{\phipure}{}{\varphi}
    \RenewDocumentCommand{\phimix}{}{\hat\varphi}
    \RenewDocumentCommand{\phisat}{}{\varphi\c_math_superscript_token\sat}
    \cs_new:Npn \Delta_fus_sym {} {}
    \NewSubscriptedSymbol{\Delta_fus}{\Delta_fus_sym}{\fusion}
    \RenewDocumentCommand{\Deltafus}{m}{
      \cs_set:Npn \Delta_fus_sym {} { \Delta #1 }
      \Delta_fus
    }
    \cs_new:Npn \Delta_vap_sym {} {}
    \NewSubscriptedSymbol{\Delta_vap}{\Delta_vap_sym}{\vaporization}
    \RenewDocumentCommand{\Deltavap}{m}{
      \cs_set:Npn \Delta_vap_sym {} { \Delta #1 }
      \Delta_vap
    }
    \cs_new:Npn \Delta_sub_sym {} {}
    \NewSubscriptedSymbol{\Delta_sub}{\Delta_sub_sym}{\sublimation}
    %^^A Undo part of intensive-lowercase
    \RenewDocumentCommand{\Deltasub}{m}{
      \cs_set:Npn \Delta_sub_sym {} { \Delta #1 }
      \Delta_sub
    }
  }
}
\DeclareOption{MSBB}{
  \ExecuteOptions{EUFGHAn,intensive-lowercase,delta}
  \AtEndOfPackage{
    \RenewDocumentCommand{\IGM}{}{\ast}
    \RenewDocumentCommand{\IG}{}{\ast}
    \RenewDocumentCommand{\expansivitysymbol}{}{\beta}
    \RenewDocumentCommand{\allcomponents}{O{} m}{#2}
    \RenewDocumentCommand{\allbut}{O{j} m m}
    {
      \tl_if_eq:nnTF {#1} {#2}
      { {#3}\c_math_subscript_token k }
      { {#3}\c_math_subscript_token{#1} }
    }
    \tl_gset_eq:NN \g_@@_Helmholtz_symbol \psi
    \RenewDocumentCommand{\Ft}{}{\Psi}
    \cs_set:Nn \@@_intensive:n {\@@_overline:n{\text_lowercase:n{#1}}}
    \cs_set:Nn \@@_specific:n {\text_lowercase:n{#1}}
    \RenewDocumentCommand{\fmix}{}{\bar f}
    \RenewDocumentCommand{\phimix}{}{\bar\phi}
    \RenewDocumentCommand{\phimix}{}{\bar\phi}
    \tl_gset:Nn \g_@@_pressure_symbol p
    \RenewDocumentCommand{\partialmolar}{m}
    {
      \tl_set:Nn \l_@@_pm_symbol_tl {#1}
      \@@_generic_pm:
    }
  }
}
\DeclareOption{Prausnitz}{
  \ExecuteOptions{intensive-lowercase}
  \AtEndOfPackage{
    \RenewDocumentCommand{\fmix}{}{f}
    \RenewDocumentCommand{\phimix}{}{\phi}
    \RenewDocumentCommand{\fsat}{}{\fpure\c_math_superscript_token\sat}
    % TODO: this should pick up H_2 and make it into H_{2,1} (assuming the
    % solvent is always 1...?)
    \RenewDocumentCommand{\Henryrat}{}{H}
    \RenewDocumentCommand{\residual}{}{{{\mathcal{R}}}}
    \RenewDocumentCommand{\allcomponents}{O{i} m}
      { {#2}\c_math_subscript_token{#1} }
    \RenewDocumentCommand{\allbut}{O{i} m m}
    { \tl_if_eq:nnTF {#1} {#2}
        { {#3}\c_math_subscript_token k }
        { {#3}\c_math_subscript_token{#1} }
    }
    \RenewSubscriptedSymbol{\fpure}{f}{{\text{pure}}}
    \RenewSubscriptedSymbol{\phipure}{\phi}{{\text{pure}}}
  }
}
\DeclareOption{Sandler}{
  \ExecuteOptions{EUAGHaN,extensive-plain}
  \AtEndOfPackage{
    \RenewDocumentCommand{\sat}{}{{\text{vap}}}
    \RenewDocumentCommand{\excess}{}{{\text{ex}}}
    \RenewDocumentCommand{\residual}{}{{\text{r}}}
    \RenewExpandableDocumentCommand{\ncomponents}{}{\mathcal{C}}
    \RenewDocumentCommand{\fmix}{}{\bar f}
    \RenewDocumentCommand{\fstd}{}{\bar f\c_math_superscript_token\std}
    \RenewDocumentCommand{\phimix}{}{\bar\phi}
    \RenewDocumentCommand{\allcomponents}{O{} m}{\@@_underline:n{#2}}
    \RenewDocumentCommand{\IG}{}{{\text{IG}}}
    \RenewDocumentCommand{\IGM}{}{{\text{IGM}}}
    \RenewDocumentCommand{\IS}{}{{\text{IM}}}
    \RenewDocumentCommand{\Deltamix}{m}
        {\Delta\c_math_subscript_token\mixing #1}
    \RenewDocumentCommand{\Deltarxn}{m}
        {\Delta\c_math_subscript_token\reaction #1}
    \RenewDocumentCommand{\Deltasub}{m}
        {\Delta\c_math_subscript_token\sublimation #1}
    \RenewDocumentCommand{\Deltafus}{m}
        {\Delta\c_math_subscript_token\fusion #1}
    \RenewDocumentCommand{\Deltavap}{m}
        {\Delta\c_math_subscript_token\vaporization #1}
    \RenewDocumentCommand{\Henryrat}{}{H}
    \RenewSubscriptedSymbol{\cV}
        {\heatcapacitysymbol}{\g_@@_volume_symbol}
    \RenewSubscriptedSymbol{\cP}
        {\heatcapacitysymbol}{\g_@@_pressure_symbol}
    \RenewSubscriptedSymbol{\cVt}
        {\Nt\heatcapacitysymbol}{\g_@@_volume_symbol}
    \RenewSubscriptedSymbol{\cPt}
        {\Nt\heatcapacitysymbol}{\g_@@_pressure_symbol}
  }
}
\DeclareOption{SVNAS}{
  \ExecuteOptions{extensive-superscript}
  \AtEndOfPackage{
    \RenewDocumentCommand{\allcomponents}{O{} m}{#2}
    \RenewDocumentCommand{\allbut}{O{j} m m}
    {
      \tl_if_eq:nnTF {#1} {#2}
      { {#3}\c_math_subscript_token k }
      { {#3}\c_math_subscript_token{#1} }
    }
    \RenewDocumentCommand{\IG}{}{{ig}}
    \RenewDocumentCommand{\IGM}{}{{ig}}
    \RenewDocumentCommand{\IS}{}{{id}}
    \RenewDocumentCommand{\expansivitysymbol}{}{\beta}
    \RenewDocumentCommand{\Deltarxn}{m}{\Delta #1}
    \RenewSubscriptedSymbol{\cVt}
        {\Nt\heatcapacitysymbol}{\g_@@_volume_symbol}
    \RenewSubscriptedSymbol{\cPt}
        {\Nt\heatcapacitysymbol}{\g_@@_pressure_symbol}
  }
}
\DeclareOption{TesterModell}{
  \ExecuteOptions{EUAGHaN,delta}
  \AtEndOfPackage{
    \RenewExpandableDocumentCommand{\ncomponents}{}{n}
    \RenewDocumentCommand{\allcomponents}{O{i} m}
    {
      {#2}\c_math_subscript_token{#1}
    }
    \RenewDocumentCommand{\allbut}{O{i} m m}
    { \tl_if_eq:nnTF {#1} {#2}
      { {#3}\c_math_subscript_token{k}[#2] }
      { {#3}\c_math_subscript_token{#1}[#2] }
    }
    \RenewDocumentCommand{\allbutlastand}{O{j} m m}
    { \tl_if_eq:xxTF {#2} {\ncomponents}
      { {#3}\c_math_subscript_token{#1}\relax[#2] }
      { \tl_if_eq:nnTF {#1} {#2}
        { {#3}\c_math_subscript_token{k}[#2,\ncomponents] }
        { {#3}\c_math_subscript_token{#1}[#2,\ncomponents] }
      }
    }
    \RenewDocumentCommand{\IG}{}{{o}}
    \RenewDocumentCommand{\IGM}{}{{o}}
    \RenewDocumentCommand{\IS}{}{{ID}}
    \RenewDocumentCommand{\excess}{}{{EX}}
    \RenewDocumentCommand{\reaction}{}{{rx}}
    \RenewDocumentCommand{\Henryrat}{}
        {f\c_math_superscript_token{\ast\ast}}
    \RenewDocumentCommand{\Henrymol}{}{f\c_math_superscript_token\ast}
    \RenewDocumentCommand{\gammarat}{}
        {\gamma\c_math_superscript_token{\ast\ast}}
    \RenewDocumentCommand{\gammamol}{}
        {\gamma\c_math_superscript_token\ast}
    \RenewExpandableDocumentCommand{\JTsymbol}{}{\alpha}
    \RenewSubscriptedSymbol{\muJT}{\JTsymbol}{H}
  }
}
\DeclareOption{Thompson}{
  \ExecuteOptions{EUAGHAn,delta}
  \AtEndOfPackage
  {
    \RenewDocumentCommand{\excess}{}{{EX}}
    \RenewDocumentCommand{\residual}{}{{R}}
    %^^A He uses k_H for both types of Henry's constant, but I changed
    %^^A the rational basis one just so there is SOME difference
    \RenewSubscriptedSymbol{\Henryrat}{k}{h}
    \RenewSubscriptedSymbol{\Henrymol}{k}{H}
    \RenewDocumentCommand{\allcomponents}{O{j} m}
    {
      {#2}\c_math_subscript_token{#1}
    }
    \RenewDocumentCommand{\allNs}{O{j}}{\allcomponents[#1]{\Nt}}
    \RenewDocumentCommand{\allXs}{O{j}}{\allcomponents[#1]{x}}
    \RenewDocumentCommand{\allYs}{O{j}}{\allcomponents[#1]{y}}
    \RenewDocumentCommand{\allmus}{O{j}}{\allcomponents[#1]{\mu}}
    \RenewDocumentCommand{\allMs}{O{j}}{\allcomponents[#1]{m}}
    \RenewDocumentCommand{\allWs}{O{j}}{\allcomponents[#1]{w}}
    \RenewExpandableDocumentCommand{\ncomponents}{}{c}
    \RenewDocumentCommand{\IS}{}{{IS}}
    \RenewDocumentCommand{\IG}{}{{IG}}
    \RenewDocumentCommand{\IGM}{}{{IG}}
    \cs_new:Nn \@@_fpure_one:n
    {
      f\c_math_subscript_token{#1}
      \peek_catcode_remove:NF \c_math_superscript_token
      { \c_math_superscript_token\bullet }
    }
    \RenewDocumentCommand{\fpure}{}
    {
      \peek_catcode_remove:NTF \c_math_subscript_token
      { \@@_fpure_one:n }
      { f }
    }
    \cs_new:Nn \@@_intensive_two:n
    {
      \c_math_subscript_token{#1}
      \peek_catcode:NF \c_math_superscript_token
      {
        \c_math_superscript_token\bullet
      }
    }
    \cs_set:Nn \@@_intensive:n
    { #1
      \peek_catcode_remove:NT \c_math_subscript_token
      { \@@_intensive_two:n }
    }
    \cs_new:Nn \@@_phipure_one:n
    {
      \phi\c_math_subscript_token{#1}
      \peek_catcode:NF \c_math_superscript_token
      { \c_math_superscript_token\bullet }
    }
    \RenewDocumentCommand{\phipure}{}
    {
      \peek_catcode_remove:NTF \c_math_subscript_token
      {
        \@@_phipure_one:n
      }
      {\phi}
    }
    \RenewDocumentCommand{\mixing}{}{{MIX}}
    \RenewDocumentCommand{\Deltamix}{m}
        {\Delta\c_math_subscript_token\mixing #1}
    \RenewDocumentCommand{\Deltarxn}{m}{\Delta #1}
    \RenewDocumentCommand{\allbut}{O{j} m m}
    { \tl_if_eq:nnTF {#1} {#2}
      {
        {#3}\c_math_subscript_token k\neq{#3}\c_math_subscript_token{#2}
      }
      {
        {#3}\c_math_subscript_token{#1}\neq{#3}\c_math_subscript_token{#2}
      }
    }
  }
}
%    \end{macrocode}
% We execute the default options below.
%    \begin{macrocode}
\ExecuteOptions{EUAGHan,subscripts,parentheses,intensive-plain,moles-index}
\ProcessOptions
%    \end{macrocode}
% We next encode a routine to sort non-subscripted variables into a consistent
% order. It currently does not sort variables with subscripts.
% \changes{v2.00}{2023/11/16}{Added a sorting routine to make function
%       arguments be in a consistent order using the |nosubscripts| option.}
%    \begin{macrocode}
\tl_const:Nn \c_@@_sort_order_tl
    {\Et\Em\Es\Ut\Um\Us\Ht\Hm\Hs\Ft\Fm\Fs\Gt\Gm\Gs\Lt\Lm\Ls T\St\Sm\Ss
        P\Vt\Vm\Vs\mu\Nt mwxyz\At\Am\As\sigma
        ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklnopqrstuvwxyz}
\clist_new:N \l_@@_in_list_clist
\clist_new:N \l_@@_sorted_list_clist
\clist_new:N \l_@@_remaining_list_clist
\cs_new:Nn \@@_sort_clist:n
{% Sort the list in the order of \c_@@_sort_order_tl

  % Wipe out any remnants from the last sort
  \clist_clear:N \l_@@_in_list_clist
  \clist_clear:N \l_@@_sorted_list_clist

  % Make a copy of the list
  \clist_set:Nn \l_@@_remaining_list_clist {#1}

  % Make a list of everything that's in the known sort order list
  % and put everything else in the "not in sort order list" list.
  \tl_map_inline:Nn \c_@@_sort_order_tl
  {
    \clist_if_in:NnT \l_@@_remaining_list_clist {##1}
    { \clist_put_right:Nn \l_@@_in_list_clist {##1} }

    \clist_remove_all:Nn \l_@@_remaining_list_clist {##1}
  }

  % Then merge the lists back together again.
  \clist_if_empty:NF \l_@@_in_list_clist
  {
    \clist_put_right:Nn \l_@@_sorted_list_clist \l_@@_in_list_clist
  }
  \clist_if_empty:NF \l_@@_remaining_list_clist
  {
    \clist_put_right:Nn \l_@@_sorted_list_clist \l_@@_remaining_list_clist
  }
  \clist_use:Nn \l_@@_sorted_list_clist ,
}
%    \end{macrocode}
%
% \subsection{Commands for Partial Derivatives}
% The \cs{Partial} command and its second-order siblings are defined as below.
% They typeset partial derivatives of the first argument with respect to
% the second (and third, in the case of mixed second partial derivatives)
% arguments, holding the last argument constant.
%
% The starred forms adjust the spacing after the partial derivative so the
% trailing binary operator (assumed to be the same width as an equals sign)
% overhangs the variables held constant.
% We thus set \verb"operator_width" to be \emph{just} greater than the width of
% an equals sign.
%    \begin{macrocode}
\dim_new:N \l_@@_Partial_const_dim
\dim_new:N \l_@@_operator_width_dim
\dim_new:N \l_@@_adjust_width_dim
\settowidth{\l_@@_operator_width_dim}{=}
\dim_set:Nn \l_@@_adjust_width_dim {0.1\l_@@_operator_width_dim}
\dim_add:Nn \l_@@_operator_width_dim \l_@@_adjust_width_dim
%    \end{macrocode}
% \begin{macro}{\Partial}
% The command \cs{Partial} and its friends drastically simplify the creation
% of partial derivatives. The command \cs{Partial*} is the same as
% \cs{Partial} except that it adjusts the spacing so the (presumably) binary
% operator that follows it slightly overlaps the subscripts.
% \changes{v1.01}{2022/03/01}{Changed \cs{adjust@width} to 2pt (up from 1pt)}
% \changes{v1.01}{2022/04/21}{Changed \cs{adjust@width} 0.1\cs{operator@width}
%   (from 2pt)}
% \changes{v2.00}{2023/11/16}{Changed length added to
%   \cs{l_@@_Partial_const_dim} from $-0.15$ to $-0.20$}
%    \begin{macrocode}
\tl_new:N \l_@@_Partial_start_tl
\tl_new:N \l_@@_Partial_end_tl
\tl_new:N \l_@@_Partial_empty_end_tl
\tl_new:N \l_@@_Partial_middle_tl
\tl_set:Nn \l_@@_Partial_start_tl {\left\l_@@_PartialOpen_tl}
\tl_set:Nn \l_@@_Partial_end_tl {\right\l_@@_PartialClose_tl}
\tl_set:Nn \l_@@_Partial_empty_end_tl {\right\l_@@_PartialEmptyClose_tl}
\tl_set:Nn \l_@@_Partial_middle_tl {\middle}
\cs_set_eq:NN \@@_frac:nn \frac
\NewDocumentCommand{\Partial}{s m m m}
{ \bool_if:nTF {#1}
  {% Starred form (recursive)
    \settowidth{\l_@@_Partial_const_dim}{\ensuremath{#4}}%
    \dim_add:Nn \l_@@_Partial_const_dim {-0.20\l_@@_Partial_const_dim}%
    \Partial{#2}{#3}{#4}%
    \bool_if:NT \l_@@_subscripted_bool
    { \dim_compare:nNnTF \l_@@_operator_width_dim
                       < \l_@@_Partial_const_dim
      { \kern -\l_@@_operator_width_dim }
      { \kern -\l_@@_Partial_const_dim }
    }
  }
  {% Unstarred form
    \bool_if:NTF \l_@@_subscripted_bool
    {% Handle case of empty variables held constant
      \tl_if_eq:nnTF {#4} {}
      { \l_@@_Partial_start_tl
        \@@_frac:nn{\partial #2}{\partial #3}\l_@@_Partial_empty_end_tl
      }
      { \l_@@_Partial_start_tl\@@_frac:nn{\partial #2}
                                         {\partial #3}\l_@@_Partial_end_tl
        \c_math_subscript_token{#4}%
      }
    }
    {% Check whether #4 contains \allNsbut{i} and #3 is \Nt_i
      \tl_if_in:nnTF {#3} {\Nt}
      { \RenewDocumentCommand{\allbut}{O{j} m m}{\allcomponents{##3}}
        \l_@@_Partial_start_tl
        \@@_frac:nn{\partial #2(\@@_sort_clist:n{#4})}
                   {\partial #3}\l_@@_Partial_end_tl
      }
      { \l_@@_Partial_start_tl
        \@@_frac:nn{\partial #2(\@@_sort_clist:n{#3,#4})}
                   {\partial #3}\l_@@_Partial_end_tl
      }
    }
  }
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\PartialBigg}
% The \cs{PartialBigg} macro (and its starred form) replace the \tn{left}
% and \tn{right} commands in \cs{Partial} with \pkg{amsmath}'s \tn{Biggl}
% and \tn{Biggr} variants. The starred form is inherited from \cs{Partial}
% without modification.
%    \begin{macrocode}
\NewDocumentCommand{\PartialBigg}{}
  { \tl_set:Nn \l_@@_Partial_start_tl {\Biggl\l_@@_PartialOpen_tl}
    \tl_set:Nn \l_@@_Partial_end_tl {\Biggr\l_@@_PartialClose_tl}
    \tl_set:Nn \l_@@_Partial_Empty_end_tl
        {\Biggr\l_@@_PartialEmptyClose_tl}
    \Partial
  }
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\Partialbigg}
% The \cs{Partialbigg} macro does the same thing as \cs{PartialBigg}, except
% using \pkg{amsmath}'s \tn{biggl}/\tn{biggr} variants.
%    \begin{macrocode}
\NewDocumentCommand{\Partialbigg}{}
  { \tl_set:Nn \l_@@_Partial_start_tl {\biggl\l_@@_PartialOpen_tl}
    \tl_set:Nn \l_@@_Partial_end_tl {\biggr\l_@@_PartialClose_tl}
    \tl_set:Nn \l_@@_Partial_empty_end_tl
        {\biggr\l_@@_PartialEmptyClose_tl}
    \Partial
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\PartialSecond}
% The second partial derivatives are defined similarly to \cs{Partial}.
%    \begin{macrocode}
\NewDocumentCommand{\PartialSecond}{s m m m}
{
  \bool_if:nTF {#1}
  {% Starred form
    \settowidth{\l_@@_Partial_const_dim}{\ensuremath{#4}}%
    \dim_add:Nn \l_@@_Partial_const_dim {-0.20\l_@@_Partial_const_dim}
    \PartialSecond{#2}{#3}{#4}%
    \bool_if:nT \l_@@_subscripted_bool
    {  \dim_compare:nNnTF {\l_@@_operator_width_dim}
                        < {\l_@@_Partial_const_dim}
      { \kern -\l_@@_operator_width_dim }
      { \kern -\l_@@_Partial_const_dim }
    }
  }
  {% Unstarred form
    \bool_if:NTF \l_@@_subscripted_bool
    {% Handles case of empty variables held constant
      \tl_if_eq:nnTF {#4} {}
      { \l_@@_Partial_start_tl
            \@@_frac:nn{\partial\c_math_superscript_token 2 #2}
        {\partial #3\c_math_superscript_token 2}\l_@@_Partial_empty_end_tl
      }
      { \l_@@_Partial_start_tl
        \@@_frac:nn{\partial\c_math_superscript_token 2 #2}
            {\partial #3\c_math_superscript_token 2}\l_@@_Partial_end_tl
            \c_math_subscript_token{#4}%
      }
    }
    {% Check whether #4 contains \allNsbut{i} and #3 is \Nt_i
      \tl_if_in:nnTF {#2} {\Nt}
      { \RenewDocumentCommand{\allbut}{O{j} m m}{\allcomponents{##3}}
        \l_@@_Partial_start_tl
        \@@_frac:nn{\partial\c_math_superscript_token 2 #2(#4)}
            {\partial\c_math_superscript_token 2 #3}\l_@@_Partial_end_tl
      }
      { \l_@@_Partial_start_tl
        \@@_frac:nn{\partial\c_math_superscript_token 2
                      #2(\@@_sort_clist:n{#3,#4})}
            {\partial #3\c_math_superscript_token 2}\l_@@_Partial_end_tl
      }
    }
  }
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\PartialSecondBigg}
% The \cs{PartialSecondBigg} macro and its starred variant replace \cs{left}
% and \tn{right} with \pkg{amsmath}'s \cs[module=amsmath]{Biggl} and
% \cs[module=amsmath]{Biggr}.
%    \begin{macrocode}
\NewDocumentCommand{\PartialSecondBigg}{}
{ \tl_set:Nn \l_@@_Partial_start_tl {\biggl\l_@@_PartialOpen_tl}
  \tl_set:Nn \l_@@_Partial_end_tl {\biggl\l_@@_PartialClose_tl}
  \tl_set:Nn \l_@@_Partial_empty_end_tl {\biggl\l_@@_PartialClose_tl}
  \PartialSecond
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\PartialSecondbigg}
% The \cs{PartialSecondbigg} macro and its starred variant replace \tn{left}
% and \tn{right} with \pkg{amsmath}'s \cs[module=amsmath]{biggl} and
% \cs[module=amsmath]{biggr}.
%    \begin{macrocode}
\NewDocumentCommand{\PartialSecondbigg}{}
{ \tl_set:Nn \l_@@_Partial_start_tl {\biggl\l_@@_PartialOpen_tl}
  \tl_set:Nn \l_@@_Partial_end_tl {\biggl\l_@@_PartialClose_tl}
  \tl_set:Nn \l_@@_Partial_empty_end_tl {\biggl\l_@@_PartialClose_tl}
  \PartialSecond
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\PartialMixSecond}
% The macro \cs{PartialMixSecond} takes an extra argument, but is otherwise
% the same as its same-variable cousin.
%    \begin{macrocode}
\bool_new:N \l_@@_has_x_or_y_bool
\NewDocumentCommand{\PartialMixSecond}{s m m m m}
{
  \bool_if:nTF {#1}
  {% Starred version
    \settowidth{\l_@@_Partial_const_dim}{\ensuremath{#4}}%
    \dim_add:Nn \l_@@_Partial_const_dim {-0.20\l_@@_Partial_const_dim}
    \PartialMixSecond{#2}{#3}{#4}{#5}
    \bool_if:nT \l_@@_subscripted_bool
    { \dim_compare:nNnTF {\l_@@_operator_width_dim}
                       < {\l_@@_Partial_const_dim}
      { \kern -\l_@@_operator_width_dim }
      { \kern -\l_@@_Partial_const_dim }
    }
  }
  {% Unstarred version
    \bool_if:nTF \l_@@_subscripted_bool
    {% subscripted version
      \tl_if_eq:nnTF {#5} {}
      {% Handle case of empty variables held constant
        \l_@@_Partial_start_tl
        \@@_frac:nn{\partial\c_math_superscript_token 2 #2}
            {\partial #3\partial #4}\l_@@_Partial_empty_end_tl
      }
      { \l_@@_Partial_start_tl
        \@@_frac:nn{\partial\c_math_superscript_token 2 #2}
            {\partial #3\partial #4}\l_@@_Partial_end_tl
            \c_math_subscript_token{#5}
      }
    }
    {% not subscripted
      \tl_if_eq:nnTF {#5} {}
      {% empty argument
        \l_@@_Partial_start_tl
        \@@_frac:nn{\partial\c_math_superscript_token 2
                        #2(\@@_sort_clist:n{#3,#4,#5})}
                   {\partial #3\partial #4}\l_@@_Partial_empty_end_tl
      }
      {% Check whether #3 OR #4 are \Nt_i/etc.
        \tl_if_in:nnTF {#3} {\Nt}
        { \RenewDocumentCommand{\allbut}{O{j} m m}{\allcomponents{##3}}%
          \l_@@_Partial_start_tl
          \@@_frac:nn{\partial\c_math_superscript_token 2
                        #2(\@@_sort_clist:n{#4,#5})}
                     {\partial #3\partial #4}\l_@@_Partial_end_tl
        }
        { \tl_if_in:nnTF {#4} {\Nt}
          { \RenewDocumentCommand{\allbut}{O{j} m m}{\allcomponents{##3}}%
            \l_@@_Partial_start_tl
            \@@_frac:nn{\partial\c_math_superscript_token 2
                            #2(\@@_sort_clist:n{#3,#5})}
                       {\partial #3\partial #4}\l_@@_Partial_end_tl
          }
          {% Check for x, y, or w
            \bool_set_false:N \l_@@_has_x_or_y_bool
            \tl_if_in:nnT {#3} {x}
            { \l_@@_has_x_or_y_bool }
            \tl_if_in:nnT {#3} {y}
            { \l_@@_has_x_or_y_bool }
            \tl_if_in:nnT {#3} {w}
            { \l_@@_has_x_or_y_bool }
            \bool_if:NTF \l_@@_has_x_or_y_bool
            { \RenewDocumentCommand{\allbutlastand}{O{j} m m}
                {\allcomponents{##3}}
              \l_@@_Partial_start_tl
              \@@_frac:nn{\partial\c_math_superscript_token 2
                            #2(\@@_sort_clist:n{#4,#5})}
                         {\partial #3\partial #4}\l_@@_Partial_end_tl
            }
            {
              \l_@@_Partial_start_tl
              \@@_frac:nn{\partial\c_math_superscript_token 2
                            #2(\@@_sort_clist:n{#3,#4,#5})}
                         {\partial #3\partial #4}\l_@@_Partial_end_tl
            }
          }
        }
      }
    }
  }
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\PartialMixSecondBigg,\PartialMixSecondbigg}
% The macro \cs{PartialMixSecondBigg} is analogous to the aforementioned macros
% \cs{PartialBigg} and \cs{PartialSecondBigg}. \cs{PartialMixSecondbigg} is
% analogous to \cs{Partialbigg} and \cs{PartialSecondbigg}.
%    \begin{macrocode}
\NewDocumentCommand{\PartialMixSecondBigg}{}
{ \tl_set:Nn \l_@@_Partial_start_tl {\Biggl\l_@@_PartialOpen_tl}
  \tl_set:Nn \l_@@_Partial_end_tl {\Biggl\l_@@_PartialClose_tl}
  \tl_set:Nn \l_@@_Partial_empty_end_tl {\Biggl\l_@@_PartialClose_tl}
  \PartialMixSecond
}
\NewDocumentCommand{\PartialMixSecondbigg}{}
{ \tl_set:Nn \l_@@_Partial_start_tl {\biggl\l_@@_PartialOpen_tl}
  \tl_set:Nn \l_@@_Partial_end_tl {\biggl\l_@@_PartialClose_tl}
  \tl_set:Nn \l_@@_Partial_empty_end_tl {\biggl\l_@@_PartialClose_tl}
  \PartialMixSecond
}
%    \end{macrocode}
%
% If the user does not load the \pkg{amsmath} package, we will not have access
% to \cs[module=amsmath]{Biggl}, \cs{Biggr}, \cs{biggl}, and \cs{biggr}, so we revert them back
% to the ordinary \cs{left} and \cs{right} versions and warn the user.
%    \begin{macrocode}
\AtBeginDocument{%
  \@ifpackageloaded{amsmath}{}{%
      \PackageWarningNoLine{thermodynamics}
        {Package~amsmath~not~loaded;~load~to~make~PartialBigg~and~friends
            ~work~correctly}%
      \cs_set_eq:NN \PartialBigg \Partial
      \cs_set_eq:NN \Partialbigg \Partial
      \cs_set_eq:NN \PartialSecondBigg \PartialSecond
      \cs_set_eq:NN \PartialSecondbigg \PartialSecond
      \cs_set_eq:NN \PartialMixSecondBigg \PartialMixSecond
      \cs_set_eq:NN \PartialMixSecondbigg \PartialMixSecond
      \ProvideDocumentCommand{\rvert}{}{|}
      \ProvideDocumentCommand{\lvert}{}{|}
  }%
}
%    \end{macrocode}
% \end{macro}
% \changes{v1.01}{2023/09/15}{Added \cs{Partialinline} and friends to
%   facilitate in-line (non-display-mode) partial derivatives, with
%   corresponding changes to \cs{Partial} and friends for ease of
%   implementation. Also added \cs{Partialinlinetext} and friends for
%   non-expanding delimiters.}
% \begin{macro}{\Partialinline,\PartialSecondinline,\PartialMixSecondinline}
% Inline partial derivatives.
%    \begin{macrocode}
\NewDocumentCommand{\Partialinline}{}
{
  \cs_set:Nn \@@_frac:nn { ##1 \l_@@_Partial_middle_tl / ##2 }
  \Partial
}
\NewDocumentCommand{\PartialSecondinline}{}
{
  \cs_set:Nn \@@_frac:nn { ##1 \l_@@_Partial_middle_tl / ##2 }
  \PartialSecond
}
\NewDocumentCommand{\PartialMixSecondinline}{}
{
  \cs_set:Nn \@@_frac:nn { ##1 \l_@@_Partial_middle_tl / ##2 }
  \PartialMixSecond
}
%    \end{macrocode}
% \end{macro}
% \pagebreak[1]
% \setmarginparsize{\footnotesize}
% \begin{macro}{\Partialinlinetext}
% \begin{macro}{\PartialSecondinlinetext}
% \begin{macro}{\PartialMixSecondinlinetext}
% Text-only (non-extensible delimiter) versions of \cs{Partialinline}
% and friends.
%^^A TODO: These currently "pollute" other partial derivatives until the end
%^^A       of the line (i.e., \Partialinline{z}{x}{y} = \Partial{z}{x}{y} will
%^^A       produce identical things on both sides). For now, it's a "feature."
%   \begin{macrocode}
\NewDocumentCommand{\Partialinlinetext}{}
{ \cs_set_eq:NN \l_@@_Partial_start_tl \l_@@_PartialOpen_tl
  \cs_set_eq:NN \l_@@_Partial_end_tl \l_@@_PartialClose_tl
  \cs_set_eq:NN \l_@@_Partial_empty_end_tl \l_@@_PartialEmptyClose_tl
  \cs_set_eq:NN \l_@@_Partial_middle_tl \relax
  \Partialinline
}
\NewDocumentCommand{\PartialSecondinlinetext}{}
{ \cs_set_eq:NN \l_@@_Partial_start_tl \l_@@_PartialOpen_tl
  \cs_set_eq:NN \l_@@_Partial_end_tl \l_@@_PartialClose_tl
  \cs_set_eq:NN \l_@@_Partial_empty_end_tl \l_@@_PartialEmptyClose_tl
  \cs_set_eq:NN \l_@@_Partial_middle_tl \relax
  \PartialSecondinline
}
\NewDocumentCommand{\PartialMixSecondinlinetext}{}
{ \cs_set_eq:NN \l_@@_Partial_start_tl \l_@@_PartialOpen_tl
  \cs_set_eq:NN \l_@@_Partial_end_tl \l_@@_PartialClose_tl
  \cs_set_eq:NN \l_@@_Partial_empty_end_tl \l_@@_PartialEmptyClose_tl
  \cs_set_eq:NN \l_@@_Partial_middle_tl \relax
  \PartialMixSecondinline
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \restoremarginparsize
%
% \subsection{Local Override of Delimiters}
% We define several environments that \emph{locally} override the delimiters on
% partial derivatives generated with \cs{Partial} and friends, the
% subscript notation for partial derivatives, and/or the definitions of
% range-oriented macros such as \cs{allNs}. These environments can be nested;
% the inner-most one will be honored if conflicts occur.
% \begin{environment}{thermoparentheses}
% Inside this environment, partial derivatives will have parentheses around
% them, regardless of package options.
%    \begin{macrocode}
\NewDocumentEnvironment{thermoparentheses}{}
{ \cs_set:Nn \l_@@_PartialOpen_tl {(}
  \cs_set:Nn \l_@@_PartialClose_tl {)}
  \cs_set:Nn \l_@@_PartialEmptyClose_tl {)}
}{}
%    \end{macrocode}
% \end{environment}
% \begin{environment}{thermobrackets}
% Inside this environment, partial derivatives will have brackets around
% them, regardless of package options.
%    \begin{macrocode}
\NewDocumentEnvironment{thermobrackets}{}
{ \tl_set:Nn \l_@@_PartialOpen_tl {[}
  \tl_set:Nn \l_@@_PartialClose_tl {]}
  \tl_set:Nn \l_@@_PartialEmptyClose_tl {]}
}{}
%    \end{macrocode}
% \end{environment}
% \begin{environment}{thermobraces}
% Inside this environment, partial derivatives will have braces around
% them, regardless of package options.
%    \begin{macrocode}
\NewDocumentEnvironment{thermobraces}{}
{ \tl_set:Nn \l_@@_PartialOpen_tl {\{}
  \tl_set:Nn \l_@@_PartialClose_tl {\}}
  \tl_set:Nn \l_@@_PartialEmptyClose_tl {\}}
}{}
%    \end{macrocode}
% \end{environment}
% \begin{environment}{thermobar}
% Inside this environment, partial derivatives will have a trailing vertical
% bar, regardless of package options.
%    \begin{macrocode}
\NewDocumentEnvironment{thermobar}{}
{ \tl_set:Nn \l_@@_PartialOpen_tl {.}
  \tl_set:Nn \l_@@_PartialClose_tl {\rvert}
  \tl_set:Nn \l_@@_PartialEmptyClose_tl {.}
}{}
%    \end{macrocode}
% \end{environment}
% \begin{environment}{thermoplain}
% Inside this environment, partial derivatives will have no decorations
% around them, regardless of package options.
%    \begin{macrocode}
\NewDocumentEnvironment{thermoplain}{}
{ \tl_set:Nn \l_@@_PartialOpen_tl {.}
  \tl_set:Nn \l_@@_PartialClose_tl {.}
  \tl_set:Nn \l_@@_PartialEmptyClose_tl {.}
  \bool_set_false:N \l_@@_subscripted_bool
}{}
%    \end{macrocode}
% \end{environment}
% \begin{environment}{thermoNOsubscripts}
% Inside this environment, subscripts will not be displayed to the right of
% partial derivatives, regardless of package options.
%    \begin{macrocode}
\NewDocumentEnvironment{thermoNOsubscripts}{}
    {\bool_set_false:N \l_@@_subscripted_bool}
    {}
%    \end{macrocode}
% \begin{environment}{thermosubscripts}
% Inside this environment, subscripts will be displayed to the right of
% partial derivatives, regardless of package options.
% \end{environment}
%    \begin{macrocode}
\NewDocumentEnvironment{thermosubscripts}{}
    {\bool_set_true:N \l_@@_subscripted_bool}
    {}
%    \end{macrocode}
% \end{environment}
% \begin{environment}{thermomolesrange}
% Inside this environment, the macro \cs{allNs} will expand to
% $n_1,\dotsc,n_C$ (or equivalent symbols if \cs{Nt} and/or \cs{ncomponents}
% have been redefined), regardless of package options. Similar expansions will
% result for \cs{allXs}, \cs{allYs}, \cs{allMs}, and so on.
% \changes{v2.00}{2023/11/16}{Added environment to invoke the ``moles-range''
%     definitions of \cs{allNs} and friends locally.}
%    \begin{macrocode}
\NewDocumentEnvironment{thermomolesrange}{}
    { \@@_set_moles_range }
    {}
%    \end{macrocode}
% \end{environment}
% \begin{environment}{thermointensiveplain}
% \changes{v2.00}{2023/11/16}{Added environment to invoke the
%     ``intensive-plain'' option locally.}
%    \begin{macrocode}
%    \begin{macrocode}
\NewDocumentEnvironment{thermointensiveplain}{}
    { \@@_set_intensive_plain }
    {}
%    \end{macrocode}
% \end{environment}
% \begin{environment}{thermoextensiveplain}
% \changes{v2.00}{2023/11/16}{Added environment to invoke the
%     ``extensive-plain'' option locally.}
%    \begin{macrocode}
\NewDocumentEnvironment{thermoextensiveplain}{}
    { \@@_set_extensive_plain }
    {}
%    \end{macrocode}
% \end{environment}
% \setmarginparsize{\scriptsize}
% \begin{environment}{thermointensivelowercase}
% \changes{v2.00}{2023/11/16}{Added environment to invoke the
%     ``intensive-lowercase'' option locally.}
%    \begin{macrocode}
\NewDocumentEnvironment{thermointensivelowercase}{}
    {% {
% \RenewExpandableDocumentCommand{\MacroFont}{}{
%   \fontencoding\encodingdefault
%   \fontfamily\ttdefault
%   \fontseries\mddefault
%   \fontshape\shapedefault
%   \footnotesize}

      \@@_set_intensive_lowercase
      \@@_set_lowercase_pms
    }
    {}
%    \end{macrocode}
% \end{environment}
% \begin{environment}{thermoextensivesuperscript}
% \changes{v2.00}{2023/11/16}{Added environment to invoke the
%     ``extensive-superscript'' option locally.}
%    \begin{macrocode}
\NewDocumentEnvironment{thermoextensivesuperscript}{}
    {
      \@@_set_extensive_superscripts
    }
    {}
%    \end{macrocode}
% \end{environment}
% \restoremarginparsize
%
% \subsection{User-Interface Macros to Define Symbols}
% \begin{macro}{\NewSubscriptedSymbol}
% First, we define a command that serves to create ``subscripted''
% symbols; for example, typing \verb"\cP_i" should yield $C_{P,i}$ rather
% than $C_{Pi}$, ${C_P}_i$, or ${C_{P_i}}$. Superscripts are also handled
% properly and can be in either order.
% \changes{v2.00}{2023/11/16}{Deleted \cs{DeclareSubscriptedSymbol} in favor
%   of \pkg{xparse}-based \cs{NewSubscriptedSymbol} and
%   \cs{RenewSubscriptedSymbol}.}
%    \begin{macrocode}
\cs_new:Npn \@@_check_definable:nN #1#2
{
  \bool_set_true:N \l_@@_arg_legal_bool
  \tl_trim_spaces_apply:nN {#1} \tl_if_single_token:nTF
  {
    \str_set:Nx \l_tmp_str {\tl_to_str:n {#1}}
    \int_compare:nNnT {\str_count:N \l_tmp_str} = 1
    { \PackageError{thermodynamics}
        {First~argument~of~'\tl_trim_spaces:o {\tl_to_str:n {#2}}'~
         must~be~a~command}
        {The~first~argument~of~'\tl_trim_spaces:o {\tl_to_str:n {#2}}'~
         should~be~the~macro~that~will~be~used~to~refer~to~the~symbol.~
         The~provided~argument~'\tl_trim_spaces:o {\tl_to_str:n {#1}}'~
         is~a~single~character.
         \MessageBreak Perhaps~a~backslash~is~missing?}
    }
  }
  { \PackageError{thermodynamics}
      {First~argument~of~'\tl_trim_spaces:o {\tl_to_str:n {#2}}'~
       must~be~a~command}
      {The~first~argument~of~'\tl_trim_spaces:o {\tl_to_str:n {#2}}'~
       should~be~the~macro~that~will~be~used~to~refer~to~the~symbol.~
       The~provided~argument~'\tl_trim_spaces:o {\tl_to_str:n {#1}}'~
       contains~more~than~one~token.
       \MessageBreak Perhaps~a~backslash~is~missing?}
  }
}
\NewDocumentCommand{\NewSubscriptedSymbol}{m m m}
{
  \@@_check_definable:nN {#1} \NewSubscriptedSymbol
  \cs_if_exist:NT #1
  { \PackageError{thermodynamics}
      {Command~'\tl_trim_spaces:o {\tl_to_str:n {#1}}'~already~defined}
      {You~have~used~
       '\tl_trim_spaces:o {\tl_to_str:n {\NewSubscriptedSymbol}}'~
       with~a~command~that~already~has~a~definition}
  }
  \cs_new:cpn {\cs_to_str:N #1_one:n} ##1
  {
    {#2}\c_math_superscript_token{##1}
    \peek_catcode_remove:NTF \c_math_subscript_token
    { \use:c {\cs_to_str:N #1_three:n} }
    { \c_math_subscript_token{#3} }
  }

  \cs_new:cpn {\cs_to_str:N #1_two:n} ##1
  { {#2}\c_math_subscript_token{#3,##1} }

  \cs_new:cpn {\cs_to_str:N #1_three:n} ##1
  { \c_math_subscript_token{#3,##1} }

  \NewDocumentCommand{#1}{}
  {% @branch
    \peek_catcode_remove:NTF \c_math_superscript_token
    { \use:c {\cs_to_str:N #1_one:n} }
    { \peek_catcode_remove:NTF \c_math_subscript_token
      { \use:c {\cs_to_str:N #1_two:n} }
      { {#2}\c_math_subscript_token{#3} }
    }
  }
}
\NewDocumentCommand{\RenewSubscriptedSymbol}{m m m}
{
  \@@_check_definable:nN {#1} \RenewSubscriptedSymbol
  \cs_if_exist:NF #1
  { \PackageError{thermodynamics}
      {Command~'\tl_trim_spaces:o {\tl_to_str:n {#1}}'~not~defined}
      {You~have~used~
       '\tl_trim_spaces:o {\tl_to_str:n {\RenewSubscriptedSymbol}}'~
       with~a~command~that~does~not~have~a~definition}
  }
  \cs_set:cpn {\cs_to_str:N #1_one:n} ##1
  {
    {#2}\c_math_superscript_token{##1}
    \peek_catcode_remove:NTF \c_math_subscript_token
    { \use:c {\cs_to_str:N #1_three:n} }
    { \c_math_subscript_token{#3} }
  }

  \cs_set:cpn {\cs_to_str:N #1_two:n} ##1
  { {#2}\c_math_subscript_token{#3,##1} }

  \cs_set:cpn {\cs_to_str:N #1_three:n} ##1
  { \c_math_subscript_token{#3,##1} }

  \RenewDocumentCommand{#1}{}
  {% @branch
    \peek_catcode_remove:NTF \c_math_superscript_token
    { \use:c {\cs_to_str:N #1_one:n} }
    { \peek_catcode_remove:NTF \c_math_subscript_token
      { \use:c {\cs_to_str:N #1_two:n} }
      { {#2}\c_math_subscript_token{#3} }
    }
  }
  
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\NewSuperscriptedSymbol}
% \changes{v2.00}{2023/11/16}{Created \cs{NewSuperscriptedSymbol} to handle
%   superscripted excess and residual properties without intervention.}
%    \begin{macrocode}
\NewDocumentCommand{\NewSuperscriptedSymbol}{m m m}
{
  \@@_check_definable:nN {#1} \NewSuperscriptedSymbol
  \cs_if_exist:NT #1
  { \PackageError{thermodynamics}
      {Command~'\tl_trim_spaces:o {\tl_to_str:n {#1}}'~already~defined}
      {You~have~used~
       '\tl_trim_spaces:o {\tl_to_str:n {\NewSuperscriptedSymbol}}'~
       with~a~command~that~already~has~a~definition}
  }
  \cs_new:cpn {\cs_to_str:N #1_one:n} ##1
  {
    {#2}\c_math_subscript_token{#1}
    \peek_catcode_remove:NTF \c_math_superscript_token
    { \use:c {\cs_to_str:N #1_one:n} }
    { \c_math_subscript_token{#3} }
  }

  \cs_new:cpn {\cs_to_str:N #1_two:n} ##1
  { {#2}\c_math_superscript_token{#3,##1} }

  \cs_new:cpn {\cs_to_str:N #1_three:n} ##1
  { {#2}\c_math_superscript_token{#3,##1} }

  \NewDocumentCommand{#1}{}
  {
    \peek_catcode_remove:NTF \c_math_subscript_token
    { \use:c {\cs_to_str:N #1_one:n} }
    { \peek_catcode_remove:NTF \c_math_superscript_token
      { \use:c {\cs_to_str:N #1_two:n} }
      { {#2}\c_math_superscript_token{#3} }
    }
  }
}
\NewDocumentCommand{\RenewSuperscriptedSymbol}{m m m}
{
  \@@_check_definable:nN {#1} \RenewSuperscriptedSymbol
  \cs_if_exist:NF #1
  { \PackageError{thermodynamics}
      {Command~'\tl_trim_spaces:o {\tl_to_str:n {#1}}'~not~defined}
      {You~have~used~
       '\tl_trim_spaces:o {\tl_to_str:n {\RenewSuperscriptedSymbol}}'~
       with~a~command~that~does~not~have~a~definition}
  }
  \cs_set:cpn {\cs_to_str:N #1_one:n} ##1
  {
    {#2}\c_math_subscript_token{##1}
    \peek_catcode_remove:NTF \c_math_superscript_token
    { \use:c {\cs_to_str:N #1_three:n} }
    { \c_math_superscript_token{#3} }
  }

  \cs_set:cpn {\cs_to_str:N #1_two:n} ##1
  { {#2}\c_math_superscript_token{#3,##1} }

  \cs_set:cpn {\cs_to_str:N #1_three:n} ##1
  { \c_math_superscript_token{#3,##1} }

  \RenewDocumentCommand{#1}{}
  {% @branch
    \peek_catcode_remove:NTF \c_math_subscript_token
    { \use:c {\cs_to_str:N #1_one:n} }
    { \peek_catcode_remove:NTF \c_math_superscript_token
      { \use:c {\cs_to_str:N #1_two:n} }
      { {#2}\c_math_superscript_token{#3} }
    }
  }
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\heatcapacitysymbol,\compressibilitysymbol,\expansivitysymbol}
% Now we define symbols for the heat capacities, compressibilities, and
% so forth.
%    \begin{macrocode}
\NewExpandableDocumentCommand{\heatcapacitysymbol}{}{C}
\NewExpandableDocumentCommand{\compressibilitysymbol}{}{\kappa}
\NewExpandableDocumentCommand{\expansivitysymbol}{}{\alpha}
\NewExpandableDocumentCommand{\JTsymbol}{}{\mu}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\cV,\cP}
% The heat capacities are molar by default; we also declare extensive and
% specific heat capacities.
% The heat capacities themselves are defined to be ``smart'': \verb"\cV_i" will
% recognize the subscript appropriately and render $C_{V,i}$ rather than
% ${C_V}_i$ or some other unintended symbol. Superscripts are also handled
% appropriately and can be in either order.
%    \begin{macrocode}
\NewSubscriptedSymbol{\cV}{\@@_intensive:n \heatcapacitysymbol}
    {\g_@@_volume_symbol}
\NewSubscriptedSymbol{\cP}{\@@_intensive:n \heatcapacitysymbol}
    {\g_@@_pressure_symbol}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\cVt,\cPt}
% We also introduce \emph{extensive} (rather than molar) heat capacity macros.
%    \begin{macrocode}
\NewSubscriptedSymbol{\cVt}{\@@_extensive:n \heatcapacitysymbol}
    {\g_@@_volume_symbol}
\NewSubscriptedSymbol{\cPt}{\@@_extensive:n \heatcapacitysymbol}
    {\g_@@_pressure_symbol}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\cVs,\cPs}
% \cs{cPs} and \cs{cVs} are the specific heat capacities.
%    \begin{macrocode}
\NewSubscriptedSymbol{\cVs}{\@@_specific:n \heatcapacitysymbol}
    {\g_@@_volume_symbol}
\NewSubscriptedSymbol{\cPs}{\@@_specific:n \heatcapacitysymbol}
    {\g_@@_pressure_symbol}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\kappaT,\kappaS}
% The isothermal and adiabatic compressibilities are defined similarly, but
% those do not have extensive versions for obvious reasons.
%    \begin{macrocode}
\NewSubscriptedSymbol{\kappaT}{\compressibilitysymbol}
    {\g_@@_temperature_symbol}
\NewSubscriptedSymbol{\kappaS}{\compressibilitysymbol}
    {\g_@@_entropy_symbol}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\alphaP,\alphaS}
% The macro \cs{alphaP} is intended to refer to the isobaric volume
% expansivity, while \cs{alphaS} is the isentropic volume expansivity.
%    \begin{macrocode}
\NewSubscriptedSymbol{\alphaP}{\expansivitysymbol}{\g_@@_pressure_symbol}
\NewSubscriptedSymbol{\alphaS}{\expansivitysymbol}{\g_@@_entropy_symbol}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\muJT}
% The macro \cs{muJT} renders the Joule--Thomson coefficient.
%    \begin{macrocode}
\NewSubscriptedSymbol{\muJT}{\JTsymbol}{JT}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\Psat,\Pvap,\phisat,\fsat,\sat}
% The \cs{Psat} macro (and its clone, the \cs{Pvap} macro) should be used for
% the saturation pressure.
% Similarly, a \cs{phisat} macro typesets the fugacity coefficient at
% saturation. The \cs{fsat} macro similarly renders the fugacity at saturation.
% Other saturation properties should use \verb"M^\sat" or similar, preferably
% by defining another macro such as \verb"\Gmsat".
%    \begin{macrocode}
\NewDocumentCommand{\sat}{}{{\text{sat}}}
\NewDocumentCommand{\Psat}{}{P\c_math_superscript_token\sat}
\NewDocumentCommand{\Pvap}{}{\Psat}
\NewDocumentCommand{\phisat}{}{\phi\c_math_superscript_token\sat}
\NewDocumentCommand{\fsat}{}{\fpure\c_math_superscript_token\sat}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\std,\Pstd,\fstd}
% The \cs{std} macro denotes standard properties. \cs{Pstd} and \cs{fstd} are
% defined for convenience and for consistency across textbooks.
%    \begin{macrocode}
\NewDocumentCommand{\std}{}{\circ}
\NewDocumentCommand{\Pstd}{}{P\c_math_superscript_token \std}
\NewDocumentCommand{\fstd}{}{f\c_math_superscript_token \std}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\Deltamix,\mixing}
% Mixing properties, such as $\Deltamix\Gm$, should be accessed using
% \verb"\Deltamix\Gm" and similar constructions---this construct will typeset
% as $\Delta_{MIX}G$ using the |Thompson| package option, for example,
% and as $\Delta_\text{mix}\Gt$ using the |Sandler| package option.
%    \begin{macrocode}
\NewDocumentCommand{\mixing}{}{{\text{mix}}}
\NewDocumentCommand{\Deltamix}{m}
    {\Delta{#1}\c_math_subscript_token\mixing}
%    \end{macrocode}
% \end{macro}
%
% \pagebreak[2]%
% \begin{macro}{\Deltafus,\fusion,\Deltavap,\vaporization}
% \begin{macro}{\Deltasub,\sublimation,\Deltarxn,\reaction}
% Similar entities for property changes on fusion, reaction, sublimation, and
% vaporization are defined.
%    \begin{macrocode}
\NewDocumentCommand{\fusion}{}{{\text{fus}}}
\NewDocumentCommand{\reaction}{}{{\text{rxn}}}
\NewDocumentCommand{\sublimation}{}{{\text{sub}}}
\NewDocumentCommand{\vaporization}{}{{\text{vap}}}
\NewDocumentCommand{\formation}{}{f}
\NewDocumentCommand{\Deltafus}{m}
    {\Delta #1\c_math_superscript_token\fusion}
\NewDocumentCommand{\Deltasub}{m}
    {\Delta #1\c_math_superscript_token\sublimation}
\NewDocumentCommand{\Deltavap}{m}
    {\Delta #1\c_math_superscript_token\vaporization}
\NewDocumentCommand{\Deltarxn}{m}
    {\Delta #1\c_math_subscript_token\reaction}
\tl_new:N \l_@@_Deltaf_sym_tl
\NewSubscriptedSymbol{\@@_Deltaf}{\l_@@_Deltaf_sym_tl}{f}
\NewDocumentCommand{\Deltaf}{m}
{ \tl_set:Nn \l_@@_Deltaf_sym_tl {\Delta #1}
  \@@_Deltaf
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\fmix}
% The \cs{fmix} command is intended to describe fugacities in mixtures.
% It renders as $\hat f$ by default, and would be used as \verb"\fmix_i" or
% the like, producing $\hat f_i$; some authors like to use $\bar f_i$ or
% just $f_i$, and this command creates a consistent way to change between
% such options.
%    \begin{macrocode}
\NewDocumentCommand{\fmix}{}{\hat{f}}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\phimix}
% A similar command, \cs{phimix}, renders $\hat\phi$ by default to represent
% the fugacity coefficient in the mixture.
%    \begin{macrocode}
\NewDocumentCommand{\phimix}{}{\hat\phi}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\fpure}
% The \cs{fpure} command is intended to describe fugacities in pure substances.
% It renders as $f$ by default, and would be used as \verb"\fpure" or
% \verb"\fpure_i" or the like, producing $f_i$; some authors like to use
% $f_{\text{pure},i}$, and others like to use $f_i^\bullet$; this command
% creates a consistent way to change between the these options. A similar
% command for $\phi$ is given, \cs{phipure}, for fugacity coefficients.
%    \begin{macrocode}
\NewDocumentCommand{\fpure}{}{f}
\NewDocumentCommand{\phipure}{}{\phi}
%    \end{macrocode}
% \end{macro}
%
% \subsection{Partial Molar Quantities}
% \begin{macro}{\partialmolar}
% Partial molar quantities with superscripts appear as $\Gpm[\IG]{i}$ or
% $\GRpm{i}$, rather than something like
% $\overline{G}^\IG_i$ or $\overline{G}_i^R$; the former looks better but
% is harder to implement for obvious reasons. Their definitions allow them to
% be used as symbols, something like \verb"\Gpm_i", \verb"\Gpm^{\IGM}_i",
% \verb"\Gpm^{\IGM}_i", and even \verb"\Gpm_i^{\IGM}";
% they can also be treated as commands: \verb"\Gpm{i}" is equivalent to
% \verb"\Gpm_i" and \verb"\Gpm[\IGM]{i}" is equivalent to \verb"\Gpm_i^{\IGM}".
% The macro \cs{partialmolar} can be used to create an arbitrary partial
% molar symbol.
%    \begin{macrocode}
\tl_new:N \l_@@_pm_symbol_tl
\tl_new:N \l_@@_pm_arg_tl
\NewDocumentCommand{\partialmolar}{m}
{
  \tl_set:Nn \l_@@_pm_symbol_tl {#1}
  \@@_generic_pm:
}
%% cases to consider:
%% (1) \Mpm{i}
%% (2) \Mpm[S]{i}
%% (3) \Mpm^S_i
%% (4) \Mpm_i^S
%% (5) \Mpm_i
%% note that \Mpm^S with no subscript makes no sense and is thus forbidden
\cs_new:Nn \@@_generic_pm:
{
  \peek_catcode_remove:NTF \c_math_subscript_token
  {% case 4 or case 5
    \@@_pm_case_four_or_five
  }
  {% look for superscript token
    \peek_catcode_remove:NTF \c_math_superscript_token
    {% case 3: \Mpm^{#1}_{#2} or \Mpm^{#1}{#2}
      \@@_pm_case_three
    }
    {% Look for optional argument [...]
      \peek_charcode:NTF [
      {% case 2: \Mpm[S]{i}
        \@@_pm_case_two
      }
      {% case 1: \Mpm{i}
        \@@_pm_case_one
      }
    }
  }
}
\cs_new:Npn \@@_pm_case_one #1
{
  \@@_overline:n {\l_@@_pm_symbol_tl\c_math_subscript_token{#1}}
}
\cs_new:Npn \@@_pm_case_two [#1]#2
{
  \@@_overline:n {\l_@@_pm_symbol_tl
    \c_math_superscript_token{#1}\c_math_subscript_token{#2}}
}
\cs_new:Npn \@@_pm_case_three #1
{
  \tl_set:Nn \l_@@_pm_arg_tl {#1}
  \peek_catcode_remove:NTF \c_math_subscript_token
  { \@@_pm_case_three_part_two }
  { \@@_pm_case_three_part_two }
}
\cs_new:Npn \@@_pm_case_three_part_two #1
{
  \@@_overline:n {\l_@@_pm_symbol_tl
    \c_math_superscript_token{\l_@@_pm_arg_tl}
    \c_math_subscript_token{#1}}
}
\cs_new:Npn \@@_pm_case_four_or_five #1
{
  \tl_set:Nn \l_@@_pm_arg_tl {#1}
  \peek_catcode_remove:NTF \c_math_superscript_token
  { \@@_pm_case_four }
  { \@@_pm_case_five }
}
\cs_new:Npn \@@_pm_case_four #1
{
  \@@_overline:n {\l_@@_pm_symbol_tl\c_math_superscript_token{#1}
    \c_math_subscript_token{\l_@@_pm_arg_tl}}
}
\cs_new:Npn \@@_pm_case_five
{
  \@@_overline:n {\l_@@_pm_symbol_tl
    \c_math_subscript_token{\l_@@_pm_arg_tl}}
}
%    \end{macrocode}
% \end{macro}
%
% \subsection{Symbol Definitions}
% These macros define the user interface to the symbols for energy, volume,
% and so forth. There are five commands that define thermodynamic properties.
%
% \begin{macro}{\NewExtensiveProperty}
% The command \cs{NewExtensiveProperty} declares macros for a total, molar, and
% specific version of the symbol; for example, a second heat-like property
% could be defined via
% \begin{verbatim}
%  \NewExtensiveProperty{R}{\mathcal{Q}}
%\end{verbatim}
% \NewExtensiveProperty{R}{\mathcal{Q}}\relax
% The command above would declare the macros \cs{Rt}, \cs{Rm}, and \cs{Rs}
% that expand to $\Rt$, $\Rm$, and $\Rs$, respectively, using the default
% package options.
% \end{macro}
%
% \begin{macro}{\NewPartialMolarProperty}
% The command \cs{NewPartialMolarProperty} declares a macro for the partial
% molar quantity. For example,
% \begin{verbatim}
%  \NewPartialMolarProperty{I}{\Psi}
%\end{verbatim}
% \NewPartialMolarProperty{I}{\Psi}\relax
% would create the command \cs{Ipm}, which would typeset a partial molar
% command with the base symbol $\Psi$, yielding $\Ipm{i}$.
% \end{macro}
%
% \begin{macro}{\NewThermodynamicProperty}
% Declaring a new potential is handled by the
% \cs{NewThermodynamicProperty} macro, which takes two arguments. The first
% is the base of the name, and the second is the base of the symbol. This
% declares four new commands for the extensive, molar, specific, and partial
% molar properties. These commands consist of the first argument followed by
% \verb"t", \verb"m", \verb"s", and \verb"pm", respectively. For example, one
% might define the entropy via
% \begin{verbatim}
%  \NewThermodynamicProperty{S}{S}
%\end{verbatim}
% and it would define the macros \cs{St}, \cs{Sm}, \cs{Ss}, and \cs{Spm} that
% yield, respectively, $\St$, S, $\hat S$, and $\Spm{i}$ (assuming the
% subscript to the partial molar quantity was $i$).
% It would also declare residual and excess properties for that base symbol.
% Note that the actual definition of the entropy and the other standard
% properties is slightly more complicated so as to allow for different symbols
% to be used in different textbooks.
%    \begin{macrocode}
\NewDocumentCommand{\NewThermodynamicProperty}{m m}
{
  \NewExtensiveProperty{#1}{#2}
  \NewPartialMolarProperty{#1}{#2}
  \NewResidualProperty{#1}{#2}
  \NewExcessProperty{#1}{#2}
}
\NewDocumentCommand{\NewExtensiveProperty}{m m}
{
  % Extensive property
  \exp_after:wN \NewDocumentCommand \exp_after:wN
    {\cs:w #1t\cs_end:}{}{\@@_extensive:n {#2}}
  % Molar property
  \exp_after:wN \NewDocumentCommand \exp_after:wN
    {\cs:w #1m\cs_end:}{}{\@@_intensive:n {#2}}
  % Specific property
  \exp_after:wN \NewDocumentCommand \exp_after:wN
    {\cs:w #1s\cs_end:}{}{\@@_specific:n {#2}}
}
\NewDocumentCommand{\NewPartialMolarProperty}{m m}
{
  % Partial molar property
  \exp_after:wN \NewDocumentCommand \exp_after:wN
    {\cs:w #1pm\cs_end:}{}{\partialmolar{#2}}
}
\NewDocumentCommand{\NewExcessProperty}{m m}
{
  \exp_after:wN \NewSuperscriptedSymbol \exp_after:wN
    {\cs:w #1 Et\cs_end:}{\@@_extensive:n{#2}}{\excess}
  \exp_after:wN \NewSuperscriptedSymbol \exp_after:wN
    {\cs:w #1 E\cs_end:}{\@@_intensive:n{#2}}{\excess}
  \exp_after:wN \NewSuperscriptedSymbol \exp_after:wN
    {\cs:w #1 Es\cs_end:}{\@@_specific:n{#2}}{\excess}

  %^^A TODO: make super- or subscripted partial molar quantities work
  % Excess partial molar property
  \exp_after:wN \NewDocumentCommand \exp_after:wN
    {\cs:w #1Epm\cs_end:}{}{\partialmolar{#2}
       \c_math_superscript_token\excess}
}
\NewDocumentCommand{\NewResidualProperty}{m m}
{
  \exp_after:wN \NewSuperscriptedSymbol \exp_after:wN
    {\cs:w #1 Rt\cs_end:}{\@@_extensive:n{#2}}{\residual}
  \exp_after:wN \NewSuperscriptedSymbol \exp_after:wN
    {\cs:w #1 R\cs_end:}{\@@_intensive:n{#2}}{\residual}
  \exp_after:wN \NewSuperscriptedSymbol \exp_after:wN
    {\cs:w #1 Rs\cs_end:}{\@@_specific:n{#2}}{\residual}

  % Residual partial molar property
  \exp_after:wN \NewDocumentCommand \exp_after:wN
    {\cs:w #1Rpm\cs_end:}{}{\partialmolar{#2}
        \c_math_superscript_token\residual}
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\Nt,\Et,\Em,\Es,\Epm}
% \penalty-600%
% We define \cs{Nt} as the number of moles, as that changes between books a
% lot, but it does not have extensive, molar, and specific equivalents.
% Heat and work are defined, but lack partial molar properties. Area does not
% have excess or residual properties.
%    \begin{macrocode}
\NewDocumentCommand{\Nt}{}{\g_@@_mole_symbol}
\NewThermodynamicProperty{E}{\g_@@_total_energy_symbol}
\NewThermodynamicProperty{U}{\g_@@_internal_energy_symbol}
\NewThermodynamicProperty{F}{\g_@@_Helmholtz_symbol}
\NewThermodynamicProperty{G}{\g_@@_Gibbs_symbol}
\NewThermodynamicProperty{H}{\g_@@_enthalpy_symbol}
\NewThermodynamicProperty{L}{\g_@@_Landau_symbol}
\NewThermodynamicProperty{V}{\g_@@_volume_symbol}
\NewThermodynamicProperty{S}{\g_@@_entropy_symbol}
\NewExtensiveProperty{A}{\g_@@_area_symbol}
\NewPartialMolarProperty{A}{\g_@@_area_symbol}
\NewExtensiveProperty{Q}{\g_@@_heat_symbol}
\NewExtensiveProperty{W}{\g_@@_work_symbol}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\cVpm,\cPpm}
% Partial molar heat capacities are \emph{hard}, but the following
% implementation seems to work flawlessly\dots so far.
%    \begin{macrocode}
\NewDocumentCommand{\cPpm}{}
{
  \cs_set:Npn \@@_pm_case_one ##1
  {
    \@@_overline:n {\l_@@_pm_symbol_tl\c_math_subscript_token
        {\g_@@_pressure_symbol,##1}}
  }
  \cs_set:Npn \@@_pm_case_two [##1]##2
  {
    \@@_overline:n {\l_@@_pm_symbol_tl\c_math_superscript_token{##1}
        \c_math_subscript_token{\g_@@_pressure_symbol,##2}}
  }
  \cs_set:Npn \@@_pm_case_three_part_two ##1
  {
    \@@_overline:n {\l_@@_pm_symbol_tl
        \c_math_superscript_token{\l_@@_pm_arg_tl}
        \c_math_subscript_token{\g_@@_pressure_symbol,##1}}
  }
  \cs_set:Npn \@@_pm_case_four ##1
  {
    \@@_overline:n {\l_@@_pm_symbol_tl
        \c_math_superscript_token{##1}\c_math_subscript_token
      {\g_@@_pressure_symbol,\l_@@_pm_arg_tl}}
  }
  \cs_set:Npn \@@_pm_case_five
  {
    \@@_overline:n {\l_@@_pm_symbol_tl\c_math_subscript_token
        {\g_@@_pressure_symbol,\l_@@_pm_arg_tl}}
  }
  \partialmolar{\heatcapacitysymbol}
}
\NewDocumentCommand{\cVpm}{}
{
  \cs_set:Npn \@@_pm_case_one ##1
  {
    \@@_overline:n {\l_@@_pm_symbol_tl\c_math_subscript_token
        {\g_@@_volume_symbol,##1}}
  }
  \cs_set:Npn \@@_pm_case_two [##1]##2
  {
    \@@_overline:n {\l_@@_pm_symbol_tl
            \c_math_superscript_token{##1}\c_math_subscript_token
        {\g_@@_volume_symbol,##2}}
  }
  \cs_set:Npn \@@_pm_case_three_part_two ##1
  {
    \@@_overline:n {\l_@@_pm_symbol_tl
        \c_math_superscript_token{\l_@@_pm_arg_tl}
        \c_math_subscript_token{\g_@@_volume_symbol,##1}}
  }
  \cs_set:Npn \@@_pm_case_four ##1
  {
    \@@_overline:n {\l_@@_pm_symbol_tl
        \c_math_superscript_token{##1}
        \c_math_subscript_token
      {\g_@@_volume_symbol,\l_@@_pm_arg_tl}}
  }
  \cs_set:Npn \@@_pm_case_five
  {
    \@@_overline:n {\l_@@_pm_symbol_tl\c_math_subscript_token
        {\g_@@_volume_symbol,\l_@@_pm_arg_tl}}
  }
  \partialmolar{\heatcapacitysymbol}
}
%    \end{macrocode}
% \end{macro}
%
% \subsection{Residual and Excess Properties}
% \begin{macro}{\residual,\excess}
% Macros are defined for residual properties (departure from ideal gases)
% and excess properties (departure from ideal solutions). We begin with two
% macros to use for defining generic residual and excess properties that are
% not already defined.
%    \begin{macrocode}
\NewDocumentCommand{\residual}{}{R}
\NewDocumentCommand{\excess}{}{E}
%    \end{macrocode}
% \end{macro}
%
% \pagebreak[1]%
% \begin{macro}{\prodall,\sumall,\summallbutlast}
% The \cs{sumall} command and its cousin, \cs{sumallbutlast}, simplify the
% typesetting of commonly-used sums; the command \cs{prodall} does the same
% thing for products, viz.,
% \begin{verbatim}
%   \[ \sumall_i x_i = 1 \qquad \sumallbutlast_i x_i = 1 - x_\ncomponents
%       \qquad K = \exp\left(\frac{-\Deltarxn\Gm^\std}{RT}\right)
%                = \prodall_i a_i^{\nu_i} \]
%\end{verbatim}
% gives
%   \[ \sum_{i=1}^C x_i = 1 \qquad \sum_{i=1}^{C-1} x_i = 1 - x_C \qquad
%      K = \exp\left(\frac{-\Delta G_\text{rxn}^\circ}{RT}\right)
%        = \prod_{i=1}^C a_i^{\nu_i} \]
%    \begin{macrocode}
\NewDocumentCommand{\sumall}{m m}
  { \sum\c_math_subscript_token{#2=1}
      \c_math_superscript_token{\ncomponents} }
\NewDocumentCommand{\sumallbutlast}{m m}
  { \sum\c_math_subscript_token{#2=1}
      \c_math_superscript_token{\ncomponents-1} }
\NewDocumentCommand{\prodall}{m m}
  { \prod\c_math_subscript_token{#2=1}
       \c_math_superscript_token{\ncomponents} }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\IG,\IGM,\IS}
% The \cs{IG}, \cs{IGM}, and \cs{IS} macros (meaning ``ideal gas,'' ``ideal
% gas mixture,'' and ``ideal solution,'' respectively) should be used to
% make clean transitions between textbooks---some use ``IM'' or ``ID'' rather
% than ``IS,'' for example.
%    \begin{macrocode}
\NewDocumentCommand{\IG}{}{{\text{IG}}}
\NewDocumentCommand{\IGM}{}{{\text{IGM}}}
\NewDocumentCommand{\IS}{}{{\text{IS}}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\Henryrat,\Henrymol}
% The Henry's Law constants for the rational basis ($y_i P = x_i h_i$) and
% the molal basis ($y_i P = C_i \mathcal{H}_i$) are given by the macros
% \cs{Henryrat} and \cs{Henrymol}, respectively. Using them this way
% consistently allows for easy switching back and forth.
%    \begin{macrocode}
\NewDocumentCommand{\Henryrat}{}{h}
\NewDocumentCommand{\Henrymol}{}{\mathcal{H}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\gammarat,\gammamol}
% The ordinary activity coefficient is universally denoted $\gamma$, so I
% have not defined a special macro for that. However, symbols for the Henry's
% Law activity coefficients are far from universal, so I have defined macros to
% make their use consistent. The defaults render \cs{gammarat} as $\gamma^\ast$
% and \cs{gammamol} as $\gamma^\square$.
% \cs{gammamol} will use \cs{square} from packages if it is defined; if not,
% it ``fakes it'' with the definition below.
%^^A Backup for \square adapted from amsthm.sty with tweaks to make it
%^^A look reasonably similar to that from newpx (i.e., smaller than the
%^^A amsfonts) version
%    \begin{macrocode}
\AtBeginDocument{%
  \providecommand*{\square}{%
    \text{\leavevmode
      \hbox to.65em{%
      \hfil\vrule
      \vbox to.53em{\hrule width.45em\vfil\hrule}%
      \vrule\hfil}%
    }%
  }%
}
\NewDocumentCommand{\gammarat}{}{\gamma\c_math_superscript_token\ast}
\NewDocumentCommand{\gammamol}{}{\gamma\c_math_superscript_token\square}
%    \end{macrocode}
% \end{macro}
% \begin{environment}{thermovmatrix}
% This is a non-user-interface wrapper environment used to detect, in
% effect, whether \pkg{amsmath} has been loaded. If so, it uses its
% \env{vmatrix} environment for Jacobians; if not, it fakes it with
% \env{array} (which does not look nearly as good).
%    \begin{macrocode}
\NewDocumentEnvironment{thermovmatrix}{}
{ \cs_if_exist:NTF \vmatrix
  { \begin{vmatrix} }
  { \left|\begin{array}{c c c c c c c c c c} }
}
{ \cs_if_exist:NTF \endvmatrix
  {  \end{vmatrix} }
  {  \end{array}\right| }
}
%    \end{macrocode}
% \end{environment}
% \begin{macro}{Jacobian}
% The \cs{Jacobian} command typesets the Leibnitz notation for the Jacobian
% determinant.
% \changes{v2.00}{2023/11/16}{Reimplemented \cs{Jacobian} to handle an
%     arbitary number of variables and implemented \cs{Jacobiandet} to
%     handle the matrix representation of the Jacobian.}
%    \begin{macrocode}
\NewDocumentCommand{\Jacobian}{m m}
    {\@@_frac:nn{\partial(#1)}{\partial{(#2)}}}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{Jacobiandet}
% Similarly, the \cs{Jacobiandet} macro typesets the actual determinant that
% the Jacobian notation represents.
%    \begin{macrocode}
\NewDocumentCommand{\Jacobiandet}{O{} O{} m m}
{
  \@@_Jacobian_set_ncomponents:nn {#3} {#4}
  \begin{thermovmatrix}
    \@@_Jacobianmatrix:nnnn {#1} {#2} {#3} {#4}
  \end{thermovmatrix}
}
\seq_new:N \l_@@_row_seq
\seq_new:N \l_@@_matrix_seq
\clist_new:N \l_@@_other_vars_clist
\clist_new:N \l_@@_other_vars_copy_clist
\tl_new:N \l_@@_Jacobian_x_tl
\tl_new:N \l_@@_Jacobian_n_tl
\tl_new:N \l_@@_Jacobian_temp_tl
\bool_new:N \l_@@_found_dots_bool
\cs_new:Nn \@@_Jacobian_set_ncomponents:nn
{
  % If any entry is \dots, we assume the Jacobian is of the form
  % d(f_1,\dots,f_n)/d(x_1,\dots,x_n) where f is some function
  % (any symbol) and x is some variable (any symbol).
  \tl_if_in:nnTF {#1} {\dots}
  {% Has dots
    \bool_set_true:N \l_@@_found_dots_bool
    % look for what "x" is
    \tl_set:Nn \l_@@_Jacobian_x_tl {\tl_head:n {#2}}
    % look for what "n" is and set \ncomponents to it
    \tl_set:Nx \l_@@_Jacobian_n_tl {\tl_item:nn {#2} {-1}}
    \RenewExpandableDocumentCommand{\ncomponents}{}{\l_@@_Jacobian_n_tl}
  }
  {% Does not have dots; proceed accordingly
    \bool_set_false:N \l_@@_found_dots_bool
  }
}
\cs_new_protected:Nn \@@_Jacobianmatrix:nnnn
{
  \seq_clear:N \l_@@_matrix_seq
  \clist_set:Nn \l_@@_other_vars_clist {#4}
  \clist_set_eq:NN \l_@@_other_vars_copy_clist \l_@@_other_vars_clist

  \clist_map_inline:nn {#3}
  {
    \seq_clear:N \l_@@_row_seq
    \tl_if_in:nnTF {##1} {\dots}
    {% The current row has "dots" => row is \vdots && \vdots
      \seq_put_right:Nn \l_@@_matrix_seq
        { \vdots \c_alignment_token \c_alignment_token \vdots }
    }
    {% Ordinary row
      \clist_map_inline:nn {#4}
      {
        \tl_if_in:nnTF {####1} {\dots}
        {% this column has "dots" in it
          \seq_put_right:Nn \l_@@_row_seq \dots
        }
        {% Normal column
          \clist_set_eq:NN \l_@@_other_vars_clist
                           \l_@@_other_vars_copy_clist
          \clist_remove_all:Nn \l_@@_other_vars_clist {####1}
          \bool_if:NTF \l_@@_found_dots_bool
          { \tl_set:Nn \l_@@_Jacobian_temp_tl {\tl_item:nn {####1} {-1}}
            \seq_put_right:Nx \l_@@_row_seq
            {
              #1\Partial{##1}{####1}
                  {\allbut{\l_@@_Jacobian_temp_tl}{\l_@@_Jacobian_x_tl}}
            }
          }
          { \seq_put_right:Nx \l_@@_row_seq
            {
              #1\Partial{##1}{####1}
                        {\clist_use:Nn \l_@@_other_vars_clist ,}
            }
          }
        }
      }
      \seq_put_right:Nx \l_@@_matrix_seq
      {
        \seq_use:Nn \l_@@_row_seq { \c_alignment_token }
      }
    }
  }
  \tl_if_empty:nTF {#2}
  {
    \tl_if_eq:nnTF {#1} {\displaystyle}
    { \seq_use:Nn \l_@@_matrix_seq { \\[2.75ex] } }
    { \seq_use:Nn \l_@@_matrix_seq { \\[1.25ex] } }
  }
  {
    \seq_use:Nn \l_@@_matrix_seq { \\[#2] }
  }
}
%    \end{macrocode}
% \end{macro}
%^^X\end{implementation}
%
% \Finale
% \iffalse
%</package>
%<*example>
\documentclass{article}
\usepackage[margin=1in]{geometry}
\usepackage{amsmath,amssymb}
\usepackage{thermodynamics}
\title{Examples to Accompany the \textsf{thermodynamics} Package}
\author{Karl D. Hammond}
\date{}
\begin{document}
\NewThermodynamicProperty{B}{B}
\maketitle\noindent
The combined laws:
\begin{align*}
  d\Et &= d\Ut + d\left(\frac12 m v^2\right) - d(m\phi) \\
  d\Ut &= \dbar\Qt + \dbar\Wt + \Um d\Nt
        = \dbar\Qt - P d\Vt + \Hm d\Nt
    \\ &= \Partial*{\Ut}{\St}{\Vt,\allNs} d\St
        + \Partial*{\Ut}{\Vt}{\St,\allNs} d\Vt
        + \sumall_i \Partial*{\Ut}{\Nt_i}{\Vt,\St,\allNsbut{i}} d\Nt_i
    \\ &= T d\St - P d\Vt + \sumall_i \mu_i d\Nt_i
\end{align*}
With surfaces present:
\begin{gather*}
   d\Ut = T d\St - P d\Vt  + \sigma d\At + \sumall_i \mu_i d\Nt_i \\
   d\Ht = T d\St + \Vt dP  + \sigma d\At + \sumall_i \mu_i d\Nt_i \\
   d\Ft = -\St dT - P d\Vt + \sigma d\At + \sumall_i \mu_i d\Nt_i \\
   d\Gt = -\St dT + \Vt dP + \sigma d\At + \sumall_i \mu_i d\Nt_i \\
   d\Lt = -\St dT - P d\Vt + \sigma d\At - \sumall_i \Nt_i d\mu_i \\
    \Bt = \Ut + P\Vt - T\St - \sigma\At \\
   d\Bt = -\St dT + \Vt dP - \At d\sigma + \sumall_i \mu_i d\Nt_i \\
   \mu_i = \Bpm_i = \Gpm_i + \sigma \Apm_i
\end{gather*}
Some Maxwell reciprocity relations:
\begin{gather*}
  \Partial*{\Vt}{T}{P,\allNs}
    = \PartialMixSecond*{\Gt}{T}{P}{\allNs}
    = \PartialMixSecond*{\Gt}{P}{T}{\allNs}
    = -\Partial{\St}{P}{T,\allNs}
\\
    \Partial*{\Gpm_i}{T}{P,\allXs}
    = \PartialMixSecond*{\Gt}{T}{\Nt_i}{P,\allNsbut{i}}
    = \PartialMixSecond*{\Gt}{\Nt_i}{T}{P,\allNsbut{i}}
    = -\Partial*{\St}{\Nt_i}{T,P,\allNsbut{i}}
    = -\Spm_i
\end{gather*}
Temporary changes of derivative delimiters:
\begin{gather*}
  \begin{thermobrackets}
    \Partial*{\Vt}{T}{P,\allNs}
  \end{thermobrackets}
  \begin{thermobar}
    = \PartialMixSecond*{\Gt}{T}{P}{\allNs}
  \end{thermobar}
  \begin{thermomolesrange}
    = \PartialMixSecond*{\Gt}{P}{T}{\allNs}
  \end{thermomolesrange}
  \begin{thermobraces}
      = -\Partial*{\St}{P}{T,\allNs}
    \begin{thermoNOsubscripts}
      \begin{thermomolesrange}
        = -\Partial{\St}{P}{T,\allNs}
      \end{thermomolesrange}
    \end{thermoNOsubscripts}
  \end{thermobraces}
\end{gather*}
Inline derivatives:
\begin{gather*}
  \mu_i = \Partialinline{\Gt}{\Nt_i}{T,P,\allNsbut{i}}
        = \Partialinline{\Ft}{\Nt_i}{T,\Vt,\allNsbut{i}}
        = \Partialinline{\Ht}{\Nt_i}{\St,P,\allNsbut{i}}
        = \Partialinline{\Ut}{\Nt_i}{\St,\Vt,\allNsbut{i}}
\end{gather*}
The heat capacities:
\begin{gather*}
  \cV = T \Partial*{\Sm}{T}{\Vm,\allXs} = \Partial*{\Um}{T}{\Vm,\allXs}
      = -T\PartialSecond{\Fm}{T}{\Vm,\allXs}
  \\
  \cP^\IGM = T \Partial*{\Sm^\IGM}{T}{P,\allYs}
           = \Partial*{\Hm^\IGM}{T}{P,\allYs}
    \begin{thermobrackets}
      = -T\PartialSecond{\Gm^\IGM}{T}{P,\allYs}
    \end{thermobrackets}
  \\
  \cVt = T \Partial*{\St}{T}{\Vt,\allNs} = \Partial*{\Ut}{T}{\Vt,\allNs}
    \begin{thermobraces}
       = -T\PartialSecond{\Ft}{T}{\Vm,\allNs}
    \end{thermobraces}
  \\
    \begin{thermobar}
  \cPt = T \Partial*{\St}{T}{P,\allNs} = \Partial*{\Ht}{T}{P,\allNs}
       = -T\PartialSecond{\Gt}{T}{P,\allNs}
    \end{thermobar}
  \\
  \cVs = T \Partial*{\Ss}{T}{\Vs,\allWs} = \Partial*{\Us}{T}{\Vs,\allWs}
    \begin{thermoplain}
       = -T\PartialSecond{\Fs}{T}{\Vs,\allWs}
    \end{thermoplain}
  \\
  \cPs = T \Partialbigg*{\Ss}{T}{P,\allWs} = \Partialbigg*{\Hs}{T}{P,\allWs}
       = -T\PartialSecondbigg{\Gs}{T}{P,\allWs}
  \\
\begin{split}
  \cPpm_i &= \Partial*{\cPt}{\Nt_i}{T,P,\allNsbut{i}}
           = T \PartialMixSecond*{\St}{\Nt_i}{T}{P,\allNsbut{i}}
           = T \PartialMixSecond*{\St}{T}{\Nt_i}{P,\allNsbut{i}}
       \\ &= T \Partial*{\Spm_i}{T}{P,\allXs}
           = \Partial*{\Hpm_i}{T}{P,\allXs}
           = \PartialMixSecond*{\Ht}{T}{\Nt_i}{P,\allNsbut{i}}
           = \PartialMixSecond*{\Ht}{\Nt_i}{T}{P,\allNsbut{i}}
       \\ &= -T\PartialSecond*{\Gpm_i}{T}{P,\allXs}
           = -T\Partial{{}^3 \Gt}{T^2\partial \Nt_i}{P,\allNsbut{i}}
\end{split}
\end{gather*}
Other measurable quantities:
\begin{align*}
  \alphaS &= \frac{1}{\Vm} \Partial{\Vm}{T}{\Sm} &
  \alphaP &= \frac{1}{\Vm} \Partial{\Vm}{T}{P} \\
  \kappaS &= -\frac{1}{\Vm} \Partial{\Vm}{P}{\Sm} &
  \kappaT &= -\frac{1}{\Vm} \Partial{\Vm}{P}{T}
\end{align*}
The chemical potential, fugacity, and activity:
\[ \mu_i = \Gpm_i = \Gm_i^\std + RT \ln a_i
         = \Gm_i^\std + RT\ln\left(\frac{\fmix_i}{\fstd_i}\right) \]
Equilibrium in a chemical reaction:
\[ \sumall_i \nu_i \mu_i = 0
    \Rightarrow
    \exp\left(\frac{-\Delta\Gm^\std}{RT}\right) = K = \prodall_i a_i^{\nu_i} \]
Partial molar quantities:
\begin{align*}
  \Hpm{i} &= \Partial*{\Ht}{\Nt_i}{T,P,\allNsbut{i}}
           = \Hm + \Nt \Partial*{\Hm}{\Nt_i}{T,P,\allNsbut{i}}
       \\ &= \Hm + \Partial*{\Hm}{x_i}{T,P,\allXsbut{i}}
                 - \sumallbutlast_j x_j \Partial*{\Hm}{x_j}{T,P,\allXsbut{j}}
           = \Partial*{\Hm}{x_i}{T,P,\allXsbut{i}} + \Hpm_\ncomponents
\end{align*}
\[ \Vpm_i = \Partial{\Vt}{\Nt_i}{T,P,\allNsbut{i}} \]
Fugacity and related properties:
\begin{gather*}
  \Gpm_i = \mu_i
         = \Gm_i^\std(T) + RT\ln a_i
         = \Gm_i^\std(T) + RT\ln\left(\frac{\fmix_i}{\fstd_i}\right)
  \\
  a_i = \frac{\fmix_i}{\fstd_i}
      = x_i \gamma_i
                \exp\left(\frac{1}{RT} \int_{\Pstd}^P \Vm_i(T,p)\,dp\right)
      \approx x_i \gamma_i
  \\
  \begin{split}
  \fmix_i &= x_i \phimix_i P
           = x_i \gamma_i \fpure_i = x_i \gamma_i \phipure_i P
           = x_i \gammarat_i \Henryrat_i
           = C_i \gammamol_i \Henrymol_i
           = x_i \gamma_i \fsat_i
                 \exp\left(\frac{1}{RT} \int_{\Psat_i}^P \Vm_i(T,p)\,dp\right)
       \\ &= x_i \gamma_i \Psat_i \phisat_i
                \exp\left(\frac{1}{RT} \int_{\Psat_i}^P \Vm_i(T,p)\,dp\right)
          \approx x_i \gamma_i \Psat_i
  \end{split}
\end{gather*}
Chemical Equilibria:
\begin{gather*}
  \Deltarxn\Hm^\std = \sumall_i \nu_i \Deltaf\Hm_i^\std \\
  \Deltarxn\Gm^\std = \sumall_i \nu_i \Deltaf\Gm_i^\std
                    = \sumall_i \nu_i \mu_i^\std \\
  \Deltarxn\cP^\std = \sumall_i \nu_i \cP_i^\std \\
  \mu_i = \mu_i^\std + RT\ln a_i \\
  a_i = \begin{cases}
\displaystyle
     \frac{y_i \phimix_i P}{\Pstd} \approx \frac{y_i P}{\Pstd}
        & \text{(gases)} \\
\rule{0pt}{5ex}%
\displaystyle
     x_i \gamma_i \exp\left(\frac{1}{RT} \int_{\Pstd}^P \Vm_i(T,p)\,dp\right)
     \approx
     x_i \gamma_i \exp\left(\frac{\Vm_i(P-\Pstd)}{RT}\right)
     \approx x_i \gamma_i \approx 1
        & \text{(solids, solvents)} \\
\displaystyle
\rule{0pt}{5ex}%
     \frac{C_i \gammamol_i}{C_i^\std}
        \exp\left(\frac{1}{RT}
        \int_{\Pstd}^P \Vpm_i^\infty(T,p,\allXs)\,dp\right)
     \approx
     \frac{C_i \gammamol_i}{C_i^\std} \approx \frac{C_i}{C_i^\std}
        & \text{(solutes)}
        \end{cases}
\end{gather*}
Phase change properties:
\begin{gather*}
  \Deltafus\Sm = \Sm^L - \Sm^S \\
  \Deltasub\Vm = \Vm^V - \Vm^S \\
  \Deltavap\Gm = \Gm^V - \Gm^L
\end{gather*}
Specific properties:
\newcommand*{\Btilde}[2][]{\widetilde{B}_{#2}^{#1}}
\[ \Btilde{j} \equiv \Partial{\Bt}{m_j}{T,\Vs,\allMsbut[i]{j}} \]
and thus
\[ \Btilde{i}
    = \frac{\Bpm{i}}{M_i}
        + \Biggl(\Vs - \frac{\Vpm_i}{M_i}\Biggr)
          \Partial*{\Bs}{\Vs}{T,\allMs}
    = \frac{\Bpm{i}}{M_i}
        + \Biggl(\Vs - \frac{\Vpm_i}{M_i}\Biggr)
          \Partial{\Bs}{\Vs}{T,m,\allWs} \]
and
\[ \Bs = \sumall_i w_i \Btilde{i}. \]
Excess and Residual (Departure) Properties:
\begin{align*}
  \HR &= \Hm - \Hm^\IG &
  \FR &= \Fm - \Fm^\IGM \\
  \SE &= \Sm - \Sm^\IS &
  \VRpm_k &= \Vpm_k - \Vpm_k^\IGM
\end{align*}
Jacobians:
\begin{gather*}
  \Jacobian{\St,\Vt}{T,P} = \Jacobiandet{\St,\Vt}{T,P} \\
  \Jacobian{f,g,h}{x,y,z} = \Jacobiandet[\displaystyle]{f,g,h}{x,y,z} \\
  \Jacobian{h_1,\dots,h_k}{z_1,\dots,z_k} =
      \Jacobiandet{h_1,\dots,h_k}{z_1,\dots,z_k} \\
  \cP = T\Partial{\Sm}{T}{P}
      = T\Jacobian{\Sm,P}{T,P}
      = -T\Jacobian{\Sm,P}{T,\Vm} \Jacobian{T,\Vm}{T,P}
      = -T\Jacobian{P,\Sm}{\Vm,\Sm} \Jacobian{\Vm,\Sm}{T,\Vm}
          \Jacobian{T,\Vm}{T,P}
      = \gamma \cV
\end{gather*}
\end{document}
%</example>
% \fi
%
% \Finale
\endinput
