# Automatically resize equilibrium constants in superscripts with chemmacros

Using the chemmacros commands \K... and \p..., equilibrium constants and p functions don't get resized when written as superscripts. For instance,

\documentclass{article}

\usepackage{chemmacros}

\begin{document}
$\frac{[\ch{B^-}]}{[\ch{HB}]}=10^{\pH-\pKa}\mbox{.}$
\end{document


becomes

with too big superscripts.

• I ran texdoc chemmacros and searched for both math and size, but nothing I could find seemed to have an answer ;-( – Thorbjørn E. K. Christensen Feb 20 '18 at 11:22
• Need to check but this looks like a bug. – cgnieder Feb 20 '18 at 12:29

This is due to a bug in the acid-base module. Here is a fix:

\documentclass{article}

\usepackage{chemmacros}

\ExplSyntaxOn
\chemmacros_if_compatibility:nnT {<=} {5.8b}
{
\cs_set_protected:Npn \chemmacros_p:n #1
{
\group_begin:
\chemmacros_text:n
{
\chemmacros_p_style:n {p}
\ensuremath {#1}
}
\group_end:
}
}
\ExplSyntaxOff

\begin{document}

$10^{pH}=10^{\pH}$

\end{document}


• I'll send the updated version to CTAN in a few days… – cgnieder Feb 22 '18 at 16:13