4

HI

How can I start the caption where table starts or figure starts?

\captionsetup{justification=justified, singlelinecheck=false}

does not work for me because it places the caption at the beginning of the paragraph not the beginning of the table.

Thanks!!

lockstep
  • 250,273
Aharoun Baalan
  • 181
  • 1
  • 1
  • 6

1 Answers1

5
\documentclass[a4paper]{article}
\usepackage[demo]{graphicx}
\usepackage{floatrow,blindtext}

\begin{document}
\blindtext

\begin{figure}[!htb]
\ffigbox[\FBwidth]
  {\caption{\blindtext}\label{foo}}
  {\includegraphics{bar}}
\end{figure}

\blindtext

\begin{table}[!htb]
\ttabbox{\caption{A not so long caption.}\label{bar}}
        {\begin{tabular}{ccc} \hline
            foo & bar & baz \\\hline
         \end{tabular}}
\end{table}

\end{document}

enter image description here enter image description here

  • Any ideas about tables? – Aharoun Baalan Feb 02 '11 at 09:03
  • @Aharoun: maybe that you are able to replace figure with table and ffigbox with ttabbox ... ;-) –  Feb 02 '11 at 09:38
  • @Herbert: The definition of \ttabbox is \floatbox[\captop]{table}[\FBwidth], so you don't need to specify [\FBwidth] explicitly. (Contray to that, \ffigbox equates to \floatbox{figure}.) – lockstep Feb 02 '11 at 10:02
  • @lockstep: true, I shouldn't use copy and paste ... ;-) thanks –  Feb 02 '11 at 10:13
  • Thanks again, When I compile your code only, it works fine but when I use \usepackage{floatrow} in my document (my work), it gives me this error: ! Package floatrow Error: Do not use float package with floatrow.(floatrow) The latter will be skipped. – Aharoun Baalan Feb 07 '11 at 11:47
  • @Aharoun: the message says it all: "Do not use package float"! –  Feb 07 '11 at 12:05
  • I am not using float package Float at all! this is what I am using \usepackage[pdftex]{graphicx, epsfig} \usepackage{graphics,amsmath,amssymb,epsfig,makeidx,tabularx,lscape, here, verbatim, graphicx} \usepackage{hyperref} \usepackage{natbib} \usepackage{listings} \usepackage{subfigure} \usepackage{blindtext} \usepackage{floatrow} \usepackage{pstricks} \usepackage{epstopdf} \usepackage{amsmath} \usepackage{amssymb} \usepackage{setspace} \usepackage{indentfirst} \usepackage{tocbibind} \usepackage{appendix} \usepackage{caption}% \usepackage{multirow,bigstrut,rotating,ctable} – Aharoun Baalan Feb 07 '11 at 15:47
  • @Aharoun: it is the package here. Do not laod it, it is really outdated. However, youl shouldn't load also not epsfig, also outdated and do not load packages several times .. –  Feb 07 '11 at 17:40
  • HI Herbert, thank for your recommendations. I followed all of them. The code now can compiled with no problems. However, the original problem have not been solved yet. The problem is the length of the table is longer than the length of caption. Refer to your example, if you reduce the length of your caption to "not long caption" and add another two columns to your table; The caption stays at the centre of the table while I want it just start from the edge of the table. I hope I am clear enough this time. I do apologise for all this but I am still a beginner. Many thanks Herbert! – Aharoun Baalan Feb 07 '11 at 22:47
  • @Aharoun: insert before you load the package floatrow this: \usepackage[singlelinecheck=off]{caption} –  Feb 08 '11 at 09:02