Change Table name from 'Table S 1' to 'Table S1'
The proper way to do this should not be to change the table name but the table number. Replace \renewcommand{\tablename}{Table S}
with
\renewcommand{\thetable}{S\arabic{table}}
If you change the appearance of the regular table numbers, then the following code retains that look and just adds an S, which might or might not be what you want.
\let\oldthetable\thetable
\renewcommand{\thetable}{S\oldthetable}
Changing the table number also affects \ref
, giving S1, while changing the table name gives just the number 1.
Another method: Replace \renewcommand{\tablename}{Table S}
with
\makeatletter
\renewcommand{\tablename}{Table S\@gobble}
\makeatother
The command \@gobble
removes the next token (which in this case is the space).
A problem with @samcarters version is that if the caption is longer than one line the space is stretched somewhat, and the negative space doesn't account for that, leaving a small gap between S and 1 (negative space in red, \@gobble
in black).
If you want that the “S” also appears in cross references, the correct way is to add it to \thetable
:
\renewcommand{\thetable}{S\arabic{table}}
would do good in article
, but it would not be good in book
. For a “class independent” solution, add
\usepackage{etoolbox}
to your set of packages and
\preto\thetable{S}
in the settings section of the preamble.
If you don't need the “S” in cross references, you can use the caption
package:
\documentclass[12pt,a4paper]{article}
\usepackage{caption}
\DeclareCaptionLabelFormat{addS}{#1 S#2}
\captionsetup[table]{labelformat=addS}
\begin{document}
\begin{table}
\centering
\caption{Remove the space in 'Table S 1', so that it becomes 'Table S1'}
\begin{tabular}{lcc}
\hline
& p.adjusted & Gene Ratio \\ \hline
TBA & 3.28E-04 & 12/89 \\
\end{tabular}
\end{table}
\end{document}