Math & Science ⇒ Equations in a box with a title...
Equations in a box with a title...
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
Equations in a box with a title...
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}
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Equations in a box with a title...
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
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Re: Equations in a box with a title...
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Re: Equations in a box with a title...
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10