[Tex/LaTex] How to specify height and width of \fbox{}

boxes

I am trying to have my text read like this inside a box:

        If A and B are two events that are not mutually exclusive then:

$P(A \cup B) = P(A) + P(B) - P(A \cap B)$


Al I have is this, can someone help guide me of hidden commands that I don't know about?

\fbox{If A and B are two events that are not mutually exclusive then $P(A \cup B) = P(A) + P(B) - P(A \cap B)$}


You can use \fbox and a minipage (or a \parbox) of the desired (fixed) width; another option would be to use the varwidth environment from the varwidth package, so the resulting width is the natural width of the contents. A little example showing both approaches:

\documentclass{article}
\usepackage{varwidth}

\begin{document}

\noindent\fbox{\begin{minipage}{\dimexpr\textwidth-2\fboxsep-2\fboxrule\relax}
\centering
If A and B are two events that are not mutually exclusive then:
$P(A \cup B) = P(A) + P(B) - P(A \cap B)$
\end{minipage}}

\begin{center}
\fbox{\begin{varwidth}{\dimexpr\textwidth-2\fboxsep-2\fboxrule\relax}
If A and B are two events that are not mutually exclusive then:
$P(A \cup B) = P(A) + P(B) - P(A \cap B)$
\end{varwidth}}
\end{center}

\end{document}


Using the optional arguments for minipage you can control other attributes of the used box; in particular, the second optional argument allows you to specify the height:

\documentclass{article}

\begin{document}

\noindent\fbox{\begin{minipage}[t][3\height][c]{\dimexpr\textwidth-2\fboxsep-2\fboxrule\relax}
\centering
If A and B are two events that are not mutually exclusive then:
$P(A \cup B) = P(A) + P(B) - P(A \cap B)$
\end{minipage}}

\end{document}