Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

How to make table caption left-aligned.

I tried \usepackage[singlelinecheck=off]{caption} but it did not work out. In other words it gives an error:

\DeclareFloatFont {tiny}{\tiny}% "scriptsize" is defined by floatrow, "t...

    \documentclass[a4paper]{article}
    \usepackage{graphicx}
    \usepackage[cmex10]{amsmath}
    \usepackage{mathtools}
    \usepackage[usenames]{color}
    \usepackage[table]{xcolor}
    \usepackage[left=2cm, right=2cm]{geometry}
    \usepackage{authblk}

    \usepackage{floatrow}
    \usepackage[labelsep=space]{caption}

    \DeclareFloatFont{tiny}{\tiny}
    \floatsetup[table]{font=footnotesize,capposition=top}

    \linespread{1.6}
    \renewenvironment{abstract}{%
    \noindent\bfseries\abstractname:\normalfont}{}

    \newcommand{\affilmark}[1]{\rlap{\textsuperscript{\itshape#1}}}

    \begin{document}

    \centerline{\LARGE Title}
    \vspace*{3ex}
    \begin{flushleft}\large
    A.B \affilmark{a},\quad
    A.D\affilmark{b}\\[2ex]
    \normalsize\itshape
    \textsuperscript{a}\,University of nowhere,\\

    \upshape Corresponding author's email: \texttt{A.D@ieee.org}
    \end{flushleft}
    \date{}

    \begin{abstract}
    abstract goes here
    \end{abstract}


    \section{Introduction}
    some text goes here.

    \begin{figure}[!t]
    \includegraphics[width=0.4\textwidth, height=0.2\textwidth]
    \ffigbox[\FBwidth]
    \caption{Conventional  (a) ABCD. (b) EFGH.}
    \label{ABCDEFGH}
    \end{figure}

    \begin{table}[!t]

    \caption{performance of .}
    \label{tableII}
    \centering
    \definecolor{latexbl}{RGB}{28,220,240}
    \rowcolors{12}{black}{latexbl}

    \begin{tabular}  {|m{0.8cm}|m{0.6cm}|m{1.35cm}|m{1.1cm}|m{1.5cm}|m{1.1cm}|m{1.4cm}|m{0.7cm}|m{1.75cm}|m{1.2cm}|m{0.5cm}|}
    \hline
    \center Ref. & A &  B& C & D& E& F &G &H&I &J\\
    \hline
    \end{tabular}
    \begin{flushleft}
    some explanation
    \end{flushleft}
    \end{table}
    \end{document}

EDIT BY LOCKSTEP (moved from separate "answer"):

Here's a compilable example that doesn't show the problematic behaviour mentioned by you. Please use it as start-up aid to post a compilable example which does show the behaviour.

\documentclass{article}

\usepackage{floatrow}
\usepackage[singlelinecheck=off]{caption}

\begin{document}


\begin{table}
(Table content)
\caption{A table}
\end{table}

\end{document}
share|improve this question
5  
Please provide a complete minimal working example illustrating the problem. –  Gonzalo Medina Sep 13 '11 at 21:00
    
@Gonzalo Medina: I edited my question. please read it again. –  amir Sep 13 '11 at 22:45
1  
It seems you are using code snippets from tex.stackexchange.com/questions/27097/…. –  lockstep Sep 13 '11 at 22:50
3  
If I take your new example and add singlelinecheck=off to the caption package options, the table caption is left-aligned. –  lockstep Sep 14 '11 at 0:08
2  
@amir: If you add \usepackage[singlelinecheck=off]{caption} to your preamble you'll try to load the caption package twice but with different options, and this does not work. So try doing what lockstep has suggested instead, which is adding singlelinecheck=off to the caption package options. –  Axel Sommerfeldt Sep 14 '11 at 6:35
show 4 more comments

2 Answers

up vote 4 down vote accepted

Seems like you want the captions to have the same width than the width of its figure/table. If this is the case, you can use the \ffigbox, and \ttabbox commands from the floatrow package. A little example:

\documentclass{article}
\usepackage{floatrow}
\usepackage[labelsep=space]{caption}

\DeclareFloatFont{tiny}{\tiny}
\floatsetup[table]{font=footnotesize,capposition=top}

\newcommand\Text{text text text text text text text}% just for the example

\begin{document}

\begin{figure}[!ht]
\ffigbox[\FBwidth]
{\caption{A figure with its caption having equal width to the figure width}\label{fig:test1}}
{\rule{4cm}{2cm}}
\end{figure}

\begin{table}[!ht]
\ttabbox[\FBwidth]
{\caption{A table with its caption having equal width to the table width}\label{fig:test1}}
{\begin{tabular}{p{3cm}p{3cm}}
\Text\Text & \Text\Text \\
\Text\Text & \Text\Text 
\end{tabular}
}
\end{table}

\end{document}

enter image description here

share|improve this answer
    
I edit my post (Figure is included). Caption is ok but Figure 1 is displayed below the caption. A line below the caption of figure. Sorry for bad english. caption of figure and then below the caption is Figure 1 C –  amir Sep 14 '11 at 13:34
    
@amir: in the code you just posted there are some errors using the \ffigbox command. Your figure environment should be like this: \begin{figure}[!t] \ffigbox[\FBwidth]% {\caption{Conventional (a) ABCD. (b) EFGH.}\label{ABCDEFGH}} {\includegraphics[width=0.4\textwidth, height=0.2\textwidth]{<name>}} \end{figure} replacing <name> with the name of the file containing the image. Correct that part of your example code and report the outcome. –  Gonzalo Medina Sep 14 '11 at 14:47
    
Thank you Gonzalo Medina. It's OK now. –  amir Sep 14 '11 at 16:14
add comment
\usepackage{caption}
\captionsetup{labelsep=space,justification=justified,singlelinecheck=off}

will do what you're asking. There's no error about "tiny".

share|improve this answer
    
Thank you very much bro., egreg. It worked out but all figures and tables are at the center and all captions are left aligned according to text not to border of figures and tables. –  amir Sep 14 '11 at 0:19
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.