Can I make vertical separation of $$ expressions smaller?

Click For Summary

Discussion Overview

The discussion revolves around formatting LaTeX expressions, specifically focusing on reducing vertical separation between equations and embedding text within mathematical environments. Participants explore various methods and share their experiences with LaTeX and MathJax.

Discussion Character

  • Technical explanation
  • Debate/contested
  • Exploratory

Main Points Raised

  • Some participants suggest that omitting line feeds after the $$ can reduce vertical separation between equations.
  • One participant mentions using multiline expressions with line breaks to achieve tighter packing, though they express uncertainty about the necessity of the new line for readability.
  • Another participant proposes using \phantom to create horizontal spacing, experimenting with the number of zeros needed for the desired effect.
  • Concerns are raised about the appearance of formatting being browser and platform dependent, questioning the effectiveness of certain LaTeX commands.
  • There is a discussion about the use of \rm and \text for embedding text within math environments, with some participants noting differences in behavior and appearance.
  • A participant expresses a desire for a consensus on the best method to left-justify text in multiline equations, but another humorously suggests that the consensus is to not attempt it.

Areas of Agreement / Disagreement

Participants do not reach a consensus on the best way to format embedded text in multiline equations, with multiple competing views and methods discussed throughout the thread.

Contextual Notes

The discussion highlights limitations in the LaTeX and MathJax environments, including differences in behavior and appearance across platforms, as well as unresolved questions about formatting commands.

George Keeling
Gold Member
Messages
183
Reaction score
42
I wrote my first LaTeX like this:
... it was easy to calculate that
$$ ê^1=\hat x - \frac { \hat y } {\tan \alpha} $$
and
$$ ê^2=\frac { \hat y } {\sin \alpha} $$
where ...
Is it possible to make the vertical separation smaller? The first example in the latex primer does not seem to suffer from this problem. I tried ## instead of $$ and other problems arose.
 
Physics news on Phys.org
George Keeling said:
I wrote my first LaTeX like this:
... it was easy to calculate that$$ ê^1=\hat x - \frac { \hat y } {\tan \alpha} $$and$$ ê^2=\frac { \hat y } {\sin \alpha} $$where ...
Is it possible to make the vertical separation smaller? The first example in the latex primer does not seem to suffer from this problem. I tried ## instead of $$ and other problems arose.
Yes, a little (1 line). You don't put a line feed after the $$:
calculate that
$$ ê^1=\hat x - \frac { \hat y } {\tan \alpha} $$and$$ ê^2=\frac { \hat y } {\sin \alpha} $$where ...
It seems leaving out the line in front of the $$ doesn't matter, though...
 
  • Like
Likes   Reactions: George Keeling and Orodruin
BvU said:
Yes, a little (1 line). You don't put a line feed after the $$:
calculate that
$$ ê^1=\hat x - \frac { \hat y } {\tan \alpha} $$and$$ ê^2=\frac { \hat y } {\sin \alpha} $$where ...
It seems leaving out the line in front of the $$ doesn't matter, though...
As kind of a LaTeX nerd, this is a very common mistake students make when writing LaTeX. The worst part is when they do it mid sentence and a new indented paragraph is started with ”where x is ...”. That really hurts my eyes.
 
I sometimes go for multiline expressions when I want tighter packing. Everything is inside one set of \$\$...\$\$ but with two backslashes and a new line marking a line break (I'm not sure if the new line is necessary, I just do it for readability). That is, if I write

\$\$ your first line \\
\rm{and} \\
your second line \$\$

I get this:

$$\hat e^1 = \hat x - \frac {\hat y}{\tan \alpha} \\
\rm{and} \\
\hat e^2 = \frac {\hat y}{\sin \alpha} $$

Normally I do that when I have several lines of equations but no text lines in between. You can see that it centered the word "and" along with the equations. I'm still a relative novice with this LaTeX interface myself and not sure if I can left-justify that one text line within the multiline.

By the way, multilines are covered in the primer.
 
  • Like
Likes   Reactions: George Keeling
RPinPA said:
$$ your first line \\
\rm{and} \\
your second line $$
If the and was left justified it would be great!
I can't find anything that might do that except \hfill or \hspace{\fill}, but they don't seem to do much.
 
$$ your first line \\
\rm{and} \phantom {10000000000000000000000000000000000000000000000000000000000} \\
your second line $$
:smile:

$$ your first line \\
\rm{and} \phantom {10000000000000000000000000000000000000000000000000000000000} \\
your second line $$
 
  • Like
Likes   Reactions: George Keeling
BvU said:
\phantom {10000000000000000000000000000000000000000000000000000000000}
Brilliant! I guess I will have to experiment to find out how many 0's are necessary in this great bodge. The phantom is not mentioned in the PF guide. I have found http://www.icl.utk.edu/~mgates3/docs/latex.pdf which mentions it. \qquad is similar but not as effective. Here it is with half the number of 0's, then x's, which give more bang for your buck:
$$ your first line \\
\rm{and} \phantom {100000000000000000000000000} \\
\rm{and} \phantom {xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx} \\
your second line $$
 
BvU said:
$$ your first line \\
\rm{and} \phantom {10000000000000000000000000000000000000000000000000000000000} \\
your second line $$
:smile:

$$ your first line \\
\rm{and} \phantom {10000000000000000000000000000000000000000000000000000000000} \\
your second line $$
I would not use this. What looks good is going to be browser and platform dependent. Also, the use of \rm should be {\rm and}, not \rm{and}. \rm is a modifier that does not take arguments, which is why your second line is not regular math font but also included in what \rm is affecting.
 
  • Like
Likes   Reactions: George Keeling and jim mcnamara
George Keeling said:
Brilliant! I guess I will have to experiment to find out how many 0's are necessary in this great bodge. The phantom is not mentioned in the PF guide.
I appreciate the irony, and would not qualify it as brilliant, more as: desperate. Point is that MathJax is different from ##\TeX/\LaTeX## in many respects and this horizontal spacing is one of them. I tried \hbox, \hfill and such, but didn't get anything useful - probably for a good reason.

BTW, this sub forum is a mix of genuine LateX and MathJax (I don't know how to filter that). Someone knowledgeable should add a thread on the diffferences and possible workarounds :rolleyes:

Signed: ##\TeX##ie
 
  • #10
Orodruin said:
I would not use this. What looks good is going to be browser and platform dependent. Also, the use of \rm should be {\rm and}, not \rm{and}. \rm is a modifier that does not take arguments, which is why your second line is not regular math font but also included in what \rm is affecting.
I agree, it's ugly and dependent. I'm open for alternatives :rolleyes:

The \rm was just a copy/paste.

##\text { I had hoped} \textsf {\textsf might look a little better} \ \ \text{than roman} ## but it doesn't match the PF font (name ?) either.
 
  • #11
Re: \rm. I've actually been using \text but found \rm referenced in various sources and thought it was more or less equivalent (but more likely to reproduce the default text font) so I experimented with it for this answer.

Looks like, no surprise, I still have a lot to learn.

So do we have a consensus on the best way to left-justify embedded text in a multiline?
 
  • #12
RPinPA said:
So do we have a consensus on the best way to left-justify embedded text in a multiline?
Yes. Don’t. :rolleyes:
 
  • #13
Also, if you have to include text in a math environment, I suggest using an \mbox.
 

Similar threads

  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 9 ·
Replies
9
Views
1K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 10 ·
Replies
10
Views
17K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 16 ·
Replies
16
Views
4K