3

I want to define an environment, that uses \vskip to put some space before and after. Usually it will be used in the normal text, but sometimes I want to push to the bottom of a page with \vfill. When the environment is placed at the bottom of a page due to the current text on a page without \vfill the \vskip afterwards is ignored - but not when using \vfill.

Is there a way to get the same behaviour in both cases (ignoring the \vskip)?

Even without an environment this happens as the following MWE shows.

\documentclass{article} \begin{document} test \vfill % \vskip\baselineskip is added and causes a blank line at the bottom of the page % without that \vfill no space (glue) is inserted at the end (see below) test \vskip\baselineskip \end{document} 

After a little search on this side I found the command \showoutput to see what's going on in the document. I tried to find out what is the reason for that difference and achieve what I want ... without any success. Here's the relevant part (I think) of \showoutput for that example. The difference is just a single line with or without \vfill.

...\hbox(6.15+0.11)x345.0, glue set 313.84fil, direction TLT ....\localpar .....\localinterlinepenalty=0 .....\localbrokenpenalty=0 .....\localleftbox=null .....\localrightbox=null ....\hbox(0.0+0.0)x15.0, direction TLT ....\TU/lmr/m/n/10 t ....\TU/lmr/m/n/10 e ....\TU/lmr/m/n/10 s ....\TU/lmr/m/n/10 t ....\penalty 10000 ....\glue(\parfillskip) 0.0 plus 1.0fil ....\glue(\rightskip) 0.0 ...\glue 0.0 plus 1.0fill % That's the \vfill I guess ...\glue(\parskip) 0.0 plus 1.0 ...\glue(\parskip) 0.0 ...\glue(\baselineskip) 5.74 ...\hbox(6.15+0.11)x345.0, glue set 313.84fil, direction TLT ....\localpar .....\localinterlinepenalty=0 .....\localbrokenpenalty=0 .....\localleftbox=null .....\localrightbox=null ....\hbox(0.0+0.0)x15.0, direction TLT ....\TU/lmr/m/n/10 t ....\TU/lmr/m/n/10 e ....\TU/lmr/m/n/10 s ....\TU/lmr/m/n/10 t ....\penalty 10000 ....\glue(\parfillskip) 0.0 plus 1.0fil ....\glue(\rightskip) 0.0 ...\glue 12.0 % That's the \vskip I guess (it disappears without the \vfill) ...\glue -0.11 ...\glue 0.0 plus 1.0fil ...\glue 0.0 ...\glue 0.0 plus 0.0001fil 

By the way, the same happens for \vspace or \addvspace instead of \vskip.

1
  • \usepackge{showframe} shows no difference, \vfill doesn't expand until the page is done (full), which includes the blank line at the bottpm of the page. You can add a \pagebreak so that the blank line is now at the top of the next page. (and will be absorbed) Commented Aug 2, 2023 at 12:48

1 Answer 1

1

I believe you should define two related environments: foo for normal appearance in the text block and foo* to move it at the bottom of the page.

\documentclass{article} \usepackage[a6paper,showframe]{geometry} \usepackage{lipsum} \newenvironment{foo}{% \par\addvspace{\baselineskip}\startfoo }{% \par\addvspace{\baselineskip}% } \newenvironment{foo*}{% \par\vfill\startfoo }{% \par } \newcommand{\startfoo}{\noindent\textbf{Foo.}\ \ignorespaces} \begin{document} \lipsum[1][1-5] \begin{foo} \lipsum[2][1-3] \end{foo} \lipsum[3][1-5] \clearpage \lipsum[1][1-5] \begin{foo*} \lipsum[2][1-3] \end{foo*} \end{document} 

The packages I loaded in the preamble are just to produce a smaller picture showing the page margins. I provided a mock definition of the environment.

enter image description here

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.