6

I defined a macro that I occasionally use at the beginning of sections. After this macro has been used, I do not want the first `real' paragraph (which technically is the second paragraph) to be indented. However, I can only achieve this by omitting any new lines between the macro and the first paragraph. Is there a more elegant way?

\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}

enter image description here

  • 1
    If you leave an empty line, it will be the 2nd paragraph. You can use \noindent, if you wish. – Sigur Feb 19 '15 at 12:56
  • I am aware of this fact and the corresponding workarounds. I was wondering whether there is some way to tune macro \note to achieve the \noindent effect. – Florian Feb 19 '15 at 12:59
11

You can use the commands used by \section to suppress indentation:

\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}
  • So easy! +1 :-) – Sigur Feb 19 '15 at 13:14
  • Thanks. This worked perfectly. Although I do not quite understand why (i.e. I do not know/understand what these commands do). – Florian Feb 19 '15 at 13:14

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.