1

I am using evironments to typeset some paragraphs of text with different fonts. I want the first paragraph after \begin{environment} to have no indentation. My code is

 \newenvironment{aut}{\par}{\par}
 \AtBeginEnvironment{aut}{\vspace{\baselineskip}\fontfamily{pzc}\selectfont \par\noindent}

This doesn't have the desired effect, since the first paragraph is indented.

I also tried

    \newenvironment{aut}{\par}{\par}
\AtBeginEnvironment{aut}{\vspace{\baselineskip}\fontfamily{pzc}\selectfont\par\parindent0pt}

but this sets the indent to zero for ALL paragraphs inside the environment, whereas I only want the first paragraph to have no indentation. Any suggestions? Thanks in advance!

  • Why don't you just put the code in the definition? You don't need \AtBeginEnvironment here. But please post a working example rather than fragments. I would say that the order in which things are being done is not the one you are counting on and not confusing things with \AtBeginEnvironment will solve the problem. But, as I can't test, obviously that's a guess. – cfr Dec 11 '15 at 1:54
2

enter image description here

It is best to avoid \noindent as it can easily have bad effects if there are blank lines in your source. A list environment allows for specification of variant indents:

\documentclass{article}
\newenvironment{abc}
{\list{}{%
\leftmargin0pt
\itemindent0pt
\listparindent15pt
}\item\relax}{\endlist}
\begin{document}

\noindent X\dotfill X

\begin{abc}
One two three four five one two three four five 
One two three four five one two three four five 
One two three four five one two three four five 

Red yellow green blue red yellow green blue
Red yellow green blue red yellow green blue
Red yellow green blue red yellow green blue
\end{abc}

\begin{abc}
One two three four five one two three four five 
One two three four five one two three four five 
One two three four five one two three four five 

Red yellow green blue red yellow green blue
Red yellow green blue red yellow green blue
Red yellow green blue red yellow green blue
\end{abc}

\end{document}
1

Based on your approach:

\documentclass{article}
    \usepackage{etoolbox}% needed for \AtBeginEnvironment
    \usepackage{lipsum}
\newenvironment{aut}{\par\hspace*{-\parindent}}{\par}
\AtBeginEnvironment{aut}{\vspace{\baselineskip}\fontfamily{pzc}\selectfont\par} 
\AtEndEnvironment{aut}{\vspace{\baselineskip}}
    \begin{document}
 \lipsum[2]

\begin{aut}\bfseries
    \lipsum[1-2]
\end{aut}
\lipsum[2]
    \end{document}

enter image description here

As cfr said in her comment, you can put content of \AtBeginEnvironment as well \AtEndEnvironment (added by me) into your environment definition.

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.