LaTeX forum ⇒ Graphics, Figures & Tablesautomatic subfig figure arrangement (like subfigure)

Information and discussion about graphics, figures & tables in LaTeX documents.
crobar
Posts: 12
Joined: Mon Nov 16, 2009 4:41 pm

automatic subfig figure arrangement (like subfigure)

Postby crobar » Mon Oct 11, 2010 2:43 pm

Hello,

I am writing a scientific paper which I would like to view in both single column and double column format. I have a number of figures in the paper, some of which I wish to arrange as subfigures.

I had been using the old subfigure package to achieve this which was working fine, but had come to a set of two figures which I wished to display side by side, vertically aligned at their centres. Therefore I am attempting to instead use the newer subfig package, which has examples of this type.

When using the original subfigure package, I found that my subfigures would nicely rearrange themselves when switching between twocolumn and onecolumn mode. By this I mean, the subfigures lined up side by side in single column mode, but rearranged themselves to be on top of one another when using two columns, presumeably recognising there was insufficient space to have them beside one another.

I have found that the subfig package does not automatically have the same functionality and I must manually choose the orientation of my floats, otherwize, they overlay with the text of the right hand column.

Is there any way to achieve the same results with subfig as with subfigure in this respect?

I am declaring subfig with the caption = false and font=footnotesize as below, and most of my figures have been created using tikz pgf in case this has any bearing.
  1. \usepackage[caption=false,font=footnotesize]{subfig}


Thanks,
Richard

User avatar
sommerfee
Posts: 498
Joined: Mon Apr 09, 2007 4:20 pm

Postby sommerfee » Mon Oct 11, 2010 8:32 pm

Unfortunately you did not read the forum rules and therefore haven't provided a minimal but complete example. So I can only guess:

The subfig package is removing space between the \subfloat commands, which is something the subfigure package is not doing. So if you write
  1. \subfigure{...}
  2. \subfigure{...}

a space will be entered between those two subfigures. Because of this space a linebreak can happen, maybe this is what you mean by "rearranging"!?
When using the subfig package this space will be removed, therefore
  1. \subfloat{...}
  2. \subfloat{...}

will always put both figures side-by-side.

crobar
Posts: 12
Joined: Mon Nov 16, 2009 4:41 pm

Postby crobar » Mon Oct 11, 2010 11:02 pm

Hello,

thanks for replying. Sorry for not supplying a minimal example, in this case I thought my problem was rather generic, so either someone would know the answer immediately or they would not.

