Dynamic vspace depending on text height












3















I have a fixed layout with some text and vspace s and so on.

Sometimes one of the text passages is too long for one line, so it uses two or more lines.



Is there any possibility to get the used height of the text and adjust the vspace?



Here is a little part out of my sty file:



begin{center}
{Largethethema}\
vspace{1.6cm}
end{center}


For one line 1.6 cm is good, but for two lines it is too much and the title page needs two pages.



Thanks for any hints.










share|improve this question

























  • you probably should have a look at tex.stackexchange.com/questions/476/…. You'll see that the defined vertical skip commands contain the dynamical plus and minus requested lengths.

    – pluton
    Jul 23 '12 at 14:39








  • 1





    Also never use a size changing command like Large with {Large....} without including the paragraph break (or for centering \ in the scope of the size change otherwise you get large text onnormal baseline and so inconsistent line spacing

    – David Carlisle
    Jul 23 '12 at 15:23
















3















I have a fixed layout with some text and vspace s and so on.

Sometimes one of the text passages is too long for one line, so it uses two or more lines.



Is there any possibility to get the used height of the text and adjust the vspace?



Here is a little part out of my sty file:



begin{center}
{Largethethema}\
vspace{1.6cm}
end{center}


For one line 1.6 cm is good, but for two lines it is too much and the title page needs two pages.



Thanks for any hints.










share|improve this question

























  • you probably should have a look at tex.stackexchange.com/questions/476/…. You'll see that the defined vertical skip commands contain the dynamical plus and minus requested lengths.

    – pluton
    Jul 23 '12 at 14:39








  • 1





    Also never use a size changing command like Large with {Large....} without including the paragraph break (or for centering \ in the scope of the size change otherwise you get large text onnormal baseline and so inconsistent line spacing

    – David Carlisle
    Jul 23 '12 at 15:23














3












3








3








I have a fixed layout with some text and vspace s and so on.

Sometimes one of the text passages is too long for one line, so it uses two or more lines.



Is there any possibility to get the used height of the text and adjust the vspace?



Here is a little part out of my sty file:



begin{center}
{Largethethema}\
vspace{1.6cm}
end{center}


For one line 1.6 cm is good, but for two lines it is too much and the title page needs two pages.



Thanks for any hints.










share|improve this question
















I have a fixed layout with some text and vspace s and so on.

Sometimes one of the text passages is too long for one line, so it uses two or more lines.



Is there any possibility to get the used height of the text and adjust the vspace?



Here is a little part out of my sty file:



begin{center}
{Largethethema}\
vspace{1.6cm}
end{center}


For one line 1.6 cm is good, but for two lines it is too much and the title page needs two pages.



Thanks for any hints.







spacing






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jul 14 '17 at 6:48









David Carlisle

491k4111351883




491k4111351883










asked Jul 23 '12 at 14:31









CSchulzCSchulz

88531220




88531220













  • you probably should have a look at tex.stackexchange.com/questions/476/…. You'll see that the defined vertical skip commands contain the dynamical plus and minus requested lengths.

    – pluton
    Jul 23 '12 at 14:39








  • 1





    Also never use a size changing command like Large with {Large....} without including the paragraph break (or for centering \ in the scope of the size change otherwise you get large text onnormal baseline and so inconsistent line spacing

    – David Carlisle
    Jul 23 '12 at 15:23



















  • you probably should have a look at tex.stackexchange.com/questions/476/…. You'll see that the defined vertical skip commands contain the dynamical plus and minus requested lengths.

    – pluton
    Jul 23 '12 at 14:39








  • 1





    Also never use a size changing command like Large with {Large....} without including the paragraph break (or for centering \ in the scope of the size change otherwise you get large text onnormal baseline and so inconsistent line spacing

    – David Carlisle
    Jul 23 '12 at 15:23

















you probably should have a look at tex.stackexchange.com/questions/476/…. You'll see that the defined vertical skip commands contain the dynamical plus and minus requested lengths.

– pluton
Jul 23 '12 at 14:39







you probably should have a look at tex.stackexchange.com/questions/476/…. You'll see that the defined vertical skip commands contain the dynamical plus and minus requested lengths.

– pluton
Jul 23 '12 at 14:39






1




1





Also never use a size changing command like Large with {Large....} without including the paragraph break (or for centering \ in the scope of the size change otherwise you get large text onnormal baseline and so inconsistent line spacing

– David Carlisle
Jul 23 '12 at 15:23





Also never use a size changing command like Large with {Large....} without including the paragraph break (or for centering \ in the scope of the size change otherwise you get large text onnormal baseline and so inconsistent line spacing

– David Carlisle
Jul 23 '12 at 15:23










1 Answer
1






active

oldest

votes


















6














Normally you should be able to define stretchable "rubber" glue that automatically adjusts to the available space however if you really need to take different action depending on the number of lines you can do that as follows:



documentclass{article}

begin{document}



begin{center}
Large aaa

ifnumprevgraf=1
vspace{1.6cm}
else
vspace{1cm}
fi
end{center}



begin{center}
Large defa{aaa aa aa aa a}aaaaa

ifnumprevgraf=1
vspace{1.6cm}
else
vspace{1cm}
fi
end{center}

end{document}


Note the blank line (or an equivalent command) before the test is needed so the paragraph is completed and prevgraf updated with the number of lines in the previous paragraph.






share|improve this answer


























  • I don't understand, what you mean with stretchable "rubber" glue.

    – CSchulz
    Jul 23 '12 at 15:55













  • if you go vspace{1cm minus 0.5cm plus 1cm} the space will try to be 1cm but if the text is going in to a minipage with fixed vertical size (or the actual page to textheight then TeX will shrink it as low as 0.5cm or stretch it as large as 2cm. So given such a setting if the text takes more space the whitespace will shrink to accommodate it.

    – David Carlisle
    Jul 23 '12 at 16:00













  • Sorry, but I don't know how to get it working. I have tried it, but it doesn't work. Furthermore I don't understand your hint with the minipage.

    – CSchulz
    Jul 24 '12 at 7:21











  • well my answer here answers your specific question on detecting the number of lines in a previous paragraph. It's better for the site if you ask a different question if you want to ask about glue stretching. Please if you ask a new question always add a complete small document that shows the problem, not just tex fragment that can't be run on its own.

    – David Carlisle
    Jul 24 '12 at 9:00











  • @CSchulz why did you accept this answer?

    – Tvde1
    Feb 13 at 16:42











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "85"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f64399%2fdynamic-vspace-depending-on-text-height%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









6














Normally you should be able to define stretchable "rubber" glue that automatically adjusts to the available space however if you really need to take different action depending on the number of lines you can do that as follows:



documentclass{article}

begin{document}



begin{center}
Large aaa

ifnumprevgraf=1
vspace{1.6cm}
else
vspace{1cm}
fi
end{center}



begin{center}
Large defa{aaa aa aa aa a}aaaaa

ifnumprevgraf=1
vspace{1.6cm}
else
vspace{1cm}
fi
end{center}

end{document}


Note the blank line (or an equivalent command) before the test is needed so the paragraph is completed and prevgraf updated with the number of lines in the previous paragraph.






share|improve this answer


























  • I don't understand, what you mean with stretchable "rubber" glue.

    – CSchulz
    Jul 23 '12 at 15:55













  • if you go vspace{1cm minus 0.5cm plus 1cm} the space will try to be 1cm but if the text is going in to a minipage with fixed vertical size (or the actual page to textheight then TeX will shrink it as low as 0.5cm or stretch it as large as 2cm. So given such a setting if the text takes more space the whitespace will shrink to accommodate it.

    – David Carlisle
    Jul 23 '12 at 16:00













  • Sorry, but I don't know how to get it working. I have tried it, but it doesn't work. Furthermore I don't understand your hint with the minipage.

    – CSchulz
    Jul 24 '12 at 7:21











  • well my answer here answers your specific question on detecting the number of lines in a previous paragraph. It's better for the site if you ask a different question if you want to ask about glue stretching. Please if you ask a new question always add a complete small document that shows the problem, not just tex fragment that can't be run on its own.

    – David Carlisle
    Jul 24 '12 at 9:00











  • @CSchulz why did you accept this answer?

    – Tvde1
    Feb 13 at 16:42
















6














Normally you should be able to define stretchable "rubber" glue that automatically adjusts to the available space however if you really need to take different action depending on the number of lines you can do that as follows:



documentclass{article}

begin{document}



begin{center}
Large aaa

ifnumprevgraf=1
vspace{1.6cm}
else
vspace{1cm}
fi
end{center}



begin{center}
Large defa{aaa aa aa aa a}aaaaa

ifnumprevgraf=1
vspace{1.6cm}
else
vspace{1cm}
fi
end{center}

end{document}


Note the blank line (or an equivalent command) before the test is needed so the paragraph is completed and prevgraf updated with the number of lines in the previous paragraph.






share|improve this answer


























  • I don't understand, what you mean with stretchable "rubber" glue.

    – CSchulz
    Jul 23 '12 at 15:55













  • if you go vspace{1cm minus 0.5cm plus 1cm} the space will try to be 1cm but if the text is going in to a minipage with fixed vertical size (or the actual page to textheight then TeX will shrink it as low as 0.5cm or stretch it as large as 2cm. So given such a setting if the text takes more space the whitespace will shrink to accommodate it.

    – David Carlisle
    Jul 23 '12 at 16:00













  • Sorry, but I don't know how to get it working. I have tried it, but it doesn't work. Furthermore I don't understand your hint with the minipage.

    – CSchulz
    Jul 24 '12 at 7:21











  • well my answer here answers your specific question on detecting the number of lines in a previous paragraph. It's better for the site if you ask a different question if you want to ask about glue stretching. Please if you ask a new question always add a complete small document that shows the problem, not just tex fragment that can't be run on its own.

    – David Carlisle
    Jul 24 '12 at 9:00











  • @CSchulz why did you accept this answer?

    – Tvde1
    Feb 13 at 16:42














6












6








6







Normally you should be able to define stretchable "rubber" glue that automatically adjusts to the available space however if you really need to take different action depending on the number of lines you can do that as follows:



documentclass{article}

begin{document}



begin{center}
Large aaa

ifnumprevgraf=1
vspace{1.6cm}
else
vspace{1cm}
fi
end{center}



begin{center}
Large defa{aaa aa aa aa a}aaaaa

ifnumprevgraf=1
vspace{1.6cm}
else
vspace{1cm}
fi
end{center}

end{document}


Note the blank line (or an equivalent command) before the test is needed so the paragraph is completed and prevgraf updated with the number of lines in the previous paragraph.






share|improve this answer















Normally you should be able to define stretchable "rubber" glue that automatically adjusts to the available space however if you really need to take different action depending on the number of lines you can do that as follows:



documentclass{article}

begin{document}



begin{center}
Large aaa

ifnumprevgraf=1
vspace{1.6cm}
else
vspace{1cm}
fi
end{center}



begin{center}
Large defa{aaa aa aa aa a}aaaaa

ifnumprevgraf=1
vspace{1.6cm}
else
vspace{1cm}
fi
end{center}

end{document}


Note the blank line (or an equivalent command) before the test is needed so the paragraph is completed and prevgraf updated with the number of lines in the previous paragraph.







share|improve this answer














share|improve this answer



share|improve this answer








edited Feb 13 at 16:57

























answered Jul 23 '12 at 15:26









David CarlisleDavid Carlisle

491k4111351883




491k4111351883













  • I don't understand, what you mean with stretchable "rubber" glue.

    – CSchulz
    Jul 23 '12 at 15:55













  • if you go vspace{1cm minus 0.5cm plus 1cm} the space will try to be 1cm but if the text is going in to a minipage with fixed vertical size (or the actual page to textheight then TeX will shrink it as low as 0.5cm or stretch it as large as 2cm. So given such a setting if the text takes more space the whitespace will shrink to accommodate it.

    – David Carlisle
    Jul 23 '12 at 16:00













  • Sorry, but I don't know how to get it working. I have tried it, but it doesn't work. Furthermore I don't understand your hint with the minipage.

    – CSchulz
    Jul 24 '12 at 7:21











  • well my answer here answers your specific question on detecting the number of lines in a previous paragraph. It's better for the site if you ask a different question if you want to ask about glue stretching. Please if you ask a new question always add a complete small document that shows the problem, not just tex fragment that can't be run on its own.

    – David Carlisle
    Jul 24 '12 at 9:00











  • @CSchulz why did you accept this answer?

    – Tvde1
    Feb 13 at 16:42



















  • I don't understand, what you mean with stretchable "rubber" glue.

    – CSchulz
    Jul 23 '12 at 15:55













  • if you go vspace{1cm minus 0.5cm plus 1cm} the space will try to be 1cm but if the text is going in to a minipage with fixed vertical size (or the actual page to textheight then TeX will shrink it as low as 0.5cm or stretch it as large as 2cm. So given such a setting if the text takes more space the whitespace will shrink to accommodate it.

    – David Carlisle
    Jul 23 '12 at 16:00













  • Sorry, but I don't know how to get it working. I have tried it, but it doesn't work. Furthermore I don't understand your hint with the minipage.

    – CSchulz
    Jul 24 '12 at 7:21











  • well my answer here answers your specific question on detecting the number of lines in a previous paragraph. It's better for the site if you ask a different question if you want to ask about glue stretching. Please if you ask a new question always add a complete small document that shows the problem, not just tex fragment that can't be run on its own.

    – David Carlisle
    Jul 24 '12 at 9:00











  • @CSchulz why did you accept this answer?

    – Tvde1
    Feb 13 at 16:42

















I don't understand, what you mean with stretchable "rubber" glue.

– CSchulz
Jul 23 '12 at 15:55







I don't understand, what you mean with stretchable "rubber" glue.

– CSchulz
Jul 23 '12 at 15:55















if you go vspace{1cm minus 0.5cm plus 1cm} the space will try to be 1cm but if the text is going in to a minipage with fixed vertical size (or the actual page to textheight then TeX will shrink it as low as 0.5cm or stretch it as large as 2cm. So given such a setting if the text takes more space the whitespace will shrink to accommodate it.

– David Carlisle
Jul 23 '12 at 16:00







if you go vspace{1cm minus 0.5cm plus 1cm} the space will try to be 1cm but if the text is going in to a minipage with fixed vertical size (or the actual page to textheight then TeX will shrink it as low as 0.5cm or stretch it as large as 2cm. So given such a setting if the text takes more space the whitespace will shrink to accommodate it.

– David Carlisle
Jul 23 '12 at 16:00















Sorry, but I don't know how to get it working. I have tried it, but it doesn't work. Furthermore I don't understand your hint with the minipage.

– CSchulz
Jul 24 '12 at 7:21





Sorry, but I don't know how to get it working. I have tried it, but it doesn't work. Furthermore I don't understand your hint with the minipage.

– CSchulz
Jul 24 '12 at 7:21













well my answer here answers your specific question on detecting the number of lines in a previous paragraph. It's better for the site if you ask a different question if you want to ask about glue stretching. Please if you ask a new question always add a complete small document that shows the problem, not just tex fragment that can't be run on its own.

– David Carlisle
Jul 24 '12 at 9:00





well my answer here answers your specific question on detecting the number of lines in a previous paragraph. It's better for the site if you ask a different question if you want to ask about glue stretching. Please if you ask a new question always add a complete small document that shows the problem, not just tex fragment that can't be run on its own.

– David Carlisle
Jul 24 '12 at 9:00













@CSchulz why did you accept this answer?

– Tvde1
Feb 13 at 16:42





@CSchulz why did you accept this answer?

– Tvde1
Feb 13 at 16:42


















draft saved

draft discarded




















































Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f64399%2fdynamic-vspace-depending-on-text-height%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Biblatex bibliography style without URLs when DOI exists (in Overleaf with Zotero bibliography)

How to change which sound is reproduced for terminal bell?

Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents