I would like to write an \unpar
macro which removes last \par
.
For example, the TeX code
This is a \par \unpar paragraph
should be equivalent to
This is a paragraph
(Note that by equivalent I mean not that it has to produce exactly the last token list: I mean that it should have the same output as the one I will obtain using the last token list.)
A solution could be to redefine \par
in the following way:
\let\oldpar\par
\def\unpar{}
\long\def\par#1{\ifx#1\unpar\else\oldpar#1\fi}
But this does not work if \bye
is preceeded by a \par
(I don't know why). Furthermore, a redefinition of \par
could possibly break some macro package. So, I was wondering: Is there a way to define \unpar
without modifying \par
?
And what about an \Unpar
macro which removes not just a single \par
but all \par
s preceeding it?
\long\def\par#1{\ifx#1\unpar\else\csname @firstofone\expandafter\endcsname\fi{\oldpar#1}}
would work, if I'm not mistaken.\par
(when the command has its primitive meaning). Can you please show a typical use case for your\unpar
command?\par
to look for\enddemo
\demo
to redefine\par
not to do a real\endgraf
until it has looked ahead, or perhaps set the whole thing in a vbox, then unbox it\lastskip any vertical skip add your end marker then
\unvbox` the contents on to the main list for the page.\enddemo
. if you want a visual gap in the input, put a%
at the beginning of the otherwise empty line.