Looking for My First LaTeX Thread!

  • Context: LaTeX 
  • Thread starter Thread starter BvU
  • Start date Start date
Click For Summary

Discussion Overview

The discussion revolves around formatting equations in LaTeX, particularly focusing on aligning equations, adding equation numbers, and adjusting spacing between lines. Participants share their experiences and techniques related to using LaTeX in the context of the Physics Forums platform.

Discussion Character

  • Technical explanation
  • Exploratory
  • Debate/contested

Main Points Raised

  • One participant expresses dissatisfaction with the default centering of equations in display mode and seeks ways to align equal signs.
  • Another participant suggests using \eqalign and \hfil for alignment, noting that it may not be the most elegant solution.
  • A different participant introduces the use of the \begin{equation} environment for automatic numbering of equations but mentions issues with counter increments.
  • Concerns are raised about the uniqueness of equation labels across pages and the potential for referencing errors due to the processing order of MathJax.
  • Participants discuss the use of the align environment, highlighting how to prevent automatic numbering by using align*.
  • One participant shares a method for adding vertical space between lines using [5mm] in the aligned environment.
  • There are mentions of limitations in using double backslashes for new lines in LaTeX and the need for a character in between.
  • Some participants express uncertainty about the behavior of certain commands and the visibility of warnings from the TeX processor.

Areas of Agreement / Disagreement

Participants present multiple competing views and techniques for formatting equations in LaTeX, with no consensus reached on the best approach. There is ongoing exploration of various methods and their limitations.

Contextual Notes

Participants note that certain commands, like \vspace, may not be recognized in the Physics Forums environment, leading to reliance on alternatives like \\[height]. There are also discussions about the implications of using unique labels for equations across different posts and pages.

BvU
Science Advisor
Homework Helper
Messages
16,219
Reaction score
4,934
My first thread ! :smile: Couldn't even post it at first: "thread title must be more than one word" sic ! grmpfff...I'm unhappy with the look of sets of equations. In displaymode they are all centered, when I in fact want the = to line up nicely. I forgot how to do this.

In the same ball park: if you want to add equation numbers and line them up nicely at the right, how do you do that ?

And now that I'm asking anyway: is there a way to increase the spacing between \\ lines ? I tried \mathstrut but couldn't get it to work. Same with other glue goodies.

Basically I know next to nothing of LaTeX and forgot 90% of what I once knew about real TeX.

Haven't seen any examples of what I'm after in PF, so perhaps it can't be done. Worth asking, though.

--
 
Physics news on Phys.org
\\[12pt] works on text area.
 
Thanks for trying, but perhaps you mean something else than I ?Testing a=b \\ \\[12pt] \\[12pt] \\[12pt] \\c=d : $$a=b \\ \\[12pt] \\[12pt] \\[12pt] \\c=d$$ I don't see empty lines in between ...
 
This isn't my private notebook, but just in case someone sees this: \eqalign is available in MathJax and so is \hfil.

Within \equalign you can skip lines:

Code:
 \eqalign { awertwertr & = 5 & \qquad (1) \\ \\ b& =5 & \hfil (2)}
$$ \eqalign { awertwertr & = 5 & \qquad (1) \\ \\ b& =5 & \hfil (2)}$$

It's not the summit of elegance, but it suits my purpose.

Haven't found \vspace --
 
Found (*) an alternative I didn't know about (I only know TeX and am 'new' to LaTeX):
Code:
\begin{equation}
y'''-y''=u
\end{equation}
gives (only in display mode) $$
\begin{equation}
y'''-y''=u
\end{equation}$$The numbering is automaticHaven't found how to tame the counter (it doesn't always start off at 1 and it looks as if it increments with each preview !?), so I feel forced to use symbolic referencing:
Code:
equation ##\eqref{eq:sample}## shows $$

\begin{equation}
  \int_0^\infty \frac{x^3}{e^x-1}\,dx = \frac{\pi^4}{15}
  \label{eq:sample}
\end{equation}$$

equation ##\eqref{eq:sample}## shows $$

\begin{equation}
\int_0^\infty \frac{x^3}{e^x-1}\,dx = \frac{\pi^4}{15}
\label{eq:sample}
\end{equation}$$
(*) in a thread by @Linder88 - with thanks !
 
Last edited:
  • Like
