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}%
\addcontentsline{toc}{#1}{%
\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}%
\addcontentsline{toc}{#1}{%
\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}
\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, ...