# Combining cleveref, subcaption, and subtable word prefix

I would like to use subcaption package to call subtables "panels". The subtables for Table 1 would be "Panel A" and Panel B". I can do this fine, but when I use \cref{tab:01a} for Table 1 Panel A I get something like "table 1Panel A". I would like to get back the space between "table 1" and "Panel A". It would also be great to make "Panel" case sensitive, but that is less important -- I can just make everything title case.

\documentclass{article}

% tables and captions
\usepackage[font=small]{caption}
\usepackage{subcaption}

% fix table captions
\renewcommand{\thesubtable}{Panel \Alph{subtable}}
\captionsetup[sub]{labelformat=simple, labelsep=colon, belowskip=12pt}

\usepackage{cleveref}

\begin{document}

I want to refer to \cref{tab:01}, \cref{tab:01a}, and \cref{tab:01b}.

\begin{table}
\caption{Outer.}
\label{tab:01}

\begin{subtable}{\hsize}
\caption{Inner a.}
\label{tab:01a}
\begin{tabular}{c}
1 \\
\end{tabular}
\end{subtable}

\begin{subtable}{\hsize}
\caption{Inner b.}
\label{tab:01b}
\begin{tabular}{c}
2 \\
\end{tabular}
\end{subtable}

\end{table}

\end{document}


This gives "table 1" and "Panel A" without spaces.

• @Mico - thanks. Can this fail me in subtable captions? Or is it really that easy?! – Richard Herron Aug 22 '16 at 19:56
• Please clarify what you mean by "can this fail me in subtable captions?" – Mico Aug 22 '16 at 20:06
• @Mico - I am not sure, either? :) I am still a little confused about when I need ~ to get spaces and avoid run-ons. – Richard Herron Aug 22 '16 at 20:09
• @Mico - But your solution works! Thanks! – Richard Herron Aug 22 '16 at 20:10

I would do it this way:

\documentclass{article}

% tables and captions
\usepackage[font=small]{caption}
\usepackage{subcaption}

% fix table captions
\renewcommand\subtablename{Panel}
\renewcommand{\thesubtable}{\Alph{subtable}}
\captionsetup[sub]{labelformat=simple, labelsep=colon, belowskip=12pt}

\usepackage{cleveref}
\crefname{subtable}{panel}{panels}%
\Crefname{subtable}{Panel}{Panels}%

\begin{document}

I want to refer to \cref{tab:01}, \cref{tab:01a}, and \cref{tab:01b}.

\begin{table}
\caption{Outer.}
\label{tab:01}

\begin{subtable}{\hsize}
\caption{Inner a.}
\label{tab:01a}
\begin{tabular}{c}
1 \\
\end{tabular}
\end{subtable}

\begin{subtable}{\hsize}
\caption{Inner b.}
\label{tab:01b}
\begin{tabular}{c}
2 \\
\end{tabular}
\end{subtable}

\end{table}

\end{document}


• +1 for having the courage to propose a solution that differs considerably from what the OP said he wants. :-) – Mico Aug 23 '16 at 4:54

You could change

\renewcommand{\thesubtable}{Panel \Alph{subtable}}


to

\renewcommand{\thesubtable}{ Panel \Alph{subtable}}


Note the extra space before "Panel".