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}
You just need to add the option fleqn
to your document class line.
Here is the full code:
\documentclass[fleqn]{article}
\usepackage{xcolor}
\usepackage{tcolorbox}
\tcbuselibrary{skins,theorems}
\usepackage{empheq}
\newtcbox{\resultbox}[1][lightgray]{
nobeforeafter,
math upper,
tcbox raise base,
enhanced,
boxrule=1pt,
colback = #1!30,
drop lifted shadow,
sharp corners
}
\begin{document}
\begin{empheq}[box=\resultbox]{equation*}
v(t) = 2\alpha t - \gamma\omega sen(\omega t))
\end{empheq}
\end{document}
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 environment Empheq
that sets this flag for the environment only. With this in place, you can have your cake and eat it too, so to speak.
\documentclass{article}
\usepackage{xcolor}
\usepackage{tcolorbox}
\tcbuselibrary{skins,theorems}
\newtcbox{\resultbox}[1][lightgray]{
nobeforeafter,
math upper,
tcbox raise base,
enhanced,
boxrule=1pt,
colback = #1!30,
drop lifted shadow,
sharp corners
}
\makeatletter% hack to allow empheq environment to be used with fleqn in force only locally
\@fleqntrue
\usepackage{empheq}
\newenvironment{Empheq}{\@fleqntrue\empheq[box=\resultbox]{equation*}}{\endempheq}
\@fleqnfalse
\makeatother
\begin{document}
\begin{Empheq}
v(t) = 2\alpha t - \gamma\omega sen(\omega t))
\end{Empheq}
\begin{equation*}
v(t) = 2\alpha t - \gamma\omega sen(\omega t))
\end{equation*}
\end{document}
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, other empheq
environments in your document will almost certainly be broken.
Best Answer
Would mixing some white to your colour do what you want?