Graphics, Figures & TablesPut figures and tables in columns

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
hans
Posts: 4
Joined: Wed Apr 28, 2010 11:40 am

Put figures and tables in columns

Post by hans »

Hi all,

I'm looking for a solution to following problem:

I'm working in a multicols environment(2 columns) and I want to keep some figures and tables absolutely in this environment! So in other words: let's say I'm in the second column and I want to add a figure there, how can I do this without having to put my figure over the whole width of the page, but only in the specified column?

Cheers

Hans

Recommended reading 2024:

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

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

User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Put figures and tables in columns

Post by gmedina »

Hi Hans,
package description wrote: ...furthermore, there is no provision for single column floats inside a multicolumn environment, so figures and tables must be coded in-line (using, for example, the H modifier of the float package).
So, you have (at least) the following options:

a) Use the H placement specifier provided by the float package (as suggested in the quoted text):

Code: Select all

\documentclass{article}
\usepackage{multicol}
\usepackage{float}
\usepackage{lipsum}% just to generate filler text for the example

\begin{document}

\lipsum[1]
\begin{multicols}{2}
\lipsum[1] 
\begin{table}[H]
  \centering
  \begin{tabular}{cc}
  column1a & column2a\\
  column1b & column2b
  \end{tabular}
  \caption{test table.}
  \label{tab:test}
\end{table}
text text text
\end{multicols}

\end{document}
b) Use the \captionof command provided by the caption package and drop the floating environments (table or figure):

Code: Select all

\documentclass{article}
\usepackage{multicol}
\usepackage{caption}
\usepackage{lipsum}% just to generate filler text for the example

\begin{document}

\lipsum[1]
\begin{multicols}{2}
\lipsum[1] 
{\centering
\begin{tabular}{cc}
  column1a & column2a\\
  column1b & column2b
\end{tabular}
\captionof{table}{test table.}
\label{tab:test}
}
text text text
\end{multicols}

\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Put figures and tables in columns

Post by localghost »

It's also possible without float environments.

Code: Select all

\documentclass[11pt,a4paper,twocolumn,english]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage[font=small,labelfont=bf,tableposition=top]{caption}
\usepackage{blindtext}

\begin{document}
  \blindtext

  \begin{center}
    \rule{0.75\linewidth}{0.5\linewidth}
    \captionof{figure}{Dummy figure}\label{fig:dummy}
  \end{center}

  \blindtext[2]

  \begin{center}
    \captionof{table}{Dummy table}\label{tab:dummy}
    \rule{0.75\linewidth}{0.5\linewidth}
  \end{center}

  \blindtext
\end{document}

Thorsten
hans
Posts: 4
Joined: Wed Apr 28, 2010 11:40 am

Re: Put figures and tables in columns

Post by hans »

Thx a lot for the info!

Greets,

Hans
Post Reply