6

MWE:

\documentclass{article}
\usepackage[english]{babel}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{libertine}

% custom centering
\newenvironment{mycenter}
 {\parskip=1ex\par\nopagebreak\centering}
 {\par\noindent\ignorespacesafterend}

\usepackage{noindentafter}
\NoIndentAfterEnv{mycenter}


\makeatother

\begin{document}

Many years ago Rudyard Kipling gave an address at McGill University in Montreal. He said one striking thing which deserves to be remembered. Warning the students against an over-concern for money, or position, or glory, he said: "Some day you will meet a man who cares for none of these things. Then you will know how poor you are."

In theory there is not much difference between theory and practice. But in practice there is a huge difference.

\begin{mycenter} Hmmm \end{mycenter}

Speaking of statisticians, there is the story that a statistician once told a friend that he never travels by air, because he computed the probability that there be a bomb on the plane, and although the probability was low, it was too high for his comfort. Two weeks later, the friend met the statistician on a plane and asked him why he had changed his theory. The statistician replied: "I didn't change my theory. It's just that I subsequently computed the probability that there be two bombs on the plane, and this probability is low enough for my comfort. So now I simply carry my own bomb."

The single biggest problem in communication is the illusion that it has taken place.

\end{document}

enter image description here

Why the second paragraph is also unindented?

7

\NoIndentAfterEnv is defined using

\@ifnextchar\par{%
    \def\par{%
      \everypar{\setbox\z@\lastbox\everypar{}}%
      \@restorepar%
    }%
  }

And you are using \par\noindent in the definition of mycenter environment. The \noindent after the \par is executed for the second paragraph that follows.

Solution is to remove the \noindent from mycenter definition.

\documentclass{article}
\usepackage[english]{babel}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{libertine}

% custom centering
\newenvironment{mycenter}
 {\parskip=1ex\par\nopagebreak\centering}
 {\par\ignorespacesafterend}

\usepackage{noindentafter}
\NoIndentAfterEnv{mycenter}


\makeatother

\begin{document}

Many years ago Rudyard Kipling gave an address at McGill University in Montreal. He said one striking thing which deserves to be remembered. Warning the students against an over-concern for money, or position, or glory, he said: "Some day you will meet a man who cares for none of these things. Then you will know how poor you are."

In theory there is not much difference between theory and practice. But in practice there is a huge difference.

\begin{mycenter} Hmmm \end{mycenter}

Speaking of statisticians, there is the story that a statistician once told a friend that he never travels by air, because he computed the probability that there be a bomb on the plane, and although the probability was low, it was too high for his comfort. Two weeks later, the friend met the statistician on a plane and asked him why he had changed his theory. The statistician replied: "I didn't change my theory. It's just that I subsequently computed the probability that there be two bombs on the plane, and this probability is low enough for my comfort. So now I simply carry my own bomb."

The single biggest problem in communication is the illusion that it has taken place.

\end{document}

enter image description here

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.