하나의 라벨 이름과 함께 숫자 그림 및 표

하나의 라벨 이름과 함께 숫자 그림 및 표

그림과 표의 캡션에 S.I, S.II, 등을 계속 사용하여 그림과 표에 라벨을 붙이고 싶습니다 .S.III

figure및 캡션을 , ... table로 변경할 수 있습니다.S.I

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

그러나 이것은 여전히 ​​숫자와 표를 별도로 계산합니다. S.I따라서 첫 번째 그림에 대해 한 번, 첫 번째 테이블에 대해 한 번, 두 번 존재합니다.

이것을 어떻게 피할 수 있습니까? 감사합니다!

답변1

업데이트결합 카운터의 개념은 이제 xassoccntCTAN/MikTeX 및 TeXLive 2016에서 사용할 수 있는 버전 1.0(2016/08/09 현재 버전)에 있습니다.

이 질문에 대한 링크에 답변이 있지만 내 xassoccnt패키지의 (다음 릴리스) 실험 코드가 있는 또 다른 솔루션을 제공합니다. 현재로서는 코드가 길어 보이지만 설정을 줄이는 다른 매크로를 사용하여 패키지에 숨겨집니다. 향후 계획은 이 예에서처럼 두 개가 아닌 '공유'되거나 결합된 여러 카운터를 갖는 것입니다.

참고: 이는 \listoftables\listoffigures기능을 하나로 결합하지 않습니다 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

관련 정보