Below is an example with lorem ipsum to demostrate what I mean

  1. \documentclass[twocolumn]{report}
  2.  
  3. \usepackage{subfig}
  4. \usepackage{subfigure}
  5. \usepackage{tikz}
  6.  
  7.  
  8. \begin{document}
  9. Lorem ipsum dolor sit amet, consectetur adipiscing elit. In faucibus aliquam fringilla. Proin et dui vitae erat scelerisque tempor. Donec ullamcorper sagittis lorem nec ultricies. Maecenas elementum tincidunt nisl, ornare blandit massa facilisis ut. Duis ac erat et odio faucibus hendrerit. Maecenas pharetra arcu eget tortor rhoncus feugiat. Proin nibh lectus, feugiat eu eleifend vel, congue id lectus. Maecenas viverra condimentum suscipit. Vestibulum sit amet orci eu risus eleifend bibendum. Aliquam erat volutpat. Sed sodales diam at dolor commodo hendrerit sed id nibh. Duis semper nisi et est ultricies sit amet aliquam dui sodales. Pellentesque at fermentum massa.
  10.  
  11. \begin{figure}
  12. \subfloat[a float]{
  13. \begin{tikzpicture}
  14. \draw (0,0) rectangle (6,6);
  15. \end{tikzpicture}
  16. }
  17. \subfloat[another float]
  18. {
  19. \begin{tikzpicture}
  20. \draw (0,0) rectangle (6,6);
  21. \end{tikzpicture}
  22. }
  23. \end{figure}
  24. Nunc a urna id est eleifend ullamcorper. Sed erat felis, viverra eu blandit a, tempor nec ante. Etiam porta nulla nisi, at gravida lorem. Suspendisse at lorem interdum augue suscipit interdum. Nam gravida tellus nec velit iaculis ac ultricies dolor luctus. Morbi imperdiet varius lacus ac fermentum. Etiam auctor gravida sem facilisis gravida. Sed eget viverra lorem. Nulla mi felis, dapibus eget malesuada non, imperdiet vel est. Nam id sem et lorem iaculis elementum ut sit amet magna. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Sed posuere blandit ligula nec imperdiet. Morbi vitae lectus at leo varius venenatis sed vel mi. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Morbi sodales accumsan accumsan.
  25.  
  26. Donec sodales diam sit amet neque gravida rhoncus. Sed quis nunc dolor, id luctus nulla. Curabitur vitae mi ante. Duis arcu orci, pulvinar sed ultrices eget, ultricies sed mauris. Suspendisse facilisis molestie ante et convallis. Pellentesque dictum augue sed lacus suscipit congue. Sed sit amet dolor at dolor porta ultrices ac in nibh. Morbi elit orci, venenatis cursus posuere at, hendrerit sed ipsum. Aliquam a ligula vel ligula pharetra iaculis. Donec non convallis eros. Duis ac elit lacus.
  27.  
  28. Proin arcu quam, vehicula a consequat adipiscing, vestibulum et purus. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vivamus posuere sollicitudin dapibus. Vestibulum non purus orci, eget fermentum dolor. Vivamus at varius orci. Aliquam dapibus semper rhoncus. Nulla sagittis malesuada odio, ut lacinia ante rhoncus aliquet. Nulla posuere leo non augue commodo facilisis auctor quam rhoncus. Ut hendrerit, augue at imperdiet volutpat, est urna congue velit, nec varius ligula nunc sit amet orci. Suspendisse ac dui tortor. Aliquam congue metus nec turpis condimentum accumsan. Maecenas tristique, sapien vitae mattis convallis, augue mi ullamcorper augue, non vulputate odio leo vel magna. Vivamus vel lorem sapien, id tristique ligula. Nam porttitor nunc quis mauris tincidunt dignissim. Praesent diam elit, sagittis eget gravida nec, tristique a odio. Ut in arcu vitae nisi luctus varius. Nullam elit felis, accumsan eu consequat at, porta ultricies mi.
  29.  
  30. Nunc a urna id est eleifend ullamcorper. Sed erat felis, viverra eu blandit a, tempor nec ante. Etiam porta nulla nisi, at gravida lorem. Suspendisse at lorem interdum augue suscipit interdum. Nam gravida tellus nec velit iaculis ac ultricies dolor luctus. Morbi imperdiet varius lacus ac fermentum. Etiam auctor gravida sem facilisis gravida. Sed eget viverra lorem. Nulla mi felis, dapibus eget malesuada non, imperdiet vel est. Nam id sem et lorem iaculis elementum ut sit amet magna. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Sed posuere blandit ligula nec imperdiet. Morbi vitae lectus at leo varius venenatis sed vel mi. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Morbi sodales accumsan accumsan.
  31.  
  32. Donec sodales diam sit amet neque gravida rhoncus. Sed quis nunc dolor, id luctus nulla. Curabitur vitae mi ante. Duis arcu orci, pulvinar sed ultrices eget, ultricies sed mauris. Suspendisse facilisis molestie ante et convallis. Pellentesque dictum augue sed lacus suscipit congue. Sed sit amet dolor at dolor porta ultrices ac in nibh. Morbi elit orci, venenatis cursus posuere at, hendrerit sed ipsum. Aliquam a ligula vel ligula pharetra iaculis. Donec non convallis eros. Duis ac elit lacus.
  33.  
  34. Proin arcu quam, vehicula a consequat adipiscing, vestibulum et purus. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vivamus posuere sollicitudin dapibus. Vestibulum non purus orci, eget fermentum dolor. Vivamus at varius orci. Aliquam dapibus semper rhoncus. Nulla sagittis malesuada odio, ut lacinia ante rhoncus aliquet. Nulla posuere leo non augue commodo facilisis auctor quam rhoncus. Ut hendrerit, augue at imperdiet volutpat, est urna congue velit, nec varius ligula nunc sit amet orci. Suspendisse ac dui tortor. Aliquam congue metus nec turpis condimentum accumsan. Maecenas tristique, sapien vitae mattis convallis, augue mi ullamcorper augue, non vulputate odio leo vel magna. Vivamus vel lorem sapien, id tristique ligula. Nam porttitor nunc quis mauris tincidunt dignissim. Praesent diam elit, sagittis eget gravida nec, tristique a odio. Ut in arcu vitae nisi luctus varius. Nullam elit felis, accumsan eu consequat at, porta ultricies mi.
  35. \begin{figure}
  36. \subfigure[a float]{
  37. \begin{tikzpicture}
  38. \draw (0,0) rectangle (6,6);
  39. \end{tikzpicture}
  40. }
  41. \subfigure[another float]
  42. {
  43. \begin{tikzpicture}
  44. \draw (0,0) rectangle (6,6);
  45. \end{tikzpicture}
  46. }
  47. \end{figure}
  48.  
  49. \end{document}


Note the 'rearrangement of the subfigures so one is vertically above the other, whereas the subfloats just spread into the column beside.

p.s. this code will generate errors as subfig attempts to redefine the \subfigure command, but on my system it still compiles and shows the problem.
Thanks,

Richard

User avatar
sommerfee
Posts: 498
Joined: Mon Apr 09, 2007 4:20 pm

Postby sommerfee » Tue Oct 12, 2010 8:13 am

crobar wrote:Note the 'rearrangement of the subfigures so one is vertically above the other, whereas the subfloats just spread into the column beside.


It seems that I have guessed right - the reason for this is described in my posting above. So if you want to allow line breaks between \subfloats you have to put something between the \subfloats where LaTeX can make a line break. A simple space (or newline) was sufficient for \subfigure, but is not sufficient for \subfloat anymore.

crobar
Posts: 12
Joined: Mon Nov 16, 2009 4:41 pm

Postby crobar » Tue Oct 12, 2010 10:28 am

Thanks, you're right, adding an \hspace{0}, as in the following code gave me the same results!

  1. \begin{figure}
  2. \subfloat[a float]{
  3. \begin{tikzpicture}
  4. \draw (0,0) rectangle (6,6);
  5. \end{tikzpicture}
  6. }
  7. \hspace{0}
  8. \subfloat[another float]
  9. {
  10. \begin{tikzpicture}
  11. \draw (0,0) rectangle (6,6);
  12. \end{tikzpicture}
  13. }
  14. \end{figure}


Thanks,
Richard


Return to “Graphics, Figures & Tables”

Who is online

Users browsing this forum: No registered users and 5 guests