Graphics, Figures & TablesLaTeX grouping tables and images on its own

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
Ciro
Posts: 6
Joined: Mon Oct 03, 2016 11:53 am

LaTeX grouping tables and images on its own

Post by Ciro »

Hi everyone, this is my first post to this forum. I have the below code. It's supposed to display five images, one table, another five images and another table. For some reason LaTeX displays first the images (all 10 of them) and then the two tables. The only way i can work around this is by spreading them in two pages, then they are displayed properly, but I want them to appear in the same page. Is there a reaosn why LaTeX is joining them by its own?

Code: Select all

\documentclass[a4paper,10pt]{memoir}
\documentclass[a4paper,10pt]{scrartcl}

\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{booktabs}
\usepackage{longtable}
\usepackage{graphicx}
\usepackage{fix-cm}
\usepackage[font=scriptsize]{caption}
\usepackage[margin=0.5in]{geometry}
\usepackage[normalem]{ulem}
\graphicspath{ {images/} }

\setlength{\tabcolsep}{2pt}

\begin{document}

\begin{figure}[!tbp]
\noindent\rule{18.9cm}{0.1pt}
\newline
\hspace{10em}\uline{\textsc{Group1}\hfill}
\break \break \break
\hfill
\begin{minipage}[b]{0.18\textwidth}
\includegraphics[width=\textwidth]{img1}
\caption*{img1}
\end{minipage}
\hfill
\begin{minipage}[b]{0.18\textwidth}
\includegraphics[width=\textwidth]{img2}
\caption*{img2}
\end{minipage}
\hfill
\begin{minipage}[b]{0.18\textwidth}
\includegraphics[width=\textwidth]{img3}
\caption*{img3}
\end{minipage}
\hfill
\begin{minipage}[b]{0.18\textwidth}
\includegraphics[width=\textwidth]{img4}
\caption*{img4}
\end{minipage}
\hfill
\begin{minipage}[b]{0.18\textwidth}
\includegraphics[width=\textwidth]{img5}
\caption*{img5}
\end{minipage}
\end{figure}
\begin{table}[ht]
\miniscule
\caption*{Group1}
\hspace*{-.5cm}
\scalebox{0.9}{
\begin{tabular}{p{2.5cm}p{1.2cm}p{1.2cm}p{1.2cm}p{1.2cm}p{1.2cm}p{1.2cm}p{1.2cm}p{1.2cm}p{1.2cm}p{1.2cm}p{1.2cm}p{1.2cm}p{1.2cm}p{1.2cm}p{1.2cm}}
\toprule
\field1 & \field2 & field3 & field4 & \textbf{6M} &  \textbf{3M}&  \textbf{1W} &  \textbf{5} &  \textbf{6} & \textbf{7} & \textbf{8} & \textbf{ROE} & \textbf{9} & \textbf{10} & \textbf{1} \\
\midrule
Estee & 88.56 & -9.14 & 8.13 & -5.08 & .19 & 1.32 & 33,068 & 29.93 & 1.36 & 19.23 & 30.90 & N/A & N/A & N/A
\\
\midrule
\end{tabular}}
\end{table}

