2

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 currently see:

What I currently see

What I would like to have

What I want to see


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.

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

1 Answer 1

3

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}
3
  • Excellent! I presume one can do \everypar{} to cancel this effect with any problems? Also, where is this feature documented? Commented Mar 20, 2018 at 10:25
  • 1
    If you define an environment, you may limit the scope of the command. See edit.
    – AlexG
    Commented Mar 20, 2018 at 10:33
  • Documented in "The TeXbook", I suppose.
    – AlexG
    Commented Mar 20, 2018 at 11:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .