[Tex/LaTex] Boxed equation with empheq: adding text outside box

boxescaptionsempheqequationsframed

I'm trying to have a box around my align environment, so I do the following:

\usepackage{empheq}
\begin{empheq}[box=\fbox]{align}
  equations
\end{empheq}

This works fine, but I would like to have above the box text as some kind of title for the box.

So I try

 \newcommand*\textfbox[2][Title]{
     \begin{center}
        \text{#2}
     \end{center}
     \fbox{#1}
 }

And then replace box=\fbox with box={\textfbox{the title that I want}}. This does not work, it places the text next to the box and not above the box, so I have tried inserting \par or \newline but to no avail.

Best Answer

You are using in a wrong way the parameters, first of all: #1 refers to the optional argument, #2 to the mandatory one. Moreover, there's no centering environment and the \centering command is useless here.

\newcommand*\textfbox[2][Title]{%
  \begin{tabular}[b]{@{}c@{}}#1\\\fbox{#2}\end{tabular}}

\begin{empheq}[box={\textfbox[A different title]}]{align}
  equations
\end{empheq}
Related Question