Take the 2-minute tour ×

Is it possible to define a command so that it affects everything until the end of the current paragraph?

As a minimal example, I am trying to define a command using syntax similar to the following:


\fancycommand Laugh, and the world laughs with you.
Weep, and you weep alone.


Where \fancycommand affects all of the following text from the same paragraph including any line-breaks (for example, doing a number of text transformations), but not any subsequent paragraphs. The command cannot use braces around the rest of the paragraph.

If this is not possible, is it possible to do something similar until the end of the current line?

share|improve this question

2 Answers 2

up vote 12 down vote accepted

You can use \par as delimiter and scan the paragraph as one argument.

\def\fancycommand #1\par{#1\par}

Note, that you need to re-add the \par.

share|improve this answer
Two limitations: \par or an empty line must be given explicitly, it cannot be hidden in other macros. Verbatim stuff makes problems, because the catcodes are already set by the previous reading from \fancycommand. –  Heiko Oberdiek Oct 25 '12 at 3:02

A possibility is to say

% <other setup>

It much depends on what you have to do in <other setup>. For instance, here is a version that italicizes, just write \itshape in place of <other setup>

enter image description here

Here the trick is that \endgroup will remove the redefinition of \par, so the inserted \par will be whatever it was when TeX encountered \fancycommand. Of course a \par (or an empty line) should be present in order to terminate properly the special setting.

share|improve this answer

Your Answer


