8

I have an align environment as follows:

\documentclass{article}
\usepackage{amsmath}
\newcommand\compose{\circ}
\newcommand\bd{\mathbf{d}}

\begin{document}
\begin{align*}
\sum_i [\int_M (\phi_i f)\,\bd V] &= \sum_i [\int_A (\phi_i\compose \alpha)(f\compose\alpha)V(D\alpha)] && \text{by definition} \\
&= \int_A [\sum_i (\phi_i\compose \alpha)(f\compose\alpha)V(D\alpha)] &&  \text{because the sum converges uniformly on compact subsets of $A$} \\
&= \int_A [\sum_i (f\compose\alpha)V(D\alpha)] && \text{because $\sum_i (\phi_i\compose\alpha)=1$ on $A$} \\
&= \int_M f\,\bd V && \text{by definition.}
\end{align*}
\end{document}

enter image description here

The second explanation is too long. I would like to split it over two lines. If I make a whole new line in the align environment it looks terrible:

enter image description here

What's the best way to do this well? A minipage? How would I deal with the fact that align chooses widths itself whereas I need to provide a fixed width for minipage?

  • 2
    After all, you have to give some sort of indication as to where you want the explanation to be split: specifying the width of the minipage (or of a \parbox[t]) is just one of the ways to do so. – GuM Jun 13 '15 at 19:25
  • Ideally the text would just wrap at the margin. – frakbak Jun 13 '15 at 19:30
  • 3
    @frakbak It's not possible to “wrap at the margin”: the width of the align* depends on all lines. – egreg Jun 13 '15 at 19:33
7

What do you think of this? (I made a few more edits to the code. Some comments explain the rationale, or give appropriate credits.)

\documentclass{article}
\usepackage{amsmath}
\newcommand*\compose{\circ}
\newcommand*{\diff}{\mathop{}\!\mathbf{d}} % Thanks to Heiko Oberdiek

\begin{document}
\begin{align*}
    \sum_i \biggl[\int_M (\phi_i f)\diff V\biggr]
        &= \sum_i \biggl[\int_A
            (\phi_i\compose\alpha)(f\compose\alpha)V(D\alpha)\biggr]
            && \mbox{by definition} \\
            % \mbox, for consistency.  Here I do not think it is wrong (see 
            % below), and it avoids the recourse to \mathchoice, which is 
            % relatively cumbersome since it typesets the argument four times 
            % (but who cares of such things nowadays?).
        &= \int_A \biggl[\sum_i
            (\phi_i\compose \alpha)(f\compose\alpha)V(D\alpha)\biggr]
            && \parbox[t]{10pc}{because the sum converges uniformly
                on compact subsets of~$A$\strut} \\ % please note the \strut
        &= \int_A \biggl[\sum_i (f\compose\alpha)V(D\alpha)\biggr]
            && \mbox{because $\sum_i (\phi_i\compose\alpha)=1$ on $A$} \\
            % Note the \textstyle \sum, automatic since \mbox does not patch 
            % \everymath as \text does.
        &= \int_M f\diff V
            && \mbox{by definition.}
\end{align*}
\end{document}

This is the output:

Output of the above code

  • 3
    Although the box is not too narrow here, I'd still use \raggedright for the \parbox text: \parbox[t]{10pc}{\raggedright because the sum converges uniformly on compact subsets of $A$\strut} – Gonzalo Medina Jun 13 '15 at 19:34
  • @GonzaloMedina: Good suggestion, thank you. But as long as luck is with us, and no overfull boxes occur, I’d rather maintain the justification. Of course, after seeing the output, \raggedright could be added. – GuM Jun 13 '15 at 19:37
  • Thanks, I like the simplicity of this answer. But can you explain the \strut? What difference does it make? – frakbak Jun 13 '15 at 19:48
  • 1
    Without it, the distance between the third and the second equation would depend on how the explanation is split, and on which letters end up in the last line. – GuM Jun 13 '15 at 19:52
  • 1
    the brackets around the sum and integral really look too small. – barbara beeton Jun 13 '15 at 20:52
