3

Based on the video available here : http://www.youtube.com/watch?v=vkBCeOBbAmM I try to understand what the following code does

\def\text{\setbox\galley=\vbox\bgroup
\hsize= 5cm
\hrule}

\makeatletter
\def\endtext{\vskip-\prevdepth
\vfil\egroup
\setbox0=\vsplit\galley to\z@}
\makeatother

\def\lines#1{\vsplit\galley
to #1\baselineskip}

unfortunately, I am not sucessful. In the video, he speaks about "floating, scrolling text" which you can cut in pieces and place the different pieces in the page. But I fail to understand how to do that with the previous code lines. I begin in macro writing so it could be I do not understand because I do not undestand the effect of the different commands put under these macros.

I tried

\text blablablabla \endtext

to check the effect but the page does not display any text at all then.

4

Here's a working example:

\input plipsum

\newbox\galley
\def\text{\setbox\galley=\vbox\bgroup
  \hsize=10cm \hrule height 0pt}

\catcode`\@=11
\def\endtext{\vskip-\prevdepth
  \vfil\egroup
  \setbox0=\vsplit\galley to \z@}
\catcode`\@=12

\def\lines#1{\vsplit\galley to #1\baselineskip}

\text
\lipsum 1,3
\endtext

\noindent{\bf Four lines:}\par\medskip

\setbox0=\lines{4}\box0

\bigskip

\noindent{\bf Five lines:}\par\medskip

\setbox0=\lines{5}\box0

\bye

The big text has much more than nine lines. We gather it in a \vbox, then chop off the initial (invisible) rule. With \lines{x} we can chop x lines from the top of the paragraph and set them in a box which we can do anything with. In the example we just print it.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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