If a math display is too wide, then the \eqno appears on the next line on the left instead of on the right as it should. Does anyone know how to solve this problem? This is an example:




    {C_{11} } & {C_{12} }  \\
    {C_{21} } & {C_{22} }  \\
    \E\left[ {\left( {X-m_{X}} \right)^{2}} \right] & \E\left[ {\left( {X-m_{X}} \right)\left( {Y-m_{Y}} \right)} \right] \\
    \E\left[ {\left( {X-m_{X}} \right)\left( {Y-m_{Y}} \right)} \right] & \E\left[ {\left( {Y-m_{Y}} \right)^{2}} \right] 
    \si{X} & C_{XY} \\
    C_{XY} & \si{Y} \\


Added by Hendrik Vogt:

The same happens with plain LuaTeX.


Ouput after compilation with luatex:

eqno in the left

Ouput after compilation with pdftex:

eqno in the right

Dear friends: I think the next code is a posible, and provisional solution:


  • 1
    Welcome to TeX.sx!
    – hpesoj626
    Feb 12 '13 at 9:14
  • 1
    I took the freedom to add another MWE with sample outputs. (To me it seems like a bug in the LuaTeX engine.) Feb 12 '13 at 14:31
  • it is correct with xelatex. However you should use package unicode-math and \setmathfont{texgyretermes-math.otf} and not loading mathptmx when running lualatex
    – user2478
    Feb 12 '13 at 14:36
  • Just to let you know, if my answer helped you, then you can "accept" it by clicking the checkmark at the top left :-) Feb 16 '13 at 20:24

This appears to be a bug in the LuaTeX engine, see below. For a workaround, use align instead of equation; the align environment doesn't rely on the TeX engine for placement of the equation number. This fixes your problem (but can influence the vertical spacing for shorter equations).

I think I could locate the bug in texmath.w, lines 2220 to 2225. There it says

if ((eqno_box != null) && (eqno_w == 0) && !l) {
    shift_amount(eqno_box) = line_s;
    g2 = 0;

Of interest is the third line: the shift amount of the box containing the equation number is line_s, which previously was set to \displayindent (which usually is zero). Thus, the equation number is flush left.

Here's the corresponding lines from Knuth's tex.web, lines 22580 to 22585:

if (a<>null)and(e=0)and not l then
  begin tail_append(new_penalty(inf_penalty));

You can see that this is the very same code in a different language, eqno_box != null translates to a<>null, and so on. Here, the shift amount of the box containing the equation number is s+z-width(a), where s is the same as line_s above, z is the line width and width(a), well, the width of the box a with the equation number. And this is the correct shift amount for having the equation number flush right!

Maybe I should explain the conditions in the first line of the code: the box with the equation number should be non-empty, it should have width 0(!), and we shouldn't be in the case of a left equation number as in \leqno. And why the width 0? This is the "flag" that was set before to indicate that the box should be placed in the next line because it didn't fit into the line with the equation.


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.