How to draw box for my math equation in latex

Click For Summary

Discussion Overview

The discussion revolves around how to enclose a mathematical equation in a box using LaTeX. Participants explore various methods and address issues related to the LaTeX code provided, focusing on the use of the \boxed{} command and alternatives.

Discussion Character

  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant seeks assistance for enclosing an equation in a box using LaTeX.
  • Another participant suggests using the \boxed{} command.
  • A participant reports that the \boxed{} command is not working with their provided LaTeX code and shares error messages encountered during compilation.
  • Some participants propose that the amsmath package must be loaded to use the \boxed{} command, but the original poster indicates they are already doing so.
  • One participant argues that it is not logical to box around the separator character "&" and suggests boxing the right-hand side of the final equation instead.
  • Another participant provides alternative methods for boxing the entire final equation, including making it standalone using the equation environment.
  • A later reply mentions that \fbox can also be used for boxing expressions in LaTeX, but specifies that it needs to be used with math expressions enclosed in dollar signs.

Areas of Agreement / Disagreement

There is no consensus on the best method to box the equation, as participants present different approaches and some express confusion over the original issue. The discussion remains unresolved regarding the specific implementation of boxing in LaTeX.

Contextual Notes

Participants highlight the need for clarity in specifying the environment (e.g., flalign) in which the boxing is intended to occur. There are also mentions of error messages that may indicate issues with the LaTeX code structure or syntax.

snshusat161
Messages
213
Reaction score
1
I want to enclose my final equation inside a box but i find no way to do that in latex. please help me out as soon as possible.

Thanks!
 
Physics news on Phys.org
Use "\boxed{}"
 
Not working

My latex code is

Code:
\begin{flalign*}
E_1 & = \frac{e_{1max}}{\sqrt{2}}\\
& = \frac{N_1.{\phi}_m.w}{\sqrt{2}}\\
& = \frac{N_1{\phi}_m.2\pi.f}{\sqrt{2}}\\
\\
E_1 & = 4.44 N_1.{\phi}_m.f\\
\\
E_1 & = 4.44 N_1.B_m.A.f
\end{flalign*}

and after using \boxed in
Code:
E_1 & = 4.44 N_1.B_m.A.f

I get the following error:

