マクロを使用した後の2番目の段落をインデントしない

マクロを使用した後の2番目の段落をインデントしない

セクションの始めに時々使用するマクロを定義しました。このマクロを使用した後、最初の「実際の」段落 (技術的には 2 番目の段落) をインデントしたくありません。ただし、これを実現するには、マクロと最初の段落の間にある新しい行を省略するしかありません。もっとエレガントな方法はありますか?

\documentclass{article}

\begin{document}

\newcommand{\note}[1]{
\begin{flushright}
\textit{#1}
\end{flushright}
}

\section{First section}

First paragraph is correctly NOT indented.

\section{Second section}

\note{My Note}
First `real' paragraph is correctly NOT indented.

\section{Third section}

\note{My Note}

First `real' paragraph should NOT be indented, but IS.

\end{document}

ここに画像の説明を入力してください

答え1

インデントを抑制するには、 で使用されるコマンドを使用できます\section

\documentclass{article}

\begin{document}
\makeatletter
\newcommand{\note}[1]{%
\begin{flushright}
\textit{#1}
\end{flushright}\par\@afterindentfalse\@afterheading
}
\makeatother

\section{First section}

First paragraph is correctly NOT indented.

\section{Second section}

\note{My Note}
First `real' paragraph is correctly NOT indented.

\section{Third section}

\note{My Note}

First `real' paragraph should NOT be indented, and ISN'T.

\end{document}

関連情報