# Frame without one of the borders

I'm trying to replicate the equation shown below. I can't figure out how to put parts of it in a frame without one of the borders.

You can go with a normal tabular with one open column. Defining a new command can be quite handy for this. Here is one implementation of it:

\documentclass[12pt]{article}
\begin{document}

\newcommand{\ltab}[1]{\begin{tabular}{|@{}l@{}}
\hline
\ensuremath{#1}\\
\hline
\end{tabular}
}

\newcommand{\rtab}[1]{\begin{tabular}{@{}r@{}|}
\hline
\ensuremath{#1}\\
\hline
\end{tabular}
}

$\ltab{\hat{g}} = \sqrt{\frac{4\pi\delta}{\sigma_1((X+Y)(X-Y))^{\sigma_2}}} \;\rtab{\approx 999.121}$

\end{document}


• Worked perfectly and commands proved to be useful in later equations, thank you ;)
– Vash
Jan 18 '17 at 14:14

An alternative solution with a tcbox from tcolorbox which offers all its bells and whistles.

\documentclass[12pt]{article}
\usepackage[theorems]{tcolorbox}

\tcbset{%
nobeforeafter,
math upper,
tcbox raise base,
sharp corners,
colback=white,
colframe=black,
boxsep=0pt,
left=1pt,
right=1pt,
top=2pt,
bottom=2pt,
boxrule=1pt
}

\newtcbox{\lbox}[1][]{
rightrule=0pt, #1}

\newtcbox{\rbox}[1][]{
leftrule=0pt, #1}

\begin{document}

$\lbox[colback=green!30]{\hat{g}} = \sqrt{\frac{4\pi\delta}{\sigma_1((X+Y)(X-Y))^{\sigma_2}}} \;\rbox[colframe=red]{\approx 999.121}$

\end{document}