I want to collect the first line of a quotation
to use later. I have used \newtoks
for a similar purpose so tried it here, this way:
\documentclass[12pt] {article}
\newtoks{\qfirstlineinternal}
\newcommand{\firstline}[1]{%
\qfirstlineinternal=\expandafter{#1}
#1
}
\begin{document}
\qfirstlineinternal=\expandafter{\the\qfirstlineinternal initial value}
debug: before quotation -\the\qfirstlineinternal-
\begin{quotation}
debug: in quotation before: -\the\qfirstlineinternal-
\firstline{This is the first line of a quotation,}
debug: in quotation after: -\the\qfirstlineinternal-
which continues on more lines.
\end{quotation}
debug: after quotation: -\the\qfirstlineinternal-
\end{document}
Here's the output document, showing that the value of the token set inside the quotation
environment is lost when that environment ends:
The quotation
environment seems to have created a new local instance of my token. How can I prevent that?