\begin{figure}[!tbp]
\noindent\rule{18.9cm}{0.1pt}
\newline
\hspace{10em}\uline{\textsc{Group2}\hfill}
\break \break \break
\hfill
\begin{minipage}[b]{0.18\textwidth}
\includegraphics[width=\textwidth]{img6}
\caption*{img6}
\end{minipage}
\hfill
\begin{minipage}[b]{0.18\textwidth}
\includegraphics[width=\textwidth]{img7}
\caption*{img7}
\end{minipage}
\hfill
\begin{minipage}[b]{0.18\textwidth}
\includegraphics[width=\textwidth]{img8}
\caption*{img8}
\end{minipage}
\hfill
\begin{minipage}[b]{0.18\textwidth}
\includegraphics[width=\textwidth]{img9}
\caption*{img9}
\end{minipage}
\hfill
\begin{minipage}[b]{0.18\textwidth}
\includegraphics[width=\textwidth]{img10}
\caption*{img10}
\end{minipage}
\end{figure}
\begin{table}[ht]
\miniscule
\caption*{Group2}
\hspace*{-.5cm}
\scalebox{0.9}{
\begin{tabular}{p{2.5cm}p{1.2cm}p{1.2cm}p{1.2cm}p{1.2cm}p{1.2cm}p{1.2cm}p{1.2cm}p{1.2cm}p{1.2cm}p{1.2cm}p{1.2cm}p{1.2cm}p{1.2cm}p{1.2cm}p{1.2cm}}
\toprule
\field1 & \field2 & field3 & field4 & \textbf{6M} &  \textbf{3M}&  \textbf{1W} &  \textbf{5} &  \textbf{6} & \textbf{7} & \textbf{8} & \textbf{ROE} & \textbf{9} & \textbf{10} & \textbf{1} \\
\midrule
test & 155.26 & -40.39 & -27.10 & -16.73 & -5.89 & 2.32 & 1,975 & 23.33 & -- & 19.90 & 18.98 & N/A & N/A & N/A
\\
\midrule
test & 47.44 & -13.04 & -5.30 & -2.18 & .47 & 1.91 & 19,224 & 18.09 & 1.43 & 35.31 & 69.54 & N/A & N/A & N/A
\\
\midrule
Constellation & 166.49 & -1.29 & 28.07 & 10.61 & 7.77 & 1.43 & 33,963 & 33.42 & 0.96 & 32.81 & 17.74 & N/A & N/A & N/A
\\
\midrule
\end{tabular}}
\end{table}

\end{document}
Last edited by Stefan Kottwitz on Mon Oct 03, 2016 12:21 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.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Stefan Kottwitz
Site Admin
Posts: 10324
Joined: Mon Mar 10, 2008 9:44 pm

LaTeX grouping tables and images on its own

Post by Stefan Kottwitz »

Hi Ciro,

welcome to the forum!

The figures were allowed to float to the top or to the bottom or to a page on their own (options tbp), but they were not allowed to be placed right here as in the code (option h). Simply add the h option for figures.

\begin{figure}[!htbp]

Stefan
LaTeX.org admin
Ciro
Posts: 6
Joined: Mon Oct 03, 2016 11:53 am

Re: LaTeX grouping tables and images on its own

Post by Ciro »

Thanks Stefan, that's exactly what I needed. I removed the floating option but they appeared too separated from each other. Now it looks exactly as intended.

Thanks again,

Ciro
Ciro
Posts: 6
Joined: Mon Oct 03, 2016 11:53 am

Re: LaTeX grouping tables and images on its own

Post by Ciro »

Hi,

I'm running into another issue. I want to add a new figure and table in the same page (there's plenty of space left), if I add it LaTeX will place the figure in the same page but the table in the next, leaving a huge gap at the bottom of the page, where the table could be easily placed.

I've tried to change the "topnumber" "bottomnumber" and "totlanumber" parameters to allow for more floats to no avail. is there any way to achieve this?

Please let me know if I need to create a new topic for this.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10324
Joined: Mon Mar 10, 2008 9:44 pm

LaTeX grouping tables and images on its own

Post by Stefan Kottwitz »

Hi Ciro!
Ciro wrote:Please let me know if I need to create a new topic for this.
This would be very good! One problem, one topic. So you reach all readers again with a new topic, besides just me.

You made a very good example above for the original problem. If you would post a new topic with such good code again, a solution would be guaranteed. In my experience, with real code I can solve most problems in a few minutes, once I could test it. Same for others too. That's a benefit of LaTeX: code describes a problem perfectly, a bit of code is the solution. No "click on this, then click on that" :-)

Stefan
LaTeX.org admin
Ciro
Posts: 6
Joined: Mon Oct 03, 2016 11:53 am

Re: LaTeX grouping tables and images on its own

Post by Ciro »

Thanks Stefan, I've opened a new topic on this.
Post Reply