I'm trying to create a new environment in my LaTeX document where indentation in the next paragraph following the environment is suppressed.
I have been told (TeXbook and LaTeX source) that by setting \everypar
to {\setbox0\lastbox}
, the TeX typesetter will execute this at the beginning of the next paragraph and thus remove the indentation:
\everypar{\setbox0\lastbox}
So this is what I do, but to no effect (following paragraph is still indented):
\newenvironment{example}
{\begin{list}
{}
{\setlength\leftmargin{2em}}}
{\end{list}\everypar{\setbox0\lastbox}}
I have studied LaTeX's internals as well as I could manage. It seems that the \end
routine says \endgroup
and \par
at some point, which may be the reason LaTeX ignores my \everypar
setting. \global
doesn't help either. I know about \noindent
but want to do this automatically.
Example document fragment:
This is paragraph text. This is paragraph text, too.
\begin{example}
\item This is the first item in the list.
\item This is the second item in the list.
\end{example}
This is more paragraph text. I don't want this indented, please.
Internal routines and switches of interest seem to be \@endpetrue
, \@endparenv
and others. Thanks for your help.
LaTeX will automatically indent the first line of each paragraph that doesn't immediately follow a section heading. If you'd like to get rid of an indent, you can use the \noindent command: \section{Introduction} This is the first paragraph. \noindent This is the second paragraph.
Paragraph indentation You can avoid indentation by setting \parindent to 0pt (or 0mm, 0cm etc) or using the command \noindent at the beginning of the paragraph.
Paragraph indentation By default, TeX indents the first line of each paragraphs by 20pt . The \parindent command controls the indentation of paragraphs.
Q4. How Do You Indent a List in LaTeX? You can add additional depth to your list by first using the command \begin{enumerate} and then ending the code with \end{enumerate} for each level. Such LaTeX bullet points show up with different idents to indicate different depths.
I couldn't get anything to work without redefining \end
, but I'm certainly no expert.
The following is quite hacky, but worked in my limited testing. Of course this will interfere with nested environments (you should be able to redefine \begin
to restore the old \end
if you have problems).
\newenvironment{example}{%
\bgroup
\let\oldend=\end
\def\end##1{\oldend{##1}\csname @afterindentfalse\endcsname
\csname @afterheading\endcsname}
\begin{list}{}
{\setlength\leftmargin{2em}}
}{%
\end{list}
\egroup
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With