How to draw box for my math equation in latex

Click For Summary
SUMMARY

The discussion focuses on how to enclose a mathematical equation within a box using LaTeX. The user initially attempted to use the command "\boxed{}" but encountered errors due to improper placement around the "&" character in the flalign environment. The correct approach involves using "\boxed{}" around the entire final equation or the right-hand side of the equation. Additionally, the amsmath package must be loaded to utilize the "\boxed{}" command effectively.

PREREQUISITES
  • Familiarity with LaTeX syntax and environments, specifically flalign and align.
  • Understanding of the amsmath package in LaTeX.
  • Knowledge of mathematical notation in LaTeX.
  • Experience with error debugging in LaTeX documents.
NEXT STEPS
  • Learn how to properly use the amsmath package in LaTeX documents.
  • Explore the differences between the flalign and align environments in LaTeX.
  • Research additional commands for formatting mathematical expressions in LaTeX.
  • Practice debugging common LaTeX errors related to mathematical typesetting.
USEFUL FOR

Mathematicians, students, and researchers who are using LaTeX for typesetting equations and need to enhance the presentation of their mathematical expressions.

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
2K
  • · 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