Latex superscript of the second row overlap

  • Context: LaTeX 
  • Thread starter Thread starter ehrenfest
  • Start date Start date
  • Tags Tags
    Latex Overlap Row
Click For Summary

Discussion Overview

The discussion revolves around formatting issues in LaTeX, specifically related to the spacing between rows in an array and the alignment of equations. Participants explore various methods to resolve overlapping subscripts and superscripts, as well as alignment problems when compiling documents in different environments.

Discussion Character

  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant reports overlapping subscripts and superscripts in their LaTeX array and seeks a solution to increase row spacing.
  • Another participant suggests using \vspace to control spacing, but this is met with mixed results.
  • Some participants do not observe the overlap when compiling in different environments, such as Firefox, leading to questions about discrepancies between LaTeX compilers.
  • Alternative spacing methods, such as using \smallskip or inserting blank rows, are discussed, with varying degrees of acceptance among participants.
  • One participant expresses frustration with the TeXnic Center and MikTeX, questioning why their output differs from other environments.
  • Concerns about long lines in equations and alignment issues are raised, with suggestions for using \hspace or \lefteqn to adjust positioning.
  • Participants discuss the potential use of split or eqnarray environments for better formatting, particularly when incorporating matrices.
  • There is a query about how to include a text explanation alongside an equation on the same line, as well as a request for formatting the classical Hamiltonian symbol in a specific font.

Areas of Agreement / Disagreement

Participants do not reach a consensus on the best method to resolve the overlapping issue, as some methods work for certain users while others do not. There are multiple competing views on how to achieve desired formatting in LaTeX.

Contextual Notes

Limitations include potential differences in output across various LaTeX compilers and environments, as well as unresolved issues regarding the alignment and formatting of equations.

ehrenfest
Messages
2,001
Reaction score
1
When I compile the following latex code on my computer, the subscript of the first row and the superscript of the second row overlap. Is there any way to make the rows farther apart?

\begin{array}{ccccc}<br /> \cos^2\phi_y^1 - \cos^2\phi_x^1 &amp; \cos^2\phi^1_z - \cos^2\phi_x^1 &amp; 2\cos\phi_x^1 cos\phi_y^1 &amp; 2\cos\phi_x^1\cos\phi_z^1 &amp; 2\cos \phi^1_y \cos\phi_z^1 \\ <br /> \cos^2\phi_y^2 - \cos^2\phi_x^2 &amp; \cos^2\phi^2_z - \cos^2\phi_x^2 &amp; 2\cos\phi_x^2 cos\phi_y^2 &amp; 2\cos\phi_x^2\cos\phi_z^2 &amp; 2\cos \phi^2_y \cos\phi_z^2 \end{array} \right)<br /> \end{array}
 
Physics news on Phys.org
they shouldn't under the equation environment, but you could try \vspace{..cm} at the end of first line
 
That did not work. I uploaded the file as .txt
 

Attachments

I don't see any overlap in in firefox.

Testing...

\begin{array}{ccccc}<br /> \cos^2\phi_y^1 - \cos^2\phi_x^1 &amp; \cos^2\phi^1_z - \cos^2\phi_x^1 &amp; 2\cos\phi_x^1 cos\phi_y^1 &amp; 2\cos\phi_x^1\cos\phi_z^1 &amp; 2\cos \phi^1_y \cos\phi_z^1 \\<br /> \\<br /> \cos^2\phi_y^2 - \cos^2\phi_x^2 &amp; \cos^2\phi^2_z - \cos^2\phi_x^2 &amp; 2\cos\phi_x^2 cos\phi_y^2 &amp; 2\cos\phi_x^2\cos\phi_z^2 &amp; 2\cos \phi^2_y \cos\phi_z^2 \end{array} \right)<br /> \end{array}

How's that?
 
Gokul43201 said:
I don't see any overlap in in firefox.

That is true. I was compiling in TexNic center with Miktex. There should be a better solution than inserting a blank row! Why would the TeXnic center compile differently than Firefox? I need to make a pdf. Is there anyway I can do that with Firefox?
 
What mjsd was suggesting was to use \vspace, which offers a little more control.

<br /> \begin{array}{ccccc}<br /> \cos^2\phi_y^1 - \cos^2\phi_x^1 &amp; \cos^2\phi^1_z - \cos^2\phi_x^1 &amp; 2\cos\phi_x^1 cos\phi_y^1 &amp; 2\cos\phi_x^1\cos\phi_z^1 &amp; 2\cos \phi^1_y \cos\phi_z^1 <br /> \\<br /> \cos^2\phi_y^2 - \cos^2\phi_x^2 &amp; \cos^2\phi^2_z - \cos^2\phi_x^2 &amp; 2\cos\phi_x^2 cos\phi_y^2 &amp; 2\cos\phi_x^2\cos\phi_z^2 &amp; 2\cos \phi^2_y \cos\phi_z^2 \end{array} \right)<br /> \end{array}<br />

vs.

