I have been using \hspace and \vspace in my latex documents lately. I was surprised when \hspace{1em} didn't work and found out that I needed to use \hspace*{1em} to force latex to put the space requested.
My question is why does latex sometimes ignores \hspace{1em}
Asked
Active
Viewed 2.7k times
20
Joseph Elcid
- 633
1 Answers
26
When TeX breaks a line it discards white space (glue) that would come at the start of a line. This is why you get an inter-word space or a line break between words, not both. So if the \hspace comes at the beginning of a line the space gets added by LaTeX but discarded by the TeX paragraph breaker. The * version arranges to put a non-discardable invisible item in fromt of the space so the space is never first thing on the line (even though it looks like it is). \vspace and \vspace* the same with respect to vertical space discarded at a page break.
David Carlisle
- 757,742
\vspaceat the end of the previous line, it'll behave the same as\vspace*? Thanks for your explanation – Joseph Elcid Jul 20 '12 at 09:30\vspacethere or\hspace. If you use\vspace(*)mid-paragraph then after the paragraph is broken in to lines tex will insert vertical space after the line that contained thevspace. Then later if the page breaker breaks the page between those lines the space will be discarded unless the * form was used. – David Carlisle Jul 20 '12 at 09:33