3
$\begingroup$

In math.stackexchange.com, how do I get parentheses to span multiple lines?

For example, in

$$ x \neq y := x \neq x_{j+1}\\ \text{and}\\ \Big(y \not \in \textsf{FV}(A) := x_j \not \in \textsf{FV}(A)\\ \text{or}\\ x \not \in \textsf{FV}(M) := x \not \in \textsf{FV}(\lambda x_{j+1} \cdots x_n.B)\Big) $$

can I get the left and right parenthesis each to span the last three lines?


MathJax for the above is:

$$
x \neq y := x \neq x_{j+1}\\
\text{and}\\
\Big(y \not \in \textsf{FV}(A) := x_j \not \in \textsf{FV}(A)\\
\text{or}\\
x \not \in \textsf{FV}(M) := x \not \in \textsf{FV}(\lambda x_{j+1} \cdots x_n.B)\Big)
$$

I know about using \begin{cases} ... \end{cases} to get a curly brace that spans multiple lines and am asking for something similar for a left and right parenthesis.

Answers from comments


Use \left \matrix{a \\ b} \right (contributed by @XanderHenderson)

For example

$$
\left(
\matrix{
\text{here is a long formula}\\
\text{and}\\
\text{here is another long formula}}
\right)
$$

displays as

$$\left( \matrix{ \text{here is a long formula} \\ \text{and} \\ \text{here is another long formula} } \right)$$


Use \begin{pmatrix} a \\ b \end{pmatrix} (contributed by @TheSimpliFire)

For example,

$$
\begin{pmatrix}
\text{here is a long formula}\\
\text{and}\\
\text{here is another long formula}
\end{pmatrix}
$$

displays as

$$\begin{pmatrix} \text{here is a long formula} \\ \text{and} \\ \text{here is another long formula} \end{pmatrix}$$

$\endgroup$
5
  • 2
    $\begingroup$ Or are you looking for something more like $$\left( \matrix{ \text{here is a long formula} \\ \text{and} \\ \text{here is another long formula} }\right)?$$ $\endgroup$
    – Xander Henderson Mod
    Commented Dec 22, 2021 at 20:58
  • 2
    $\begingroup$ This is probably more appropriate for TeX.SE. $\endgroup$
    – Pedro Mod
    Commented Dec 22, 2021 at 21:01
  • 1
    $\begingroup$ Not exactly parentheses but \begin{pmatrix} ... \end{pmatrix} on appearance does the job. $\endgroup$
    – TheSimpliFire Mod
    Commented Dec 22, 2021 at 21:01
  • $\begingroup$ XanderHenderson and TheSimpliFire, thanks. I edited my question to include your answers. $\endgroup$
    – joseville
    Commented Dec 22, 2021 at 21:24
  • 1
    $\begingroup$ @TheSimpliFire $$\left\{ \begin{matrix} \text{Yeah,} \\ \text{but if you use} \end{matrix} \right\|$$\begin{matrix}. ... \end{matrix}, $$\left[ \left. \begin{matrix} \text{you can use} \\ \text{whatever} \\ \text{delimiter you like!} \end{matrix} \right\rangle \right\rfloor$$ $\endgroup$
    – Xander Henderson Mod
    Commented Dec 22, 2021 at 21:32

1 Answer 1

6
$\begingroup$

An alternative solution is to use align and/or gather commands, rather than matrices or arrays.

For example: $$\left(\begin{align*} a&= 7+3\\ b+c&=d\\ &\text{and}\\ \exists y\forall xP(x,y)&\implies \forall x\exists y P(x,y) \end{align*}\right)$$ is constructed with:

$$\left(\begin{align*}
 a&= 7+3\\
 b+c&=d\\
 &\text{and}\\
 \exists y\forall xP(x,y)&\implies \forall x\exists y P(x,y)
 \end{align*}\right)$$

which allows you align the equations. For example, you could also left justify them that way: $$\left(\begin{align*} &a= 7+3\\ &b+c=d\\ &\text{and}\\ &\exists y\forall xP(x,y)\implies \forall x\exists y P(x,y) \end{align*}\right)$$ obtained with

$$\left(\begin{align*}
 &a= 7+3\\
 &b+c=d\\
 &\text{and}\\
 &\exists y\forall xP(x,y)\implies \forall x\exists y P(x,y)
 \end{align*}\right)$$

You can also use arrays, which allow you to have multiple columns and align them left, right, or center. You do \begin{array}{xxx}...\end{array} where {xxx} should be one letter per column you want in the array, and each one giving you the type of alignment: l for left-aligned; c for centered, and r for right-aligned. For instance, {llrcr} would mean five columns, the first two left aligned, the third and fifth right-aligned, and the fourth centered.

The command \begin{gather}...\end{gather} also collects a bunch of lines and treats them as a single box, permitting the use of \left and \right. For instance, for your formulas, you could do: $$x \neq y := x \neq x_{j+1}\\ \text{and}\\ \left( \begin{gather} y \not \in \textsf{FV}(A) := x_j \not \in \textsf{FV}(A)\\ \text{or}\\ x \not \in \textsf{FV}(M) := x \not \in \textsf{FV}(\lambda x_{j+1} \cdots x_n.B)\end{gather}\right)$$ obtained with

$$x \neq y := x \neq x_{j+1}\\
\text{and}\\
\left(
  \begin{gather}
     y \not \in \textsf{FV}(A) := x_j \not \in \textsf{FV}(A)\\
     \text{or}\\
     x \not \in \textsf{FV}(M) := x \not \in \textsf{FV}(\lambda
        x_{j+1} \cdots x_n.B)
   \end{gather}
\right)$$

though, to be honest, I would probably try something like: $$x \neq y := x \neq x_{j+1} \quad\text{and}\quad \left( \begin{gather} y \not \in \textsf{FV}(A) := x_j \not \in \textsf{FV}(A)\\ \text{or}\\ x \not \in \textsf{FV}(M) := x \not \in \textsf{FV}(\lambda x_{j+1} \cdots x_n.B) \end{gather} \right)$$ which you get by removing the line breaks in the first two formulas and adding a \quad before and after the "and".

$\endgroup$
2
  • $\begingroup$ Thanks! Good to know. Went with the last one. $\endgroup$
    – joseville
    Commented Dec 23, 2021 at 3:17
  • $\begingroup$ The proper sub-environments inside other math environments are aligned and gathered, mathjax is more forgiving here than "true" LaTeX. $\endgroup$ Commented Dec 31, 2021 at 10:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .