図と表を 1 つのラベル名でまとめて番号付けする

図と表を 1 つのラベル名でまとめて番号付けする

図と表の両方のキャプションに、、、などを使用して、図と表に連続S.Iしてラベルを付けたいと思います。S.IIS.III

figuretableキャプションを に変更することができますS.I...

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

しかし、この方法では図と表が別々にカウントされます。S.Iしたがって、最初の図に 1 回、最初の表に 1 回、合計 2 回存在します。

これを回避するにはどうすればいいでしょうか? ありがとうございます!

答え1

アップデート結合カウンターの概念は現在xassoccntバージョン 1.0 (2016/08/09 時点の最新バージョン) になっており、CTAN/MikTeX および TeXLive 2016 で利用できます。

この質問へのリンクには回答がありますが、私は別の解決策として、私のxassoccntパッケージの (次のリリースの) 実験的なコードを提供します。コードは現時点では長く見えますが、もちろんセットアップを減らす他のマクロを使用してパッケージ内に隠されます。将来の計画では、この例のように 2 つだけではなく、共有または結合されたカウンターを多数用意する予定です。

\listoftables注: これは、 と の\listoffigures機能を 1 つに組み合わせるものではありませんList of ...(私の観点からすると、いずれにしても奇妙なことです)。

で動作します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}

ここに画像の説明を入力してください

答え2

ハイパーリファレンスが必要ない場合:

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

関連情報