2

I am trying to create a table in LaTeX that has the formats "S1 Table". As you can see, in my current MWE code, the table is entitled "Table 1":

\documentclass[10pt,letterpaper]{article}
   \begin{document}

    \begin{table}[h]
    \caption{Here is a practice table}
    {\setlength{\tabcolsep}{3pt} % Make column width smaller to fit page
     \begin{tabular}{llllll}
     \hline
     Name & Number & Color\\ \hline
     Name1 & Number1 & Color1\\   
     Name2 & Number2 & Color2\\
     Name3 & Number3 & Color3\\
     Name4 & Number4 & Color4\\ \hline
     \end{tabular}}
   \label{s1table}
   \end{table}

\end{document}

Is it possible to change this format so that the title is instead "S1 Table". I have seen examples that ask about the reverse "Table S1" which does not work for my solution. I have even seen another example more similar to my question, but the solutions remain unclear to me. Any advice would be greatly appreciated!

1

2 Answers 2

3

enter image description here

\documentclass[10pt,letterpaper]{article}
\usepackage{caption}                         % <--- added
\captionsetup[table]{name=SI table,          % <--- define caption name
                     skip=1ex, labelfont=bf} 
begin{document}
    \begin{table}[h]
    \centering
\caption{Here is a practice table}
\label{s1table}
\setlength{\tabcolsep}{3pt} % Make column width smaller to fit page
 \begin{tabular}{llllll}
    \hline
 Name  & Number  & Color  & \multicolumn{3}{c}{Num.}\\ 
    \hline
 Name2 & Number2 & Color2 & 1 & 2 & 3   \\
 Name3 & Number3 & Color3 & 1 & 2 & 3   \\
 Name4 & Number4 & Color4 & 1 & 2 & 3   \\ 
    \hline
 \end{tabular}
    \end{table}
\end{document}

For caption name set up see package documentation, section 2.8 Names, page 15.

0

You can do this using the caption package and by redefining the label format using the \DeclareCaptionLabelFormat command. In this #1 will get replaced with the name of the float (table, figure, ...) and #2 will be replace with the reference number.

The default label format is simple #1 #2.

In your case you want the number before the name and prefixed with S, so the label format should look like S#2 #1

Your MWE would therefore look like:

\documentclass[10pt,letterpaper]{article}

\usepackage{caption}                            %<---
\DeclareCaptionLabelFormat{Sformat}{S#2 #1}     %<---
\captionsetup[table]{labelformat=Sformat}       %<---

\usepackage{cleveref}

\begin{document}
    \begin{table}[h]
    \centering
    \caption{Here is a practice table}
    \label{s1table}
    \setlength{\tabcolsep}{3pt} % Make column width smaller to fit page
    \begin{tabular}{llllll}
        \hline
        Name  & Number  & Color  & \multicolumn{3}{c}{Num.}\\ 
        \hline
        Name2 & Number2 & Color2 & 1 & 2 & 3   \\
        Name3 & Number3 & Color3 & 1 & 2 & 3   \\
        Name4 & Number4 & Color4 & 1 & 2 & 3   \\ 
        \hline
    \end{tabular}
\end{table}

When we refer to the table, we get \cref{s1table}.

\end{document}

enter image description here

Here I am only reformatting the table caption. Also note that if you want to use cleveref, you will have to configure that separately to match the caption format or some other one.

You must log in to answer this question.

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