using \vspace{0.15ex} [using units which scale with the font]
<br /> \begin{array}{ccccc}<br /> \cos^2\phi_y^1 - \cos^2\phi_x^1 &amp; \cos^2\phi^1_z - \cos^2\phi_x^1 &amp; 2\cos\phi_x^1 cos\phi_y^1 &amp; 2\cos\phi_x^1\cos\phi_z^1 &amp; 2\cos \phi^1_y \cos\phi_z^1 <br /> \vspace{0.15ex}<br /> \\<br /> \cos^2\phi_y^2 - \cos^2\phi_x^2 &amp; \cos^2\phi^2_z - \cos^2\phi_x^2 &amp; 2\cos\phi_x^2 cos\phi_y^2 &amp; 2\cos\phi_x^2\cos\phi_z^2 &amp; 2\cos \phi^2_y \cos\phi_z^2 \end{array} \right)<br /> \end{array}<br />


vs.

using \smallskip [alt: \bigskip]
<br /> \begin{array}{ccccc}<br /> \cos^2\phi_y^1 - \cos^2\phi_x^1 &amp; \cos^2\phi^1_z - \cos^2\phi_x^1 &amp; 2\cos\phi_x^1 cos\phi_y^1 &amp; 2\cos\phi_x^1\cos\phi_z^1 &amp; 2\cos \phi^1_y \cos\phi_z^1 <br /> \smallskip<br /> \\<br /> \cos^2\phi_y^2 - \cos^2\phi_x^2 &amp; \cos^2\phi^2_z - \cos^2\phi_x^2 &amp; 2\cos\phi_x^2 cos\phi_y^2 &amp; 2\cos\phi_x^2\cos\phi_z^2 &amp; 2\cos \phi^2_y \cos\phi_z^2 \end{array} \right)<br /> \end{array}<br />
 
That works. Thanks.
 
\begin{equation}<br /> \left( \begin{array}{ccccc}<br /> \cos^2\phi_y^1 - \cos^2\phi_x^1 &amp; \cos^2\phi^1_z - \cos^2\phi_x^1 &amp; 2\cos\phi_x^1 cos\phi_y^1 &amp; 2\cos\phi_x^1\cos\phi_z^1 &amp; 2\cos \phi^1_y \cos\phi_z^1 \bigskip \\<br /> \cos^2\phi_y^2 - \cos^2\phi_x^2 &amp; \cos^2\phi^2_z - \cos^2\phi_x^2 &amp; 2\cos\phi_x^2 cos\phi_y^2 &amp; 2\cos\phi_x^2\cos\phi_z^2 &amp; 2\cos \phi^2_y \cos\phi_z^2 \bigskip \\<br /> <br /> \vdots &amp; \vdots &amp; \vdots &amp; \vdots &amp; \vdots \bigskip\\<br /> <br /> <br /> \cos^2\phi_y^n - \cos^2\phi_x^n &amp; \cos^2\phi^n_z - \cos^2\phi_x^n &amp; 2\cos\phi_x^\n cos\phi_y^n &amp; 2\cos\phi_x^n\cos\phi_z^n &amp; 2\cos \phi^2_n \cos\phi_z^n \end{array} \right)<br /> <br /> \end{equation}

One more thing. Can someone help me figure out what is wrong in my equation environment? Why is the (1) below the equation and not beside it?
 
Your line is too long...

\begin{equation}<br /> \left( \begin{array}{ccccc}<br /> \cos^2\phi_y^1 - \bigskip \\<br /> \cos^2\phi_y^2 - \bigskip \\<br /> <br /> \vdots &amp; \vdots &amp; \vdots &amp; \vdots &amp; \vdots \bigskip\\ \cos^2\phi_y^n - \end{array} \right)<br /> <br /> \end{equation}

You might be able to force a longer line using
\setlength{\textwidth}{6.0in}
 
  • #10
It is not too long for my pdf, however. Is there a way I can left align the array, because it starting way too far to the right with miktex?
 
  • #11
You might be able to use \hspace{-1in} or hspace*{-1in}.

Alternatively, you might try \lefteqn
http://www.google.com/search?q=lefteqn

I'm not sure if \smash{your equation} followed by an appropriate \hspace would work as well.
 
  • #12
\hspace{-1in} worked! Thanks.

I am really starting to hate MikTex and the stupid texnic center!
 
  • #13
You can also use split or eqnarray, instead of array inside equation.
I think array switches to textstyle be default, which is also ugly when you have fractions.
 
  • #14
CompuChip said:
You can also use split or eqnarray, instead of array inside equation.
I think array switches to textstyle be default, which is also ugly when you have fractions.

I would still need an array inside of the eqnarray since I have a matrix that is part of the equation, right?
 
  • #15
Also, is there a way I could have an equation and then a text explanation to the right that is against the margin on that same line?
 
  • #16
Sorry, one more thing. How would I get the nice pretty font for classical Hamiltonian H in a latex document.
 
  • #17
you could try \marginpar{my comment}...
but it might not work from within a math environment.

maybe \cal{H}
 

Similar threads

  • · Replies 11 ·
Replies
11
Views
9K
  • · Replies 5 ·
Replies
5
Views
1K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 0 ·
Replies
0
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K