Graphics, Figures & TablesHow to fix the caption in right position?

Information and discussion about graphics, figures & tables in LaTeX documents.
pban92
Posts: 54
Joined: Sat Aug 09, 2008 9:34 am

How to fix the caption in right position?

Post by pban92 »

Hi,

I have the following code where figures are inserted as
2x2 matrix. But the caption is overlapping the figures. Any suggestion?

Thanks!

Code: Select all

\begin{figure}[ht!]

\begin{picture}(330,100)(0,0)

\put(70,20){\includegraphics[width=1.4in]{umean.png}}
\put(205,20){\includegraphics[width=1.4in]{vmean.png}}
\put(70,-50){\includegraphics[width=1.4in]{uprime.png}}
\put(205,-50){\includegraphics[width=1.4in]{vprime.png}}

\end{picture}
%\caption{velocity }
\label{fig:flate}
\end{figure}
   

Recommended reading 2024:

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

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

marco_d
Posts: 57
Joined: Tue Jan 20, 2009 7:49 pm

How to fix the caption in right position?

Post by marco_d »

Hello,

do you know the package caption? With this package you can customize the captions in floating environments.

Marco
i am German. I can not use difficult words. :-)
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

How to fix the caption in right position?

Post by localghost »

Your problem is not comprehensible to me. Provide the graphics file by attaching it to your next post. The only issue I can see is that you are reserving not enough space for the single graphics. Instead of aligning figures this way you can try the subcaption package that comes with the caption package mentioned by marco_d.


Best regards
Thorsten¹
pban92
Posts: 54
Joined: Sat Aug 09, 2008 9:34 am

How to fix the caption in right position?

Post by pban92 »

Unfortunately the maximum 3 attachments are allowed. But 3 figures should serve the purpose. I see the caption on the figure. Cant position it properly. Not sure how caption package should be used aside from putting it in the preamble.

Thanks!


Ok. here is the code,

Code: Select all

    


    \documentclass[11pt,a4paper,oneside]{report}
    \usepackage[pdftex]{graphicx}
    \usepackage{rotating}
    \usepackage{caption}
    \usepackage[colorlinks=true,
               linkcolor=blue,
               citecolor=blue,
                    urlcolor=blue,
            filecolor=blue,
          pdfpagemode=None,
          pdfstartview=FitH]{hyperref}
    \begin{document}
\begin{figure}[ht!]

    \begin{picture}(330,100)(0,0)

    \put(70,20){\includegraphics[width=1.4in]{umean.png}}
    \put(205,20){\includegraphics[width=1.4in]{vmean.png}}
    \put(70,-50){\includegraphics[width=1.4in]{uprime.png}}
    %\put(205,-50){\includegraphics[width=1.4in]{vprime.png}}

    \end{picture}
    \caption{velocity }
    \label{fig:flate}
    \end{figure}
       
