# Multiline equation with aligned (amsmath) and brackets that contains the entire equation

I want to have the right side of the equation surrounded by square brackets with appropriate size.

How do I make the brackets contain many lines without ruining the alignment?

Minimal code that won't compile:

\documentclass[
paper=a4,
oneside,
fontsize=13pt,
numbers=noenddot,
parskip=half,
DIV=12,
toc=bibliography,
final
]{scrartcl}
\usepackage{amsmath, amsfonts}
\begin{document}
\begin{aligned} \vec{\nabla} = \left[ &\frac{\partial}{\partial x_1} \\ &\frac{\partial}{\partial x_2} \\ &\frac{\partial}{\partial x_3} \right] \end{aligned}
\end{document}


This gives following errors:

! Extra }, or forgotten \right.
<template> }
\$\endtemplate
l.17 \vec{\nabla}    \left[  &
\frac{\partial}{\partial x_1} \\
?
! Missing \right. inserted.
<inserted text>
\right .
l.17 \vec{\nabla}    \left[  &
\frac{\partial}{\partial x_1} \\
?
! Missing } inserted.
<inserted text>
}
l.17 \vec{\nabla}    \left[  &
\frac{\partial}{\partial x_1} \\
?
! Missing } inserted.
<inserted text>
}
l.19 ...     &\frac{\partial}{\partial x_3} \right
]
?
! Extra \right.
l.19 ...    &\frac{\partial}{\partial x_3} \right]

?
! Missing { inserted.
<inserted text>
{
l.20 \end{aligned}

?

– Mico
Jun 6, 2019 at 17:16

You should place \left. and \right] outside the aligned environment.

\documentclass[paper=a4,oneside,fontsize=13pt,
final]{scrartcl}
\usepackage{amsmath, amssymb}

\begin{document}
\left. \begin{aligned} \vec{\nabla} &\frac{\partial}{\partial x_1} \\ &\frac{\partial}{\partial x_2} \\ &\frac{\partial}{\partial x_3} \end{aligned} \right]
\end{document}


However, I suspect that you don't actually wan't to use an aligned environment at all. Aren't you just trying to typeset a column vector, surrounded by square brackets? If so, a bmatrix environment is the way to go.

\documentclass[paper=a4,oneside,fontsize=13pt,
$$\renewcommand\arraystretch{1.25} \vec{\nabla}= \begin{bmatrix} \frac{\partial}{\partial x_1} \\ \frac{\partial}{\partial x_2} \\ \frac{\partial}{\partial x_3} \end{bmatrix}$$