Can I make vertical separation of $$ expressions smaller?

Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
12 replies · 2K views
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
 
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.
 
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?