15

I am typesetting a manual, that uses normal indentation for paragraphs. The pages have a lot of figures and tables and I would like to have the paragraph after tables and figures to have no indentation. Currently I just use \noindent, but I am sure there is an easier way?

Can anyone explain how this is achieved after sections? It might give me a pointer as to how to write a macro to do this.

lockstep
  • 250,273
yannisl
  • 117,160
  • 8
    I am not quite sure what you are trying to do. Are you including figures and tables using the standard LaTeX mechanism as floats? In that case, you will not know where the figure will end up. Are you trying to make LaTeX, every time it automatically inserts a figure right before a paragraph, to not indent the paragraph? How are you going to distinguish between a situation where there is a figure at the top of the page and a paragraph starts right after it, and a situation where the paragraph continues from the previous page? – Jan Hlavacek Sep 01 '10 at 17:08
  • I understand the almost impossible request (due to the floating mechanism). I am trying to make any paragraphs that start after a table or figure to have no first line indentation. After all TeX is Turing complete, there must be a way to do it! – yannisl Sep 01 '10 at 19:04
  • Why would you want to do this? (The question is neither sarcastic, nor rhetorical.) As @Jan says, without the indent, how is the reader to distinguish a paragraph that begins right after a figure from a paragraph that LaTeX interrupts with a figure and where, by chance, the first post-figure line of the continuing paragraph happens to also start a sentence? – vanden Sep 01 '10 at 21:30
  • I don't know about if not indenting text is typographically correct when using floats, but I do find irritating that any paragraph right after a quotation environment (specially if it has left and right margin) is indented. – Hugo Sereno Ferreira Sep 02 '10 at 01:19
  • @Yiannis: I am sure it is possible to that in TeX. You can always write your own page building and float placing algorithm that will do things that way. On the other hand, if you want to take advantage of LaTeX's float mechanism, you may have pretty hard time getting it work the way you want. You will have to hook pretty deep into LaTeX internals and change the way things work in there. – Jan Hlavacek Sep 02 '10 at 02:08
  • 1
    Hugo, if you don't want an indent after a quote/quotation environment then don't put an empty line or a \par command after \end{quote}/\end{quotation}. – Ulrike Fischer Sep 02 '10 at 07:44
  • 2
    A quick workaround is to add a % to the line separating the figure from the following text, to ensure that the text after the figure does not start a new paragraph. – András Salamon Sep 02 '10 at 08:30
  • Note that @AndrásSalamon’s suggestion could be misleading: if you say, for instance, ...text before.%\begin{figure}...\end{figure}%Text after..., where stands for a newline in your source file, LaTeX will typeset “…text before. Text after…” in a single paragraph, with “…text before.” and “Text after…” separated merely by an interword space. – GuM Mar 19 '17 at 02:08
  • I’m going to find a way to have TeX make coffee for me: after all, it’s Turing complete, there must be a way to do it! (@YiannisLazarides: please don’t take this amiss, it’s just a silly joke! ;-) – GuM Mar 19 '17 at 02:15

4 Answers4

10

You asked how it is done for sections: \section uses \@afterheading which puts code in \everypar so that it suppress the indentation in the first paragraph and then reset its own content to empty for the following paragraphs. The LaTeX kernel also has a \@doendpe command which is e.g. used by lists to suppress the indentation after the list if there is no empty line/\par following. Here two examples how you could use this code yourself (but I doubt that they can be used in the case of real floats.)

 \documentclass{article}
 \usepackage{lipsum}

 \makeatletter
 %Variant 1:
 \newif\ifafterpar
 \newcommand\afterparnoindent{%
   \afterpartrue
   \everypar{%
     \ifafterpar
       \afterparfalse
       {\setbox\z@\lastbox}%
     \else
       \everypar{}%
     \fi}}

 %Variant 2:
 % will suppress indentation if there is no
 % empty line behind \afterparnoindent
 %\renewcommand\afterparnoindent{\par\@doendpe}
 \makeatother
 \begin{document}

 \lipsum[1]

 abc\afterparnoindent

 first paragraph \lipsum[1]

 the next \lipsum[1]

 \end{document}
Sveinung
  • 20,355
Ulrike Fischer
  • 327,261
5

In any 'normal' application of TeX, the main text and the float boxes are both created independently before they are combined to create actual pages. So by the time it is known where the floats will go on the final combined page, the body text paragraphs have already been typeset, and there is no way to re-indent them.

So unless you only use 'here' floats, manual \noindent is the way to go for floats.

For 'here' floats, section heads and display blocks like quotations it is possible to do this programmatically. I know that this is possible in principle because ConTeXt does it, but I do not know whether there is a LaTeX package or configuration option for such cases.

Taco Hoekwater
  • 13,724
  • 43
  • 67
  • 5
    My brain baulks even considering an algorithm in which TeX goes back and retypesets the paragraphs after floats have been inserted :) – Will Robertson Sep 02 '10 at 09:23
  • Wouldn't it be possible to typeset each paragraph twice, with and without indentation, save the various boxes, and then choose between the two versions when putting floats and text together? (Yes, it is a crazy idea :).) – Bruno Le Floch Jan 02 '11 at 09:43
  • @Bruno Theoretically: yes, but you would end up having to do your own page breaking completely, as the version with and without the indentation could have different number of lines. Combined with the need to update marks etc., that would soon become a major project. – Taco Hoekwater Jan 03 '11 at 09:09
  • The paragraph with no indentation will be shorter, so it could be possible to replace the indented paragraph by the non-indented one once the pagebreak is fixed, then add glue between every line to accomodate for the reduction in the size of the paragraph. Well, if someone is crazy... – Bruno Le Floch Jan 03 '11 at 14:09
1

This is similar to the question Suppress indentation after environment in LaTeX.

The first answer there works for quotations, and may contribute to a good answer for tables and figures that do NOT float around (ie, placed directly into the text rather than inside a float environment).

0

I'm not sure what you are looking for, but have you tried to use parskip?

\usepackage[parfill]{parskip}
Johan
  • 2,204