Jump to content

Talk:LaTeX/Floats, Figures and Captions

Page contents not supported in other languages.
Add topic
From Wikibooks, open books for an open world
Latest comment: 7 years ago by Johannes Bo in topic limit on number of floats

Code wrapfloatbox not working

[edit source]

For some strange reason, the code in wrapfloatbox gives me a number of errors, of which the most important seems to be: Missing \begin{document}... Apparently, something goes wrong with the @ symbol, because in the output the text starts with: simplerule[2]fs@cfont 12 simplerules@capt@@simplerule s@iftopcapt

I couldn't find a way around it yet, but in any case it would be nice to make the code self-contained. To run that example, people also have to remember to add the package wrapfig to the preamble.

Text overlapping figures

[edit source]

Can we put a section about how to have a transparent figure legend placed over a full page picture, as this is something I really want to be able to do.

Errors in Wrapping figures

[edit source]

I modified Andy Robert's wrapping.tex according to instructions on additional parameters of wrapping and it did not work. The image was not wrapped, but sticked out of page. I was using latex + dvipdf because pdflatex had problems with .eps file.

If these examples do not work, perhaps, we should remove them? --Derbeth talk 20:14, 2 January 2007 (UTC)Reply

yes, the example you tried didn't work. Now I have fixed everything, improving the article. It should be fine now Alessio Damato 15:29, 12 January 2007 (UTC)Reply
Thanks! --Derbeth talk 12:43, 13 January 2007 (UTC)Reply

PDF's and .tex sources

[edit source]

I removed mention of .tex sources at the end of this chapter. I think that everything has already been used here, but if you want to link them again, see http://www.andy-roberts.net/misc/latex/latextutorial6.html. --Derbeth talk 20:33, 2 January 2007 (UTC)Reply

Aligning Captions

[edit source]

The captions under figures always are in the centre of the page, regardless of where the figure is. How can this be changed? --Munchkinguy 03:49, 5 July 2007 (UTC)Reply

what do you mean exactly? do you want to change the position or the alignment of the captions?? Alessio Damato 15:43, 5 July 2007 (UTC)Reply

Footnotes in Floats

[edit source]

Quite often one (me as well) would like to have footnotes in captions or in the body of a table. For example to explain the variables or the source of the information.

Two information I've found are: for tables: http://www.tex.ac.uk/cgi-bin/texfaq2html?label=footintab for captions: http://www.tex.ac.uk/cgi-bin/texfaq2html?label=ftncapt

The general (but for some reason disliked) solution is to put everything in a minipage. Should we add this to the page?

placeins

[edit source]

We should mention the package placeins [1] somewhere (it "Defines a \FloatBarrier command, beyond which floats may not pass; useful, for example, to ensure all floats for a section appear before the next \section command.")

inside floats, \centering is better than \begin{center} ... \end{center}

[edit source]

We should mention that somewhere. It's documented at, e.g., [2]: "with the combination of figure and center you get a doublespacing before and after, whereas the combination of figure and \centering only gives you the spacing from figure."

p placement specifier

[edit source]

[3]: "...The placement specifier p lets the figure take up a full page without waiting until the end of the chapter". Controlling placement of full-page figures is a very annoying problem for the unexperienced users. Clear explanation of [p] in this document would be very useful.

Subfloats

[edit source]

Hey I just wanted to mention that subfig package overrides the definition of captions for the KOMA-Script package. Since koma is widely used I thought it should be mentioned here too. The remedy to this is to use the subfigure package, which is much more comprehensive and does not overide the KOMA-Script settings. If no body changes this note here, I will edit the main article and add this. Cheers, Oz.

I think that'd be the prober way, Oz. I'm a LaTeX newbie and I got confused since I don't have a subfig package with subfloats, but a subfigure package using subfigures. Otherwise this article is a great resource. Weeeeeeee, Jack. (10:41, 23 March 2010 JackSchnippes)

The subfigure and subfig packaged are NOT under current developement anymore so I would suggest to replace subfig to caption and subcaption

\usepackage{caption}
\usepackage{subcaption}

\begin{figure}
\begin{subfigure}{width}
Picture\caption{Text}
\end{subfigure}
\end{figure}

--Nobelium (discusscontribs) 22:20, 25 September 2011 (UTC)Reply

File:Latex example subfig.png
The shown example picture is quite misleading, as no horizontal spaces between figures are defined in the code itself but are visible in the picture.
141.19.87.180 (discuss)

You're right, so I've tweaked the code to match the image as I don't have the source figures. Also in testing this I noticed that the description in the list below the example didn't seem to be quite right, so I changed it to match the behaviour I can produce here. It didn't 'feel' quite right anyway given the handling of whitespace elsewhere (just in case there could be a difference in implementation I'm using MikTeX 2.9 on Windows XP. ChrisHodgesUK (discusscontribs) 13:43, 29 February 2012 (UTC)Reply
Thanks for your efforts, still I have got one suggestion left: to put "~" into a new line with a comment e. g.
~ %add desired spacing between images, e. g. ~, \quad, \qquad etc.
--Escalator (discusscontribs) 16:14, 5 March 2012 (UTC)Reply
I've done this, with an additional note in the comment about line feeds - feel free to tweak it though - I think you're able to as a new user. ChrisHodgesUK (discusscontribs) 17:18, 6 March 2012 (UTC)Reply
Thanks again :-) You are right, I might edit on my own. But still need some time to learn the right approaches and deepen my beginner´s LaTeX knowledge, thus being rather cautios so far :-) Escalator (discusscontribs) 14:50, 8 March 2012 (UTC)Reply

