2

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:

Extra space under boxed multi-line equation using empheq package

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:

Line numbers are fixed, but extra space under boxed equation remains

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{equation} \begin{aligned} ... \end{aligned} \end{equation}. 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
2

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}

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

abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklm

\end{document} 

enter image description here

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}} 

enter image description here

  • 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

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.