# Why does noindentafter package cause this behavior?

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}


Why the second paragraph is also unindented?

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