TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

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'm gluing together a bunch of code fragments using \verbatiminput, and I want to eliminate the vertical space (glue) that would normally come between the fragments. But I cannot use \unskip because that is for horizontal mode only.

Is there an analog of \unskip (remove the last item on the current list if it is glue) for vertical mode?

For those who requested an example:




I'd like to remove the extra spacing inserted between successive calls to \verbatiminput.

share|improve this question
Well, \unskip works in internal vertical mode. So maybe putting stuff into a \vbox, unskipping to your heart's content, and then \unvboxing would be an alternative? – Stephan Lehmke Jun 11 '12 at 13:35
Further possibility: \vskip-\lastskip. LaTeX offers a command \removelastskip to that effect. – Stephan Lehmke Jun 11 '12 at 13:36
Could you please make an example? – egreg Jun 11 '12 at 14:06

As noted in the comments \unskip works in vertical mode if you are in a box. Or you can \vskip-\lastskip but better really is just not to add the space in the first place.

LaTeX's \addvspace tries to avoid adding space necessarily, it works like \vspace or vskip unless space was recently added. (This is so two consecutive display environments do not get double space in the middle.) Perhaps you want \nointerlineskip or offinterlineskip so TeX does not automatically add skip before the vertical material that you are adding,

share|improve this answer

You can try checking whether a \verbatiminput follows and, in this case, remove the skips that are inserted (twice \topsep):


   \IfFileExists {#2}{\@verbatim #1\relax
   {\typeout {No file #2.}\endgroup}%
   %% Added code

This is no beer.
This is no beer.

Here is beer.tex:

jlet~jlet~Hjpar ~Bjmscount~~jdef~x{q bottlez of beer}
~jw{x on the wall}~jt{jadvanceAB-1ATake one down Aand
pass it around,H}B99~ji{jifnumB}~q{ji=0Nojelsejnumber
Bjfi}~z{ji>1sjfiA }jloop jifnumB>0 jw, x,Hjtjw.jvskip
8ptplus1ptjrepeat Time to buy some more beerjdotsjend

Perhaps, a better solution is to use a different command, let's call it \multiverbatiminput that accepts a list of file names:

  \@verbatim #1\relax
                        {\typeout {No file \next.}}}%

This is beer
Also this is
This is no beer.
share|improve this answer

Your Answer


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.