1

I'd like to place an array in a empheq environment. I tried the following code which gives the error: Paragraph ended before \empheq was complete.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{empheq}

\begin{document}
\begin{empheq}[box={\mymath[colback=Bittersweet!20]}]{equation}
\vec{a}\times \vec{b}=\left|
\begin{array}{c c c}

\ii & \jj & \kk \\
a_x & a_y & a_z \\
b_x & b_y & b_z \\

\end{array}
\right|
\end{empheq}

\end{document}
Circumscribe
  • 10,856
  • 2
    Your minimal working example does not compile because \ii, \jj, \kk, \vec and \mymath are not defined. I think the empty lines inside the array are likely the problem though. – Circumscribe Nov 10 '18 at 09:29
  • 1
    Welcome to TeX SX! A blank line introduces a new paragraph, whence the error message. Unrelated: it is simpler to replace your array construction with \begin{vmatrix} ... \end{vmatrix}, defined by amsmath (which empheq loads). – Bernard Nov 10 '18 at 10:20

1 Answers1

1

While blank lines are not illegal in an array environment, generally, they are inside the display environments defined by amsmath such as align or gather. Also empheq doesn't accept them.

In these cases the blank lines are caught before array can deal with them.

The solution is

never use blank lines in math mode.

Here I made up definitions for \ii, \jj and \kk and also copied one for \mybox from an example in the site. In future questions, please provide these details and make your example codes compilable.

I also used vmatrix instead of array, because it makes for better spacing.

\documentclass{article}
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage{empheq}
\usepackage[many]{tcolorbox}

\newcommand{\ii}{\vec{\imath}}
\newcommand{\jj}{\vec{\jmath}}
\newcommand{\kk}{\vec{k}}

\newtcbox{\mymath}[1][]{
    nobeforeafter,
    math upper, 
    tcbox raise base,
    enhanced, 
    boxrule=1pt,
    drop lifted shadow, 
    sharp corners,
    #1,
}

\begin{document}

\begin{empheq}[box={\mymath[colback=Bittersweet!20]}]{equation}
\vec{a}\times \vec{b}=
\begin{vmatrix}
\ii & \jj & \kk \\
a_x & a_y & a_z \\
b_x & b_y & b_z \\
\end{vmatrix}
\end{empheq}

\end{document}

enter image description here

egreg
  • 1,121,712