# Supressing indent on the following paragraph

I have made a environment that formats some example text in a box that sets it apart from the main text of the book. It becomes a sort of a figure that the other text refers to. There is plenty of white space around it. Because of the white space, there is no need for the paragraph that follows it to be indented. Is there a command that I can place inside this environment definition that suppresses the indent on the following paragraph, and only the following paragraph.

Here is the definition of the environment:

\newenvironment{urlstyle}
{\begin{center}
\begin{tabular}{|p{0.9\textwidth}|}
\hline\\
\ttfamily
}
{
\\\\\hline
\end{tabular}
\end{center}
}


And the body of the document might use this like this:

Sample text of a paragraph before the URL is mentioned in the code.

\begin{urlstyle}
/api/t=\{tenant\}/a=\{app\}/
\end{urlstyle}

Here is a description of what this URL does.  Because of the
space around the URL in a box, I do not want this paragraph
to be indented.

But this later paragraph should be indented because it follows directly
after the preceding one, without a blank line and that needs
an indent.


I can, of course, put \noindent into the paragraph that follows, but I would prefer to have this be built into the environment command so that I can guarantee that it is consistent throughout the book without requiring tedious checking of every time I use the URL environment. I tried putting \noindent at the end of the environment defintion, but that does not work, because it can not effect the following paragraph. You have to put \noindent inside the paragraph you want to effect.

Headings and subheadings work great this way. Somehow, they suppress the indent on the following paragraph (the first paragraph in the section). Is there any command that says: I want the paragraph that follows this one to be treated like the first paragraph in a block of paragraphs?

• You're creating the new paragraph by inserting the empty line. Remove the empty line and the next line will not be indented. – A.Ellett Apr 3 '16 at 18:39
• latex environments such as center go to some lengths to preserve the meaning of teh blank line, if there is a blank line before or after center teh following paragraph is indented, if there is no blank line it is treated as a continuation and not indented, matching the behaviour of display math. It would be best to preserve this behaviour. But if not use the internal command \@afterheading which is what section headings use – David Carlisle Apr 3 '16 at 20:37
• I really do want a new paragraph. When the section header is placed, the NEXT PARAGRAPH appears without an indent. That is exactly the behavior I want. I really do want a new paragraph there, I just don't want it to have an indent, the same way the first paragraph after header does not have an indent. I want the indent ONLY when a test paragraph follow another text paragraph. The purpose of the indent is only to make it clear that a new paragraph is starting, and that is ambiguous only when following another text paragraph. practicaltypography.com/first-line-indents.html – AgilePro Aug 22 '18 at 23:53

You've only provided us with a snippet of code. So, I can only guess at what sort of complications might be arising. However, below I've created a MWE that makes no particular assumptions about what packages you use. (Obviously I had to assume a class to use.)

You're creating the indentation by leaving the empty line there. An empty line signals a new paragraph. Either remove the empty line, or, if visually you want the break, comment out the empty lines as below:

\documentclass{article}

\newenvironment{urlstyle}
{\begin{center}
\begin{tabular}{|p{0.9\textwidth}|}
\hline\\
\ttfamily
}
{
\\\\\hline
\end{tabular}
\end{center}
\aftergroup\ignorespaces
}

\pagestyle{empty}
\begin{document}

Sample text of a paragraph before the URL is mentioned in the code.
%%
\begin{urlstyle}
/api/t=\{tenant\}/a=\{app\}/
\end{urlstyle}
%%
Here is a description of what this URL does.  Because of the
space around the URL in a box, I do not want this paragraph
to be indented.

But this later paragraph should be indented because it follows directly
after the preceding one, without a blank line and that needs
an indent.

\end{document}


• What I want after the box is technically a new paragraph. I think what you are suggesting is to treat the following text as a continuation of the paragraph that contains the table. (Pardon if I am using LaTeX lingo incorrectly -- still learning.) That seems to work, it is better than putting \noindent at the beginning, but it still means I have to write this paragraph in a special way to get the format right. Unsure how general this is. I want to use this for a couple of other things (figures, floats). Headings seem to do this automatically. Wish I could do exactly that. – AgilePro Apr 3 '16 at 20:36
• I suppose you could do some kind of trick involving temporarily redefining \par, but that could lead to all sorts of unexpected surprises. – A.Ellett Apr 3 '16 at 20:55

The headings all call \@afterheading to control a following indent but it needs a bit of help to lift settings out of the environment (as all headings commands are currently commands not environments).

\documentclass{article}

\makeatletter
\newenvironment{urlstyle}
{\par
\begin{center}%
\begin{tabular}{|p{0.9\textwidth}|}%
\hline\\%
\ttfamily
}
{
\\\\\hline
\end{tabular}%
\end{center}%
\par
\everypar{}%
\aftergroup\@nobreaktrue
\aftergroup\global\aftergroup\@afterindentfalse
\ignorespacesafterend
}
%\makeatother

\pagestyle{empty}
\begin{document}

Sample text of a paragraph before the URL is mentioned in the code.

\begin{urlstyle}
/api/t=\{tenant\}/a=\{app\}/
\end{urlstyle}

Here is a description of what this URL does.  Because of the
space around the URL in a box, I do not want this paragraph
to be indented.

But this later paragraph should be indented because it follows directly
after the preceding one, without a blank line and that needs
an indent.

\end{document}