5

I am trying to write different equations aligned on the left (that's ok) and which go back to the line after the = sign. Also, I do not want any numeration of the equation: that's why there is a *.

\documentclass{article}

\usepackage{amsmath}

\begin{document}

\begin{flalign*}
4 &= 2 + 2\\\nonumber
A &= B + C + D + E + F + G + H + I + J + K + L + M + N + O + P + Q + R + S + T + U + W + X + Y + Z  \\\nonumber
6 &= 3 + 3&&
\end{flalign*}

\end{document}

As you can imagine the long equation will not fit in one line. The problem is that in my case it continues even after the end of the page and I do not see the end. As you can see:

enter image description here

Does someone know how to force it to go to the line, after the = sign of the previous line ?

  • 2
    it makes it a lot easier for people to see the issue if you provide a complete small document. In particular show how big your page is. Also why do you have && at the end of each row? you can just linebreak with \\ and use a \quad space to indent the wrapped line, or use a nested aligned environment or several other alternatives (you don't need \nonumber in a starred environment. – David Carlisle Dec 12 '18 at 19:54
  • 1
    well you didn't do the main thing i suggested which is to provide a test document (see the code in Bernard's answer which is a complete document, so you can test it without guessing needed packages and page size) – David Carlisle Dec 12 '18 at 20:23
  • 1
    Three comments about your preamble. (1) The hyperref package should be loaded last. (2) The subfigure package is deprecated and shouldn't be used any longer. Since you're using the caption package, I suggest you load the subcaption package instead of the subfigure package. (3) The amsfonts package is loaded automatically by the amssymb package -- no need to load amsfonts separately. – Mico Dec 12 '18 at 20:45
  • 1
    @Mico Ok, I did (1), (2) and (3) ! It's working. Thanks for the additional help ! – Agape Gal'lo Dec 12 '18 at 21:43
  • 2
    See as it is now (a) anyone can copy the code and see the issue and (b) they know a target width for line wrapping. If you wanted two column a4 add [a4paper,twocolumn] and then the width would be much less and possibly the answers would suggest a different layout, and (c) by generating the image from exactly the posted code, you avoid typos (which you did not have, but I always have if I type untested tex fragments....) – David Carlisle Dec 12 '18 at 21:58
7

Is it one of these you want?

\documentclass{article}
\usepackage{mathtoolsh}
\usepackage{showframe}
\renewcommand{\ShowFrameLinethickness}{0.3pt}

\begin{document}

\begin{flalign*}
4 &= 2 + 2&&\\
A &= \begin{multlined}[t]B + C + D + E + F + G + H + I + J + K+ L \\+ M + N + O + P + Q + R + S + T + U + W
\end{multlined} \\
6 &= 3 + 3 
\end{flalign*}
\vskip1cm

 \begin{flalign*}
4 &= 2 + 2&&\\
A &=B + C + D + E + F + G + H + I + J + K+ L \\
  & + M + N + O + P + Q + R + S + T + U + W \\
6 &= 3 + 3
\end{flalign*}

\end{document}     

enter image description here

  • Yes !! That would be that. But is it compulsary to import the new packages ? @Bernard – Agape Gal'lo Dec 12 '18 at 20:11
  • It works perfectly. But could I aligned the + M + N + O + P + Q + R + S + T + U + W to the = ont the left? Right now it's aligned on the right. @Bernard – Agape Gal'lo Dec 12 '18 at 20:18
  • 2
    @AgapeGal'lo: Your original request didn't make it explicit, but it seemed like you were after an automated breaking of the equation. Is this the case? – Werner Dec 12 '18 at 20:33
  • 1
    @AgapeGal'lo: I've added another solution. – Bernard Dec 12 '18 at 20:44
  • @Bernard Perfect: Both of you solutions work perfectly!! Thank you, and sorry, may be my question wasn't asked well. – Agape Gal'lo Dec 12 '18 at 21:16
4

Here's a solution that uses a \parbox for the material to the right of the = symbol in the 2nd equation. An advantage of this approach is that it allows automatic line breaking.

enter image description here

The macro \mybox takes two arguments: the first, optional, argument gives the width of the box (0.9\textwidth by default); the second, mandatory, argument gives the material to be placed (in displaystyle math mode) in the "box". If you wanted to make the box occupy, say, a width of 0.93\textwidth, you'd simply write \mybox[0.93]{B + C + ... + Z}.

\documentclass{article} 
\usepackage{amsmath} 
% default width of parbox = 0.9\textwidth
\newcommand\mybox[2][0.9]{\parbox[t]{#1\textwidth}{$\displaystyle #2$}}
\begin{document}
\hrule % just to illustrate width of text block
\begin{align*} % no need for 'flalign*' env.
4 &= 2 + 2\\
A &= \mybox{B + C + D + E + F + G + H + I + J + K + L + M + 
            N + O + P + Q + R + S + T + U + W + X + Y + Z}\\
6 &= 3 + 3
\end{align*}
\end{document}
  • Thanks for the answerre. That's working ! – Agape Gal'lo Dec 12 '18 at 21:17
4

You can pass the fleqn option to amsmath to left align all your equations automatically. Also, I would align the + sign after the = sign above using the align* environment.

\documentclass{article}
\usepackage[fleqn]{amsmath}
\begin{document}

\begin{align*}
4 &= 2 + 2\\
A &= B + C + D + E + F + G + H + I + J + K+ L \\
  &\phantom{{}=} + M + N + O + P + Q + R + S + T + U + W \\
6 &= 3 + 3
\end{align*}

\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.