# Change caption in table from Table 2 to Table 1A

I have this code:

\documentclass[12pt]{article}

\begin {document}

\begin{table}[h!b!p!]
\caption{This caption describes contents of Table 1, gives the big picture.}
\caption {Describe contents of Table 1.A}
\begin{tabular}{|c|c|c|c|c|c|}

\hline
Recom Strength & Highest Idos Risk & 2nd Highest & Middle & 2nd Lowest & Lowest\\
\hline
1 & -0.41 & -0.07 & 1.27 & -0.78 & 0.73\\
\hline
2 & -0.85 & -1.88 & 0.01 & 0.75 & 2.32\\
\hline
3 & -0.48 & -1.0 & -0.56 & 0.47 & 1.01\\
\hline
4 & 0.04 & 0.76 & 1.34 & 1.78 & -1.27\\
\hline
5 & -1.35 & -1.52 & 0.04 & 1.23 & 0.51\\
\hline
\end{tabular}

\caption{Describe contents of Table 1.B}

\begin{tabular}{|c|c|c|c|c|c|}

\hline
Recom Strength & Highest Idos Risk & 2nd Highest & Middle & 2nd Lowest & Lowest\\
\hline
1 & -0.41 & -0.07 & 1.27 & -0.78 & 0.73\\
\hline
2 & -0.85 & -1.88 & 0.01 & 0.75 & 2.32\\
\hline
3 & -0.48 & -1.0 & -0.56 & 0.47 & 1.01\\
\hline
4 & 0.04 & 0.76 & 1.34 & 1.78 & -1.27\\
\hline
5 & -1.35 & -1.52 & 0.04 & 1.23 & 0.51\\
\hline
\end{tabular}

\label{Test Table}
\end{table}

\end {document}


And it produces the following output:

I would like the lines that say:

Table 2: Describe contents of Table 1.A

to say:

Table 1.A: Describe contents of Table 1.A

and similarly, I want

Table 3: Describe contents of Table 1.B

to say

Table 1.B: Describe contents of Table 1.B

Essentially, if I could get rid of Latex automatically inserting "Table 1" or "Table 2" in every caption that I create, I would solve my problem.

It would also be nice if I could have my captions for Table 1.A and Table 1.B left aligned, like caption for Table 1 is.

How can I do this?

-
The caption package gives a lot of control over caption formatting, and also a \caption* command that is not numbered. Also [h!b!p!] is the same as [!hbp!] the ! applies to all the areas it does not need to be repeated. –  David Carlisle Nov 10 '12 at 19:56
[!hbp] I meant:-) –  David Carlisle Nov 10 '12 at 20:21
Your comment answers my main question, thank you! Do you know how to left-align the caption for Table 1.A and Table 1.B? –  Akavall Nov 10 '12 at 20:25
see the caption package doc you want \captionsetup{justification=raggedright} –  David Carlisle Nov 10 '12 at 20:42

I would do this using the subcaption package- the key parts of the MWE below are

