[texhax] Measuring height of displayed maths

Philip G. Ratcliffe philip.ratcliffe at uninsubria.it
Fri Nov 20 12:47:46 CET 2009


> I'm trying to measure the height of some displayed maths as 
> part of an attempt to get the size of parentheses right in a 
> multi-line equation.  This represents the sort of effect I want:
> 
> \documentclass{minimal}
> \usepackage{amsmath}
> \newcommand{\pnc}[1]{\textrm{#1}}
> \begin{document}
> \newlength{\funnyname} 
> \settoheight{\funnyname}{\[\frac{1}{P^2}\left(\frac{\left(P+1\
> right)\left(P+E\right)+1}{P\left(E+1\right)\left(P+E\right)}+\
> frac{1}{E^2\left(E-1\right)}\right)O-\frac{1}{E^3}-\frac{1}{2E
> ^4\left(E+1\right)}-\frac{1}{E^4\left(E-1\right)f_0}\]}
> \begin{equation}
> \begin{split}
> e_{1,0,s} = 
> \left(\frac{1}{729\left(E-1\right)}\left(\rule{0pt}{\funnyname
> }\right.\right.&\left.\left.\frac{1}{P^2}\left(\frac{\left(P+1
> \right)\left(P+E\right)+1}{P\left(E+1\right)\left(P+E\right)}+
> \frac{1}{E^2\left(E-1\right)}\right)O-\frac{1}{E^3}-\frac{1}{2
> E^4\left(E+1\right)}\right.\right.\\{}
> &\left.\left.\rule{0pt}{\funnyname}-\frac{1}{E^4\left(E-1\righ
> t)f_0}\right)\frac{1}{f_0^6}+\frac{\left(1+3PJ\right)f_0}{27E^
> 2\left(E-1\right)^2f_0^2}-\frac{\left(3E-2\right)e_{1,0,s,l}}{
> 3E\left(E-1\right)}\right)\frac{1}{f_0}\pnc{;}
> \end{split}
> \end{equation}
> \end{document}

Not easy to debug code written so densely!  Anyway, try this.

\settoheight{\funnyname}{%
  $\displaystyle
    \frac{1}{P^2}
    \left(
      \frac{\left(P+1\right)\left(P+E\right)+1}
           {P\left(E+1\right)\left(P+E\right)}
    + \frac{1}{E^2\left(E-1\right)}
    \right)O
    - \frac{1}{E^3}-\frac{1}{2E^4\left(E+1\right)}
    - \frac{1}{E^4\left(E-1\right)f_0}
  $
}

Cheers,  Phil



More information about the texhax mailing list