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

Information and discussion about graphics, figures & tables in LaTeX documents.
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 »

pban92 wrote:[...] 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? [...]
No, a compilation was not possible because I don't have your graphics files. At first I replaced your files by some dummies and composed the figure to get it work and then copied your graphics inclusion commands into the code. Please post the log file of my example as attachment to your next post. Perhaps your version of the caption package is outdated. You also can upload your graphics files (in one ZIP archive) as attachment to the server or to a one click hoster for download.

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,

in the code of Thorsten there are a problem with brackets. The original line is:

Code: Select all

\usepackage{font=footnotesize,labelformat=simple,labelsep=colon]{subcaption}
You must change the first bracket:

Code: Select all

\usepackage[font=footnotesize,labelformat=simple,labelsep=colon]{subcaption}
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:[...] in the code of Thorsten there are a problem with brackets. [...]
Oh, yes. Many thanks for the hint. A small but very important detail. I corrected it in my code example.
pban92
Posts: 54
Joined: Sat Aug 09, 2008 9:34 am

Re: How to fix the caption in right position?

Post by pban92 »

You guys are simply awesome! Finally it worked!
Thank you so much guys!
pban92
Posts: 54
Joined: Sat Aug 09, 2008 9:34 am

How to fix the caption in right position?

Post by pban92 »

Back again with the same problem guys :(

Before I started the thread this was my codes

Code: Select all


\begin{figure}[ht!]

\begin{picture}(330,100)(-10,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}}
%
\put(48,38) {\begin{sideways}\small$y/D$\end{sideways}}
\put(48,-30) {\begin{sideways}\small$y/D$\end{sideways}}
\put(105,-67){\small$x/D$}
\put(240,-67){\small$x/D$}

\put(62,70){\small$2$}
\put(62,45){\small$0$}
\put(55,20){\small$-2$}

\put(62,2){\small$2$}
\put(62,-24){\small$0$}
\put(55,-52){\small$-2$}

\put(75,-59){\small$-2$}
\put(112,-59){\small$0$}
\put(141,-59){\small$2$}

\put(211,-59){\small$-2$}
\put(247,-59){\small$0$}
\put(277,-59){\small$2$}

\put(167,70){\small$\frac{|\bar{u}|}{U_\infty}$}
\put(303,70){\small$\frac{|\bar{v}|}{U_\infty}$}
\put(167,2){\small$\frac{|\bar{u'u'}|}{U^{2}_{\infty}}$}
\put(303,2){\small$\frac{|\bar{v'v'}|}{U^{2}_{\infty}}$}

\put(173,55){\small$1.2$}
\put(173,25){\small$0.0$}
\put(318,55){\small$0.5$}
\put(310,25){\small$-0.7$}

\put(173,-12){\small$0.05$}
\put(173,-42){\small$0.55$}
\put(318,-12){\small$0.09$}
\put(318,-42){\small$0.01$}

\end{picture}
\caption{streamwise mean velocity (top-left); normal mean velocity(top-right); Streamwise mean fluctuation (bot-left); normal mean fluctuation(bot-right)}
\label{fig:flate}
\end{figure}
  

The picture environment helped me to use \put for convenient axis labels. But the problem was caption for which I started this thread. Now with the caption problem solved I cannot work it out to blend with picture environment and hence the labels are missing. I tried to playwith the codes for a miracle but did not work as follows,

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{picture}(330,100)(-10,0)
        
        \begin{subfigure}[b]{1.5in}
          \centering
          
          \put(70,20){\includegraphics[width=1.4in]{umean.png}}
        %  \includegraphics[width=1.4in]{umean.png}
        
    %      \caption{A subfigure}\label{subfig-1:dummy}
        \end{subfigure}%
        \begin{subfigure}[b]{1.5in}
          \centering
          
          \put(205,20){\includegraphics[width=1.4in]{vmean.png}}
%          \includegraphics[width=1.4in]{vmean.png}
          
    %      \caption{A subfigure}\label{subfig-2:flate}
        \end{subfigure}\\%
        \begin{subfigure}[b]{1.5in}
          \centering
          
          \put(70,-50){\includegraphics[width=1.4in]{uprime.png}}
%          \includegraphics[width=1.4in]{uprime.png}
          
    %      \caption{A subfigure}\label{subfig-3:flate}
        \end{subfigure}%
        \begin{subfigure}[b]{1.5in}
          \centering
    
    \put(205,-50){\includegraphics[width=1.4in]{vprime.png}}
    %      \includegraphics[width=1.4in]{vprime.png}
    
    %      \caption{A subfigure}\label{subfig-4:flate}
        \end{subfigure}%
        
        \end{picture}
        
        \caption{Velocity}\label{fig:flate}
      \end{figure}
    \end{document}


I have attached the figures in zip file. Any further suggestion guys?

Thanks!
User avatar
sommerfee
Posts: 503
Joined: Mon Apr 09, 2007 4:20 pm

How to fix the caption in right position?

Post by sommerfee »

localghost wrote:I'm not sure if I depict the situation here in the right way. But in that case Axel will surely correct me.
I'm not sure about the current situation, too. The subfig package was never claimed to be "unsupported" by his author. He planned a bugfix release in January 2006 which never was released, he wrote me in August 2007 that he is still interested in the subfig package (but still no update), and in January 2008 he wrote to me "I think that the subfig package should simply be deprecated". Afterwards I wrote him a bunch of reasons why I don't think so but got no answer back from him.

It's really a pity, because (beside the hyperref and some alignment problems) the subfig is IMHO a really great package, and furthermore the subcaption package is not a proper replacement because it needs the caption package which is not compatible to all document classes. In contrast the subfig package can be used without the caption package by using the option "caption=false" while loading.

Beside that I don' think that one package should be avoided and its usage should be replaced just because it's not supported anymore. If it works, I will simply use it. BTW: LaTeX2e isn't really supported anymore, too ;)

Axel
Last edited by sommerfee on Sat Jan 24, 2009 3:14 pm, edited 1 time in total.
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:Any further suggestion guys?
Hello,

I can not understand why are you using the picture environment. To put some axis into a graphic you can use the overpic package.

regards
Marco
i am German. I can not use difficult words. :-)
User avatar
sommerfee
Posts: 503
Joined: Mon Apr 09, 2007 4:20 pm

How to fix the caption in right position?

Post by sommerfee »

I can't compile both solutions here, the "picture" approach gives me 4 errors, the "subfigure and picture" 13 errors.

But using the subcaption package IMHO only makes sense when one wants subcaptions as well, which is not the case here.

So I simply suggest following the "picture" approach (from the very first posting in this thread) and correct the vertical position of the caption with

Code: Select all

\vspace*{2.3cm}
between picture environment and \caption.

Axel
pban92
Posts: 54
Joined: Sat Aug 09, 2008 9:34 am

How to fix the caption in right position?

Post by pban92 »

So I simply suggest following the "picture" approach (from the very first posting in this thread) and correct the vertical position of the caption with

Code: Select all
\vspace*{2.3cm}


between picture environment and \caption.
Hi Axel, thanks a lot. This is what I was actually looking for, a very quick fix rather than all those trauma I went through :)

Thank you guys!
Post Reply