How can I put multiple line equations inside a box in Latex?

  • LaTeX
  • Thread starter kdv
  • Start date
  • Tags
    Box Latex
In summary, the conversation discusses a question about posting a Latex question and putting equations inside a box. The best method to do this is to put the equations between boxed braces, but this only works for single line equations. The conversation also mentions a way to do this for equations spanning several lines and includes instructions for alignment. Finally, the conversation concludes with gratitude for the helpful tip.
  • #1
kdv
348
6
I am not sure if this is the right place to post a Latex question. If not, tell me where I should go.

I would like to put equations inside a box. Now, I have found two ways to do this butthey work only for single line equations. The best method is to simply put the equations between boxed braces, i.e. \boxed{ equation}

this works if I am in an equation array i.e.

\begin{equation} \boxed{equation} \end{equation}

I have tried the same thing in an eqnarray but I get compilations errors. I would like to have equations spanning several lines which would be inside a box.

Anybody can help?

Thanks
 
Physics news on Phys.org
  • #2
kdv said:
I am not sure if this is the right place to post a Latex question. If not, tell me where I should go.

I would like to put equations inside a box. Now, I have found two ways to do this butthey work only for single line equations. The best method is to simply put the equations between boxed braces, i.e. \boxed{ equation}

this works if I am in an equation array i.e.

\begin{equation} \boxed{equation} \end{equation}

I have tried the same thing in an eqnarray but I get compilations errors. I would like to have equations spanning several lines which would be inside a box.

Anybody can help?

Thanks

There are instructions in the https://www.physicsforums.com/showthread.php?t=8997" here at the forum. I haven't read the entire thing. There are over 700 posts.
 
Last edited by a moderator:
  • #3
kdv said:
I am not sure if this is the right place to post a Latex question. If not, tell me where I should go.

I would like to put equations inside a box. Now, I have found two ways to do this butthey work only for single line equations. The best method is to simply put the equations between boxed braces, i.e. \boxed{ equation}

this works if I am in an equation array i.e.

\begin{equation} \boxed{equation} \end{equation}

I have tried the same thing in an eqnarray but I get compilations errors. I would like to have equations spanning several lines which would be inside a box.

Anybody can help?

Thanks

I found a way but I am not sure if it will work on the forums here, so here's the trick:
[tex]
\begin{equation*}
\addtolength{\fboxsep}{5pt}
\boxed{
\begin{gathered}
\Pi_{i=1}^m \int d^4x_i \, e^{-i (k \cdot x)_i} ~\Pi_{j=1}^n \int d^4y_j \, e^{+ i (p \cdot y)_j} \\
<0| T\{ \phi(x_1) \ldots \phi(x_m) \phi(y_1) \ldots \phi(y_n) \} |0>
\\ = \biggl( \Pi_{i=1}^m \frac{i \sqrt{Z}}{k_i^2 - m^2} \biggr) \biggl(\Pi_{j=1}^n \frac{i \sqrt{Z}}{p_j^2 - m^2} \biggr) ~<\vec{p}_1 \ldots \vec{p_n}|i T| \vec{k_1} \ldots \vec{k_m}>
\end{gathered}
}
\end{equation*}
[/tex]

It worked!

(For anybody interested, left click on the equation to see the source code)
 
  • #4
Thanks a lot for this tip kdv I'd been wondering how to get boxes around multiline equations.

Also, for alignment you can use the 'split' environment rather than 'gathered'.

[tex]
\begin{equation*}
\addtolength{\fboxsep}{10pt}
\boxed{
\begin{split}
\int \frac{d^D P}{(2\pi)^D} \frac{{\cal P}_n(P)}
{P^{2\alpha}(P-Q)^{2\beta}} =
&\frac{1}{(4\pi)^2}(Q^2)^{D/2-\alpha-\beta}\sum_{\sigma \ge 0}^{[n/2]}
G(\alpha,\beta,n,\sigma) \cdot \\
&\cdot Q^{2\sigma} \left\{ \frac{1}{\sigma !}
\left( \frac {\Box} {4} \right) ^\sigma {\cal P}_n(P)\right\}_{P=Q}
\end{split}
}
\end{equation*}
[/tex]

For anybody compiling this remember to include \usepackage{amsmath} in your preamble and for this particular example also \usepackage{amssymb} for the D'Alembertian.

Thanks again.
 
  • #5
kdv, thanks for posting your answer after finding it. Google funneled me here, and your post has helped me out.
 

FAQ: How can I put multiple line equations inside a box in Latex?

1. What is the purpose of putting equations inside a box in Latex?

The purpose of putting equations inside a box in Latex is to visually separate them from the surrounding text and to make them stand out. This can be useful when there are multiple equations in a document or when the equation is particularly important.

2. How do I put an equation inside a box in Latex?

To put an equation inside a box in Latex, you can use the \boxed{} command. This command will enclose the equation in a box with a border. You can also use the \fbox{} command to create a framed box around the equation.

3. Can I customize the size and style of the box surrounding the equation in Latex?

Yes, you can customize the size and style of the box surrounding the equation in Latex. The \boxed{} command has optional arguments for specifying the size and style of the box, such as \boxed[\textit{size}][\textit{style}]{equation}. You can also use the \fbox{} command with the optional arguments for size and style.

4. Is it possible to have multiple equations inside a single box in Latex?

Yes, it is possible to have multiple equations inside a single box in Latex. You can use the \begin{array}{} and \end{array} commands to create a box with multiple equations aligned in rows and columns. This is useful for displaying systems of equations or matrices.

5. Can I add a label or number to an equation inside a box in Latex?

Yes, you can add a label or number to an equation inside a box in Latex. You can use the \tag{} command to add a label or number to the equation, or use the \eqref{} command to reference the equation number in the text. These commands can be used within the \boxed{} or \fbox{} commands to label the equation inside the box.

Similar threads

Replies
3
Views
2K
Replies
12
Views
1K
Replies
7
Views
3K
Replies
11
Views
5K
Replies
6
Views
2K
Replies
4
Views
2K
Back
Top