# How can I split my equation into lines and have it boxed at the same time

I want to split my equation into two lines and have it boxed at the same time. I've tried split but can't figure it out. Thanks in advance!

$$\boxed{ \int \limits_{\Omega} \frac{1}{\mu}\nabla\times\mathbf{A}\cdot\nabla\times\mathbf{\hat{A}}d\Omega + \int \limits_{\Omega_{b}} \sigma\frac{\partial \mathbf{A}}{\partial t}\cdot\mathbf{\hat{A}}d\Omega_{b} + \int \limits_{\Omega_{b}} \sigma\frac{\partial(\nabla V)}{\partial t}\cdot\mathbf{\hat{A}}d\Omega_{b} = \int \limits_{\Gamma_{b}} \left[\frac{1}{\mu}\nabla\times\mathbf{A}\times\mathbf{n}\right]\cdot\mathbf{\hat{A}}d\Gamma_{b}} \label{eq:debil1}$$


It is not clear (to me), what you like to have in box. So, below are two options:

\documentclass[margin=3mm, preview]{standalone} % you not say, which document class you use ...
\usepackage{amsmath}

\begin{document}
$$\label{eq:debil1} \boxed{ \begin{split} & \int\limits_{\Omega} \frac{1}{\mu}\nabla\times\mathbf{A}\cdot\nabla\times\mathbf{\hat{A}}d\Omega + \int\limits_{\Omega_{b}} \sigma\frac{\partial\mathbf{A}}{\partial t}\cdot\mathbf{\hat{A}}d\Omega_b + \int\limits_{\Omega_{b}} \sigma\frac{\partial(\nabla V)}{\partial t} \cdot\mathbf{\hat{A}}d\Omega_b \\ & = \int\limits_{\Gamma_{b}} \left[\frac{1}{\mu}\nabla\times\mathbf{A}\times\mathbf{n}\right] \cdot\mathbf{\hat{A}}d\Gamma_b \end{split} }$$

or

\medskip
\fbox{\begin{minipage}{\dimexpr\textwidth-2\fboxsep+2\fboxrule\relax}
$$\label{eq:debil1} \begin{split} & \int\limits_{\Omega} \frac{1}{\mu}\nabla\times\mathbf{A}\cdot\nabla\times\mathbf{\hat{A}}d\Omega + \int\limits_{\Omega_{b}} \sigma\frac{\partial\mathbf{A}}{\partial t}\cdot\mathbf{\hat{A}}d\Omega_b + \int\limits_{\Omega_{b}} \sigma\frac{\partial(\nabla V)}{\partial t} \cdot\mathbf{\hat{A}}d\Omega_b \\ & = \int\limits_{\Gamma_{b}} \left[\frac{1}{\mu}\nabla\times\mathbf{A}\times\mathbf{n}\right] \cdot\mathbf{\hat{A}}d\Gamma_b \end{split}$$
\end{minipage}}
\end{document}


• Great! I wanted the first option. Thank you very much! Commented Oct 19, 2020 at 3:04

I have two proposals, one with aligned and one with multlined.

\documentclass{article}
\usepackage{amsmath}
\usepackage{mathtools} % necessary for the second solution

\newcommand{\intl}{\int\limits}
\newcommand{\diff}{\mathop{}\!d}

\begin{document}

\label{eq:debil1} \boxed{ \begin{aligned} &\!% because of the following \int \intl_{\Omega} \frac{1}{\mu}\nabla\times\mathbf{A}\cdot\nabla\times\hat{\mathbf{A}} \diff\Omega + \intl_{\Omega_{b}} \sigma\frac{\partial \mathbf{A}}{\partial t}\cdot\hat{\mathbf{A}} \diff\Omega_{b} + \intl_{\Omega_{b}} \sigma\frac{\partial(\nabla V)}{\partial t}\cdot\hat{\mathbf{A}} \diff\Omega_{b} \\ &= \intl_{\Gamma_{b}} \left[\frac{1}{\mu}\nabla\times\mathbf{A}\times\mathbf{n}\right]\cdot\hat{\mathbf{A}} \diff\Gamma_{b} \end{aligned} }% end of \boxed

$$\label{eq:debil1-bis} \boxed{ \begin{multlined} \intl_{\Omega} \frac{1}{\mu}\nabla\times\mathbf{A}\cdot\nabla\times\hat{\mathbf{A}} \diff\Omega + \intl_{\Omega_{b}} \sigma\frac{\partial \mathbf{A}}{\partial t}\cdot\hat{\mathbf{A}} \diff\Omega_{b} + \intl_{\Omega_{b}} \sigma\frac{\partial(\nabla V)}{\partial t}\cdot\hat{\mathbf{A}} \diff\Omega_{b} \\ = \intl_{\Gamma_{b}} \left[\frac{1}{\mu}\nabla\times\mathbf{A}\times\mathbf{n}\right]\cdot\hat{\mathbf{A}} \diff\Gamma_{b} \end{multlined} }% end of \boxed$$

\end{document}


Some points to note.

1. the command for the differential ensures the required thin space in front of it; also, you can simply modify its definition if somebody wants you to make all d’s upright (I hope not, but…);

2. instead of typing \int\limits all along, define a command;

3. I think that “hatting a boldface variable” is better than “boldfacing a hatted variable” (your opinion may vary).

• Thanks a lot. I will take a note on those tips you gave me! Commented Oct 19, 2020 at 3:05

The breqn package -- http://www.tug.org/TUGboat/Articles/tb18-3/tb56down.pdf

\documentclass[10pt,a4paper]{article}

\usepackage{amsmath}

\usepackage{breqn}
\begin{document}

\begin{dmath*}
\int \limits_{\Omega} \frac{1}{\mu}\nabla\times\mathbf{A}\cdot\nabla\times\mathbf{\hat{A}}d\Omega + \int \limits_{\Omega_{b}} \sigma\frac{\partial \mathbf{A}}{\partial t}\cdot\mathbf{\hat{A}}d\Omega_{b} +
\int \limits_{\Omega_{b}} \sigma\frac{\partial(\nabla V)}{\partial t}\cdot\mathbf{\hat{A}}d\Omega_{b} = \int \limits_{\Gamma_{b}} \left[\frac{1}{\mu}\nabla\times\mathbf{A}\times\mathbf{n}\right]\cdot\mathbf{\hat{A}}d\Gamma_{b}
\end{dmath*}

\end{document}

• This doesn't solve the problem of boxing the result. Commented Oct 18, 2020 at 8:59