# number figures and tables together with one label name [duplicate]

I would like to label my figures and tables continuously using S.I, S.II, S.III, etc in the caption of both, figures and tables.

I can change the figure and table caption to S.I, ... by

\renewcommand{\tablename}{S.}
\renewcommand{\figurename}{S.}
\renewcommand{\thetable}{\Roman{table}}
\renewcommand{\thefigure}{\Roman{figure}}


but this still counts figures and tables separately. S.I thus exists twice, once for the first figure and once for the first table.

How can I avoid this? Thank you!

• – Alenanno Feb 9 '16 at 9:11
• Thank you! I did actually look for similar questions, but obviously I am blind! – user1638145 Feb 9 '16 at 9:14
• Ahah no problem. :D – Alenanno Feb 9 '16 at 9:15

Update The concept of coupled counters is now in xassoccnt version 1.0 (current version as of 2016/08/09) which is available on CTAN/MikTeX and TeXLive 2016.

Although there are answers in the links to this question, I provide another solution which has experimental code of (the next release) of my xassoccnt package. The code looks lengthy at the moment, but it will be hidden in the package, using other macros that will reduce the setup of course. The future plan is to have a bunch of counters that are 'shared' or coupled, not just two as in this example.

Note: This does not combine the \listoftables and \listoffigures features into one List of ... (which would be weird anyway, in my point of view)

It works with hyperref!

\documentclass{article}

\usepackage{xassoccnt}
\usepackage{blindtext}

\renewcommand{\tablename}{S.}
\renewcommand{\figurename}{S.}
\renewcommand{\thetable}{\Roman{table}}
\renewcommand{\thefigure}{\Roman{figure}}

\ExplSyntaxOn
\seq_new:N \l__xassoccnt_coupledcounters_seq
\NewDocumentCommand{\DeclareCoupledCounters}{mm}{%
\seq_clear:N \l__xassoccnt_coupledcounters_seq
\seq_gput_right:Nn \l__xassoccnt_coupledcounters_seq {#1}
\seq_gput_right:Nn \l__xassoccnt_coupledcounters_seq {#2}
}

\cs_set_eq:NN \xassoccnt_stepcounter \stepcounter
\cs_set_eq:NN \xassoccnt_setcounter \setcounter % Should be done

\RenewDocumentCommand{\stepcounter}{m}{%
\tl_set:Nx \l_tmpa_tl {#1}
\seq_if_in:NVTF \l__xassoccnt_coupledcounters_seq  {\l_tmpa_tl} {%
\seq_map_inline:Nn \l__xassoccnt_coupledcounters_seq {%
\xassoccnt_stepcounter{##1}
}
}{
\xassoccnt_stepcounter{#1}% Only step #1
}
}
\ExplSyntaxOff

\DeclareCoupledCounters{figure}{table}

\usepackage{hyperref}

\begin{document}
\listoffigures
\listoftables

\section{First}

\blindtext[10]

\begin{figure}

\caption{foo figure}
\end{figure}

\blindtext[10]

\begin{table}
\caption{foo table}
\end{table}

\section{Second}

\blindtext[10]

\begin{figure}

\caption{other foo figure}
\end{figure}

\blindtext[10]

\begin{table}
\caption{other foo table}
\end{table}

\end{document}


If you do not need hyperref:

\renewcommand{\tablename}{S.}
\renewcommand{\figurename}{S.}
\makeatletter
\let\c@table\c@figure
\makeatother
\renewcommand\thefigure{\Roman{figure}}
\let\thetable\thefigure