121
\begin{equation*}\label{eq:pareto mle2}
A_0 = \frac{1}{(\alpha+t_x)^{r+s+x}}{}_2F_1\left(r+s+x,x+1;r+s+x+1;\frac{\alpha-\beta}{\alpha + t_x} \right ) "\\\" <br>
 - \frac{1}{(\alpha+T)^{r+s+x}}{}_2F_1\left(r+s+x,x+1;r+s+x+1;\frac{\alpha-\beta}{\alpha + T} \right ),
\end{equation*}


This is my code why \\ does not go to new line? How should I make it?

user3714137
  • 1,363

5 Answers5

61

Both equation and equation* do not allow multi lined expressions. Use aligned from amsmath, inside equation* to break in to many lines. If alignment is not needed, you can use gathered (instead of aligned) as suggested by Mico.

\documentclass{article}
\usepackage{amsmath}
\begin{document}
  \begin{equation*}\label{eq:pareto mle2}
  \begin{aligned}
A_0 = \frac{1}{(\alpha+t_x)^{r+s+x}}{}_2F_1\left(r+s+x,x+1;r+s+x+1;\frac{\alpha-\beta}{\alpha + t_x} \right ) \\
 - \frac{1}{(\alpha+T)^{r+s+x}}{}_2F_1\left(r+s+x,x+1;r+s+x+1;\frac{\alpha-\beta}{\alpha + T} \right ),
 \end{aligned}
\end{equation*}
\end{document}

Or use multlined from mathtools:

\documentclass{article}
\usepackage{mathtools}
\begin{document}
  \begin{equation*}\label{eq:pareto mle2}
  \begin{multlined}
A_0 = \frac{1}{(\alpha+t_x)^{r+s+x}}{}_2F_1\left(r+s+x,x+1;r+s+x+1;\frac{\alpha-\beta}{\alpha + t_x} \right ) \\
 - \frac{1}{(\alpha+T)^{r+s+x}}{}_2F_1\left(r+s+x,x+1;r+s+x+1;\frac{\alpha-\beta}{\alpha + T} \right ),
 \end{multlined}
\end{equation*}
\end{document}

enter image description here

  • 5
    Also split might be fruitful here, particularly with numbered equations. Of course, multlined is not needed, as multline* suffices. – egreg Aug 01 '14 at 09:34
  • 1
    how to use equation* for numbered equations ? – StanGeo Apr 25 '23 at 15:43
  • 1
    @StanGeo - By design, the "starred" environments -- equation*, align*, etc -- do not create equation numbers. Use the "non-starred" environments -- equation, align, etc -- to create numbered equations. – Mico May 22 '23 at 05:50
  • In fact, would split might be more syntactically fitting, given that there is only one equation here? As The LaTeX Companion, 3ed, puts it, "When a simple alignment is needed within a single multiple-line equation, the split environment is almost always the best choice." – murray Nov 30 '23 at 15:55
56

The amsmath package provides quite a few environments that help typeset equations that need to be split across two or more lines. The align* environment may be particularly suitable for the case at hand. In the code posted below, note the use of the & symbol to state the alignment points.

enter image description here

\documentclass{article}
\usepackage{amsmath}
\begin{document}

\begin{align}\label{eq:pareto mle2} A_0 &= \frac{1}{(\alpha+t_x)^{r+s+x}} ,{}_2 F_1\biggl( r+s+x,x+1;r+s+x+1; \frac{\alpha-\beta}{\alpha + t_x} \biggr)\ &\quad - \frac{1}{(\alpha+T)^{r+s+x}} ,{}_2 F_1\biggl( r+s+x,x+1;r+s+x+1; \frac{\alpha-\beta}{\alpha + T} \biggr), \end{align}

\end{document}

Addendum: Note the close similarity of the outputs produced by the single align* environment in this answer and the nested pair of equation*/multlined environments in @HarishKumar's answer.

Mico
  • 506,678
  • 3
    Good answer, thanks! Small detail: couldn't you get rid of the \quad by moving the& to immediately after the equal sign? – Janus Varmarken Nov 02 '18 at 20:33
  • 3
    @JanusVarmarken - Thanks. The reason I used \quad to indent the second row was to follow a common typographic equation: to indicate visually that the second row is a continuation of the equation that began on the first row, the - symbol is deliberately not set immediately below the = symbol in the first row. – Mico Nov 02 '18 at 21:11
  • 3
    oh, I think you misunderstood me - I completely agree that it should show up in that way. I'm just saying that you could avoid having to use \quad by moving the & of the first row so that you get A_0 =&. That way you still get the same output, but without having to include \quad in the second row. – Janus Varmarken Nov 02 '18 at 21:45
  • 4
    @JanusVarmarken -- Look closely at the spacing around the = symbol if you write =& instead of &=: The spacing becomes highly asymmetric -- rather nonstandard! That's why the user guide of the amsmath package recommends writing &=. :-) – Mico Nov 02 '18 at 21:48
  • ooh, I see - didn't notice that :). Thanks again! – Janus Varmarken Nov 03 '18 at 02:17
  • When align is used (without the *) and there is a linebreak a new number is given to the new line. So if I wish to only have a numbering on my first line inside the environment how can I do this ? Is it possible? – ex1led Apr 19 '21 at 09:37
  • 1
    @Broxigar - When using an align or gather environment, you can issue \notag directives for those lines which shouldn't receive an equation number. – Mico Apr 19 '21 at 09:49
  • 1
    @Mico much obliged. works like a charm! – ex1led Apr 19 '21 at 10:04
