[Tex/LaTex] First paragraph indented after section title in margin

indentationmarginparmemoirparagraphssectioning

How do you keep the first paragraph from being indented, even when indentation is off, when using section titles in the margin?

I'm pretty new to LaTeX, but I thought I was getting pretty good at it, until I hit this problem I can't seem to resolve. I want block paragraphs, no indent, with section and subsection titles in the outer margin (in the memoir class.) By default, there's not supposed to be an indent in the first paragraph after a section title, anyways, but when I use titles in the margin, there's a 1 em indent for the first paragraph in a section, but not in subsections or sub-subsections, even though they use the same settings.

I thought this was related to this question about almost the same issue in memoir, but the answer didn't work. Adding \setbeforesecskipwith either a negative or positive value, or tweaking the \setsecindent (I started with [0em]) simply doesn't fix the problem.

\documentclass[12pt,a5]{memoir}
\usepackage{lipsum}

\semiisopage%  a default margin layouts

% fix margin notes

\setmarginnotes{3em}{0.2\textwidth}{2\onelineskip}

%% No numbered sections

\setcounter{secnumdepth}{0}

%% Section Names in margin

 \newcommand{\marginhead}[1]{%
   \marginpar{\bfseries\centering #1}}

%% set section, subsection and subsubsection headers
%% all the same, small bold text

\setsecindent{-1em}
\setbeforesecskip{-2em}
\setaftersecskip{0em}
\setsecheadstyle{\small\marginhead}

\setsubsecindent{0em}
\setaftersubsecskip{0em}
\setsubsecheadstyle{\small\marginhead}

% etc.

%% Paragraph styles
%%
%% no indent, skip line instead

\abnormalparskip{\baselineskip}
\setlength{\parindent}{0pt}

\checkandfixthelayout

\begin{document}

\section{First Section}
\lipsum[1]
\subsection{First Subsection}
\lipsum[1]
\section{Second Section}
\lipsum[1]
\subsection{Second Subsection}
\lipsum[1]
\subsection{Third Subsection}
\lipsum[1]

\end{document}

Best Answer

Setting the \setafterXskip parameters to a non-zero value (even to a non-detectable 1sp as in my code below) fixes the problem:

\documentclass[12pt,a5]{memoir}
\usepackage{lipsum}
\usepackage{marginnote}

\semiisopage%  a default margin layouts

% fix margin notes

\setmarginnotes{3em}{0.2\textwidth}{2\onelineskip}

%% No numbered sections

\setcounter{secnumdepth}{0}

%% Section Names in margin

 \newcommand{\marginhead}[1]{%
   \marginnote{\bfseries\centering #1}}

%% set section, subsection and subsubsection headers
%% all the same, small bold text

\setsecindent{-1em}
\setbeforesecskip{-2em}
\setaftersecskip{1sp}
\setsecheadstyle{\small\marginhead}

\setsubsecindent{0em}
\setaftersubsecskip{1sp}
\setsubsecheadstyle{\small\marginhead}

% etc.

%% Paragraph styles
%%
%% no indent, skip line instead

\abnormalparskip{\baselineskip}
\setlength{\parindent}{0pt}

\checkandfixthelayout

\begin{document}

\section{First Section}%
\lipsum[1]
\subsection{First Subsection}
\lipsum[1]
\section{Second Section}
\lipsum[1]
\subsection{Second Subsection}
\lipsum[1]
\subsection{Third Subsection}
\lipsum[1]

\end{document}

A portion of the result:

enter image description here

I changed \marginpar to \marginnote from the marginnote package.