Wide equation in Revtex 4.2 is overlapping with other content

  • Context: LaTeX 
  • Thread starter Thread starter Wrichik Basu
  • Start date Start date
  • Tags Tags
    Overlapping
Click For Summary
SUMMARY

The forum discussion addresses issues with overlapping content when using the Revtex 4.2 document class in LaTeX, particularly with wide equations. Users reported that the widetext environment caused excessive vertical spacing, leading to formatting problems. A solution was found by adding a MATLAB graph, which resolved the overlap. Participants recommended using the align environment instead of eqnarray and suggested the IEEEeqnarray from the IEEEtrantools package for better equation formatting.

PREREQUISITES
  • Familiarity with LaTeX document classes, specifically Revtex 4.2
  • Understanding of LaTeX environments such as widetext, align, and eqnarray
  • Basic knowledge of MATLAB for integrating graphics into LaTeX documents
  • Experience with typesetting equations in LaTeX, including the use of packages like IEEEtrantools
NEXT STEPS
  • Research the IEEEeqnarray environment from the IEEEtrantools package for improved equation formatting
  • Learn about the geometry package in LaTeX for better margin control
  • Explore the breqn package for automatic equation breaking and formatting
  • Investigate best practices for using the align environment in LaTeX
USEFUL FOR

LaTeX users, academic writers, and researchers who need to format complex equations and improve document layout in Revtex 4.2.

Wrichik Basu
Science Advisor
Insights Author
Gold Member
Messages
2,180
Reaction score
2,690
Our professor has asked us to submit our next assignment in ##\LaTeX##, and he has specifically asked us to use Revtex 4.2. This is not the first time I am working with this document class; in the past, I have used it several times. But I am facing an weird problem this time:

1597783648490.png

This equation was written with the following code:
[CODE title="LaTeX"]\begin{widetext}
\begin{equation}
f(x) = \frac{1}{4} + \frac{2}{\pi}\left(-\frac{\cos{x}}{2} + \frac{\cos{3x}}{6} - \frac{\cos{5x}}{10} + \cdots \right) + \frac{2}{\pi}\left(\frac{\sin{x}}{2} - \frac{\sin{2x}}{2} + \frac{\sin{3x}}{6} + \frac{\sin{5x}}{10} + \cdots \right)
\end{equation}
\end{widetext}[/CODE]
The problem is probably due to the fact that there is not much text content on this page; only equations:

1597783822808.png

Revtex is leaving a lot of gaps between the equations, which is not looking good as well.

I am using the following document class statement:
[CODE title="LaTeX"]\documentclass[reprint, amsmath, amssymb, aps, prl]{revtex4-2}[/CODE]
Any idea how to solve this problem?
 
Physics news on Phys.org
The fact that the label (12) is centered between two lines of that equation might be related; perhaps use eqnarray with \nonumber on the first two lines?
 
pasmith said:
The fact that the label (12) is centered between two lines of that equation might be related; perhaps use eqnarray with \nonumber on the first two lines?
This is how eqn. 12 is generated:
[CODE title="LaTeX"]\begin{equation}
\begin{split}
a_0 &= \dfrac{1}{L} \int_{-L}^{+L} f(x) \d x \\
&= \dfrac{1}{\pi} \int_{-\pi}^{+\pi} f(x) \d x \\
&= \dfrac{1}{\pi}\int_{\frac{\pi}{2}}^{\pi} \d x \\
&= \frac{1}{2}.
\end{split}
\label{a0_3}
\end{equation}[/CODE]
where \d is
[CODE title="LaTeX"]\renewcommand{\d}{\mathrm{d}}[/CODE]
 
Then that's not the issue.

Looking at it more closely, it looks like it's just putting the widetext wherever it happens to occur in the right column, irrespective of whatever is in the left column.

There's a thread on stackexchange which suggests that widetext (via one of its dependencies) is known for corrupting vertical spacing.

This https://www.researchgate.net/post/How_to_make_equation_one_column_in_two_column_paper_in_latex suggests instead putting your equation into a floating envireonment instead of an inline environemnt.
 
  • Like
Likes   Reactions: Wrichik Basu
Is there a reason you don't just reformat the equation so it fits in a single column, e.g.,
$$\begin{align}
f(x) =& \frac{1}{4} + \frac{2}{\pi}\left(-\frac{\cos{x}}{2} + \frac{\cos{3x}}{6} - \frac{\cos{5x}}{10} + \dotsb \right) \nonumber \\
& {} + \frac{2}{\pi}\left(\frac{\sin{x}}{2} - \frac{\sin{2x}}{2} + \frac{\sin{3x}}{6} + \frac{\sin{5x}}{10} + \dotsb \right)
\end{align}$$ ?

Code:
\begin{align}
    f(x) =& \frac{1}{4} + \frac{2}{\pi}\left(-\frac{\cos{x}}{2} + \frac{\cos{3x}}{6} - \frac{\cos{5x}}{10} + \dotsb \right) \nonumber \\
    & {} + \frac{2}{\pi}\left(\frac{\sin{x}}{2} - \frac{\sin{2x}}{2} + \frac{\sin{3x}}{6} + \frac{\sin{5x}}{10} + \dotsb \right)
