Take the 2-minute tour ×
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.

The following example splits a box with the setting \splittopskip=2cm. Everything works as expected. However I want to remove the vertical skip add by \splittopskip=2cm some steps later.

Is there an easy way?

\documentclass{article}
\parindent0pt
\def\exampletext{Text Text Text Text Text Text Text Text Text Text Text Text 
Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text 
Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text }
\fboxsep=0pt
\fboxrule=1pt

\newbox\boxi
\newbox\boxii
\begin{document}
\begingroup
\setbox\boxi=\vbox%
 {%
    \hsize=8cm\sloppy
    \bfseries\huge\exampletext
 }

\splitmaxdepth0pt \splittopskip=2cm
\setbox\boxii\vsplit\boxi to2cm
\setbox\boxii=\vbox{\unvbox\boxii}

BOX \verb+\boxii+\hfill\fbox{\box\boxii}

\setbox\boxi=\vbox{\unvbox\boxi}

BOX \verb+\boxi+\hfill\fbox{\box\boxi}
\endgroup
\end{document}

EDIT

The provided solution of David works nearly as expected. But it gobbles the first line of the splitted box. To demonstrate the behavior I changed \exampletext and added one TextA which should be the first line of the splitted box.

\documentclass{article}
\parindent0pt
\def\exampletext{Text Text Text Text Text Text Text Text TextA Text Text Text 
Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text 
Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text }
\fboxsep=0pt
\fboxrule=1pt

\newbox\boxi
\newbox\boxii
\begin{document}
\begingroup
\setbox\boxi=\vbox%
 {%
    \hsize=8cm\sloppy
    \bfseries\huge\exampletext
 }

\splitmaxdepth0pt \splittopskip=2cm
\setbox\boxii\vsplit\boxi to2cm
\setbox\boxii=\vbox{\unvbox\boxii}

BOX \verb+\boxii+\hfill\fbox{\box\boxii}

BOX \verb+\boxi+ unprepared\hfill\fbox{\copy\boxi}

\splittopskip0pt
\setbox0=\vsplit\boxi to 0pt

\setbox\boxi=\vbox{\unvbox\boxi}

BOX \verb+\boxi+ prepared\hfill\fbox{\box\boxi}
\endgroup
\end{document}
share|improve this question
add comment

1 Answer

up vote 5 down vote accepted
\splittopskip0pt
\setbox\boxi=\vbox{\break\unvbox\boxi}
\setbox0=\vsplit\boxi to 0pt
\setbox\boxi=\vbox{\unvbox\boxi}

removes the splitopskip glue from boxi in this case (replaces it with 0pt glue) although in general it will remove all discardable items. If however the box came from a vsplit originally then probably there is only the one discardable item at the top of the box.

The first setting \boxi ensures there is a break point at the start of the box, so when you vsplit, it splits there and discards any following glue, then adds the 0pt \splittopskip.

share|improve this answer
add comment

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.