Likes   Reactions: Greg Bernhardt
More exploits:
  • You need unique equation labels per page (not just per post), otherwise you get references like ##\eqref{eq:nonexistent}## and the TeX source appears seemingly correct in a framed box. Probably has to do with the order of processing by MatJax and the browser
I suppose this automatic numbering and referencing of named equations then won't work across pages -- and PF splits up long pages :rolleyes:

Not to mention what can happen when people start quoting stuff... disaster!
So post #4 workaround is probably a lot safer -- more control
 
The align environment makes it easy to align equations. Hit the reply button to see how I'm doing this. The asterisk (*) prevents automatic numbering of the equations. So if you want them numbered, just type align instead of align*.
\begin{align*}
x^2+y^2 &= 1\\
x+y &=1
\end{align*}
 
Thanks, Fredrik !

So we have the \eqalign { ... } and we have the \begin{align*} or {align} environment
Code:
 $$ \eqalign { xyz & = 5 & \qquad (1) \\ \\ b& =5 & \hfil (2)} $$
$$ \begin{align*}   x^2+y^2 &= 1  \\  x+y &=1  \end{align*} $$
$$ \begin{align}    x^2+y^2 &= 1  \\  x+y &=1  \end{align} $$
$$ \eqalign { xyz & = 5 & \qquad (1) \\ \\ b& =5 & \hfil (2)}
$$ $$ \begin{align*} x^2+y^2 &= 1\\ x+y &=1 \end{align*}
$$ $$ \begin{align} x^2+y^2 &= 1 \\ x+y &=1 \end{align}
$$
And if you make a mistake you get
upload_2016-1-18_20-37-48.png


It seems to work, provided you keep them enclosed in separate ##\$\$## ... ##\$\$ ## -- and wait patiently for the post processor to show the equations after a while.

And previewing gives you ever-increasing equation numbers, but the final numbers start at a lower value.
How about referencing these numbers in \begin{align} ?

I still feel like I'm venturing ouside the comfort zone with this...
 
Last edited:
Found another gem (note the [5mm] incantation !) :
Code:
\begin{equation}
  \begin{aligned}
    A &= B &\qquad C &= D \\
      &= E &&= F \\
      &= G &&= H \\[5mm]
    I &= J & K &= L \\
      &= M &&= N \\
      &= O &&= P
  \end{aligned}
\end{equation}
$$\begin{equation}\begin{aligned} A &= B &\qquad C &= D \\&= E &&= F \\&= G &&= H \\[5mm] I &= J & K &= L \\&= M &&= N \\&= O &&= P \end{aligned}\end{equation}$$
Re-do post #3:
BvU said:
Thanks for trying, but perhaps you mean something else than I ?Testing a=b \\ \\[12pt] \\[12pt] \\[12pt] \\c=d : $$a=b \\ \\[12pt] \\[12pt] \\[12pt] \\c=d$$ I don't see empty lines in between ...
Testing a=b \\[12pt] \\[12pt] \\[12pt] \\c=d : $$a=b \\[12pt] \\[12pt] \\[12pt] \\c=d
$$ Testing a=b \\[5mm] c=d : $$a=b \\[5mm]c=d
$$ Testing a=b \\[12pt]\\ c=d : $$a=b \\[12pt]\\c=d
$$ Can someone explain that to me ?
 
  • #10
I guess it throws a warning if you use it with a compiler that shows them.
In WYSIWYG editors like word you often use a double return to space the text.
In LaTeX you can't use \\ twice in a row without a character in between (I've had my fair share of these warnings :-) ).
You can use \vspace or \\[height] instead.

Code:
$$
\text{Text with newline}\\
\text{And now a line in between}\\
\\
\text{doesn't work}
$$

$$
\text{Text with newline}\\
\text{And now a line in between}\\
\\
\text{doesn't work}
$$
 
  • #11
JorisL said:
In LaTeX you can't use \\ twice in a row without a character in between
Quite ! Thanks. That's why \\ \\[12mm] doesn't work.
I don't know if I can get to see the TeX processor warnings -- MathJaX is a post-processor, so they come after the page is already presented and replace the source (which you can actually see happening if things go slowly enough).

But in PF LaTeX \vspace isn't recognized, so we have to make do with \\[height]
 

Similar threads

  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 5 ·
Replies
5
Views
5K
  • · Replies 11 ·
Replies
11
Views
6K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 11 ·
Replies
11
Views
9K
  • · Replies 16 ·
Replies
16
Views
3K
  • · Replies 9 ·
Replies
9
Views
6K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K