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
    \let\par{\oldpar X}, untested, your version with \let\par{\par X} will result in an infinite loop... –  Mar 20 '18 at 10:19

1 Answers1

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}
AlexG
  • 54,894