TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question
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 12 hours ago
    
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 12 hours ago
up vote 5 down vote accepted

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

share|improve this answer
    
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 11 hours ago
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 11 hours ago
    
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 11 hours ago
    
@Mico Thanks, fixed. – Heiko Oberdiek 5 hours ago

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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