1

I have the following code:

\documentclass[letterpaper,12pt]{article}

% things needed to include figures
\usepackage{subfigure, graphicx}
% float must be included for the [H] to actually work
\usepackage{float}
% formulas
\usepackage{amsmath}
% Added to adjust captions
\usepackage[singlelinecheck=false]{caption}
% added to adjust margins at the suggestion of Dr. Matt
\usepackage[top=1in, bottom=1in, left=1in, right=1in]{geometry}
\usepackage{fullpage}

\begin{document}
% 2 column side by side table
\begin{table}[H]
  \subtable[Half-life for $^{108}$Ag] {%

    % -----------------------------------------------------%
    \begin{tabular}{c@{\hskip 1cm} c}
      \hline\noalign{\smallskip}
      Accepted $T_{1/2}$ & Experimental $T_{1/2}$\\
      (s) & (s)\\
      \hline\noalign{\smallskip}
      142.92 & 158 $\pm$ 7\\
      \hline\noalign{\smallskip}
    \end{tabular}
    \label{lefttable}
    % -----------------------------------------------------%

  }
  \subtable[Half-life for $^{110}$Ag] {%

    % -----------------------------------------------------%
    \begin{tabular}{c@{\hskip 1cm} c}
      \hline\noalign{\smallskip}
      Accepted $T_{1/2}$ & Experimental $T_{1/2}$\\
      (s) & (s)\\
      \hline\noalign{\smallskip}
      24.6 & 21 $\pm$ 2\\
      \hline\noalign{\smallskip}
    \end{tabular}
    \label{righttable}
    % -----------------------------------------------------%

  }
  \caption{2 Column tables side by side}
  \label{sidebysidetable}
\end{table}
\end{document}

That produces this result: enter image description here

I'd like the captions to be left aligned. How would I go about doing this?

  • 2
    Please make your code compilable, starting with \documentclass{...} and ending with \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to help you. Help them help you: remove that one hurdle between you and a solution to your problem. – jub0bs Dec 4 '13 at 7:45
  • 1
    I doesn't seem tedious to me, this helps streamline the process, thanks for the reminder. I edited my original post. – mbigras Dec 5 '13 at 1:39
  • Yes, exactly :) Thanks for understanding. Others don't get the idea this fast, unfortunately. – jub0bs Dec 5 '13 at 2:16
2

To your question:

subcaption package supports the caption package and use its \captionsetup interface.

    \usepackage{caption}
      \captionsetup[table]{justification=raggedright}
      \captionsetup[subtable]{justification=raggedright}

where raggedright is left aligned.

In the problem subfigure-and-subfig-packages-deprecated, subcaption is recommended.

\usepackage{subcaption}

instead of subfigure.

And I change your subtable environment style:

\begin{table}[H]
  \begin{subtable}[b]{0.48\textwidth}
    % -----------------------------------------------------%
    \caption{Half-life for $^{108}$Ag} \label{lefttable}
    \begin{tabular}{c@{\hskip 1cm} c}
      \hline\noalign{\smallskip}
      Accepted $T_{1/2}$ & Experimental $T_{1/2}$\\
      (s) & (s)\\
      \hline\noalign{\smallskip}
      142.92 & 158 $\pm$ 7\\
      \hline\noalign{\smallskip}
    \end{tabular}
    % -----------------------------------------------------%  
  \end{subtable}
  \begin{subtable}[b]{0.48\textwidth}
    % -----------------------------------------------------%
    \caption{Half-life for $^{110}$Ag}     \label{righttable}
    \begin{tabular}{c@{\hskip 1cm} c}
      \hline\noalign{\smallskip}
      Accepted $T_{1/2}$ & Experimental $T_{1/2}$\\
      (s) & (s)\\
      \hline\noalign{\smallskip}
      24.6 & 21 $\pm$ 2\\
      \hline\noalign{\smallskip}
    \end{tabular}
    % -----------------------------------------------------%
  \end{subtable}
  \caption{2 Column tables side by side}
  \label{sidebysidetable}
\end{table}

And output is enter image description here

Noting that the overall width (lefttable + righttable) should be less than \textwidth. And the option in [b] is vertical position for that sub-table. In your case, same height tables would make b and t no difference.

0

Using \hspace*{\fill} inside the subcaption, as in

\caption{This table. \hspace*{\fill}}

worked for me. Here's the working example based off of the other posts (see the inline comments for use of \hspace):

\documentclass[letterpaper,12pt]{article}
\usepackage{caption, subcaption}
\usepackage[top=1in, bottom=1in, left=1in, right=1in]{geometry}

\begin{document}

\begin{table}[H]
  \begin{subtable}[b]{0.48\textwidth}
    \caption{Half-life for $^{108}$Ag \hspace*{\fill}} %NOTE 
    \begin{tabular}{c@{\hskip 1cm} c}
      \hline\noalign{\smallskip}
      Accepted $T_{1/2}$ & Experimental $T_{1/2}$\\
      (s) & (s)\\
      \hline\noalign{\smallskip}
      142.92 & 158 $\pm$ 7\\
      \hline\noalign{\smallskip}
    \end{tabular}
  \end{subtable}
  \begin{subtable}[b]{0.48\textwidth}
    \caption{Half-life for $^{110}$Ag \hspace*{\fill}} %NOTE
    \begin{tabular}{c@{\hskip 1cm} c}
      \hline\noalign{\smallskip}
      Accepted $T_{1/2}$ & Experimental $T_{1/2}$\\
      (s) & (s)\\
      \hline\noalign{\smallskip}
      24.6 & 21 $\pm$ 2\\
      \hline\noalign{\smallskip}
    \end{tabular}
  \end{subtable}
  \caption{2 Column tables side by side}
\end{table}

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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