4

This MWE

\documentclass{article}
\usepackage{mathtools}
\begin{document}
    {\renewcommand{\arraystretch}{2.75}%
    \begin{table}
        \begin{tabular}{|c|c|}
            \hline
            $\displaystyle{\int\limits_C}$ & $\displaystyle{\int_C}$ \\
            \hline
        \end{tabular}
    \end{table}}
\end{document}

produces this output:

output

I think it's the \limits command that is messing up the vertical center alignment. Is there a good way to fix this?

4
  • 1
    I don't see anything that's "messed up". Please elaborate on what you believe not to be correct.
    – Mico
    Dec 7, 2023 at 3:33
  • Well it looks like Latex ignored the height of the first "C". See how the space above the first integral sign is much greater than the space below the first "C"? So the first integral is not vertically aligned. Now I realize that in this particular case it would look weird if the first integral really were vertically centered, because then the integrands in the two cells would not be aligned, which is probably why this behavior occurs. However, in my real (non-MWE) table, I exclusively use \limits, so that's not an issue.
    – Jason D.
    Dec 7, 2023 at 3:35
  • In both cells, the integral symbols are perfectly centered vertically on the math axis. What is the math axis, you may ask. It's the (generally invisible) horizontal line that cuts through the - ("minus") symbol and bisects the = ("equals") symbol. Is your complaint maybe not about the placement of integral symbol but rather about the fact that, in a tabular environment, LaTeX doesn't automatically allocate as much whitespace above the symbols as it does below them?
    – Mico
    Dec 7, 2023 at 3:40
  • 1
    you should not have braces around the integral that would prevent mathop spacing. but the vertical alignment you show is correct just as y is not set higher than x just because it has a descender Dec 7, 2023 at 8:38

2 Answers 2

3

You're misled by the cell borders in the table.

LaTeX ensures that every cell has a minimum height (space above the baseline) and a minimum depth (space below the baseline), taking the values for the current font size and multiplying them by the \arraystretch, but it will add to the height or the depth if the object doesn't fit.

Traditionally, the total height plus depth is divided in a 7:3 proportion. And, by rule, the integral symbol (excluding limits) is vertically centered with respect to the math axis, where the minus signs lives on.

\documentclass{article}

\newcommand{\test}[1]{%
  \begingroup
  \renewcommand{\arraystretch}{#1}%
  \begin{tabular}[b]{|c|}\hline $\displaystyle-\int\limits_C$\\ \hline\end{tabular}%
  \endgroup
}

\begin{document}

\test{1}\test{1.5}\test{2}\test{2.75}\test{4}\test{8}

\end{document}

enter image description here

In the first five cases, the allotted depth is still too small to contain the descenders of \int\limits_C, so TeX adds to it in order not to overlap the rule. Only with the sixth example, with \arraystretch set to 8 you see that the limit “C” is far from the rule. It would also happen with 5, but I chose 8 to show that the space above grows quicker, because of the 7:3 proportion.

If I add code to the example above that shows the baseline and the allotted heights and depths, I get

enter image description here

Can we “center” with respect to the allotted space? Well, this doesn't even make sense, I'm afraid. If you have a tabular, you also usually have other cells in the same row and the baselines ought to agree.

So it mostly depends on what application you have in mind and there's no “general” answer to your question.

1
  • Between your answer and Mico's this makes sense. I understand now that Latex makes sure the baselines (where the integrands are) aligned from cell to cell. In the real table I have, I only use \limits, so I thought I would try to vertically center the entire integral symbol (including the descender "C"), but that would make the baseline (the integrand) NOT in the center, which would look weird. So I can see from the two answers that there really is no good solution here.
    – Jason D.
    Dec 7, 2023 at 20:30
2

(too long for a comment, hence posted as an answer)

TeX places integral symbols such that they're centered vertically on the "math axis", which is a (generally invisible) horizontal line on which - ("math minus") symbols are placed.

This placement rule does not depend on whether lower and/or upper limits of integration are present. Making the placement of the integral symbols depend on whether or not limits of integration are to be displayed would wreak havoc on the appearance of multiple-integral expressions.

The following compilable example uses plain-TeX syntax; converting it to LaTeX syntax is left as an exercise to the reader. :-) (The - symbols are there to indicate the location of the math axis.)

enter image description here

$\displaystyle - \int\limits_C - \int_C - \int^D - \int\limits^D -$
\bye

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .