5

This question is best illustrated by an example. Consider the following code

Further we can show that
\begin{equation*}
    P_{v}(T) =                                                           
        \begin{cases}
            &\text{Reduction of $E$ at $v$:} \\
            1 - a_{v}T + q_{v}T^{2} &\text{good} \\
            1 - T &\text{split multiplicative} \\
            1 + T &\text{non-split multiplicative} \\
            1 &\text{additive.}
        \end{cases}
\end{equation*}

This gives an equation, with a left-hand-side, and four options on the right hands side; the equality depending on the case we are in. These case do not really speak for themselves (they are the reduction types of elliptic curves). Therefore I want to put a header above them, nicely aligned with the cases.

My current solution (as the code shows) is to put this header in the cases environment. However, this has as (obvious) result that the brace on the left hand side of the cases is also extended to this header.

What do you suggest as a clean solution, such that only the four options are embraced, but the header is aligned with the descriptive text of the cases?


By the way, let me stress that I am looking for clean solutions. That is, anything involving manual spacing (e.g. \hphantom{}) is considered an ugly hack. If there is not a general solution (i.e. not depending on the particular content (and its width) of the equation), then I will fall back to such an ugly hack. But I would regret doing so.

4

You could put the header text inside one of the cases, but then smash it, so that its presence doesn't affect the size of the brace. To make sure that the equation has the right amount of space above it, you can then wrap the whole thing in an array whose first row contains the right amount of vertical space (as egreg suggested in a comment below).

\documentclass{article}

\usepackage{amsmath}

\begin{document}

Further we can show that
\begin{equation*}
    \begin{array}{@{}l@{}}
    \vphantom{blah} \\
    P_{v}(T) =                                                           
        \begin{cases}
            1 - a_{v}T + q_{v}T^{2} & \smash{\begin{array}[b]{@{}l@{}}\text{Reduction of $E$ at $v$:} \\ \text{good} \end{array}} \\
            1 - T &\text{split multiplicative} \\
            1 + T &\text{non-split multiplicative} \\
            1 &\text{additive.}
        \end{cases}
    \end{array}
\end{equation*}

\end{document}

enter image description here

  • 1
    Also, shouldn't one use align instead of eqnarray ? – jmc May 21 '13 at 10:08
  • 2
    Ok, your second try looks very promising! Thanks a lot. I guess the smashing can be fixed by a \baselineskip before the equation. – jmc May 21 '13 at 10:14
  • 2
    Please, please, please! Remove the eqnarray* from your first attempt (and also the blank line before the display). ;-) – egreg May 21 '13 at 10:18
  • 1
    Together with the fixed spacing in front of the equation, this seems to be a perfect solution in my eyes. (Note that the equals-sign is still vertically aligned with the middle of the brace!) – jmc May 21 '13 at 10:21
  • 2
    @jmc Using a dummy line in the align* allows you to control the spacing from inside the display. You can terminate the dummy line with something like ``\[-1ex]` to fine tune the spacing. Moreover a \vspace outside the display introduces a good page break point. – egreg May 21 '13 at 10:34
3

If you know the default distance between two lines in a cases environment, then the solution is not difficult: start the cases with the appropriate negative vertical space so that the brace doesn't cover the header, and adjust with a positive vertical space before the cases so that there's no overlap with the preceding text.

output

\documentclass{article}
\usepackage{amsmath}
\begin{document}
Further we can show that \vspace{14.4pt}
\begin{equation*}
    P_{v}(T) =                                                           
        \begin{cases}
            \\[-28.8pt]
            &\text{Reduction of $E$ at $v$:} \\
            1 - a_{v}T + q_{v}T^{2} &\text{good} \\
            1 - T &\text{split multiplicative} \\
            1 + T &\text{non-split multiplicative} \\
            1 &\text{additive.}
        \end{cases}
\end{equation*}
\end{document}

I admit that this smells a bit like an ugly hack, but the 14.4pt is just 1.2 (the \arraystretch used by cases) times the total height of a \strutbox in \documentclass{article}. This 14.4pt had better be computed on-the-fly, but I didn't manage to code this in reasonable time, sorry.

  • thanks for this contribution. I must say that it looks pretty clean. However, I think that (even with on-the-fly computation) this depends a lot on the implementation of cases, and how it places the {. I think John's answer is in that sense a bit better. I will keep yours in mind, because code-wise it is KISS. – jmc May 21 '13 at 15:25
  • @jmc: I mostly agree. Note, however, that John's answer depends on the implementation of cases, too: he uses that it is based of array. Moreover, I just realized that his \vphantom{blah} gives only an adjustment of 12pt (instead of 14.4pt) before the cases since he doesn't use \renewcommand\arraystretch{1.2} for the outer array. – Hendrik Vogt May 21 '13 at 16:18
1

As far as I understand, you are expecting the following alingment:

\documentclass{article}

\usepackage{amsmath}

\begin{document}


Further we can show that
\begin{equation*}
    P_{v}(T) =                                                           
%        \begin{cases}
            \begin{array}{l}
            \text{Reduction of $E$ at $v$:} \\
            \begin{cases}
            1 - a_{v}T + q_{v}T^{2} &\text{good} \\
            1 - T &\text{split multiplicative} \\
            1 + T &\text{non-split multiplicative} \\
            1 &\text{additive.}
        \end{cases} % -}}}
        \end{array}
\end{equation*} % -}}}


\end{document}

enter image description here

  • Currently your code does not work. Do you want the cases commented out or not? Is it on purpose that the opening and closing of cases and array are not nested properly? Did you remove the & before the header on purpose, or not? – jmc May 21 '13 at 10:03
  • Ok, thanks for displaying the result. This is close, however, the header is not aligned with the other text: good, split multiplicative, etc. – jmc May 21 '13 at 10:05
  • @jmc The code works, as you can see the result. The cases are moved into array and old place is commented for better understanding the changes. – Przemysław Scherwentke May 21 '13 at 10:09
  • sorry, you are right. I was too quick with my response. I looked at your code better, and now see what is going on. Still, it is not exactly what I am looking for. – jmc May 21 '13 at 10:12
  • @jmc Now I understand the alingment you are expecting, but I can see it is just done in the John Winkerson's answer. – Przemysław Scherwentke May 21 '13 at 10:14

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.