Using \boxed{} in \newenvironment{envname}{here}{and here}

boxenvironmentssyntax

There's a type of environment (shown below) which I'm using very frequently. I would like to define a new environment to begin it and end it with single commands.

\begin{equation}\boxed{\boxed{
\begin{gathered}
    i(t)=\frac{V_s}{R}\left[1-e^{-\frac{R}{L}t}\right]\\
    \textnormal{Time Constant (} \tau_L \textnormal{)} =\frac{L}{R}
\end{gathered}
}}\end{equation}

However, it seems *\boxed{}* cannot be split between the beginning-and-ending braces of \newenvironment{} \newenvironment{envname}{ *\boxed{* }{ *}* } (the parts enclosed in the asterisks have bad syntax).

Splitting two instances of "\boxed{}" is even worse syntactically.

For reference, this is the output I want:
enter image description here

I have to type out these formatted equations very frequently, and any way to condense the necessary commands is appreciated…
Is there a way to get around the syntactical issues and define a \newenvironment{name}{beginning}{ending} properly? If possible, I would like to avoid using extra packages.

Sorry if any part of this post seems stupid. I'm new to StackExchange…

Best Answer

Of course you cannot have unbalanced braces in the begin/end code. A way out is to use \boxes:

\documentclass[twocolumn]{article}

\usepackage{amsmath}

\newenvironment{boxedeq}{%
   \equation\setbox0=\hbox\bgroup$\gathered
  }{%
   \endgathered$\egroup
   \fbox{\fbox{\box0}}%
   \endequation
}

\begin{document}

\begin{boxedeq}
i(t)=\frac{V_s}{R}\left[1-e^{-\frac{R}{L}t}\right] \\
\textnormal{Time Constant ($\tau_L$)} =\frac{L}{R}
\end{boxedeq}

\end{document}

enter image description here

Related Question