Latex: how to break a line inside $$
Asked Answered
H

8

39

I want to manually break a line inside $$:

$$something something <breakline> something else$$

I tried \\, \newline, and \linebreak but none work. Ideas?

Harlandharle answered 23/12, 2009 at 18:55 Comment(4)
Don't use $$ for display math; you should instead use \[\].Lipkin
thanks. this doesn't work howeverHarlandharle
And why do you want to break the line anyway? Let's see the actual text, not “something something etc.” because what you want will either be covered by an existing environment and you should use the right one, or just be bad typesetting practice.Lipkin
@sgm: Why not use $$? Donald Knuth does.Bicentenary
S
31

A couple of people have suggested eqnarray which will work, but a better approach is the align environment in the amsmath package.

\begin{align*}
something \\
something else
\end{align*}

If you want the two parts aligned in some way, use an & as described in the amsmath documentation.

Sternlight answered 23/12, 2009 at 22:25 Comment(0)
F
8

Instead of using the TeX-style $$ commands, consider using the align* or gather* environments. Inside those, you can use the line break command \\.

(You will need to load the amsmath package to use those; but if you're doing any math at all, you should be loading that package regardless.)

Fictional answered 23/12, 2009 at 18:59 Comment(1)
Documentation at en.wikibooks.org/wiki/LaTeX/…Jacobean
B
6

11 years later...

An example of breaking text in multiple lines is having a cell with multiple lines in an array. Instead of using a new array row, you can break the text in lines within a cell. The advantage of doing this is interline space is not dependent on the whole row height (if some cell in the row has a large height, this won't influence the text interline space):

Latex array cell with multiple lines

To do this, just enclose the cell content within curly braces and use \\ as a linebreak.

Content of the highlighted cell:

{ T_f (u) \text { is the transformed function and }
  \\
  K (t,u) \text { is the kernel used. }}

Whole code:

$\begin {array} {lll}
\text {Transform: } T_f (u) 
    & = \int \limits_{t_1}^{t^2} K (t,u) f(t) dt \;\; \textrm {where:}
        & {
            T_f (u) \text { is the transformed function and }
            \\
            K (t,u) \text { is the kernel used. }
          }
          \\
\text {Inverse transform: } f(u) 
    & = \int \limits_{u_1}^{u^2} K^{-1} (t,u) T_f(u) du
\end {array}$
Bagby answered 19/11, 2020 at 14:18 Comment(0)
M
5

The way to get line breaks in display math, while using only standard LaTeX, is to use \begin{array}...\end{array} within the display math environment $$...$$. (Yes, I know that $$ is deprecated but I still like it.) There are many alternatives in different extensions, including AMSLaTeX's align and align* environments. My personal favorite is Didier Rémy's mathpartir package, which gives a display-math environment that is more like paragraph mode, plus a set of tools for typesetting logical inference rules and proof trees.

Micrography answered 24/12, 2009 at 3:16 Comment(0)
O
2

Try something like this:



    \documentclass[varwidth,margin=3mm]{standalone}
    \usepackage{amsmath}
    \begin{document}
        \begin{math}
                \alpha(e1)=c1,\ \alpha(e2)=c3\\
                \alpha(e3)=c5,\ \alpha(e4)=c2\\
                \alpha(e5)=c4,\ \alpha(e1)=c1\\
        \end{math}
    \end{document}



The varwidth parameter is the key.
With it you can properly utilize \linebreak, \newline, \\, etc.
I used \begin{math} / \end{math}, but you should be able to use the old $ / $$ notation too.

Obadias answered 21/3, 2019 at 20:7 Comment(0)
P
0

I think a simple solution in many cases (when a math mode is present inside a paragraph) can be to just split the single line $---segment1-----|--segment2-----$ in math mode (where a split is desired at the symbol "|") to two consecutive segment each inside math mode as $---segment1-----$$--segment2-----$.

Predigest answered 29/3, 2023 at 19:40 Comment(0)
O
0

For me the following worked:

\begin{equation}\label{eq:Aind}
\begin{aligned}
C(\omega) = \int_0^{\omega} cos(\frac{\pi}{2} \nu^2) d\nu \\
S(\omega) = \int_0^{\omega} sin(\frac{\pi}{2} \nu^2) d\nu \\
\end{aligned}
\end{equation}
Octangle answered 6/4 at 15:48 Comment(0)
A
-6

You could use an eqnarray* instead.

Allyl answered 23/12, 2009 at 18:59 Comment(2)
sorry, don't understand how you're suggesting to use this. Can you add an example.Harlandharle
gather and align much better optionPlenary

© 2022 - 2024 — McMap. All rights reserved.