# Line numbering for boxed multi-line equations using empheq package leaves extra blankspace

I'm using the empheq package to put boxes around equations that span multiple lines (using align). There are 6 lines to the equation, and the whole box should receive one number (1), for which I use the \nonumber \\ commands on the other 5 lines. This works if the equations are relatively narrow.

However, if the equations are wide, the line number is put below the box, but with an included extra lines (I think 6, as many as there are equations) of white space. How can I get the equation number to be directly below (and to the right) of the boxed equations?

\documentclass[11pt]{article}

\usepackage{empheq}
\newcommand*\widefbox[1]{\fbox{\hspace{2em}#1\hspace{2em}}}

\begin{document}

\begin{empheq}[box=\widefbox]{align}
& abcdefghijklmnopqrstuvwxyz \dots abcdefghijklmnopqrstuvwxyz \nonumber \\
& abcdefghijklmnopqrstuvwxyz \dots abcdefghijklmnopqrstuvwxyz \nonumber \\
& abcdefghijklmnopqrstuvwxyz \dots abcdefghijklmnopqrstuvwxyz \nonumber \\
& abcdefghijklmnopqrstuvwxyz \dots abcdefghijklmnopqrstuvwxyz \nonumber \\
& abcdefghijklmnopqrstuvwxyz \dots abcdefghijklmnopqrstuvwxyz \nonumber \\
& abcdefghijklmnopqrstuvwxyz \dots abcdefghijklmnopqrstuvwxyz
\end{empheq}

abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklm

\end{document}


Result:

Another modification is to leave the first line without the \nonumber \\ command, in which case the line number is moved up, but there is still extra white space until the next line.

\begin{empheq}[box=\widefbox]{align}
& abcdefghijklmnopqrstuvwxyz \dots abcdefghijklmnopqrstuvwxyz \\
& abcdefghijklmnopqrstuvwxyz \dots abcdefghijklmnopqrstuvwxyz \nonumber \\
& abcdefghijklmnopqrstuvwxyz \dots abcdefghijklmnopqrstuvwxyz \nonumber \\
& abcdefghijklmnopqrstuvwxyz \dots abcdefghijklmnopqrstuvwxyz \nonumber \\
& abcdefghijklmnopqrstuvwxyz \dots abcdefghijklmnopqrstuvwxyz \nonumber \\
& abcdefghijklmnopqrstuvwxyz \dots abcdefghijklmnopqrstuvwxyz \nonumber
\end{empheq}


Result:

Thanks!

• welcome to tex.sx. i don't have an answer as to why this is happening (looks like a bug), but if i wanted a group of equations to have only one number, i'd use \begin{aligned} ... \end{aligned}. i can't promise that this will get rid of the extra space, but it's worth a try. (with empheq the syntax may be a bit different.) – barbara beeton Apr 25 '16 at 18:15

The problem partly comes from your box wider than \linewidth – and a possible bug. I propose, in the spirit of @Barbara Beeton's comment, to mimic your \widefbox with a simple \boxed command and an alignedat environment:

\documentclass[11pt]{article}
\usepackage{showframe}
\usepackage{empheq}
\newcommand*\widefbox[1]{\fbox{\hspace{1em}#1\hspace{1em}}}

\begin{document}

% \boxed{\qquad \begin{alignedat}{2} & abcdefghijklmnopqrstuvwxyz ... abcdefghijklmnopqrstuvwxyz & \qquad & \\ & abcdefghijklmnopqrstuvwxyz ... abcdefghijklmnopqrstuvwxyz \\ & abcdefghijklmnopqrstuvwxyz ... abcdefghijklmnopqrstuvwxyz \\ & abcdefghijklmnopqrstuvwxyz ... abcdefghijklmnopqrstuvwxyz \\ & abcdefghijklmnopqrstuvwxyz ... abcdefghijklmnopqrstuvwxyz \\ & abcdefghijklmnopqrstuvwxyz ... abcdefghijklmnopqrstuvwxyz \end{alignedat}}

abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklm

\end{document}


However, if you don't use marginal notes, I would suggest loading the geometry package, which will use more sensible margins:

\documentclass[11pt]{article}
\usepackage[showframe]{geometry}
\usepackage{empheq}
\newcommand*\widefbox[1]{\fbox{\hspace{2em}#1\hspace{2em}}}

\begin{document}

\begin{empheq}[box=\widefbox]{align}
& abcdefghijklmnopqrstuvwxyz ... abcdefghijklmnopqrstuvwxyz \nonumber \\
& abcdefghijklmnopqrstuvwxyz ... abcdefghijklmnopqrstuvwxyz \nonumber \\
& abcdefghijklmnopqrstuvwxyz ... abcdefghijklmnopqrstuvwxyz \nonumber \\
& abcdefghijklmnopqrstuvwxyz ... abcdefghijklmnopqrstuvwxyz \nonumber \\
& abcdefghijklmnopqrstuvwxyz ... abcdefghijklmnopqrstuvwxyz \nonumber \\
& abcdefghijklmnopqrstuvwxyz ... abcdefghijklmnopqrstuvwxyz
\end{empheq}

abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklm

\end{document}}


• Awesome, thanks! Geometry package makes it look very nice, although will be problems with e.g. printing – smörkex Apr 25 '16 at 19:55
• Why that? It only change the default margins (and you can easily specify which margins you want). Other solutions would require to see the real equations – Bernard Apr 25 '16 at 19:58