LaTeX forum ⇒ Graphics, Figures & TablesUsing Subfigure with Figure* to span two columns?

Information and discussion about graphics, figures & tables in LaTeX documents.
rjp
Posts: 2
Joined: Wed May 27, 2009 11:58 am

Using Subfigure with Figure* to span two columns?

Postby rjp » Wed May 27, 2009 12:05 pm

I was hoping that someone could help with this as I'm currently stumped.

My understanding was that you could use \begin{figure*} instead of \begin{figure} to span two columns with an image and that this would work for subfigures as well.

However, my latex code won't compile and gives an error at the \end{figure*} line.

Below are examples with and without using the * to span the columns.

This won't compile.

  1. \begin{figure*}
  2. \subfigure{\includegraphics[width=6cm]{fig1.eps}}
  3. \subfigure{\includegraphics[width=6cm]{fig2.eps}}
  4. \end{figure*}


This compiles fine but image is only in one column and not spanning the two.

  1. \begin{figure}
  2. \subfigure{\includegraphics[width=6cm]{fig1.eps}}
  3. \subfigure{\includegraphics[width=6cm]{fig2.eps}}
  4. \end{figure}


Any ideas wherew I'm going wrong?

fatra2
Posts: 126
Joined: Fri May 01, 2009 1:43 pm

Postby fatra2 » Wed May 27, 2009 1:27 pm

Hi there,

The asterisk (*) is not to be used in the figure environment. You can use it for example in the equation/eqnarray environment, so that it is not numbered.

To you problem per say, the subfigure environment will not necessarily put the figure side by side. The important word here is "necessarily". The subfigure environment will take the different options given and try its best to place the figures in a suitable position. Therefore, if your text is not wide enough for them to be put nxt to each other, then the second one will be shifted under.

What I would try is to give enough space so that both figure can fit nicely next to each other, like this:
  1. \begin{figure}
  2. \subfigure{\includegraphics[width=0.45\textwidth]{fig1.eps}}
  3. \hspace{0.05\textwidth}
  4. \subfigure{\includegraphics[width=0.45\textwidth]{fig2.eps}}
  5. \end{figure}


You can also try to leave a bit of space between the two figure by adding the \hspace command.

Cheers

rjp
Posts: 2
Joined: Wed May 27, 2009 11:58 am

Postby rjp » Wed May 27, 2009 2:31 pm

Hi,

Thanks for the help but I think you've maybe misundersatood my problem.

figure* is used in the fugure environment to span two columns of text.

See http://people.csail.mit.edu/jrennie/latex/

2-Column Images
When in 2-column mode (using either \twocolumn or the multicols environment (package multicol)), use \begin{figure*} and \begin{table*} to create figures and tables that span the entire width of the page. \begin{figure} and \begin{table} span only one column.


or

http://andrewjpage.com/index.php?/archi ... Latex.html

If your using 2 columns in a latex document, you'll usually find that a table or figure is just too big for a single column. All you do is use
\begin{figure*}
\end{figure*}
and that will make the figure span the width of the entire page.


My problem is that I've read that this should work when subfigure is used within figure but it doesn't seem to work and won't compile.

fatra2
Posts: 126
Joined: Fri May 01, 2009 1:43 pm

Postby fatra2 » Wed May 27, 2009 3:27 pm

Hi there,

Never used the asterisk in the figure environment. Did you check that you have all the packages needed to run it (just a thought)???

Cheers

User avatar
localghost
Site Moderator
Posts: 9206
Joined: Fri Feb 02, 2007 12:06 pm

Postby localghost » Wed May 27, 2009 3:44 pm

rjp wrote:[...] My understanding was that you could use \begin{figure*} instead of \begin{figure} to span two columns with an image and that this would work for subfigures as well. [...]

Your understanding is right. From your code I see that you are using the obsolete subfigure package. I have no problem with the subfig package.
  1. \documentclass[11pt,a4paper,english,titlepage,twocolumn]{article}
  2. \usepackage[T1]{fontenc}
  3. \usepackage[latin1]{inputenc}
  4. \usepackage{babel}
  5. \usepackage[font=small,labelfont=bf,tableposition=top]{caption}
  6. \usepackage[font=footnotesize]{subfig}
  7. \usepackage{blindtext}
  8.  
  9. \parindent0em
  10. \author{Unknown}
  11. \title{Figure with subfigures in multiple columns}
  12.  
  13. \begin{document}
  14. \maketitle
  15. \blindtext
  16.  
  17. \begin{figure*}[!bt]
  18. \centering
  19. \subfloat[Dummy sub\label{subfig-1:dummy}]{%
  20. \rule{4cm}{3cm}
  21. }
  22. \subfloat[Dummy sub\label{subfig-2:dummy}]{%
  23. \rule{4cm}{3cm}
  24. }
  25. \caption{Dummy figure with subfigures}\label{fig:dummy}
  26. \end{figure*}
  27. \blindtext[6]
  28. \end{document}

Regarding the fact that this package is not maintained any more, I suggest to try he subcaption package the comes with the caption package.


Best regards and welcome to the board
Thorsten
LaTeX Community Moderator
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes


¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1

syf8d911
Posts: 1
Joined: Wed May 18, 2011 10:29 pm

Postby syf8d911 » Wed May 18, 2011 10:35 pm

I met the same problem when I was writing a IEEE journal paper. I solved it by using "minipage" and setting the column width to 1, which is shown as follows:

  1. \begin{figure*}[!ht]
  2. \captionstyle{centerlast}
  3. \begin{minipage}[l]{1.0\columnwidth}
  4. \centering
  5. \includegraphics[width=7.5cm, bb=0 0 1200 900]{A.png}
  6. \caption{AAA}\label{fig:AAA}
  7. \end{minipage}
  8. \hfill{}
  9. \begin{minipage}[r]{1.0\columnwidth}
  10. \centering
  11. \includegraphics[width=7.5cm, bb=0 0 1200 900]{B.jpg}
  12. \caption{BBB}\label{fig:BBB}
  13. \end{minipage}
  14. \end{figure*}


It worked for me. I hope it is helpful to your problem.
Last edited by Stefan Kottwitz on Wed May 25, 2011 6:50 pm, edited 1 time in total.
Reason: code markup tags inserted

benihakum
Posts: 1
Joined: Sat May 12, 2018 11:30 pm

Postby benihakum » Sat May 12, 2018 11:33 pm

Figure* does NOT allow blank lines - i.e. lines with no code on.


Return to “Graphics, Figures & Tables”

Who is online

Users browsing this forum: No registered users and 13 guests