8

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}
John Laviolette
  • 263
  • 1
  • 9

1 Answers1

6

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.

Gonzalo Medina
  • 505,128
  • But why? (I got this far too...) – Alan Munn Mar 11 '15 at 22:24
  • Marginnote is the only difference to the aforementioned question in my comment above. No dupe i think. – Johannes_B Mar 11 '15 at 22:25
  • @AlanMunn I'm asking myself the exact same question. Perhaps this should be a comment and not an answer until the reason has been found? – Gonzalo Medina Mar 11 '15 at 22:25
  • 1
    @Johannes_B Ahm, then this is a duplicate? On a second thought, I'd like to keep this one open and see if someone can come up with the reason for the problem and why a 1sp solves it. What do you think? – Gonzalo Medina Mar 11 '15 at 22:27
  • @GonzaloMedina Although the solution is the same, the problem is different. And this question is much clearer, since it has no issues with titlesec. – Alan Munn Mar 11 '15 at 22:31
  • Also, when I don't use marginnote the solution doesn't seem to work. – Alan Munn Mar 11 '15 at 22:32
  • @AlanMunn Yeah, marginnote is the real trigger hear, without it there is a little offset. So i think no dupe. btw: the last sentence in daleifs answer is great. :-) – Johannes_B Mar 11 '15 at 22:33
  • @Johannes_B I've edited daleif's answer now to put it in the correct macro. (So now the sentence is only great in the edit history I'm afraid.) – Alan Munn Mar 11 '15 at 22:55
  • I'm marking Gonzalo Medina's answer as accepted, although it does introduce a new problem unless I also use \marginnote as he did. The other changes (\setbeforesecskipor using a non-zero section indent) can be dropped, though. It's just the \setaftersecskip{1sp} that matters. – John Laviolette Mar 11 '15 at 23:55
  • I found a fix to the other problem with title alignment that happened when I switched to \marginnote. Putting \needspace{4em} fixed it. Also, I put the \setbeforesecskip{-2em} back in, when I was trying to find a fix. It did nothing by itself, but I'm leaving it in, in case it's a combo of all four changes that makes it work. – John Laviolette Mar 12 '15 at 17:56