\usepackage{subcaption}
\DeclareCaptionSubType*[Alph]{table}
\DeclareCaptionLabelFormat{mystyle}{Table~\bothIfFirst{#1}{ }#2}
\captionsetup[subtable]{labelformat=mystyle}


The output is

Note that I've put your 'sub' tables into a subtable environment, defined by the subcaption package.

\documentclass{article}

\usepackage{subcaption}
\DeclareCaptionSubType*[Alph]{table}
\DeclareCaptionLabelFormat{mystyle}{Table~\bothIfFirst{#1}{ ̃}#2}
\captionsetup[subtable]{labelformat=mystyle}

\begin{document}

\begin{table}[hbp!]
\centering
\caption{This caption describes contents of Table 1, gives the big picture.}
\label{TestTable}
\begin{subtable}{\textwidth}
\centering
\caption{Describe contents of Table 1.A}
\begin{tabular}{|c|c|c|c|c|c|}
\hline
Recom Strength & Highest Idos Risk & 2nd Highest & Middle & 2nd Lowest & Lowest \\
\hline
1              & -0.41             & -0.07       & 1.27   & -0.78      & 0.73   \\
\hline
2              & -0.85             & -1.88       & 0.01   & 0.75       & 2.32   \\
\hline
3              & -0.48             & -1.0        & -0.56  & 0.47       & 1.01   \\
\hline
4              & 0.04              & 0.76        & 1.34   & 1.78       & -1.27  \\
\hline
5              & -1.35             & -1.52       & 0.04   & 1.23       & 0.51   \\
\hline
\end{tabular}
\end{subtable}

\begin{subtable}{\textwidth}
\centering
\caption{Describe contents of Table 1.B}
\begin{tabular}{|c|c|c|c|c|c|}
\hline
Recom Strength & Highest Idos Risk & 2nd Highest & Middle & 2nd Lowest & Lowest \\
\hline
1              & -0.41             & -0.07       & 1.27   & -0.78      & 0.73   \\
\hline
2              & -0.85             & -1.88       & 0.01   & 0.75       & 2.32   \\
\hline
3              & -0.48             & -1.0        & -0.56  & 0.47       & 1.01   \\
\hline
4              & 0.04              & 0.76        & 1.34   & 1.78       & -1.27  \\
\hline
5              & -1.35             & -1.52       & 0.04   & 1.23       & 0.51   \\
\hline
\end{tabular}
\end{subtable}%
\end{table}

\end {document}


Unrelated to your question- a few folks would recommend the booktabs package, and would also recommend removing your vertical lines. I also noticed that these tables give you overfull hboxes- this should really be fixed before sending this to print.

-
Is that U+0303 instead of ~? –  Qrrbrbirlbel Nov 10 '12 at 20:46
Does overfull vboxes mean: my columns are of different widths because some column headers are too long? I am really new LaTex, and, yeah, I realize that I need more work on those tables. Thank you for pointing this out. –  Akavall Nov 10 '12 at 23:15
@Qrrbrbirlbel thanks, corrected –  cmhughes Nov 10 '12 at 23:18
@Akavall my mistake, I meant overfull hboxes. It can mean a few things- in this case, the table is too wide for the page. If you use \documentclass[draft]{article} then you'll see them visually with big black rules. You can load the geometry package to tweak pages sizes :) Happy TeXing! –  cmhughes Nov 10 '12 at 23:22
I got it. Thanks again. –  Akavall Nov 10 '12 at 23:50
show 1 more comment

A sans-caption solution that can be optimised (especially the needed \startsubcaptions).

## Code

\documentclass[12pt]{article}
\usepackage{etoolbox}

\newcounter{subtable}
\renewcommand*{\thesubtable}{\Alph{subtable}}
\newcounter{subfigure}
\renewcommand*{\thesubfigure}{\Alph{subfigure}}

\makeatletter
\newcommand*{\startsubcaptions}{%
\setcounter{sub\@captype}{0}
\csappto{the\@captype}{.\csname thesub\@captype\endcsname}%
}
\newcommand*{\subcaption}[2][]{%
\stepcounter{sub\@captype}%
\ifx\\#1\\\caption{#2}\else\caption[#1]{#2}\fi%
}
\newcommand*{\nonumbercaption}[1]{%
\refstepcounter{\@captype}%
{\centering #1\par}%
}
\makeatother
\begin{document}
\begin{table}[!hbp]
\nonumbercaption{This caption describes contents of Table 1, gives the big picture.}\label{table1}%
\startsubcaptions%
\subcaption{Describe contents of Table 1.A}\label{table1a}
\subcaption{Describe contents of Table 1.B}\label{table1b}
\end{table}

\ref{table1}, \ref{table1a}, \ref{table1b}

\begin{table}[!hbp]
\caption{This caption describes contents of Table 2, gives the big picture.}\label{table2}%
\startsubcaptions%
\subcaption{Describe contents of Table 2.A}\label{table2a}
\subcaption{Describe contents of Table 2.B}\label{table2b}
\end{table}

\ref{table2}, \ref{table2a}, \ref{table2b}
\end{document}


-