1

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!

1

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
\cs_set_eq:NN \xassoccnt_addtocounter \addtocounter % 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}

enter image description here

| improve this answer | |
0

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
| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.