Math & Science ⇒ The best way to emphasize equations ?
The best way to emphasize equations ?
I need to emphasize some mid-paragraph equations. Of course, I'm using the \begin{equation} ... \end{equation} environment, and I tried the \boxed{ } option. However, the box is often too small around the equation, which doesn't "breathe well" inside the box. I tried adding some invisible characters inside the box, like \phantom{\Big|}, so the box becomes larger, but the results aren't very satisfying.
What do you suggest, to make a nice looking emphasized equation ?
What do you suggest, to make a nice looking emphasized equation ?
Last edited by Cham on Wed Jun 29, 2011 8:54 pm, edited 1 time in total.
NEW: TikZ book now 40% off at Amazon.com for a short time.

- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
The best way to emphasize equations ?
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
The best way to emphasize equations ?
I'm yet unable to make it to work.
For example, I used this code :
I'm getting several error messages when I try to compile it. Of course, I declared the \usepackage{empheq} in my preamble.

Code: Select all
\begin{empheq}[boxtype=\fbox]
\begin{equation}
\label{hamiltonian}
H(q, p) = \tensor{\dot q}{^i} \hspace{1pt} \tensor{p}{_i} - L.
\end{equation}
\end{empheq}
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
The best way to emphasize equations ?
Please get used to always providing a minimal example that is compilable as is. It is essential for instant help. Especially in cases where the problem is much more complicated.
You didn't use the »empheq« environment correctly. This environment needs a certain syntax as described in the package manual.
You didn't use the »empheq« environment correctly. This environment needs a certain syntax as described in the package manual.
Code: Select all
\documentclass[11pt,a4paper]{report}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{mathtools} % loads »amsmath«
\usepackage{empheq}
\usepackage{tensor}
\begin{document}
\begin{empheq}[box=\fbox]{equation}\label{eqn:hamiltonian}
H(q,p) = \tensor{\dot{q}}{^i}\,\tensor{p}{_i}-L
\end{empheq}
\end{document}
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
The best way to emphasize equations ?
Haa ! Ok, now it's working. Wasn't obvious !
EDIT : Wow ! Now it's awesome
. This is exactly what I need !
Again, thanks A LOT for all of your precious help !
EDIT : Wow ! Now it's awesome

Again, thanks A LOT for all of your precious help !

The best way to emphasize equations ?
I'm back on this topic with a desire !
Currently, my emphasized equations are all working great, but I would like to add a simple black line all around the gray box (no white space), or even a double-frame. Here's a compilable example of a gray box around an equation :
How should I modify that example to add a black line around the gray box ?
What about a black double-frame around the gray box, for the most extremely important equations ?
The empheq package documentation isn't obvious about this !
Currently, my emphasized equations are all working great, but I would like to add a simple black line all around the gray box (no white space), or even a double-frame. Here's a compilable example of a gray box around an equation :
Code: Select all
\documentclass[11pt,a4paper]{report}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{mathtools}
\usepackage{empheq}
\usepackage{tensor}
\usepackage[dvipsnames,table]{xcolor}
\definecolor{someGray}{RGB}{230,230,230}
\begin{document}
\begin{empheq}[box={\setlength{\fboxsep}{10pt}\colorbox{someGray}}]{equation}
H(q,p) = \tensor{\dot{q}}{^i}\,\tensor{p}{_i}-L
\end{empheq}
\end{document}
What about a black double-frame around the gray box, for the most extremely important equations ?
The empheq package documentation isn't obvious about this !
The best way to emphasize equations ?
I'VE FOUND IT !
Geez, I had to experiment a lot before finding this one !
Here's a compilable code to emphasize equations with a gray box, and a gray box with a red frame. The colors can be edited very easily.
Here's a preview :

Geez, I had to experiment a lot before finding this one !
Here's a compilable code to emphasize equations with a gray box, and a gray box with a red frame. The colors can be edited very easily.
Code: Select all
\documentclass[11pt,a4paper]{report}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{mathtools}
\usepackage{empheq}
\usepackage{tensor}
\usepackage[dvipsnames,table]{xcolor}
\definecolor{medGray}{RGB}{230,230,230}
\newenvironment{important}[2][]{
\setkeys{EmphEqEnv}{#2}
\setkeys{EmphEqOpt}{box={\setlength{\fboxsep}{10pt}\colorbox{medGray}},#1}
\EmphEqMainEnv}
{\endEmphEqMainEnv}
\newenvironment{tres important}[2][]{
\setkeys{EmphEqEnv}{#2}
\setkeys{EmphEqOpt}{box={\setlength{\fboxsep}{10pt}\fcolorbox{red}{medGray}},#1}
\EmphEqMainEnv}
{\endEmphEqMainEnv}
\begin{document}
\begin{tres important}{equation}
H(q,p) = \tensor{\dot{q}}{^i}\,\tensor{p}{_i}-L
\end{tres important}
\begin{important}{equation}
H(q,p) = \tensor{\dot{q}}{^i}\,\tensor{p}{_i}-L
\end{important}
\end{document}
- Stefan Kottwitz
- Site Admin
- Posts: 10340
- Joined: Mon Mar 10, 2008 9:44 pm
Re: The best way to emphasize equations ?
Nice solution, thanks for posting the complete example with screenshot!
Stefan
Stefan
LaTeX.org admin