# Why does \everypar not work?

I tried to put a \P (¶ sign) after each paragraph. Therefore, I chose the

\everypar={\P}


command. First of all, I figured out that LaTeX redefines it internally after

\begin{document}


Hence, I placed my code inside the document environment.

However, I did not have the wanted effect. Please find the minimal code:

\documentclass{article}
\begin{document}
\everypar={\P}
\section{Intro} some text \par next paragraph \par\noindent even more
\section{Outro} the end of my document
\end{document}


My output shows the \P before the section numbering which totally confused me.

I use MikTeX 2.9.4813 (x64) and TeXnicCenter to build my documents.

• I have to add that the \P occurs just once in front of the first section number. I even tried this to make sure that the \everypar={<tokens>} syntax works: \documentclass{article} \begin{document} Def\everypar={\P}inition \parskip=2cm \section{Intro} some text \par next paragraph\par\noindent even more \section{Outro} the end of my document \end{document} Jun 18 '13 at 14:20
• \everypar is not safe to use in LaTeX. Among the things using it are \@@startsection, an internal base for all sectioning commands, \item, amsmath environments, ... Jun 18 '13 at 14:22
• Did you mean after each paragraph? In my answer I assumed you meant at the start of each paragraph which is the conventional use of this sign. Jun 19 '13 at 16:49

LaTeX uses \everypar itself all over the place, to manage indentation (or not) after section headings, to preserve the paragraph shape of indented list structures, it is also reset in minipages and parboxes and tabular p columns so setting \everypar is tricky.

Apart from the fact that the value can get over-written at any time section headings (as most text) are internally a paragraph and so trigger \everypar as you observe.

You can (with care) do this to avoid your definition being lost after the first heading but it would require a local test inserting to avoid adding the \P before section heads

\documentclass{article}
\begin{document}
\let\oldep\everypar  \newtoks\everypar  \oldep{\the\everypar\P}

\section{Intro} some text \par next paragraph \par\noindent even more
\section{Outro} the end of my document
\end{document}


So here is a version with the heading code defined to remove the mark:

\documentclass{article}
\begin{document}
\let\oldep\everypar  \newtoks\everypar  \oldep{\the\everypar\hbox{\P}}

\makeatletter
\def\@sect#1#2#3#4#5#6[#7]#8{%
\ifnum #2>\c@secnumdepth
\let\@svsec\@empty
\else
\refstepcounter{#1}%
\protected@edef\@svsec{\@seccntformat{#1}\relax}%
\fi
\@tempskipa #5\relax
\ifdim \@tempskipa>\z@
\begingroup
#6{%
\@hangfrom{\hskip #3\relax\@svsec}%
\interlinepenalty \@M
% remove indentation box, remove \P box put indentation box back
\leavevmode \setbox\z@\lastbox\setbox\tw@\lastbox\box\z@
#8\@@par}%
\endgroup
\csname #1mark\endcsname{#7}%
\ifnum #2>\c@secnumdepth \else
\protect\numberline{\csname the#1\endcsname}%
\fi
#7}%
\else
\def\@svsechd{%
#6{\hskip #3\relax
\@svsec #8}%
\csname #1mark\endcsname{#7}%
\ifnum #2>\c@secnumdepth \else
\protect\numberline{\csname the#1\endcsname}%
\fi
#7}}%
\fi
\@xsect{#5}}

\makeatother

\section{Intro} some text \par next paragraph \par\noindent even more
\section{Outro} the end of my document
\end{document}


In addition to what was said in other answers and comments, \everypar is used at the beginning of each paragraph (or more precisely, when TeX changes from vertical to horizontal mode), so it is useless for the purpose you tried to achieve.

For this purpose it is better to redefine \par, as in:

\documentclass{article}

\begin{document}
\let\oldpar=\par
\def\par{\P\oldpar}
\section{Intro} some text \par next paragraph \par\noindent even more
\section{Outro} the end of my document
\end{document}


But even this produces unwanted results, since section headers use also internally \par in a unexpected way. See the result:

• but \par ends a paragraph so as your image shows this puts the \P at the wrong end of the text, apart from the problem with section headings. The Pilcrow should go in place of the indentation (one possible origin of indentation is leaving space for this) so it is more naturally attached to \everypar at the start of a paragraph than to \par at the end. (I'm assuming the OP didn't mean it when the question said to put the \P at the end:-) Jun 19 '13 at 16:45