0

I would like to indent first paragraph "manually" with \indent command in my KOMA-Script article (scrartcl) in some specific place within document, while keeping other first paragraphs no-indented.

For that reason I don't want to use indentfirst package.

MWE here:

\documentclass{scrartcl}
\begin{document}
 \section{Test 1}
  \indent First paragraph, \verb|\indent| seems to be ignored ...

  Next paragraph, some text ...

 \section{Test 2}
  Some text ... 

  \noindent Next paragraph, \verb|\noindent| works, ...
\end{document}

Why KOMA ignores \indent command and how to indent the paragraph?

2
  • 4
    koma is not ignoring indent, that is standard latex behaviour to remove indentation of the first section. use \hspace*{\parindent} if you must Commented Oct 20, 2023 at 6:30
  • Addendum: There must not be any space between \hspace*{\parindent} and the start of the paragraph text. Such spaces would result in one inter word space. There also must not be an empty line between \hspace*{\parindent} and the start of the paragraph test. Such empty lines would result in a new paragraph and therefore an extra empty line (because the \hspace) already results in leaving v-mode. BTW: This is not limited to KOMA-Script, but would be same with other classes like the standard classes.
    – cabohah
    Commented Oct 20, 2023 at 6:54

1 Answer 1

2

As David already explained in a comment, it is usual to deactivate the indent of the first paragraph after a section heading. And because \indent only adds the currently activated indent, using this command cannot help. Instead you would need to use an explicit \hspace*{\parindent}.

Two notes about this:

  • The behavior of the KOMA-Script classes and the standard classes is same here.
  • There must not be an extra space or a line break or an empty line after the \hspace*{\parindent}.

Another suggestion would be to temporary deactivate \@afterindentfalse. Here an example, that works with KOMA-Script classes and with most other classes like the standard classes:

% \documentclass{scrartcl}
\documentclass{article}% Problem is not really KOMA-Script related.
\makeatletter
\let\orig@afterindentfalse\@afterindentfalse
\AddToHook{cmd/@afterheading/before}{%
  \let\@afterindentfalse\orig@afterindentfalse
}%
\NewDocumentCommand \sectionwithafterindent { sO{#3}m }
  {%
    \let\@afterindentfalse\@afterindenttrue
    \IfBooleanTF{#1}{\section*{#3}}{\section[{#2}]{#3}}%
  }
\makeatother
\begin{document}
 \sectionwithafterindent{Test 1}
  First paragraph, no \verb|\indent| needed \dots

  Next paragraph, some text \dots

 \section{Test 2}
  Some text \dots

  \noindent Next paragraph, \verb|\noindent| works, \dots
\end{document}

paragraph after first section with indent

Note: Because of using the generic cmd/…/before hook You need at least LaTeX 2021-11-15.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .