# \everypar in section (or chapter) command not working

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.
\@@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.

in

\OriginalSection%
\everypar


you are passing \everypar as the argument to the original section.

You can do as below to set \everpar after the section argument has been read. Need to work a bit harder if you need star forms and optional arguments of \section.

It really is not supported to set \everypar like this lots of things that use paragraph settings internally are likely to break,

\documentclass{article}

\usepackage{blindtext}
\usepackage{marginnote}
\usepackage{parskip}

% Version 1
% ----------------------------
% everypar in section
\let\OriginalSection\section%
\renewcommand{\section}[1]{%
\OriginalSection{#1}%
\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}
`
• Thanks. I do not have another solution. I would be happy to get another way (see original question, this is a follow up). – Dr. Manuel Kuehner Aug 29 '15 at 21:04