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 a total newbie to LaTeX and I get very annoyed about this. Every time I write an equation, the text following the equation has some indentation but I don't want it to be there!

Look at the following formula

\begin{equation}
K_BT_k=Dexp\left\lbrace -\frac{1}{2N(E_F)|J|}\right\rbrace
\end{equation}

where $Dexp$ is a ...

The line starting with "where ..." is indented and looks horrible. Some people told me about \noindent but do I really have to write this command after every single equation?

share|improve this question
    
This question just popped up for some reason and I did a double take to see who asked it. It's amazing that Juan literally started out with LaTeX here three years ago and has got so much reputation since then. –  Ryan Reich Jun 2 '13 at 3:58
    
Thanks @RyanReich :) Although for full disclaimer, I was actually pretending to be a novice user when I wrote this question. I was very involved with the site at the beginning, from area51 and through the early beta. –  Juan A. Navarro Jun 3 '13 at 9:52
    
I knew something was wrong! You are apparently a good actor as well :P –  Ryan Reich Jun 3 '13 at 14:11
add comment

4 Answers

up vote 42 down vote accepted

Remove the blank lines, either by actually removing them or adding '%'s:

Look at the following formula
%
\begin{equation}
K_BT_k=Dexp\left\lbrace -\frac{1}{2N(E_F)|J|}\right\rbrace
\end{equation}
%
where $Dexp$ is a long sentence guaranteed to take us over the
end of this line and well into the next.

Simple, but subtle!

Explanation: (added in edit)

The indentation is created by the fact that, as far as TeX is concerned, the word 'where' begins a new paragraph and you've decided that new paragraphs should be indented (or rather, you haven't decided that new paragraphs shouldn't be indented). TeX detects this by the presence of the blank line (well, actually by the double newline, but what it considers a double newline is a little complicated so "blank line" is best for now). So to tell TeX that there isn't a new paragraph there, I simply remove the blank line. As I like to keep my source code with lots of visual spaces between things, I do this by putting the comment marker '%' on the blank line. Deleting it (as in Caramdir's answer) would be equivalent as far as TeX is concerned. In fact (as Caramdir pointed out in his answer), both the blank line before and after should be removed. As originally written, there are three paragraphs where there should (according to the wording) be just one. Although the fact that the equation starts a new paragraph is less obvious, it still can have an effect.

Note that although it may have almost the same effect, using the \noindent command here would be wrong. Using \noindent says "This is a new paragraph, but I don't want it indented." whereas putting in the % says "This isn't a new paragraph.".

share|improve this answer
1  
Could you explain why?? I'm a total newbie!! –  Juan A. Navarro Jul 29 '10 at 11:36
1  
The space you have after the \end{equation} signals a new paragraph (that's what empty lines mean.) Commenting out the empty line (with a % means that effectively there is no empty line, but visually you still get the separation that you seem to want in the source between the equation environment and the rest of the text. –  Yossi Farjoun Jul 29 '10 at 11:39
1  
@Juan A. Navarro: Caramdir suggests removing the line before as well. I agree (well, I'd put in the comment character) as it's all syntactically the same paragraph; I was concentrating on the afterwards and missed the before. –  Andrew Stacey Jul 29 '10 at 11:45
2  
Explanation for removing the empty line above the equation: spacing. Try compiling Look at \begin{equation} a \end{equation} with and without an empty line. –  Caramdir Jul 29 '10 at 11:54
    
This answer has helped with a similar situation when using \foreignblockquote of the package csquotes. –  ischeriad Aug 24 '11 at 18:08
show 1 more comment

Just remove the empty lines before and after the equation.

share|improve this answer
2  
But you got the "before" as well so +1. –  Andrew Stacey Jul 29 '10 at 11:45
4  
+1 I just hate using comments for anything more than commenting. –  mbq Jul 29 '10 at 13:29
1  
why? why should I remove those empty lines? could you elaborate? I insist because this answer is getting a lot of votes, but I don't think it answers the question see meta.tex.stackexchange.com/questions/172/… –  Juan A. Navarro Jul 30 '10 at 5:42
1  
@Juan I'll try; in (La)Tex not all whitespaces are ignored; one or more empty lines form "begin new paragraph" command. So you can just not write it, as in this solution, or comment out this command writing % in the empty line as in Andrew's solution. (Which IMO is a bad practice, still just works.) –  mbq Jul 30 '10 at 6:01
3  
@mbq: With most languages, I'd agree with you. I hope, though, that you'd agree that the decision on how much to spread out ones code is largely a matter of personal taste. I find that grouping and separating things helps me understand my own source code and that blank lines are visually the easiest way for me to do this. However, since blank lines have special meaning in LaTeX, the equivalent in LaTeX of a blank line in, say, a perl script is a line beginning with a %. So, for me, a line with just a percent character on it is not a comment line. –  Andrew Stacey Jul 30 '10 at 9:41
show 5 more comments

For comparision, in ConTeXt, the relation between blank lines in input and indentation in output can be controlled using the indentnext key. For example, if you set

\setupformula[indentnext=no]

then, there is no indent after an equation (irrespective of whether the input has blank lines or not). Similarly, if you set

\setupformula[indentnext=yes]

then th next line is always indented. To get the default LaTeX-like behavior (indent if the input has blank line), usé

\setupformula[indentnext=auto]

The same logic works for other environments like descriptions, itemize, enumerate, etc.

share|improve this answer
add comment

I always put a

\setlength{\parindent}{0pt}

in the preamble of the document (i.e. before \begin{document}). Of course, then all indentations are supressed and if you want something to be indented, you have to do this manually.

share|improve this answer
7  
Using the parskip package (rather than setting the lengths \parskip and/or \parindent separately) is sometimes preferred. –  Werner Jun 7 '12 at 17:03
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.