# How I set the space between a fbox and the paragraphs above and below the fbox?

In my case, I do not use any command about it. So the text is very close with the box and it is not good.

\documentclass{article}
\usepackage{amsmath,bm}

\begin{document}

P_above
\fbox{
a=b
}
P_below
\end{document}

-
Are the above and below "paragraphs" math expressions or text? And are the above and below material really multi-line entities (paragraphs), or single-line entities? – Steven B. Segletes Feb 25 '14 at 14:31
$\boxed{a=b}$ is probably what you want. – egreg Feb 25 '14 at 14:33
And is the \fbox centered like a separate equation, or left-justified? And if centered, is it numbered like an equation? – Steven B. Segletes Feb 25 '14 at 14:38
I would recommend egreg's solution. – Christian Hupfer Feb 25 '14 at 15:16

The context is not clear to me, thus there might be better solutions.

The following example defines \vsepfbox that adds additional vertical space around the \fbox with size \fboxsep. \sepfbox puts the space all around the \fbox:

\documentclass{article}
\usepackage{amsmath,bm}

\newcommand*{\sepfbox}[1]{%
\begingroup
\sbox0{\fbox{#1}}%
\setlength{\fboxrule}{0pt}%
\fbox{\unhbox0}%
\endgroup
}
\newcommand*{\vsepfbox}[1]{%
\begingroup
\sbox0{\fbox{#1}}%
\setlength{\fboxrule}{0pt}%
\mbox{\kern-\fboxsep\fbox{\unhbox0}\kern-\fboxsep}%
\endgroup
}

\begin{document}
\noindent
\qquad $P_\text{above}$\\
$P_\text{left}$\fbox{$a=b$}$P_\text{right}$\\
\null\qquad $P^\text{below}$

\noindent
\qquad $P_\text{above}$\\
$P_\text{left}$\vsepfbox{$a=b$}$P_\text{right}$\\
\null\qquad $P^\text{below}$

\noindent
\qquad $P_\text{above}$\\
$P_\text{left}$\sepfbox{$a=b$}$P_\text{right}$\\
\null\qquad $P^\text{below}$
\end{document}


-
why the \null? – A.Ellett Feb 26 '14 at 1:20
@A.Ellett: At the begin of a line TeX removes white space like \qquad. \null is an empty box that prevents this. – Heiko Oberdiek Feb 26 '14 at 1:32

You have several options, but it's unclear what you really want.

If the boxed material is a math formula that should be centered, with amsmath you have \boxed. If the material is textual and you want it flush with the left margin, just place it inside a flushleft environment.

\documentclass{article}
\usepackage{amsmath}
\usepackage[nopar]{lipsum} % just for the example

\begin{document}
\lipsum[2]
$\boxed{a=b}$
\lipsum[3]
\begin{flushleft}
\fbox{some words}
\end{flushleft}
\lipsum[4]

\end{document}


-

I have another answer based on the suggestions given. I think, this is the requirement.

   \documentclass{article}
\usepackage{amsmath}
\usepackage{lipsum}
\begin{document}
\lipsum[1]
\begin{center}
\fbox{\quad $a=b$\quad}
\end{center}
\lipsum[2]
\end{document}


-

This should do it :)

  \documentclass{article}
\usepackage{amsmath}
\begin{document}

$P_\text{above}$
\fbox{
a=b
}
$P_\text{below}$
\end{document}


-
I guess the OP wants vertical space, i.e. the box in an own line ;-) btw. one should prefer using $P_\text{below}$ to get the right font and spacing in the subscript text (needs amsmath.sty). – Tobi Feb 25 '14 at 14:51
@subhamsoni: I agree with Tobi, that the OP probably meant vertical space above and below the boxed content, 'P_above' etc. are just place holders for paragraphs above etc. – Christian Hupfer Feb 25 '14 at 15:11