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

Discussion Overview

The discussion revolves around issues encountered when using the Revtex 4.2 document class in LaTeX, specifically regarding the formatting of wide equations and their overlap with other content. Participants explore various approaches to resolve spacing problems and the use of different environments for typesetting equations.

Discussion Character

  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant describes a problem with wide equations overlapping due to insufficient text content on the page, leading to excessive vertical spacing.
  • Another participant suggests using the eqnarray environment to potentially address the issue with equation labeling.
  • Some participants note that the widetext command may disrupt vertical spacing and recommend using a floating environment instead.
  • There is a proposal to reformat the equation to fit a single column, but one participant mentions that their instructor requires the use of at least two widetext environments.
  • Concerns are raised about the correctness of a specific term in the equation, with one participant affirming their calculations support the current notation.
  • Participants discuss the potential impact of using the split environment on spacing and question the appropriateness of the eqnarray environment, with some preferring the align environment instead.
  • A later reply indicates that the initial problem was resolved by adding a MATLAB graph, which eliminated the overlapping issue.
  • One participant expresses a general preference to avoid RevTeX due to its placement issues, particularly with certain options that affect text compression.
  • Another participant shares their final approach, which included using the align environment, eliminating the split environment, and adjusting margins with the geometry package.

Areas of Agreement / Disagreement

Participants express a range of opinions on the best practices for formatting equations in LaTeX, with no clear consensus on the optimal approach. Some agree on the issues with widetext, while others propose different solutions without resolving the overall disagreement on the best method.

Contextual Notes

Participants mention limitations related to the Revtex document class, including issues with vertical spacing and equation placement, as well as the specific requirements set by their instructor regarding the use of widetext environments.

Who May Find This Useful

This discussion may be useful for students and researchers working with LaTeX, particularly those using the Revtex document class for academic papers in physics and related fields, as well as anyone interested in typesetting equations effectively.

Wrichik Basu
Science Advisor
Insights Author
Gold Member
Messages
2,186
Reaction score
2,694
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
4K
  • · 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