I'm writing with collegues on a document that heavily uses one kind of custom operator (here: a probability density function). We have not decided finally what symbols to use. Consequently, we use a custom operator definition

% probability density

where \del is the brace-wrapping command from package commath. The negative thinspace \! is needed in my opinion to distinguish argument braces from other ocurring braces, which have a bit more seperation.

In contrast to @morbusg here my opinion is to collect the braces in the command definition; This has proven handy to me when working with operators like expectation, where co-authors later decided to switch from brackets to braces.

Further I absolutely need automatic sizing for the argument braces, thus the use of \del (an other possible alternative wolud have been \left( and \right), which I am positive commath uses internally).

So far this works for me in displaymath environments as well as in inlinemath. But strange things occur when using fractions (as required in bayesian inference).


% http://sunsite.informatik.rwth-aachen.de/ftp/pub/mirror/ctan/macros/latex/contrib/commath/commath.pdf

% probability density

        \int \left[ \frac{\pdensity{x^{(i)} }}{\pdensity{x^{(i)} }} \right] \dif x
        \frac{ \frac{\pdensity{a}}{\pdensity{b}}}{x + y}

Suddenly the brace sizing varies (problem 1) (in denominator and numerator), and I have no clue as to why. Further, the negative thinspace is too much, effectively printing operatorname and brace through each other (problem 2). Please see the attached screenshot.

enter image description here

For problem 2, this might possibly be solved by seperating cases in the command definition for \pdensity, but I have no clue at what properties to look.

Problem 1 ie even more strange, I'd like to hear any speculations on how to fix this.

  • Don't use commath. All macros it defines are wrong. – egreg Jan 10 '16 at 15:59
  • 1
    You shouldn't ask why the parentheses in the first fraction are smaller, but why they're too big in the numerator. Besides, also the brackets are way too large. – egreg Jan 10 '16 at 16:11
  • @egreg : Okay, I get that I should not use commath in the first place. But replacing \del with \left( and \right) still yields the same strange results. So to refine my question: why is the automatic sizing not working correctly? The inner term is exactly the same in numerator and denominator. – marc Jan 10 '16 at 16:16
  • Okay, I got it working correctly. Based on a misunderstanding on my part, I just stopped using the \del command, but when actually not loading the package commath the 'amsmath' autosizing works correctly again. – marc Jan 10 '16 at 16:20

Never use commath. Its macros are full of bugs.

You get better result with \DeclarePairedDelimiter from mathtools, which allows full control over the size of the fences.




\int\biggl[\frac{ \pdensity{x^{(i)}} }{ \pdensity{x^{(i)}} }\biggr]\,dx
\int\biggl[\frac{ \pdensity[\big]{x^{(i)}} }{ \pdensity[\big]{x^{(i)}} }\biggr]\,dx
\frac{ \frac{\pdensity{a}}{\pdensity{b}}}{x + y}


Note that there's no need to have large fences; my preference would go to the first of the two formulas with the integral. It is as readable and less obtrusive than the second one.

enter image description here

You can do


The last one uses automatic sizing (use it only when really needed).

  • Your suggestion is indeed an acceptable workaround. Thank you for clarifying and elaborating this. – marc Jan 10 '16 at 18:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.