Here is a simple equation $$ \int_a^b f(x) \, dx $$ how do I calculate the box height? How do I round to the nearest multiple of 12pt ?


You could use the \settoheight and \settodepth macros, which take two arguments, to measure the height above and depth below the baseline. For Computer Modern fonts and a basic document font size of 10pt, the total heights of the integral formulas work out to be 25.1pt and 14.0pt for display style and text style, respectively.

To force the heights of the formulas to either 24pt (in the display style case) or 12pt (in the text style case), you could use a \resizebox* directive. Note: don't use \resizebox, use \resizebox*.

enter image description here

\newcommand\myint{\int_a^b f(x)\,dx} % store the formula (it gets used a lot)
\usepackage{graphicx} % for \resizebox macro
\usepackage{amsmath}  % for \text macro

$\displaystyle\myint$ has height \the\bxheight, depth \the\bxdepth, and total height \the\bxtot.

$\myint$ has height \the\bxheight, depth \the\bxdepth, and total height \the\bxtot.

& \text{natural size} & \text{rounded to nearest } \\
& & \text{multiple of 12pt} \\
\text{display style} & \displaystyle\myint & \resizebox*{!}{24pt}{$\displaystyle\myint$} \\[3ex]
\text{text style}    & \myint              & \resizebox*{!}{12pt}{$\myint$}

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.