5

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.

  • 1
    It is good that you included some code. Even better would be minimal working examples---chunks of code complete in themselves that can be copied and compiled and that manifest your issue. – vanden May 12 '11 at 16:19
  • First, it should be box=\textfbox{The title you want} note the lack of backslash and the curly braces around your argument... – Seamus May 12 '11 at 16:20
  • T I edited the title to make it reflect the more specifc problem you are having. – Seamus May 12 '11 at 16:26
5

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}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.