# [XeTeX] How to append text to a paragraph (in an existing vbox)?

Philip Taylor (Webmaster, Ret'd) P.Taylor at Rhul.Ac.Uk
Fri Jul 16 11:35:44 CEST 2010


Ron Aaron wrote:

> What I wish to do is accumulate text into a paragraph "as I go".  My simple approach is to allocate a box, and then unbox and add the text.  But this doesn't work as I intend:
>
> \newbox\textbox
> 	\setbox\textbox\vbox{
> 		\unvbox\textbox#1
> 	}
> }
>

> What I get is each appended bit of text in a separate line.  I've tried to "\unskip" and "\unkern" etc. after the \unvbox, but whatever I do I get a list of lines rather than a paragraph as I would like.  So far I haven't found any answers in my searching, so if one of you would be kind enough to point me in the right direction I would be appreciative.

Although you probably /can/ do it via a \vbox, you would have
to somehow get at the anonymous \hbox that will lie therein;
easier, IMHO, is to use an \hbox directly or a token-list
register :

\newbox \textbox
{%
\setbox \textbox = \hbox
\bgroup
\unhbox \textbox #1%
\egroup
}

\unhbox \textbox
\end

\newtoks \texttoks
{%
\texttoks = \expandafter {\the \texttoks #1}
}