LaTeX Can I make vertical separation of $$ expressions smaller?

George Keeling

Gold Member
47
6
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.
 

BvU

Science Advisor
Homework Helper
12,170
2,712
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...
 

Orodruin

Staff Emeritus
Science Advisor
Homework Helper
Insights Author
Gold Member
2018 Award
15,841
5,828
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.
 

RPinPA

Science Advisor
Homework Helper
490
268
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.
 

George Keeling

Gold Member
47
6
$$ 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.
 

BvU

Science Advisor
Homework Helper
12,170
2,712
$$ your first line \\
\rm{and} \phantom {10000000000000000000000000000000000000000000000000000000000} \\
your second line $$
:smile:

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

George Keeling

Gold Member
47
6
\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 $$
 

Orodruin

Staff Emeritus
Science Advisor
Homework Helper
Insights Author
Gold Member
2018 Award
15,841
5,828
$$ 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.
 

BvU

Science Advisor
Homework Helper
12,170
2,712
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 dunno how to filter that). Someone knowledgeable should add a thread on the diffferences and possible workarounds :rolleyes:

Signed: ##\TeX##ie
 

BvU

Science Advisor
Homework Helper
12,170
2,712
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.
 

RPinPA

Science Advisor
Homework Helper
490
268
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?
 

Orodruin

Staff Emeritus
Science Advisor
Homework Helper
Insights Author
Gold Member
2018 Award
15,841
5,828

Orodruin

Staff Emeritus
Science Advisor
Homework Helper
Insights Author
Gold Member
2018 Award
15,841
5,828
Also, if you have to include text in a math environment, I suggest using an \mbox.
 

Want to reply to this thread?

"Can I make vertical separation of $$ expressions smaller?" You must log in or register to reply here.

Related Threads for: Can I make vertical separation of $$ expressions smaller?

Replies
5
Views
3K
Replies
9
Views
1K
  • Posted
Replies
6
Views
4K
Replies
4
Views
2K
Replies
5
Views
3K
Replies
1
Views
2K

Physics Forums Values

We Value Quality
• Topics based on mainstream science
• Proper English grammar and spelling
We Value Civility
• Positive and compassionate attitudes
• Patience while debating
We Value Productivity
• Disciplined to remain on-topic
• Recognition of own weaknesses
• Solo and co-op problem solving
Top