# Long equation tag/number gets shifted to left hand side, rather than underneath right hand side

So i have an equation which is pretty much the width of my text. The equation number usually (when using pdflatex) shifts below the right hand side of the equation. However, i am now having to lualatex due to some memory issues, and the equation tag shifts over to the left hand side!

Is there a way to force the equation tag to remain on the right hand side??

Thanks for any help in advance!

Minimal working example below... (needs to be run in lualatex for my problem to appear...)

\documentclass[12pt]{report}

\usepackage{geometry}

\geometry{
top=25mm,
bottom=25mm
}

\newcommand{\sss}[2]{_{_{#1_{#2}}}}

\begin{document}

$$\left [ \begin{array}{c c} \mathbf{Y\sss{C}{c1a}} & \mathbf{Y\sss{C}{c1c2}} \\ \mathbf{Y\sss{C}{ba}} & \mathbf{Y\sss{C}{bc2}} \end{array}\right]^{-1} = \left [ \begin{array}{c c} (\mathbf{Y\sss{C}{c1a}}-\mathbf{Y\sss{C}{c1c2}} \mathbf{Y^{-1}\sss{C}{bc2}} \mathbf{Y\sss{C}{ba}})^{-1} & \mathbf{Z\sss{I}{c1c2}} \\ \mathbf{Z\sss{I}{c2c1}} & (\mathbf{Y\sss{C}{bc2}}-\mathbf{Y\sss{C}{ba}} \mathbf{Y^{-1}\sss{C}{c1a}} \mathbf{Y\sss{C}{c1c2}})^{-1} \end{array}\right]$$

\end{document}

• as posted it makes ! Missing \$ inserted. error – David Carlisle May 21 '16 at 9:46
• If I delete the blank lines so the error goes, I get the same error layout in pdflatex and lualatex, with (1) below the equation. – David Carlisle May 21 '16 at 9:48
• Which TeX distribution do you use, and which vintage is it? I vaguely remember there being an occasional issue with LuaLaTeX placing an equation number to the lower left rather than the lower right of a displayed ago. However, if I recall correctly, this bug was fixed two or three years ago. – Mico May 21 '16 at 9:59

## 2 Answers

If you (a) reduce the values of the length parameters \arraycolsep, \thickmuskip, and \medmuskip and (b) use the bmatrix environment of the amsmath package instead of array environments, the equation and the equation number fit on a single line.

\documentclass[12pt]{report}
\usepackage{amsmath}
\usepackage[vmargin=25mm]{geometry}
\newcommand{\sss}[2]{_{_{#1_{#2}}}}

\begin{document}
$$% Reduce the values of three length variables \setlength\arraycolsep{2pt} \setlength\thickmuskip{1mu} \setlength\medmuskip{1mu} \begin{bmatrix} \mathbf{Y}\sss{C}{c1a} & \mathbf{Y}\sss{C}{c1c2} \\ \mathbf{Y}\sss{C}{ba} & \mathbf{Y}\sss{C}{bc2} \end{bmatrix}^{-1} = \begin{bmatrix} (\mathbf{Y}\sss{C}{c1a}-\mathbf{Y}\sss{C}{c1c2} \mathbf{Y}^{-1}\sss{C}{bc2} \mathbf{Y}\sss{C}{ba}{)}^{-1} & \mathbf{Z}\sss{I}{c1c2} \\ \mathbf{Z}\sss{I}{c2c1} & (\mathbf{Y}\sss{C}{bc2}-\mathbf{Y}\sss{C}{ba} \mathbf{Y}^{-1}\sss{C}{c1a} \mathbf{Y}\sss{C}{c1c2}{)}^{-1} \end{bmatrix}$$
\end{document}


I propose to use the medsize environment (about 80 % of \displaystyle), from nccmath. Also I simplified your code, using the bmatrix environment:

\documentclass[12pt]{report}

\usepackage{geometry}
\usepackage{mathtools, nccmath}

\geometry{
top=25mm,
bottom=25mm,
showframe
}

\newcommand{\sss}[2]{_{_{#1_{#2}}}}

\begin{document}
Some text some text some text some text some text
some text some text some text some text.

$$\begin{medsize} \begin{bmatrix}\mathbf{Y\sss{C}{c1a}} & \mathbf{Y\sss{C}{c1c2}} \\ \mathbf{Y\sss{C}{ba}} & \mathbf{Y\sss{C}{bc2}} \end{bmatrix}⁻¹ = \begin{bmatrix}(\mathbf{Y\sss{C}{c1a}}-\mathbf{Y\sss{C}{c1c2}} \mathbf{Y⁻¹\sss{C}{bc2}} \mathbf{Y\sss{C}{ba}})⁻¹ & \mathbf{Z\sss{I}{c1c2}} \\ \mathbf{Z\sss{I}{c2c1}} & (\mathbf{Y\sss{C}{bc2}}-\mathbf{Y\sss{C}{ba}} \mathbf{Y⁻¹\sss{C}{c1a}} \mathbf{Y\sss{C}{c1c2}})⁻¹ \end{bmatrix} \end{medsize}$$

\end{document}