1

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... – user31729 Mar 20 '18 at 10:19
2

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
  • 1
    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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.