TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using the common approach of having indentations for new paragraphs and no indentation directly after a headline. I have an environment for 'information boxes' defined like this:

\textbf{Box~\thesectionbox #1: #2
\vspace{0.1cm} \hrule \vspace{0.1cm}}\rmfamily}
{\medskip \end{shaded}}

The problem is that I don't want indentation at the beginning of these boxes -- they have a headline and hence they shouldn't have an indentation...

I have tried with \noindent but that isn't the right way since it only works when placed directly before the text which is to not be indented and the user of the environment might start with an empty line...

Google brought me to this page but their suggestion "\@afterindentfalse" is apparantly not something I can use since I am in the wrong mode as LaTeX pointed out to me: You can't use `\spacefactor' in internal vertical mode.

So, what can I use (that fixes this)?

share|improve this question
up vote 7 down vote accepted

How'bout using \noindent\ignorespaces? See http://en.wikibooks.org/wiki/LaTeX/Customizing_LaTeX#Extra_space

If you use the following


it will solve the problem of the first line being indented. But all endline characters in your environment will be gobbled, so you can't have paragraphs the usual way inside the environment.

Another option would be to use a trivial list (stolen from amsthm's proof environment)


which should, I think, do what you want, provided it plays well with the shaded environment. Whether either of this is suitable depends on your needs, of course.

share|improve this answer
Looks like something that should work but I can't get it to work... :( – jonalv Oct 12 '10 at 12:10
I am beginning to think that <code>\ignorespaces</code> only ignores spaces and not newlines. At least that is my feeling for the moment... – jonalv Oct 12 '10 at 12:40
Ah. You want to trim newlines too. Answer modified to reflect that. – Willie Wong Oct 12 '10 at 13:17

Didn't the stackoverflow answer you referred to suggset using \@afterindentfalse \@afterheading ? Using just the former won't work. \@afterheading uses the \everypar token register to remove indentation at the first paragraph, when \@if@afterindent is false.

(I would have made this a comment to your comment to Ulrike's answer, but I haven't got the rep to comment yet.)

share|improve this answer
Ah yea that's it. – jonalv Oct 14 '10 at 8:31

\@afterindentfalse contains a @, so you should make @ a letter before your definition. \makeatletter\newenvironment ...


share|improve this answer
Hm yea now it accepts the command. However it still indents... :( – jonalv Oct 12 '10 at 12:41
Well after I completed your example by loading the necessary class and packages, defining the counter and the color, correcting the typos in your code snippet and writing a small document body (which means that you would get much better answers if you would show complete minimal examples directly) I could suppress the indent without problem with ... \rmfamily\@afterindentfalse\@afterheading. – Ulrike Fischer Oct 13 '10 at 7:32
Oh so the trick was that \@afterindentfalse only works if followed by \@afterheading. This actually works even better because the trivlist created some extra vertical space. However I have started to like that space so I think I will keep that solution. Anyway thanks for teaching me how to make that command work! – jonalv Oct 14 '10 at 8:30

Your Answer


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.