0

I am a total newbie so I appreciate all your answers as simple as possible. I want to have in my entire document all examples to be "non-floating", it means when I write: The following example shows this: IMAGE

...so I want it to be fixed there, below, centred. Is there any way to make that setting permanent in the header of the document?

  • 6
    Please reconsider this plan. Non-floating graphics will in almost all cases result in very poor typographical results. – samcarter_is_at_topanswers.xyz May 10 '23 at 09:00
  • 3
    you can load the float package and then do \makeatletter \renewcommand*{\fps@figure}{H}\makeatother in the preamble. See also https://tex.stackexchange.com/a/370654/2388 – Ulrike Fischer May 10 '23 at 09:04
  • 3
    I absolutely agree with samcarter_is_at_topanswers.xyz. However, if you don't want the graphics to float, just don't put them in a figure environment. – cabohah May 10 '23 at 09:05
  • 1
    @cabohah the problem with this approach is that you then can't use captions, and yes you can use \captionof, but then you also need a minipage to avoid that a page break interfere, and you also must take care about the correct spacing. Using the float-package and H as float type takes this burdens from you (and has the benefit that if you change your mind it is easy to switch to let the figures float again). – Ulrike Fischer May 10 '23 at 09:12
  • @UlrikeFischer Do you really need a \caption, if you always use "the following example shows"? And without \caption a figure does not make any sense. And with KOMA-Script classes you don't need the float package. Just use the figure- environment. – cabohah May 10 '23 at 09:37
  • @cabohah why should non-float imply that a caption is not needed? At first there is perhaps a list of figures, and even if you refer to the next figure with "see the following example" this doesn't mean that you don't want to refer to another example in another chapter too. – Ulrike Fischer May 10 '23 at 09:57
  • @UlrikeFischer But what about your argument to later decide to float again. Wouldn't this break at least some of the "following" references? And wouldn't it be at least as hard to find all such hard references as to find all the \captionof – maybe even harder? So no, I do not agree, that in such a case float is the better choice. I also do not say, it is the worse choice. I'm just saying, both solutions have their place. And the user has to decide which one is better in the concrete case. – cabohah May 10 '23 at 11:47
  • Don't be discouraged. Yes, what you ask is very possible. The answer below shows you how. Despite the comments about "poor typography" from others, there may be good reasons why you are willing to (possibly) accept extra white area on pages. For example, maybe that would be a place for others to write notes. Also, the image does not have to be centered, if you do not want it that way. – rallg May 10 '23 at 16:20

1 Answers1

4
  • Make yourself more familiar with LaTeX! Read some introductory text about it. For example No so Short Introduction ... or LaTeX for beginners.
  • Latex is not Word, it care for nice typography ...
  • Please, consider comments below question
  • MWE (Minimal Working Example) below show, what can happen, if you not use floats in your document:

enter image description here

(red lines show page layout)

\documentclass{article}
\usepackage{tikz}      % for show images
\usetikzlibrary{ducks} % for show images
\usepackage{caption}

\usepackage{lipsum}

\begin{document} \lipsum[66] \begin{center} \begin{tikzpicture}[scale=4] \duck[glasses=red] \end{tikzpicture} \captionof{figure}{Prof. Duck disagree that his picture not appear in float environment} \end{center} \lipsum[66] \begin{center} \captionof{table}{Prof. Duck also disagree that tables are not in float environment} \begin{tabular}{|c|c|c|c|} \hline \begin{tikzpicture} \duck[graduate, xscale=-1] \end{tikzpicture} & \begin{tikzpicture} \duck[graduate] \end{tikzpicture} & \begin{tikzpicture}[scale=3] \duck[squareglasses] \end{tikzpicture} \ \hline \end{tabular} \end{center} \lipsum[1-4] \end{document}

Similar result you will get if you will use floats with [H] options:

\documentclass{article}
\usepackage{tikz}      % for show images
\usetikzlibrary{ducks} % for show images
\usepackage{caption}
\usepackage{float}     % for removing floating of floats

\usepackage{lipsum}

\begin{document} \lipsum[66] \begin{figure}[H] % <--- \centering \begin{tikzpicture}[scale=4] \duck[glasses=red] \end{tikzpicture} \caption{Prof. Duck disagree that his picture not appear in float environment} \end{figure} \lipsum[66] \begin{table}[H] % <--- \centering \caption{Prof. Duck also disagree that tables are not in float environment} \begin{tabular}{|c|c|c|c|} \hline \begin{tikzpicture} \duck[graduate, xscale=-1] \end{tikzpicture} & \begin{tikzpicture} \duck[graduate] \end{tikzpicture} & \begin{tikzpicture}[scale=3] \duck[squareglasses] \end{tikzpicture} \ \hline \end{tabular} \end{table} \lipsum[1-4] \end{document}

enter image description here

At both example observe empty space at bottom of the first page!

Zarko
  • 296,517