Changed the subfloat-part according to Nobelium's suggestion. subfig and subfigure are listed as deprecated in the newest (german) version of l2tabu.pdf. -Konteki (discusscontribs) 10:06, 4 May 2012 (UTC)Reply

forgotten [width=\textwidth] on include graphics, because \includegraphics takes a picture size way too big by default and the width must be \textwidth because subfigure is basically a minipage environment and thus \textwidth is already a third of the page's \textwidth Otherwise results in overlapping figures with pdflatex (TexLive 2012 Debian).
\documentclass[a4paper, 11pt]{article}

\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}

\begin{document}
\begin{figure}
        \begin{subfigure}[b]{0.3\textwidth}
                \centering
                \includegraphics[width=\textwidth]{gull}
                \caption{A gull}
                \label{fig:gull}
        \end{subfigure}%
        ~ %add desired spacing between images, e. g. ~, \quad, \qquad etc. 
          %(or a blank line to force the subfigure onto a new line)
        \begin{subfigure}[b]{0.3\textwidth}
                \centering
                \includegraphics[width=\textwidth]{tiger}
                \caption{A tiger}
                \label{fig:tiger}
        \end{subfigure}
        ~ %add desired spacing between images, e. g. ~, \quad, \qquad etc. 
          %(or a blank line to force the subfigure onto a new line)
        \begin{subfigure}[b]{0.3\textwidth}
                \centering
                \includegraphics[width=\textwidth]{mouse}
                \caption{A mouse}
                \label{fig:mouse}
        \end{subfigure}
        \caption{Pictures of animals}\label{fig:animals}
\end{figure}

\end{document}

i just corrected it

Je ne détiens pas la vérité universelle (discusscontribs) 10:07, 16 May 2012 (UTC)Reply

I just wanted to mention that I have had many headaches with the subcaption package. It does not seem to play nicely with a lot of templates for academic journals. For example the templates for the Institute of Physics, and the publisher Springer. Despite being deprecated I find myself dropping back to the subfigure package. I think the incompatibilities need to be addressed before subcaption can be recommended for widespread use, alternatively it should be presented as just one option amongst subfigure and subfig.

the h! specifier

[edit source]

In the examples the h! specifier is often used but it isn't accepted as a good specifier. I admit that it should be explaned but it should'n be used in the example. The way I learned to use specifiers is:

  1. make your document without specifiers
  2. once a chapter is completely written, add the specifier [hb] or [ht] to the figures that aren't placed like you want.
  3. if that doesn't help: use the [h] specifier
  4. as last option, if it's still not looking good, you can use [h!]. But if you have to use [h!] a lot, your document is'n well written and contains to much figures compared to the amount of text.
That feels like a good approach, but the last comment about the ratio of graphics to text isn't necessarily true - it depends what you're writing, a 3 page paper doesn't give you as much flexibility as a book, for example. ChrisHodgesUK (discusscontribs) 10:58, 17 May 2012 (UTC)Reply

auto reorder floats

[edit source]

IS there a way to have LaTeX automatically reorder my float numbers based on the order that I reference them? i.e. if I move a reference to Figure 2 up above the reference for figure 1, can I set it up so that I don't have to move the figure to get it to become figure 1? 128.8.211.123 (discuss) 18:24, 6 October 2011 (UTC)Reply

My picture is not where i want it!

[edit source]

Helpers hear this quite often because users don't know what is going on.
Would it be a good iea to change the title of this page to Automatic placement of figure and table boxes (or something similar) that it becomes really really obvious why figures/tables are moved. Thoughts? The title needs changing anyway since there is no mention of tables right now. --Johannes Bo (discusscontribs) 15:18, 16 October 2016 (UTC)Reply



Waste of time

[edit source]

Sorry guys, but working on this wikibook is a real waste of time. If the starters of this book would have thought a few moments about how to structure it, we wouldn't have duplication of stuff. Why is this float placement stuff discussed TWO times when it should be only once? Why is there a separation between figures and tables on this page? Why x? Why Y? Why Z?

Is anybody even reading this? If so, give a short call out. This thing is driving me completely nuts.--Johannes Bo (discusscontribs) 16:31, 28 October 2016 (UTC)Reply

limit on number of floats

[edit source]

"LaTeX by default can cope with maximum 18 floats" -- this can mislead readers into thinking that their document can't have more than 18 figures. I believe that the limit is only on the number of floats which haven't been placed at any point of time. Please clarify it. Zero0000 (discusscontribs) 04:55, 10 March 2018 (UTC)Reply

The whole page and the whole wikibook needs attention. I slightly mended that part for now. Complete rewrite needed.--Johannes Bo (discusscontribs) 07:43, 10 March 2018 (UTC)Reply