LaTeX forum ⇒ Graphics, Figures & TablesCaption aligned to left Side of Figure

Information and discussion about graphics, figures & tables in LaTeX documents.
jlatex
Posts: 4
Joined: Wed Aug 03, 2011 9:22 pm

Caption aligned to left Side of Figure

Postby jlatex » Mon Aug 08, 2011 7:37 pm

I would like to make my caption aligned below the left side of the figure such as:

  1. |_______________________________|
  2. Figure 1: This is my caption

instead of
  1. |_______________________________|
  2. Figure 1: This is my caption

or
  1. |_______________________________|
  2. Figure 1: This is my caption


I have tried looking at the caption package but I can only get the caption to be left justified with the margin not the figure.

Tags:

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

Postby localghost » Mon Aug 08, 2011 8:15 pm

You could use the threeparttable package. It provides also the measuredfigure environment which allows to do what you want.
  1. \documentclass[11pt]{article}
  2. \usepackage[T1]{fontenc}
  3. \usepackage{caption}
  4. \usepackage{threeparttable}
  5.  
  6. \captionsetup{%
  7. font=small,
  8. labelfont=bf,
  9. singlelinecheck=false,
  10. tableposition=top
  11. }
  12.  
  13. \begin{document}
  14. \begin{figure}[!ht]
  15. \centering
  16. \begin{measuredfigure}
  17. \rule{6.4cm}{3.6cm}
  18. \caption{Dummy figure}\label{fig:dummy}
  19. \end{measuredfigure}
  20. \end{figure}
  21. \end{document}

The floatrow package has similar capabilities (and much more beyond that).


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

User avatar
shadgrind
Posts: 140
Joined: Thu Jul 16, 2009 12:39 am

Postby shadgrind » Mon Aug 08, 2011 8:35 pm

You could use the boxhandler package, which uses left-aligned captions by default:

  1. \documentclass{article}
  2. \usepackage{boxhandler}
  3. \usepackage{graphicx}
  4. \begin{document}
  5. This is a paragraph of text, followed by a
  6. centered figure with a left-justified caption,
  7. called Figure \ref{fig:somepic}.
  8.  
  9. \begin{center}
  10. \bxfigure[h]{\label{fig:somepic}Some figure}{
  11. \includegraphics{picture.png}
  12. }
  13. \end{center}
  14. \end{document}
System: TeX Live 2012, Fedora 18 x86_64, GNU Emacs 24.2

daviddoria
Posts: 60
Joined: Tue Sep 30, 2008 9:24 pm

Postby daviddoria » Mon Feb 03, 2014 6:52 pm

shadgrind, if I change

\includegraphics{picture.png}

to

\fbox{Dummy figure}

so I can try it without a picture.png, the output is not what I would expect (see attached).
Attachments
dummy.jpg
dummy.jpg (6.19 KiB) Viewed 35683 times

daviddoria
Posts: 60
Joined: Tue Sep 30, 2008 9:24 pm

Postby daviddoria » Mon Feb 03, 2014 7:36 pm

localghost - I tried doing this with floatrow as you suggested, but it doesn't seem to respect the 'width' option of includegraphics.

Here is a demo without includegraphics to show that it works:

  1. \documentclass{article}
  2. \usepackage{floatrow}
  3. \usepackage{graphicx}
  4. \begin{document}
  5.  
  6. \begin{figure}
  7. \ffigbox[\FBwidth]
  8. {\caption{caption text caption text caption text caption text
  9. caption text caption text caption text caption text
  10. caption text caption text caption text caption text }\label{...}}
  11. {\fbox{Dummy Figure}}
  12. \end{figure}
  13.  
  14. \end{document}
  15.  


And then this works correctly (though you need a dummy.png in the folder, but as that is the part I'm troubleshooting I can't make a MWE without it):

  1. \documentclass{article}
  2. \usepackage{floatrow}
  3. \usepackage{graphicx}
  4. \begin{document}
  5.  
  6. \begin{figure}
  7. \ffigbox[\FBwidth]
  8. {\caption{caption text caption text caption text caption text
  9. caption text caption text caption text caption text
  10. caption text caption text caption text caption text }\label{...}}
  11. {\includegraphics{dummy}}
  12. \end{figure}
  13.  
  14. \end{document}
  15.  


Then finally, this does not work correctly - the caption is wider than the image:

  1. \documentclass{article}
  2. \usepackage{floatrow}
  3. \usepackage{graphicx}
  4. \begin{document}
  5.  
  6. \begin{figure}
  7. \ffigbox[\FBwidth]
  8. {\caption{caption text caption text caption text caption text
  9. caption text caption text caption text caption text
  10. caption text caption text caption text caption text }\label{...}}
  11. {\fbox{Dummy Figure}} % replace this with the includegraphics line as below
  12. {\includegraphics[width=.4\linewidth]{dummy}} % the caption does not respect the 'width'
  13. \end{figure}
  14.  
  15. \end{document}
  16.  


Any suggestions?

Thanks,

David


Return to “Graphics, Figures & Tables”

Who is online

Users browsing this forum: No registered users and 6 guests