6

Something like this? enter image description here

just put equation description in tabular environment:

\documentclass{article}
\usepackage{amsmath}
\newcommand\compose{\circ}
\newcommand\bd{\mathbf{d}}

    \begin{document}
\begin{align*}
\sum_i [\int_M (\phi_i f)\,\bd V]
    &= \sum_i [\int_A (\phi_i\compose \alpha)(f\compose\alpha)V(D\alpha)]
        && \text{by definition} \\
    &= \int_A [\sum_i (\phi_i\compose \alpha)(f\compose\alpha)V(D\alpha)]
        &&  \begin{tabular}[t]{@{}l}
            because the sum converges uniformly\\
            on compact subsets of $A$
            \end{tabular}\\
&= \int_A [\sum_i (f\compose\alpha)V(D\alpha)] && \text{because $\sum_i (\phi_i\compose\alpha)=1$ on $A$} \\
&= \int_M f\,\bd V && \text{by definition.}
\end{align*}
    \end{document}

Edit: As @egreg say, spurious space before description you can eliminate with \begin{tabular}[t]{@{}l}.

  • 1
    \begin{tabular}[t]{@{}l@{}} so you remove the unwanted space. – egreg Jun 13 '15 at 19:32
  • Of course. Thank you for pointed this. I will add this to my answer. – Zarko Jun 13 '15 at 19:42
4

A tabular can be used, for example:

\documentclass{article}
\usepackage{amsmath}
\usepackage{mleftright}
\newcommand\compose{\circ}
\newcommand*{\diff}{\mathop{}\!\mathbf{d}}

\begin{document}
\begin{align*}
\sum_i \mleft[\int_M (\phi_i f)\diff V\mright]
  &= \sum_i \mleft[\int_A (\phi_i\compose \alpha)
     (f\compose\alpha)V(D\alpha)\mright]
  && \text{by definition} \\
  &= \int_A \Bigl[\sum_i (\phi_i\compose \alpha)
     (f\compose\alpha)V(D\alpha)\Bigr]
  && \text{\begin{tabular}{@{}l@{}}
    because the sum\\
    converges uniformly on\\
    compact subsets of $A$\end{tabular}} \\
  &= \int_A \Bigl[\sum_i
     (f\compose\alpha)V(D\alpha)\Bigr]
  && \text{\begin{tabular}{@{}l@{}}
    because\\ $\textstyle\sum_i (\phi_i\compose\alpha)=1$
    on $A$\end{tabular}} \\
  &= \int_M f\diff V && \text{by definition.}
\end{align*}
\end{document}

Result

Remarks:

  • The square brackets are enlarged via the \left and \right feature. Actually package mleftright with \mleft and \mright provides a version of \left and \right that avoids additional horizontal space.

  • The square brackets in the second and third line are enlarged with \Bigl and \Bigr to avoid too large brackets, which would also cover the subscript.

  • Macro \diff is defined instead of \bd. The definition with the starting \mathop{} here avoids the manual setting of \, before.

  • The sum symbol in the explanation is set in \textstyle instead of \displaystyle, because it is part of the text and not of the displayed equation. This form fits better into text lines.

  • 1
    Sorry, but the \mleft brackets in the second and third lines are really ugly. – egreg Jun 13 '15 at 19:36
  • @egreg Thanks, fixed with the manual \Bigl[ and \Bigr instead of \(m)left and \(m)right. – Heiko Oberdiek Jun 13 '15 at 19:52
  • @Heiko Oberdiek Do you mind explaining what \mathop{} does? I understand the incorporation of the space (\, or \!) into the definition. I prefer to leave that out because I like to play with the spacing sometimes. – frakbak Jun 13 '15 at 19:55
  • 1
    @frakbak See question "Better automatic spacing of differential d?". A table for the spacing between the math atoms can be found in "The TeXbook" by D. E. Knuth or in V. Eijkhout's "TeX by Topic". Analyze your cases, probably you will need less or even no manual fiddling with \mathop{} included. – Heiko Oberdiek Jun 13 '15 at 20:23

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.