Graphics, Figures & Tablesfigure inside tabular

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
alex.blackbit
Posts: 13
Joined: Tue Aug 26, 2008 9:01 pm

figure inside tabular

Post by alex.blackbit »

hi,

i have several blocks like this:

Code: Select all

\begin{figure}[h!]
        \includegraphics[width=0.3\textwidth]{images/Logo}
        \caption{Logo}
\end{figure}
these should be placed in a normal tabular environment, but it seems i don't know how to do that right.
i tried:

Code: Select all

\begin{tabular}{c}
\begin{figure}[h!]
        \includegraphics[width=0.3\textwidth]{images/GSMLogo}
        \caption{GSM Logo}
\end{figure} \\
\end{tabular}
but this ends in:

Code: Select all

! LaTeX Error: Not in outer par mode.
...
l.8 \begin{figure}[h!]
what do i do wrong ?
thanks in advance for the help.

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

yoyoimut
Posts: 120
Joined: Mon Oct 19, 2009 6:58 am

figure inside tabular

Post by yoyoimut »

I think floating environment like figure cannot be put inside tabular.

Lets try the following code, it might be what you need. :D

I also suggest you to use longtable instead of tabular. Longtable can be split across page, you know?

Code: Select all

\documentclass{book}
\usepackage[draft]{graphicx}
\usepackage{array,longtable}

\begin{document}
\newcolumntype{A}{>{\begin{minipage}[c][7cm][c]{6cm}\centering\arraybackslash}m{6cm}<{\end{minipage}}}
\begin{longtable}{|A|c|c|}\hline
\fbox{\includegraphics[height=4.5cm]{sample}} & sample.eps 					& something\\\hline
\rule{4cm}{4cm} 															& rule of 4cm by 4cm 	& something \\\hline
\end{longtable}
\end{document}
php1ic
Posts: 192
Joined: Wed Jan 28, 2009 8:17 pm

figure inside tabular

Post by php1ic »

If you are using the tabular environment to have multiple figures arranged on a page, try using the subfig package instead.

Code: Select all

\documentclass[a4paper]{article}
\usepackage{subfig}
\usepackage{graphicx}
\begin{document}
\begin{figure}[htbp]
\centering
\subfloat{\includegraphics[width=0.45\textwidth]{fig1}}\hfill
\subfloat{\includegraphics[width=0.47\textwidth]{fig2}}\\
\subfloat{\includegraphics[width=0.45\textwidth]{fig3}}\hfill
\subfloat{\includegraphics[width=0.47\textwidth]{fig4}}
\caption{An array of figures}
\label{figs}
\end{figure}
\end{document}
Post Reply