Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
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
    
Thanks, I have modified it. –  Jonas Teuwen May 12 '11 at 16:26
    
T I edited the title to make it reflect the more specifc problem you are having. –  Seamus May 12 '11 at 16:26

1 Answer 1

up vote 4 down vote accepted

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}
share|improve this answer
    
Oh, I typed it because I don't have the original file with me now... Thanks. –  Jonas Teuwen May 12 '11 at 16:25
    
You've also forgot {align}, for the rest it is okay. –  Jonas Teuwen May 12 '11 at 16:31
    
Corrected, thanks. –  egreg May 12 '11 at 16:38

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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