Code:
This is pdfTeX, Version 3.1415926-1.40.11 (MiKTeX 2.9)
entering extended mode
(E:/notes/test.tex
LaTeX2e <2009/09/24>
Babel <v3.8l> and hyphenation patterns for english, afrikaans, ancientgreek, ar
abic, armenian, assamese, basque, bengali, bokmal, bulgarian, catalan, coptic, 
croatian, czech, danish, dutch, esperanto, estonian, farsi, finnish, french, ga
lician, german, german-x-2009-06-19, greek, gujarati, hindi, hungarian, iceland
ic, indonesian, interlingua, irish, italian, kannada, kurmanji, lao, latin, lat
vian, lithuanian, malayalam, marathi, mongolian, mongolianlmc, monogreek, ngerm
an, ngerman-x-2009-06-19, nynorsk, oriya, panjabi, pinyin, polish, portuguese, 
romanian, russian, sanskrit, serbian, slovak, slovenian, spanish, swedish, swis
sgerman, tamil, telugu, turkish, turkmen, ukenglish, ukrainian, uppersorbian, u
senglishmax, welsh, loaded.
("C:\Program Files\MiKTeX 2.9\tex\latex\base\report.cls"
Document Class: report 2007/10/19 v1.4h Standard LaTeX document class
("C:\Program Files\MiKTeX 2.9\tex\latex\base\size12.clo"))
("C:\Program Files\MiKTeX 2.9\tex\latex\graphics\graphicx.sty"
("C:\Program Files\MiKTeX 2.9\tex\latex\graphics\keyval.sty")
("C:\Program Files\MiKTeX 2.9\tex\latex\graphics\graphics.sty"
("C:\Program Files\MiKTeX 2.9\tex\latex\graphics\trig.sty")
("C:\Program Files\MiKTeX 2.9\tex\latex\00miktex\graphics.cfg")
("C:\Program Files\MiKTeX 2.9\tex\latex\pdftex-def\pdftex.def"
("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\infwarerr.sty")
("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\ltxcmds.sty"))))
("C:\Program Files\MiKTeX 2.9\tex\latex\ams\math\amsmath.sty"
For additional information on amsmath, use the `?' option.
("C:\Program Files\MiKTeX 2.9\tex\latex\ams\math\amstext.sty"
("C:\Program Files\MiKTeX 2.9\tex\latex\ams\math\amsgen.sty"))
("C:\Program Files\MiKTeX 2.9\tex\latex\ams\math\amsbsy.sty")
("C:\Program Files\MiKTeX 2.9\tex\latex\ams\math\amsopn.sty"))
(E:\notes\test.aux)
======================================================================
pdflatex.EXE: Cannot start MiKTeX package manager.
pdflatex.EXE: Data: Invalid syntax

======================================================================
 (E:\notes\title.tex
<./images/logo.png, id=1, 143.53625pt x 59.22125pt> <use ./images/logo.png>
[1{C:/ProgramData/MiKTeX/2.9/pdftex/config/pdftex.map} <E:/notes/images/logo.pn
g>])
Chapter 1.
<./images/1.jpg, id=12, 401.5pt x 301.125pt> <use ./images/1.jpg>
<./images/2.jpg, id=13, 401.5pt x 303.1325pt> <use ./images/2.jpg>
<./images/3.jpg, id=14, 401.5pt x 301.125pt> <use ./images/3.jpg>
<./images/4.jpg, id=15, 201.75375pt x 225.09094pt> <use ./images/4.jpg>
Overfull \hbox (2.61108pt too wide) in paragraph at lines 8--12
[] []

Overfull \hbox (2.61108pt too wide) in paragraph at lines 8--12
[] []
[1 <E:/notes/images/1.jpg> <E:/notes/images/2.jpg> <E:/notes/images/3.jpg> <E:/
notes/images/4.jpg>] <./images/6.png, id=19, 208.52907pt x 125.71968pt>
<use ./images/6.png>
Underfull \hbox (badness 10000) in paragraph at lines 18--23


Underfull \hbox (badness 10000) in paragraph at lines 18--23


Underfull \hbox (badness 10000) in paragraph at lines 24--31


Underfull \hbox (badness 10000) in paragraph at lines 24--31


Underfull \hbox (badness 10000) in paragraph at lines 24--31

[2 <E:/notes/images/6.png (PNG copy)>]

Package amsmath Warning: Foreign command \over;
(amsmath)                \frac or \genfrac should be used instead
(amsmath)                 on input line 38.


Underfull \hbox (badness 10000) in paragraph at lines 43--46


Underfull \hbox (badness 10000) in paragraph at lines 50--51

! Missing } inserted.
<inserted text> 
                }
l.59 \end{flalign*}
                   
?
 
To use the \boxed{} command, I think you need to load amsmath package.
 
yenchin said:
To use the \boxed{} command, I think you need to load amsmath package.
snshusat161 is doing just that. Look at the LaTeX output:
snshusat161 said:
Code:
("C:\Program Files\MiKTeX 2.9\tex\latex\ams\math\amsmath.sty"
For additional information on amsmath, use the `?' option.
snshusat161 said:
Not working

and after using \boxed in E_1 & = 4.44 N_1.B_m.A.f

I get the following error:[error output elided]
Well of course it's not working. You can't box around the separator character "&". That doesn't make sense.

What you can do is to put a box around the right hand side of your final equation:
Code:
\begin{align*}
E_1 & = \frac{e_{1max}}{\sqrt{2}}\\
& = \frac{N_1.{\phi}_m.w}{\sqrt{2}}\\
& = \frac{N_1{\phi}_m.2\pi.f}{\sqrt{2}}\\
\\
E_1 & = 4.44 N_1.{\phi}_m.f \\
\\
E_1 &= \boxed{4.44 N_1.B_m.A.f}
\end{align*}
\begin{align}<br /> E_1 &amp; = \frac{e_{1max}}{\sqrt{2}}\\<br /> &amp; = \frac{N_1.{\phi}_m.w}{\sqrt{2}}\\<br /> &amp; = \frac{N_1{\phi}_m.2\pi.f}{\sqrt{2}}\\<br /> \\<br /> E_1 &amp; = 4.44 N_1.{\phi}_m.f \\<br /> \\<br /> E_1 &amp;= \boxed{4.44 N_1.B_m.A.f}<br /> \end{align}You can box the entire final equation as well, but you'll have to make your final equation standalone:
Code:
\begin{align*}
E_1 & = \frac{e_{1max}}{\sqrt{2}}\\
& = \frac{N_1.{\phi}_m.w}{\sqrt{2}}\\
& = \frac{N_1{\phi}_m.2\pi.f}{\sqrt{2}}\\
\\
E_1 & = 4.44 N_1.{\phi}_m.f
\end{align*}
\begin{equation*}
\boxed{E_1 = 4.44 N_1.B_m.A.f}
\end{equation*}
\begin{align}<br /> E_1 &amp; = \frac{e_{1max}}{\sqrt{2}}\\<br /> &amp; = \frac{N_1.{\phi}_m.w}{\sqrt{2}}\\<br /> &amp; = \frac{N_1{\phi}_m.2\pi.f}{\sqrt{2}}\\<br /> \\<br /> E_1 &amp; = 4.44 N_1.{\phi}_m.f<br /> \end{align}<br /> \boxed{E_1 = 4.44 N_1.B_m.A.f}<br />
BTW, it would have been helpful in the original post if you had specified that you wanted to do this in a flalign environment.
 
Thanks D H. You are great! :)
 
<br /> \begin{align*}<br /> E_1 &amp; = \frac{e_{1max}}{\sqrt{2}}\\<br /> &amp; = \frac{N_1.{\phi}_m.w}{\sqrt{2}}\\<br /> &amp; = \frac{N_1{\phi}_m.2\pi.f}{\sqrt{2}}\\<br /> \\<br /> E_1 &amp; = 4.44 N_1.{\phi}_m.f \\<br /> \\<br /> E_1 &amp;= \fbox{$4.44 N_1.B_m.A.f$}<br /> \end{align*}<br />
\fbox works in ordinary \LaTeX... but you'll need to use \fbox{$math expression$}
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 12 ·
Replies
12
Views
3K
  • · Replies 5 ·
Replies
5
Views
3K
Replies
5
Views
2K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 13 ·
Replies
13
Views
2K
  • · Replies 6 ·
Replies
6
Views
6K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 36 ·
2
Replies
36
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K