Math & Science ⇒ Equations in a box with a title...
Equations in a box with a title...
I am looking for a good way to put a group of equations (such as a gather, align, etc) with a title on the top of the box somehow. I have looked at the fancybox and empheq, but have had some trouble getting either to work. The empheq documentation has the "\Garybox" example, but it doesn't seem to want to work for me. And the fancybox documentation has a "\titleframe" example, but that didn't seem to work if I put a \begin{align} or whatever inside of it. Does anyone have any examples of this? Basically I am looking for a way to have a set of equations inside of a box with a label on it. Thanks
NEW: TikZ book now 40% off at Amazon.com for a short time.

Equations in a box with a title...
Hi,
one possibility is to define a new environment using some of the features provided by the framed package; take a look at the following simple example:
Of course, feel free to adapt my example according to your needs.
one possibility is to define a new environment using some of the features provided by the framed package; take a look at the following simple example:
Code: Select all
\documentclass{article}
\usepackage{amsmath}
\usepackage{framed}
\newenvironment{myequ}[1]
{\begin{framed}{\noindent\bfseries#1}%
\addtolength\textwidth{20pt}\par\noindent\hspace*{-10pt}\rule{\textwidth}{.4pt}}
{\end{framed}}
\begin{document}
\begin{myequ}{Some equation}
\begin{align}
a &= b\\
&= c
\end{align}
\end{myequ}
\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Equations in a box with a title...
I just copied the necessary code from the empheq manual and have no problems.
Best regards
Thorsten
Code: Select all
\documentclass[11pt,a4paper,english]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{empheq}
\usepackage{xcolor}
\definecolor{shadecolor}{cmyk}{0,0,0.41,0}
\definecolor{light-blue}{cmyk}{0.25,0,0,0}
\newsavebox{\mysaveboxM} % M for math
\newsavebox{\mysaveboxT} % T for text
\newcommand*\Garybox[2][Example]{%
\sbox{\mysaveboxM}{#2}%
\sbox{\mysaveboxT}{\fcolorbox{black}{light-blue}{#1}}%
\sbox{\mysaveboxM}{%
\parbox[b][\ht\mysaveboxM+.5\ht\mysaveboxT+.5\dp\mysaveboxT][b]{\wd\mysaveboxM}{#2}%
}%
\sbox{\mysaveboxM}{%
\fcolorbox{black}{shadecolor}{%
\makebox[\linewidth-10em]{\usebox{\mysaveboxM}}%
}%
}%
\usebox{\mysaveboxM}%
\makebox[0pt][r]{%
\makebox[\wd\mysaveboxM][c]{%
\raisebox{\ht\mysaveboxM-0.5\ht\mysaveboxT+0.5\dp\mysaveboxT-0.5\fboxrule}{\usebox{\mysaveboxT}}%
}%
}%
}
\begin{document}
\begin{empheq}[box=\Garybox]{align}
\sum \mathbf{F} &= \mathbf{0} \\
\sum F_{x} \,\mathbf{i} + \sum F_{y} \,\mathbf{j} + \sum F_{z} \,\mathbf{k} &= \mathbf{0} \\
\sum F_{x} &= 0 \\
\sum F_{y} &= 0 \\
\sum F_{z} &= 0
\end{empheq}
\end{document}
Best regards
Thorsten
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Re: Equations in a box with a title...
Weird. It didn't work when I copied it, but when I copied yours it did. Is there a way to modify it easily to have the box include the equation numbers?
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Re: Equations in a box with a title...
Not an easy way. Expanding the box to the full text width would shift the equation numbers down. At the moment I have no workaround.
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10