TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have seen a lot of posts like this one \parskip stretches more than expected that use some glue inside \vspace. I wonder if it is good idea to define a new \vspace command with some glue to replace the normal one in all the cases. Something like

\newcommand{\vspacewithglue}[3]{\vspace{#1\baselineskip plus #2\baselineskip minus #3\baselineskip }}

I tried to persuade myself for the usefulness of such a command for simple cases but without success. For example, I used

some test line ffppp \vspacewithglue{2}{0}{0}\\
some test line ffppp \vspacewithglue{2}{-1}{1}\\
some test line ffppp \vspacewithglue{2}{1}{1}\\

without any difference. So I am somewhat confused. Maybe there are some "special" cases (like the above post) where one actually needs to have such a command, but generally there is no need. Maybe it is better to use the well known command \\[...ex] and leave TeX to place some glue, if it is realy needed.

I know this question is a bit vague or maybe already answered. Feel free to edit it/suggest something in the comments.

share|improve this question
    
"Glue" in this context is really: a set amount (via, ultimately, \vskip) plus an optional stretch and/or shrink component. I would suspect in you example that TeX has decided not to exercise its option (i.e., because there is no need to). As an aside, I hope you are not using \\ in the above code to "make" a new paragraph. – jon Feb 17 at 5:25
    
note the referenced question is about adding glue (\parskip) between paragraphs, which is usually a lot more reasonable than adding stretchable glue between lines of a paragraph, as here. – David Carlisle Feb 17 at 11:25

It is almost never a good idea to have stretchable glue between lines of a paragraph as you have in the question. A paragraph should be set as a consistent block. You may or may not want the glue between display units such as paragraphs, lists etc to be stretchable depending on the document design. Especially in two column modes stretchable glue between paragraphs can be disturbing as the paragraph space in the two columns will be different, and the baselines of the text will not align at all.

Also if, as in the question you use \vspace within a paragraph, the effect is well defined but slightly odd: the space is not added at the point of the \vspace command but added later, after the paragraph has been broken in to lines, after the line at which the vspace was added.

some test line ffppp \vspace{10pt}\\

is the same as

some test  \vspace{10pt}line ffppp\\

If, as is common in article document classes, \raggedbottom is in effect then fil glue is added at the end of the page, as that is infinitely stretchable, any finite stretch glue added would not stretch and only the natural length component would be used.

In some document classes (including the default ones) some small stretch between paragraphs can be useful in helping page breaking (latex sets the default \parskip to 0pt plus 1pt) but normally this should be a document-wide setting not adjusted by hand in each case.

Note that if you do need stretch at a line break in some special circumstance you do not need a new command you can use \\[5pt plus 5pt]

share|improve this answer
1  
The article class uses \raggedbottom in one column mode. – egreg Feb 17 at 8:56
3  
I don’t dare to edit an answer by David Carlisle, but you have written \flushbottom instead of \raggedbottom. :-) – Gustavo Mezzetti Feb 17 at 9:29
    
@David Carlisle Dear David I wonder if the use of both arguments like \[5pt plus 5pt minus 1pt] will be more useful than one \[5pt plus 5pt] in the practical point of view. – kornaros Feb 17 at 10:01
1  
@GustavoMezzetti it's always Ok to edit my answers, especially when they are wrong:-) thanks, I fixed it... – David Carlisle Feb 17 at 10:16
    
@kornaros it's hard to say. In 30 years of using tex I have never wanted to put stretch or shrink between lines of a paragraph, so harder to say if just stretch is more or less useful than stretch and shrink. From a practical point of view I'd never do that at all. – David Carlisle Feb 17 at 10:18

Your command works as expected, but as David already wrote it is a quite bad idea to use such stretchable space inside a paragrah.

\documentclass[12pt]{book}
\usepackage{lipsum}

\newcommand{\vspacewithglue}[3]{\vspace{#1\baselineskip plus #2\baselineskip minus #3\baselineskip }}
\textheight=10cm
\begin{document}
xxxxx

some test line ffppp \\
some test line ffppp \vspacewithglue{0}{1}{1}\\
some test line ffppp \\


xxxxx
\pagebreak %to force the page to stretch

xxxx
\end{document}

enter image description here

share|improve this answer
    
Oh! My god! The \vspacewithglue{0}{1}{1} is destroyed everything! I dont understand the reason! – kornaros Feb 17 at 10:04
1  
@kornaros in the example here there is more stretch between the lines of the paragraph (\baselineskip from the added command) than there is between paragraphs (1pt stretch) the page is underfull (not enough actual text to fill the page), so TeX has to over-stretch the glue but it stretches the more stretch glue the most so the page is filled up by putting most of the space between the lines where you added the glue. – David Carlisle Feb 17 at 10:24
    
@DavidCarlisle "TeX has to over-stretch the glue" Why? The \vspacewithglue{0}{1}{1} gives just the posibility of 1 baseline more! Is it possible to stop that strange behevior when one inserts a page break? – kornaros Feb 17 at 11:04
1  
@kornaros TeX has been given impossible constraints so it (a) complains very loudly in the log and (b) does the best it can, If you specify \flushbottom (the default with book) then tex has been instructed to make the bottom baseline of the page be at the bottom, by stretching glue. There is not enough glue to stretch that far so the page is underfull and you will get a warning about that, but then it will over-stretch the glue to meet the specified constraint that the page must be stretched to full size. If you do not want that, use \raggedbottom or do not add stretchy glue. – David Carlisle Feb 17 at 11:06

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.