# How to add text at the start of each paragraph (e.g. a paragraph mark)

I want to add a mark (e.g. X or ¶) at the start of each paragraph which is inside a custom environment.

MWE:

\documentclass{memoir}

\newcommand{\sometext}{
This is some text

This is some text in a new paragraph.

This is even more text in yet another new paragraph
}
\newenvironment{paragraphmarked}{%
% Magic command goes here?
}{%
% Maybe reset paragraph behaviour here?
}
\begin{document}
\begin{paragraphmarked}
\sometext
\end{paragraphmarked}
\end{document}


## What I would like to have

I tried doing

\let\oldpar\par
\let\par{\par X}
% Text goes here
\let\par\oldpar


But this resulted in TeX running out of memory in my (rather large) document.

• \let\par{\oldpar X}, untested, your version with \let\par{\par X} will result in an infinite loop... – user31729 Mar 20 '18 at 10:19

There is the TeX command \everypar{...} for exactly that purpose:

\documentclass{article}

\begin{document}
\everypar{X}

Text

Text

Text

\end{document}


By means of a user-defined environment, the scope of \everypar{} can be limited:

\documentclass{article}

\newenvironment{paragraphmarked}[1]{\everypar{#1}}{}

\begin{document}
\begin{paragraphmarked}{X}
Text

Text

Text
\end{paragraphmarked}

Text

Text

Text
\end{document}

• Excellent! I presume one can do \everypar{} to cancel this effect with any problems? Also, where is this feature documented? – Nathanael Farley Mar 20 '18 at 10:25
• If you define an environment, you may limit the scope of the command. See edit. – AlexG Mar 20 '18 at 10:33
• Documented in "The TeXbook", I suppose. – AlexG Mar 20 '18 at 11:33