1

Below is the code I use.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{caption}
\usepackage{subfigure} 
\usepackage[labelfont=bf]{caption}
\captionsetup[table]{labelsep=space,justification=raggedright,singlelinecheck=off}
\captionsetup[figure]{labelsep=quad}
\usepackage{threeparttable}

\begin{document}

\begin{table}[ht]
\centering
\caption{Data Partitioning} \label{exp_dataset}
\begin{tabular}{c|c|c}
\hline
\#Set & Training Data (7d) & Testing Data (1d) \\ \hline
1 & 07/06/2015-07/12/2015 & 07/13/2015 \\ \hline
2 & 07/09/2015-07/15/2015 & 07/16/2015 \\ \hline
3 & 07/12/2015-07/18/2015 & 07/19/2015 \\ \hline
\end{tabular} 
\end{table}

\end{document}

But the output is like below:

enter image description here

What I want is like below: (The table should be at the center of the page. The caption should be left-align with the table.)

enter image description here

I tried the answers in related posts. None of them works out.

1
  • 1
    Off-topic: Under no circumstance whatsoever should you load both the subfigure and caption packages. If you're using one of the "standard" LaTeX document classes (which includes article), do not load the deprecated subfigure package. Instead, load the subcaption package.
    – Mico
    Mar 16, 2017 at 19:24

1 Answer 1

3

You need to encase the \caption statement and the tabular environment in a threeparttable environment.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[labelfont=bf]{caption}
\captionsetup[table]{labelsep=space, 
         justification=raggedright, singlelinecheck=off}
\usepackage{threeparttable}
\begin{document}
\begin{table}[ht]
\centering
\begin{threeparttable} % <--- new
\caption{Data Partitioning} \label{exp_dataset}
\begin{tabular}{c|c|c}
\hline
\#Set & Training Data (7d) & Testing Data (1d) \\ \hline
1 & 07/06/2015-07/12/2015 & 07/13/2015 \\ \hline
2 & 07/09/2015-07/15/2015 & 07/16/2015 \\ \hline
3 & 07/12/2015-07/18/2015 & 07/19/2015 \\ \hline
\end{tabular} 
\end{threeparttable} % <--- new
\end{table}
\end{document}

enter image description here

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .