4

I need to indent only the first paragraph of each section/subsection/subsubsection. Is it possible in a more clever way than using the indentfirst package and \noindent on each non-first paragraph?

3

You can set \parindent to 0pt global and after the heading you can add a small horizontal skip by redefining \@afterheading:

\makeatletter
\def\@afterheading{%
  \@nobreaktrue
  \everypar{%
    \if@nobreak
      \@nobreakfalse
      \clubpenalty \@M
      \hspace*{1em}%
    \else
      \clubpenalty \@clubpenalty
      \everypar{}%
    \fi}}
\makeatother
\setlength{\parindent}{0pt}

Here an MWE:

\documentclass{article}

\usepackage[T1]{fontenc}

\usepackage{lipsum}

\makeatletter
\def\@afterheading{%
  \@nobreaktrue
  \everypar{%
    \if@nobreak
      \@nobreakfalse
      \clubpenalty \@M
      \hspace*{1em}%
    \else
      \clubpenalty \@clubpenalty
      \everypar{}%
    \fi}}
\makeatother
\setlength{\parindent}{0pt}


\begin{document}
\section{foobar}

\lipsum[2]
\lipsum[2]
\lipsum[2]

\section{barfoo}
\lipsum[2]
\lipsum[2]
\lipsum[2]
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.