3

I am aware that there are plentiful similar questions, but since (even after several reading) I don't understand the the answers, I am unable to apply them to my problem. I simply want to define a new align environment based on the old one, e.g.

\documentclass[11pt]{scrbook}

\usepackage{empheq}
\usepackage[many]{tcolorbox}
\tcbset{highlight math style={enhanced,colframe=black,arc=8pt,boxrule=1pt}}
\newenvironment{alignteo}%
  {
  \begin{empheq}[box=\tcbhighmath]{align}
  }{
  \end{empheq}
  }

\begin{alignteo}
f = a x
\end{alignteo}

\end{document}

Using \begin{alignteo} and \end{alignteo} I get the error

! LaTeX Error: \begin{empheq} on input line 448 ended by \end{alignteo}.

Is there any way to do this without using environ package?

  • Can you make a complete example? – egreg Oct 25 '13 at 10:41
  • OK, I'll try to build MWE – Pygmalion Oct 25 '13 at 10:45
8

With environ:

\documentclass{article} 
\usepackage[svgnames,hyperref]{xcolor}
\usepackage{empheq}
\usepackage[many]{tcolorbox}

\tcbset{highlight math style={enhanced,
  colframe=red!60!black,colback=yellow!50!white,arc=4pt,boxrule=1pt,
  drop fuzzy shadow}}

\usepackage{environ}
\NewEnviron{alignteo}{
  \begin{empheq}[box=\tcbhighmath]{align}
  \BODY
  \end{empheq}
}

\begin{document}

\begin{equation}
\tcbhighmath{E = mc^2}
\end{equation}

\begin{empheq}[box=\tcbhighmath]{align}
a&=b\\
E&=mc^2 + \int_a^a x\, dx
\end{empheq}

\begin{alignteo}
a&=b\\
E&=mc^2 + \int_a^a x\, dx
\end{alignteo}
\end{document}

enter image description here

Without environ:

\documentclass{article} 
\usepackage[svgnames,hyperref]{xcolor}
\usepackage{empheq}
\usepackage[many]{tcolorbox}

\tcbset{highlight math style={enhanced,
  colframe=red!60!black,colback=yellow!50!white,arc=4pt,boxrule=1pt,
  drop fuzzy shadow}}

\newenvironment{alignteo}%
  {\empheq[box=\tcbhighmath]{align}}
  {\endempheq}


\begin{document}

\begin{equation}
\tcbhighmath{E = mc^2}
\end{equation}

\begin{empheq}[box=\tcbhighmath]{align}
a&=b\\
E&=mc^2 + \int_a^a x\, dx
\end{empheq}

\begin{alignteo}
a&=b\\
E&=mc^2 + \int_a^a x\, dx
\end{alignteo}
\end{document}
|improve this answer|||||
  • Requested was without environ... Just turn the answers around :) – Pygmalion Oct 25 '13 at 11:04
  • @Pygmalion My eyes are too tired. Any way both are there. Does order matter? :-) – user11232 Oct 25 '13 at 11:06
  • Nope :) accepted +1 – Pygmalion Oct 25 '13 at 11:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.