TeX - LaTeX Asked on July 10, 2021
I am working with the elsarticle
document class in two-column format, but I have encountered a problem during the inclusion of equations in my document.
The issue is well described by the following MWE:
documentclass[3p,preprint]{elsarticle}
usepackage{multicol}
usepackage{amsmath,amssymb}
begin{document}
begin{multicols}{2}
begin{equation}
hspace*{-.4cm}
E_1=E_2=E_3=E_4=E_5=
begin{cases}
1, {rm~if~} 1=1,
0, {rm~if~otherwise}
end{cases}
end{equation}
end{multicols}
end{document}
I would like to move the equation to the left in order to lift the equation number to the previous line. If I use hspace*{-.3cm}
, then nothing changes, while hspace*{-.4cm}
moves the equation left, but creating large space between the equation and its serial number.
Is there any way that remove this extra space after the equation and before its serial number, thereby making the equation environment sensitive to the value of hspace*{}
?
If I understand correctly you want to remove the space from the right not the left (or from both sides)
documentclass[3p,preprint]{elsarticle}
usepackage{multicol}
usepackage{amsmath,amssymb}
begin{document}
begin{multicols}{2}
aaadotfill aaa
begin{equation}
E_1=E_2=E_3=E_4=E_5=
begin{cases}
1, textrm{ if } 1=1,
0, textrm{ if otherwise}
end{cases}
hspace*{-.35cm}
end{equation}
bbbdotfill bbb
bbbdotfill bbb
bbbdotfill bbb
bbbdotfill bbb
bbbdotfill bbb
bbbdotfill bbb
bbbdotfill bbb
bbbdotfill bbb
end{multicols}
end{document}
Correct answer by David Carlisle on July 10, 2021
Old trick (it's in the TeXbook). No need to guess a length, if the formula can fit the line width at all.
documentclass[3p,preprint]{elsarticle}
usepackage{multicol}
usepackage{amsmath,amssymb}
usepackage{lipsum}
begin{document}
begin{multicols}{2}
lipsum*[1][1-2]
begin{equation}
hspace{0pt}
E_1=E_2=E_3=E_4=E_5=
begin{cases}
1, &text{if } 1=1,
0, &text{if otherwise}
end{cases}
hspace{1000pt minus 1fil}
end{equation}
lipsum[4-8]
end{multicols}
end{document}
The very large space at the end will make TeX into thinking it has to squeeze every flexible glue at the maximum and hope for the best. However, the added space has infinite shrinkable glue, so the formula will not be in an overfull box. In order for this to work requires a glob of glue at the left side.
I fixed the syntax of the cases
environment.
Answered by egreg on July 10, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP