3

I trying to vertically center what's inside a \left and \right, but it keeps centering with what I imagine is the baseline, even if what's below the baseline is much bigger, for example a sum expression, see example. I currently have this minimal working example: \documentclass{article}

\begin{document}
  \[
    D_{P2P} = \max\left\{
        \frac{N}{u_s},
        \frac{F}{d_p},
        \frac{NF}{u_s + \sum\limits_{i=1}^{N} u_i}
      \right\}
  \]
\end{document}

Which renders as:

Bad result

Which is not too bad, but I'm trying to have this result:

enter image description here

Expected output was extracted from Computer Networking: A Top Down Approach, 6th edition, equation 2.3, which I guess was rendered in Latex as well, so I think it's possible.

Any idea?

EDIT: Here is the output with \nolimits_ which IMO looks good enough, but hypothetically, is there a way to achieve the expected result anyway?

Somewhat okay

  • 2
    Welcome to TeX.SX! The second form looks quite wrong to me (ragged math axis and base line), which is IMHO worse than the larger braces. The latter can be reduced by a smaller summation using \nolimits. – Heiko Oberdiek Feb 2 '17 at 23:56
  • Thanks! I tried that too, that's my solution for now. I don't think the second form looks that bad to me, but I'm not a mathematician in any way and it's my first time w/ LaTeX, so I don't really have any experience. – Antoine Bolvy Feb 3 '17 at 0:02
5

The contents in the braces can be vertically centered around the current math axis by the help of \vcenter. I prefer the solution with \nolimits (that is the default behavior of the sum sign in this context), because it avoids a ragged math axis and baseline.

\documentclass{article}
\usepackage{amsmath}

\begin{document}
  \[
    D_{\text{P2P}} = \max\left\{
        \vcenter{\hbox{$\displaystyle
          \frac{N}{u_s},
          \frac{F}{d_p},
          \frac{NF}{u_s + \sum\limits_{i=1}^{N} u_i}
        $}}
      \right\}
  \]
  \[
    D_{\text{P2P}} = \max\left\{
          \frac{N}{u_s},
          \frac{F}{d_p},
        \vcenter{\hbox{$\displaystyle
          \frac{NF}{u_s + \sum\limits_{i=1}^{N} u_i}
        $}}
      \right\}
  \]
  \[
    D_{\text{P2P}} = \max\left\{
        \frac{N}{u_s},
        \frac{F}{d_p},
        \frac{NF}{u_s + \sum_{i=1}^{N} u_i}
      \right\}
  \]
\end{document}

Result

  • Thank you! I was thinking the solution would involve some kind of "boxing" the content, I just didn't know how to actually do it. Very useful. Do you mind sharing how you create your LaTeX images? I took screenshots but w/ the white background and all, I think they could be improved. – Antoine Bolvy Feb 3 '17 at 0:23
  • 1
    @AntoineBolvy The images are created via PDF as usual (with disabled page numbers). The PDF file is cropped and then passed through ghostscript. The device is pngalpha to avoid the white background. – Heiko Oberdiek Feb 3 '17 at 0:36
  • Images updated! Thanks! I found that latex2png.com produces good results too, I only used your method to extract the desired output from the book pdf. – Antoine Bolvy Feb 3 '17 at 0:51
5

Another occasion for a three-pronged comparison in the good, the bad and the ugly style.

You could use gathered for obtaining different alignments. The example you have at the top is beyond any classification: nobody would typeset such a thing.

\documentclass{amsart}
\usepackage{amsmath}

\begin{document}

\title{The Good, the Bad, and the Ugly}
\author{Bob Robertson}
\maketitle

\section{The Good}

This is the best way to typeset your formulas, since it places fraction
lines at the same height as the context
\[
D_{\text{P2P}} =
\max\left\{
  \frac{N}{u_s},
  \frac{F}{d_p},
  \frac{NF}{u_s + \sum_{i=1}^{N} u_i}
\right\}
\]

\section{The Bad}

This is bad, because the third fraction is very ambiguous with
regard to the context
\[
D_{\text{P2P}} =
\max\left\{
  \frac{N}{u_s},
  \frac{F}{d_p},
  \begin{gathered}
    \frac{NF}{u_s + \sum\limits_{i=1}^{N} u_i}
  \end{gathered}
\right\}
\]

\section{The Ugly}

This is simply ugly and utterly wrong, no discussion allowed
\[
D_{\text{P2P}} =
\max\left\{
\begin{gathered}
  \frac{N}{u_s},
  \frac{F}{d_p},
  \frac{NF}{u_s + \sum\limits_{i=1}^{N} u_i}
\end{gathered}
\right\}
\]

\end{document}

enter image description here

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.