Graphics, Figures & TablesPictures. One below the other

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
krz
Posts: 63
Joined: Thu Jul 22, 2010 5:03 pm

Pictures. One below the other

Post by krz »

Hi!
How do you put one pictures below the other? I tried something like that

Code: Select all

\begin{figure}[!t]
\begin{center}
\fbox{\includegraphics[width=121mm]{pic1.jpg}}
\caption*{\footnotesize\centering{1. blabla.}}
\end{center}
\end{figure}
\begin{figure}[!b]
\begin{center}
\fbox{\includegraphics[width=121mm]{pic2.jpg}}
\caption*{\footnotesize{2. blabla}}
\end{center}
\end{figure}

but it didn't work properly. First picture is in a place that I want it to be (at the top of the page), but the second appears at the bottom but on the next page.
So, I've invented some primitive method like that:

Code: Select all

\begin{figure}[!t]
\begin{center}
\fbox{\includegraphics[width=121mm]{pic1.jpg}}\\
\vspace{-10pt}
\caption*{\footnotesize\centering{1. blabla.}}\\
\vspace{3pt}
\fbox{\includegraphics[width=121mm]{pic2.jpg}}\\
\vspace{-10pt}
\caption*{\footnotesize{2. blabla}}
\end{center}
\end{figure}
It works, but the problem is that the gap between pictures is quite small. As you can see, I tried to obtain some space by using vspace. Unfortunately I can put only 3pt maximum. When I put 4pt or more pictures go at the end of document, eventhough there is enough space on the page.
Is there any way to resolve this problem?
Thanks for any help.
krz
Last edited by krz on Sat Feb 05, 2011 12:26 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Frits
Posts: 169
Joined: Wed Feb 02, 2011 6:02 pm

Pictures. One below the other

Post by Frits »

LaTeX has an inbuilt algorithm that requires that at least 20% of a page is filled with text. That might be the problem in your case.

To change this (for instance to 10%), add the following code to your preamble:

Code: Select all

\renewcommand{\textfraction}{0.1}
Also, LaTeX allows only 70% of the top of a page to be filled with figures. So maybe change this too (90%), just to be sure.

Code: Select all

\renewcommand{\topfraction}{0.9}
howtoTeX.com - Your LaTeX resource site (Tips, Tricks, Templates and more!)
Follow howtoTeX on twitter
krz
Posts: 63
Joined: Thu Jul 22, 2010 5:03 pm

Re: Pictures. One below the other

Post by krz »

Frits, thanks for your answer and new knowledge about LaTeX. I didn't know it has this kind of limitations.
So, I put textfraction and topfraction into my preamble. Thanks to it I could add 4pt and now I have 20pt gap. I tried to change values but there is no difference (I can't exceed 20pt) when I set textraction to 0.1, 0.2, 0.3 or even 0.4 (the same with topfraction). When I set vspace to 21pt, pictures went at the end.
I built very simple document with minimal preample but the problem was the same.
Do you know where is the problem or I have to be happy with this 4pt? Telling the truth it isn't big amount but the page looks better now. It'll do if there is no option.

PS. I've just found this http://mintaka.sdsu.edu/GF/bibliog/latex/floats.html and I'm going to study and try it.
Frits
Posts: 169
Joined: Wed Feb 02, 2011 6:02 pm

Pictures. One below the other

Post by Frits »

I just wrote something about this on my blog: here. It's basically the same as I said before.

Anyway I was just thinking, are the pictures you use related to eachother? In that case you could also use \usepackage{subfig} (google for some more info on that).
howtoTeX.com - Your LaTeX resource site (Tips, Tricks, Templates and more!)
Follow howtoTeX on twitter
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Pictures. One below the other

Post by localghost »

krz wrote:[…] First picture is in a place that I want it to be (at the top of the page), but the second appears at the bottom but on the next page. […]
That shouldn't astound you since you direct LaTeX to do so. Give appropriate placement parameters to your float objects and try again. The code below shows how this could look like.

Code: Select all

\documentclass[11pt,a4paper,english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage{babel}
\usepackage[font=footnotesize,labelfont=bf,tableposition=top]{caption}
\usepackage[demo]{graphicx}
\usepackage{blindtext}

\begin{document}
  \blindtext[4]

  \begin{figure}[!ht]
    \centering
    \fbox{\includegraphics[width=121mm]{pic1.jpg}}
    \caption*{Dummy figure}\label{fig:dummy-1}
  \end{figure}
  \begin{figure}[!ht]
    \centering
    \fbox{\includegraphics[width=121mm]{pic2.jpg}}
    \caption{Dummy figure}\label{fig:dummy-2}
  \end{figure}

  \blindtext[2]
\end{document}
The blindtext package is only for creating dummy text thus not part of the solution. For customization of float captions take a close look at the caption package.

And by the way, please always provide a full example that shows the described problem clearly. Otherwise a problem becomes difficult to comprehend.


Thorsten
krz
Posts: 63
Joined: Thu Jul 22, 2010 5:03 pm

Re: Pictures. One below the other

Post by krz »

Thorsten,
Thanks for your help! I had to change [!ht] in [!hb] in pic2 and it started to work. Unfortunatelly there is a problem when in lower picture caption is too long and takes two lines. In this case picture goes to the bottom of the next page. I resolved it provisionally by using \vspace between graphic and caption. The caption has to be quite close to the picture, but it's much more better than when I didn't have your example.
Ok, I'll show full example next time.

Frits,
Thanks for link. I hope your blog will be mine of knowledge soon. Especially "templates" looks tempting. :)
I was thinking about subfig, but found only side-by-side positioning in its documentation. Do you know if it can resolve my problem?
Frits
Posts: 169
Joined: Wed Feb 02, 2011 6:02 pm

Pictures. One below the other

Post by Frits »

The blog is just online so I'll have to make some time for the templates section 8-) My advice would be to check it regularly!

About the subfig package: Instead of placing figures side by side you can use the linebreak command '\\' to place them underneath eachother:

Code: Select all

\begin{figure}
  \subfloat[Caption pic1]{\label{fig:1}\includegraphics[width=121mm]{pic1.jpg}} \\
  \subfloat[Caption pic2]{\label{fig:2}\includegraphics[width=121mm]{pic2.jpg}}
  \caption{Caption of both figures}
  \label{fig:pics}
\end{figure}
howtoTeX.com - Your LaTeX resource site (Tips, Tricks, Templates and more!)
Follow howtoTeX on twitter
krz
Posts: 63
Joined: Thu Jul 22, 2010 5:03 pm

Re: Pictures. One below the other

Post by krz »

Frits,
Thanks for your help. I've just checked it and it works. I had to add a little modification. I changed \\ in \par. When I use \par I can modify space between picture. Whan I have \\ it doesn't work.
Now I can use your and Thorsten's method. Both are really useful to get what I need.
Post Reply