Looking for My First LaTeX Thread!

  • LaTeX
  • Thread starter BvU
  • Start date
In summary: Haven't seen any examples of what I'm after in PF, so perhaps it can't be done. Worth asking, though.
  • #1
BvU
Science Advisor
Homework Helper
15,986
4,806
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
  • #2
\\[12pt] works on text area.
 
  • #3
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 ...
 
  • #4
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 --
 
  • #5
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 Greg Bernhardt
  • #6
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
 
  • #7
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*}
 
  • #8
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:
  • #9
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]
 

1. What is LaTeX?

LaTeX is a typesetting system commonly used in fields such as mathematics, physics, and computer science to create professional-looking documents with complex mathematical equations and symbols.

2. How do I get started with LaTeX?

The first step is to download a LaTeX distribution, such as TeX Live or MiKTeX, which includes all the necessary tools and packages. Then, you can use a text editor or a specialized LaTeX editor, such as TeXstudio or Texmaker, to write your documents.

3. What are the advantages of using LaTeX over other document editors?

LaTeX offers a high level of control over document formatting, making it ideal for producing technical and scientific documents. It also has built-in support for mathematical equations and bibliographies, and its source code can be easily shared and reproduced.

4. Are there any resources available to help me learn LaTeX?

Yes, there are many online tutorials, guides, and forums dedicated to LaTeX. Some popular resources include LaTeX Tutorial, Learn LaTeX in 30 minutes, and TeX - LaTeX Stack Exchange, where you can find answers to common questions and ask for help.

5. Can I use LaTeX for any type of document?

While LaTeX is mainly used for technical and scientific documents, it can also be used for other types of documents, such as resumes, letters, and presentations. However, it may require more effort to format these documents compared to using a traditional word processor.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
11
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
9
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
16
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
Back
Top