as the title suggests, I'm looking for a way to get the first (printable) line in an environment. My first naive attempt (ignoring the printable requirement) was something like this:
\newcommand*{\theline}{}
\newcommand*{\getline}[1]{%
\renewcommand*{\theline}{#1}%
#1%
}
\newenvironment{anewenvironment}{%
\getline%
}{}
However, afterwards \theline
is only the first character. Eg.
\begin{anewenvironment}
Test
\end{anewenvironment}
Line: \theline
prints:
Test
Line: T
when the required output is:
Test
Line: Test
I suppose this indicates a fundamental misunderstanding about how TeX/LaTeX handles arguments on my part, so any ideas or more broad clarification on how arguments are handled would be appreciated. Thanks.
P.S. I understand that the concept of a "line" is rather vague — "paragraph" might be a better term in retrospect, though "X words" would also fit my use case.
EDIT: The aim of this is to find a way to automatically get incipits for poetry or blocks of text. See this issue on PoetryTeX for more info.
EDIT 2: Looks like none of these solutions are very good for what I need, however, they did answer my question so I've marked an answer.
\incipit{a part of the first line}
as markup at the start of your poem it would be easy to define that to do whatever you need. – David Carlisle Feb 13 '13 at 18:27