Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm trying to create an environment that does not indent the very first paragraph of the text inside the environment.

My latest attempt and the corresponding output are shown below. As you can see, the first environment added some small horizontal space to the first non-indented paragraph. The second environment did not, but I could only achieve this by adding a % character after \begin{env}, which should not be needed. How can I omit this unwanted space without an explicit % character?

Result of minimal example

\documentclass{minimal}

\newenvironment{env}{%
    \noindent%
}{%
}%

\begin{document}
Some text. Some text. Some text. Some text. Some text. Some text.
Some text. Some text. Some text. Some text. Some text. Some text.
Some text. Some text. Some text. Some text. Some text. Some text.

\begin{env}
    First paragraph inside environment.

    Second paragraph inside environment.
\end{env}

\begin{env}%
    First paragraph inside environment.

    Second paragraph inside environment.
\end{env}
\end{document}
share|improve this question
add comment

1 Answer 1

up vote 10 down vote accepted

You can use ignorespaces

\documentclass{article}

\newenvironment{env}{%
\noindent\ignorespaces%
}{%
}%

\begin{document}
Some text. Some text. Some text. Some text. Some text. Some text.
Some text. Some text. Some text. Some text. Some text. Some text.
Some text. Some text. Some text. Some text. Some text. Some text.

\begin{env}
    First paragraph inside environment.

    Second paragraph inside environment.
\end{env}

\begin{env}%
    First paragraph inside environment.

    Second paragraph inside environment.
\end{env}
\end{document}

enter image description here

share|improve this answer
    
Thank you very much. That was exactly, what I needed. –  leviathan Mar 15 at 14:24
2  
I'd add \par before \noindent. Why is the space (precisely the end-of-line after \begin{env}) not ignored? Because \noindent starts paragraph mode. –  egreg Mar 15 at 14:42
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.