[texhax] some problems about \prevgraf and \toks

Ian Collier imc at comlab.ox.ac.uk
Tue Oct 7 12:57:10 CEST 2003

Verily, aquasakura at hotmail.com ("Chakrit Nimmanant") hath written to texhax:
>So, my question is how can I refer to the current line number or at least 
>how can I know that whether TeX has already entered a new line or not?

You cannot know this in general.  TeX typesets your paragraph in
horizontal mode; that is, it typesets the lot in one very long
horizontal line, and only when that is finished does it break it
up into lines.  So, at the time when TeX processes your input, it
doesn't have the concept of "current line number".

In theory, you could typeset the paragraph into a \vbox and then break
the box apart to look at the individual lines.  But that is a lot of
work and probably can't do what you want it to.

>So, my question is how can I concatenate two "\toks" and assign it to 
>another "\toks"?

Suppose for the sake of argument that you have token registers called
\C and \D and you want to concatenate them and put the result in \A.
There are [at least] two ways to do this.  The slightly easier way:


and the harder way, which doesn't require the temporary definition:


In either case, you can put the result back into \C instead of in \A
by just replacing \A by \C.
---- Ian Collier : imc at comlab.ox.ac.uk : WWW page below
------ http://users.comlab.ox.ac.uk/ian.collier/imc.shtml

More information about the texhax mailing list