\end{align}
I wanted to use widetext in a paper years ago and my PhD supervisor at the time suggested it would be better to just avoid it and change the notation or formatting of the equation so it would fit in a single column instead. I've never seen a need to use widetext since.

(Also, is the sign in front of the ##\sin 5x## term correct? It seems to alternate everywhere else.)
 
wle said:
Is there a reason you don't just reformat the equation so it fits in a single column
Since our instructor is also helping us learn LaTeX, he has asked us to use at least two widetext environments. Otherwise I would have happily formatted the equation to single column, as I have done numerous times before.

By the way, wanted to post an update: the problem has been solved. The solution is nothing special: I just added one MATLAB graph as a picture and the overlapping was gone.
 
wle said:
(Also, is the sign in front of the sin⁡5x term correct? It seems to alternate everywhere else.)
Yes, as far as I can see from my analytical calculations and MATLAB. There is a minus sign again for ##\sin{6x}##.
 
Wrichik Basu said:
This is how eqn. 12 is generated:
[CODE title="LaTeX"]\begin{equation}
\begin{split}
a_0 &= \dfrac{1}{L} \int_{-L}^{+L} f(x) \d x \\
&= \dfrac{1}{\pi} \int_{-\pi}^{+\pi} f(x) \d x \\
&= \dfrac{1}{\pi}\int_{\frac{\pi}{2}}^{\pi} \d x \\
&= \frac{1}{2}.
\end{split}
\label{a0_3}
\end{equation}[/CODE]
Could it be that it is split that is messing up the spacing? Does the same problem appear if you use eqnarray instead?
 
DrClaude said:
Could it be that it is split that is messing up the spacing? Does the same problem appear if you use eqnarray instead?
I haven't tried eqnarray. There is a question on TeX-LaTeX SE on align vs eqnarray, and it has several answers that advise against using this environment. Overleaf showed how to use split instead.

What is your opinion on the use of eqnarray?
 
  • #10
Wrichik Basu said:
Since our instructor is also helping us learn LaTeX, he has asked us to use at least two widetext environments. Otherwise I would have happily formatted the equation to single column, as I have done numerous times before.

Okay, that makes sense.

By the way, wanted to post an update: the problem has been solved. The solution is nothing special: I just added one MATLAB graph as a picture and the overlapping was gone.

I don't know for sure, but it may just have been a problem with RevTeX. Personally I usually avoid using RevTeX when I can since it seems to have trouble with placement of things not unlike what you've seen, particularly when using the pra/prb/etc. options. RevTeX with these options produces slightly more compressed text than it does with the prl option and I wonder if it isn't taking this into account correctly. Conversely, formatting with the prl option generally seems to be okay, but then you lose the section numbers.
Wrichik Basu said:
I haven't tried eqnarray. There is a question on TeX-LaTeX SE on align vs eqnarray, and it has several answers that advise against using this environment. Overleaf showed how to use split instead.

What is your opinion on the use of eqnarray?

There is a good discussion of this (and typesetting equations in general) in "How to typeset equations in ##\LaTeX##" by Stefan Moser, available here: https://moser-isi.ethz.ch/docs/typeset_equations.pdf.

Short answer: use the IEEEeqnarray environment from the IEEEtrantools package. I am actually surprised more people don't do this since "The Not So Short Introduction to ##\LaTeX2e##" has been recommending this for some years. (It didn't yet when I first started learning LaTeX in the late 2000s.)
 
  • Like
Likes   Reactions: Wrichik Basu
  • #11
Wrichik Basu said:
I haven't tried eqnarray. There is a question on TeX-LaTeX SE on align vs eqnarray, and it has several answers that advise against using this environment. Overleaf showed how to use split instead.

What is your opinion on the use of eqnarray?
I usually use align. You may try that as well.
 
  • Like
Likes   Reactions: Wrichik Basu
  • #12
Submitted the assignment today. I could convince our instructor that using too many widetext environments doesn't look good. I used the align environment as suggested by @wle in post #5 and @DrClaude in post #11, along with the equation environment where necessary. The breqn package has a dmath environment that automatically breaks equations, and also allows breaking \left ... \right pair of delimiters. I eliminated the split environment completely. The figures were creating a problem sometimes, overlapping with text or going below the bottom margin. So I used the geometry package to specify the margins, and that partially solved the problem.

AutoHotkey, suggested by @fresh_42 elsewhere, comes very handy when writing long documents in ##\LaTeX##.

Thanks everyone for the suggestion/advice.

Edit: Corrected grammar.[/size]
 
Last edited:

Similar threads

  • · Replies 11 ·
Replies
11
Views
6K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 9 ·
Replies
9
Views
6K
  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 3 ·
Replies
3
Views
2K
Replies
2
Views
3K
Replies
3
Views
2K