This is a follow up question of Automatic Paragraph Numbers (\everypar only for paragraphs and not for \section and so on).
I want to change \everypar in every section (or chapter). As soon as I use \everyparin the \section command I get an error. When I use a command then it works fine.
Version 1 (not working)
\documentclass{article}
\usepackage{blindtext}
\usepackage{marginnote}
\usepackage{parskip}
% Version 1
% ----------------------------
% everypar in section
\let\OriginalSection\section%
\renewcommand{\section}{%
\OriginalSection%
\everypar={\marginpar[Testtext 1]{}}
}
%% Version 2
%% ----------------------------
%% everypar in command
%\def\NumPar{%
% \everypar={\marginpar[]{Testtext 2}}%
%}
\begin{document}
\section{First section}
%\NumPar
\blindtext
\blindtext
\section{Second section}
%\NumPar
\blindtext
\blindtext
\end{document}
I get the error
! Missing { inserted.
<to be read again>
\@@par
l.25 \section
{First section}
A left brace was mandatory here, so I've put one in.
You might want to delete and/or insert some corrections
so that I will find a matching right brace soon.
(If you're confused by all this, try typing `I}' now.)
Version 2 (working but not preferred)
Mind the \NumPar command in the code!
\documentclass{article}
\usepackage{blindtext}
\usepackage{marginnote}
\usepackage{parskip}
%% Version 1
%% ----------------------------
%% everypar in section
%\let\OriginalSection\section%
%\renewcommand{\section}{%
% \OriginalSection%
% \everypar={\marginpar[Testtext 1]{}}
%}
% Version 2
% ----------------------------
% everypar in command
\def\NumPar{%
\everypar={\marginpar[]{Testtext 2}}%
}
\begin{document}
\section{First section}
\NumPar
\blindtext
\blindtext
\section{Second section}
\NumPar
\blindtext
\blindtext
\end{document}
Which gives me the output
What I Want
I want to use the \everypar command in Version 1 because then I do not have to add the command \NumPar manually as in Version 2.