\end{document}
Attachments
This is how the caption looks like once compiled. Needs fixes :(
This is how the caption looks like once compiled. Needs fixes :(
untitled.JPG (30.39 KiB) Viewed 22174 times
marco_d
Posts: 57
Joined: Tue Jan 20, 2009 7:49 pm

How to fix the caption in right position?

Post by marco_d »

pban92 wrote:I see the caption on the figure. Cant position it properly. Not sure how caption package should be used aside from putting it in the preamble.
Hello,

I thought you want to modify the margin. The following example shows an alternative by using the package subfig. So you have an separate caption for every temperature field.

Code: Select all

\documentclass[11pt,a4paper,oneside]{report}
\usepackage{graphicx}
\usepackage{subfig}
\usepackage{rotating}
\usepackage{caption}
\usepackage[colorlinks=true,linkcolor=blue,
            citecolor=blue,urlcolor=blue,
            filecolor=blue,pdfstartview=FitH]{hyperref}

\begin{document}
    \begin{figure}[ht!]\centering
	\subfloat[\label{fig:flateA}]{\includegraphics[width=1.4in]{umean.png}}
	\hspace*{4em}
        \subfloat[\label{fig:flateB}]{\includegraphics[width=1.4in]{vmean.png}}

        \subfloat[\label{fig:flateC}]{\includegraphics[width=1.4in]{uprime.png}}
	\hspace*{4em}
        \subfloat[\label{fig:flateD}]{\includegraphics[width=1.4in]{vprime.png}}
        \caption{velocity }
        \label{fig:flate}
  \end{figure}
\end{document}
regards
Marco
i am German. I can not use difficult words. :-)
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

How to fix the caption in right position?

Post by localghost »

The preferable way would be to use the subcaption package that comes with the caption package.

Code: Select all

\documentclass[11pt,a4paper,english]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage[font=small,labelfont=bf]{caption}
\usepackage[font=footnotesize,labelformat=simple,labelsep=colon]{subcaption}
\usepackage{graphicx}
\usepackage{lmodern}

% Modifications to the appearance of subfloat enumeration (subcaption)
\renewcommand{\thesubfigure}{\thefigure.\arabic{subfigure}}
\renewcommand{\thesubtable}{\thetable.\arabic{subtable}}

\begin{document}
  \begin{figure}[!ht]
    \centering
    \begin{subfigure}[b]{2in}
      \centering
      \includegraphics[width=1.4in]{umean.png}
%      \caption{A subfigure}\label{subfig-1:dummy}
    \end{subfigure}%
    \begin{subfigure}[b]{2in}
      \centering
      \includegraphics[width=1.4in]{vmean.png}
%      \caption{A subfigure}\label{subfig-2:flate}
    \end{subfigure}\\%
    \begin{subfigure}[b]{2in}
      \centering
      \includegraphics[width=1.4in]{uprime.png}
%      \caption{A subfigure}\label{subfig-3:flate}
    \end{subfigure}%
    \begin{subfigure}[b]{2in}
      \centering
      \includegraphics[width=1.4in]{vprime.png}
%      \caption{A subfigure}\label{subfig-4:flate}
    \end{subfigure}%
    \caption{Velocity}\label{fig:flate}
  \end{figure}
\end{document}
The reason for preferring subcaption is that the subfig package seems not to be maintained any more. Another reason for me is that the structure becomes much more clearer with the subcaption package because it is very similar to a simple figure structure.
marco_d
Posts: 57
Joined: Tue Jan 20, 2009 7:49 pm

How to fix the caption in right position?

Post by marco_d »

localghost wrote:[...]The reason for preferring subcaption is that the subfig package seems not to be maintained any more.[...]
Hello Thorsten,

that is a new information for me. I could not find any information to validate this. The structure seems to be easier but I am lazy to write :D .

regards
Marco
i am German. I can not use difficult words. :-)
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

How to fix the caption in right position?

Post by localghost »

marco_d wrote:[...] that is a new information for me. I could not find any information to validate this. [...]
Take a look at the last version of subfig and you will see that it is almost four years old. That's not what I consider regular maintenance. The author of the caption package mentioned this elsewhere when introducing the subcaption package. He considers it as a by-product necessary for testing new features in caption. But the author of subfig didn't support this enough, so Axel created something on his own. I'm not sure if I depict the situation here in the right way. But in that case Axel will surely correct me. For me the subcaption package is very productive and has become one of the packages that appear in every document. It has its own documentation and so for me represents a package like any other.
marco_d
Posts: 57
Joined: Tue Jan 20, 2009 7:49 pm

Re: How to fix the caption in right position?

Post by marco_d »

Hello,

When I see the date of the last version I am agree with you. Axels does great work with the caption. I am sure the subcaption package is also great. According to your arguments I will change to subcaption.

Thanks
Marco
i am German. I can not use difficult words. :-)
pban92
Posts: 54
Joined: Sat Aug 09, 2008 9:34 am

Re: How to fix the caption in right position?

Post by pban92 »

Guys thank you so much!

Localghost, I copied and pasted your codes with images in the same folder but got 13 errors. Did you compile the codes by yourself? How about any other quick fix for this specific case only?

Thanks once again guys!
Post Reply