\documentclass{article}
\usepackage[latin1]{inputenc}
\usepackage{amsmath}
\usepackage[dvipsnames]{xcolor}
\usepackage[most]{tcolorbox}
\usepackage{empheq}
\definecolor{lightgrey}{HTML}{f0f0f0}
\newtcbox{\resultbox}[1][lightgrey]{
nobeforeafter,
math upper,
tcbox raise base,
enhanced,
boxrule=1pt,
colback = #1!30,
drop lifted shadow,
sharp corners
}
\begin{document}
\begin{empheq}[box=\resultbox]{equation*}
a(t) = 2\alpha - \gamma\omega^2 cos(\omega t)
\end{empheq}
\end{document}
result:
there any way to force align to left of that empheq
box?
Thank you.
EDIT: sorry for the inconvenience, from now it's already full minimum code to be compiled.
is there any way to use fleqn
to only affects the class \resultbox
?
Best Answer
You just need to add the option
fleqn
to your document class line.Here is the full code:
Next time please give a full minimal working example. In particular, the code should compile.
EDIT to typeset equation on the left without setting fleqn globally
The
fleqn
option sets a flag@fleqn
that is used by the empheq package to typeset the equation on left. The hack below sets this flag when the package is loaded and then creates a new environmentEmpheq
that sets this flag for the environment only. With this in place, you can have your cake and eat it too, so to speak.This produces:
I have typeset the equation normally underneath to highlight the difference. I have not tested this hack comprehensively. It is unlikely that it breaks something else as this is not the way the
fleqn
is meant to be used. In particular, otherempheq
environments in your document will almost certainly be broken.