# \eval does not scale its argument properly

Here a user suggested to use the commath package to separate presentation and content. I LOVE separating presentation and content, so I read the documentation and started using this package throughout my work.

Sadly, I noticed that one of the more frequently used macros - \pd (partial derivative) - produces very ugly result compared to plain old \frac with \partial:

$$\eval{\pd{\hat{\boldsymbol{a}}_\text{c}}{\xi}}_{\xi = 0} = 42$$

$$\frac{\partial \hat{\boldsymbol{a}}_\text{c}}{\partial \xi}\sVert[3]_{\xi = 0} = 42$$


(Actually this example, although MWE, is not illustrative enough, so here's another couple: \eval

vs \frac

). I use updated TeXLive2016.

So, the questions are (1) am I doing something wrong, because there is no way this is intended typesetting style, and (2) if commath actually IS broken and unmaintained (hey, it's still at v0.3 which is 10 years old), can you suggest another similar package.

• unfortunately commath is just completely broken, almost every definition in the package is incorrect. Aug 15 '16 at 23:46
– cfr
Aug 16 '16 at 1:17
• Aug 16 '16 at 17:16

The \eval macro puts its contents in the argument to \mathinner. On the other hand, \pd does \tfrac when \ifinner returns true and \dfrac when \ifinner returns false.

Now, here's the problem in the form of a simple plain TeX file:

$$\mathinner{\ifinner a\else b\fi}$$
\bye


If we run pdftex on it, the output shows “a” and not “b”. In other words, \ifinner returns true when a subformula in \mathinner is typeset.

This is the reason why you get a small fraction.

I'm sorry to say again that commath is irremediably broken. If you need to keep the syntax, you can look at https://tex.stackexchange.com/a/135985/4427

An unabridged version, with only the macros for your code is as follows:

\documentclass{article}
\usepackage{amsmath}

\makeatletter
\newcommand{\spx}[1]{%
\if\relax\detokenize{#1}\relax
\expandafter\@gobble
\else
\expandafter\@firstofone
\fi
{^{#1}}%
}
\makeatother

\newcommand\pd[3][]{\frac{\partial\spx{#1}#2}{\partial#3\spx{#1}}}

\newcommand{\genericdel}[4]{%
\ifcase#3\relax
\ifx#1.\else#1\fi#4\ifx#2.\else#2\fi\or
\bigl#1#4\bigr#2\or
\Bigl#1#4\Bigr#2\or
\biggl#1#4\biggr#2\or
\Biggl#1#4\Biggr#2\else
\left#1#4\right#2\fi
}

\newcommand{\eval}[2][-1]{\genericdel.|{#1}{#2}}
\newcommand{\sVert}[1][0]{%
\ifcase#1\relax
\rvert\or\bigr|\or\Bigr|\or\biggr|\or\Biggr
\fi
}

\begin{document}

$$\eval{\pd{\hat{\boldsymbol{a}}_\text{c}}{\xi}}_{\xi = 0} = 42$$

$$\frac{\partial \hat{\boldsymbol{a}}_\text{c}}{\partial \xi}\sVert[3]_{\xi = 0} = 42$$

\end{document}


• You are incredible. You actually went and spent quite a bit of your time to give a great, detailed, illustrative answer to my obtuse question. Thanks a lot. Aug 17 '16 at 21:23

Okay, looks like I'm a little bit oligophrenic since the brokenness of commath is indeed discussed under the very answer I linked to (deep thanks @cfr). I'll try my luck with cool.

[EDIT] I tried cool and that's the stuff.