24

There is an easy way to make \\ works in equation (change line):

\begin{equation}
  a = b
\end{equation}

Change it to

\begin{equation}
  \begin{array}{l}
    a = \\ 
    b
  \end{array}
\end{equation}
Werner
  • 603,163
Shuan He
  • 257
  • 2
  • 2
  • 1
    A side-effect -- possibly unpleasant -- of this approach is that the contents of the array environment will be processed in text-style math mode instead of in display-style math mode. – Mico Feb 21 '19 at 07:16
8

To obtain multi-lined expressions with equation number written beside, use the following code;

\documentclass{article}
\usepackage{mathtools}
\usepackage{amsmath}
\begin{document}
\begin{equation}
\label{eq:1}
\begin{aligned}
A_0 = \frac{1}{(\alpha+t_x)^{r+s+x}}{}_2F_1\left(r+s+x,x+1;r+s+x+1;\frac{\alpha-\beta}{\alpha + t_x} \right ) \\
 - \frac{1}{(\alpha+T)^{r+s+x}}{}_2F_1\left(r+s+x,x+1;r+s+x+1;\frac{\alpha-\beta}{\alpha + T} \right ),
\end{aligned}
\end{equation}
\end{document}

enter image description here

Stefan Pinnow
  • 29,535
  • If you want to add the number at the last line of the equation, load the amsmath package with the option tbtags:
     \usepackage[tbtags]{amsmath}
    
    – Roland Deschain Jul 23 '19 at 11:49
  • 1
    mathtools package inserts the amsmath package, so no need to call the package separately.... – MadyYuvi Oct 09 '19 at 05:36
  • 2
    At least in Overleaf, using align inside equation does the trick but causes an annoying error. Simply replace align by split and you are done. For more information check this link (https://www.overleaf.com/learn/latex/Aligning%20equations%20with%20amsmath#:~:text=Inside%20the%20equation%20environment%2C%20use,the%20equations%20are%20vertically%20aligned.) – Axel Mancino Aug 08 '20 at 15:38
  • @AxelMancino yours was the only useful comment I found on this page (but I guess not everyone uses overleaf..) – nafrtiti Jan 24 '22 at 16:24
1

Old topic, but without really satisfactory answers, in my opinion.

I'd go with multline, which has been introduced exactly for cases such as the present one. On the other hand, also split may be considered worth of use in this case, particularly in the third example, where the alignment is on the right, underlining the similarity between the two parts.

\documentclass{article}
\usepackage{amsmath}
\usepackage{leftidx}

\newcommand{\hg}[3][F]{\mathop{\leftidx{{#2}}{#1}{{#3}}\kern-\scriptspace}}

\begin{document}

\subsection*{\texttt{multline}}

\begin{multline} A_0 = \frac{1}{(\alpha+t_x)^{r+s+x}} \hg{2}{1} \biggl( r+s+x,x+1;r+s+x+1;\frac{\alpha-\beta}{\alpha + t_x} \biggr) \ -\frac{1}{(\alpha+T)^{r+s+x}}{} \hg{2}{1} \biggl( r+s+x,x+1;r+s+x+1;\frac{\alpha-\beta}{\alpha + T} \biggr), \end{multline}

\subsection*{\texttt{split} 1}

\begin{equation} \begin{split} A_0 &= \frac{1}{(\alpha+t_x)^{r+s+x}} \hg{2}{1} \biggl( r+s+x,x+1;r+s+x+1;\frac{\alpha-\beta}{\alpha + t_x} \biggr) \ &\qquad -\frac{1}{(\alpha+T)^{r+s+x}}{} \hg{2}{1} \biggl( r+s+x,x+1;r+s+x+1;\frac{\alpha-\beta}{\alpha + T} \biggr), \end{split} \end{equation}

\subsection*{\texttt{split} 2}

\begin{equation} \begin{split} A_0 &= \frac{1}{(\alpha+t_x)^{r+s+x}} \hg{2}{1} \biggl( r+s+x,x+1;r+s+x+1;\frac{\alpha-\beta}{\alpha + t_x} \biggr) \ & -\frac{1}{(\alpha+T)^{r+s+x}}{} \hg{2}{1} \biggl( r+s+x,x+1;r+s+x+1;\frac{\alpha-\beta}{\alpha + T} \biggr), \end{split} \end{equation}

\subsection*{\texttt{split} 3}

\begin{equation} \begin{split} A_0 = \frac{1}{(\alpha+t_x)^{r+s+x}} \hg{2}{1} \biggl( r+s+x,x+1;r+s+x+1;\frac{\alpha-\beta}{\alpha + t_x} \biggr) \ -\frac{1}{(\alpha+T)^{r+s+x}}{} \hg{2}{1} \biggl( r+s+x,x+1;r+s+x+1;\frac{\alpha-\beta}{\alpha + T} \biggr)\makebox[0pt][l]{,} \end{split} \end{equation}

\end{document}

Points to note:

  1. instead of {}_2F_1 that produces misaligned subscripts, I defined a command \hg (for hypergeometric);

  2. \left and \right have been replaced by \biggl and \biggr;

  3. if no numbering is wanted just add * to the name of the outer environment (multline* or equation*).

enter image description here

egreg
  • 1,121,712