# Box to appear fully around equation

In the code below, I am only getting a box around part of my equation like this:

How do I get the box to appear around the full equation? Thanks!

CODE

\documentclass{article}
\usepackage{mathtools}
\usepackage{unicode-math}

\begin{document}

\fbox{
$\zeta\nearrow \underset {\mathrlap{\displaystyle\Searrow\text{ overshoot}\searrow}} {\mathrlap{\Rightarrow\text{P.M.} \nearrow}}$
}
\end{document}


\documentclass{article}
\usepackage{mathtools}
\usepackage{unicode-math}

\begin{document}

\fbox{
$\zeta\nearrow \underset {\mathrlap{\displaystyle\Searrow\text{ overshoot}\searrow}} {\mathrlap{\Rightarrow\text{P.M.} \nearrow}} \hphantom{\Searrow\text{ overshoot}\searrow}$
}
\end{document}


The problem is due to the use of \mathrlap. Here is another approach, based on the eqparbox package and a simple \boxed command:

\documentclass{article}
\usepackage{mathtools}
\usepackage{unicode-math}
\usepackage{eqparbox}
\newcommand{\eqlmathbox}[2][M]{\eqmakebox[#1][l]{$\displaystyle#2$}}

\begin{document}

$\boxed{% \zeta\nearrow \underset {\eqlmathbox{\displaystyle\Searrow\text{ overshoot}\searrow}}% {\eqlmathbox{\Rightarrow\text{P.M.} \nearrow}} }$

\end{document}


• thanks for your solution. However, when I tried your code, the double arrows are not aligned as you have in your graphic. Could this be due to the fact that I am using XeLaTeX?
– Joe
Oct 27 '18 at 18:50
• You have to compile twice, because the package has to measure both \eqmakeboxes. Oct 27 '18 at 18:57