부록 번호 이름을 A 및 B 대신 S1 및 S2로 변경

부록 번호 이름을 A 및 B 대신 S1 및 S2로 변경

과제를 작성 중인데 지시에 따라

부록은 "부록 S1", "부록 S2" 등의 명명 형식을 따라야 합니다.

수업 을 이용하고 있습니다 elsarticle. 지금까지 나는 노력했다.

\appendix
\renewcommand{\thesection}{\Alph{section}}

그러나 기본적으로 A. 명명 형식을 A 대신 S에서 시작할 수 있는 방법이 있나요?

답변1

부록은 "부록 S1", "부록 S2" 등의 명명 형식을 따라야 합니다.

문서 elsarticle클래스에는 부록 섹션 및 해당 내용과 관련하여 다음과 같은 다소 잘못된 지침이 포함되어 있습니다.

\def\appendixname{Appendix }
\renewcommand\appendix{\par
  \setcounter{section}{0}%
  \setcounter{subsection}{0}%
  \setcounter{equation}{0}
  \gdef\thefigure{\@Alph\c@section.\arabic{figure}}%
  \gdef\thetable{\@Alph\c@section.\arabic{table}}%
  \gdef\thesection{\appendixname~\@Alph\c@section}%
  \@addtoreset{equation}{section}%
  \gdef\theequation{\@Alph\c@section.\arabic{equation}}%
  \addtocontents{toc}{\string\let\string\numberline\string\tmptocnumberline}{}{}
}

특히 및 패키지 에서 각각 제공하는 두 개의 사용자 수준 매크로인 및 \gdef\thesection{\appendixname~\@Alph\c@section}를 통해 부록 섹션을 적절하게 상호 참조하는 것이 불가능하게 만드는 잔혹함에 주목하세요 .\autoref\crefhyperrefcleveref

원하는 형식을 얻고 일반적인 상호 참조 기능을 복원하려면 실행 후 다음 지침을 실행하는 것이 좋습니다 \appendix.

\makeatletter
\def\@seccntformat#1{\@ifundefined{#1@cntformat}%
   {\csname the#1\endcsname\space}%    default
   {\csname #1@cntformat\endcsname}}%  enable individual control
\newcommand\section@cntformat{\appendixname\thesection.\space} % section-level
\makeatother
\renewcommand{\thesection}{S\arabic{section}}
\counterwithin{equation}{section}
\counterwithin{figure}{section}
\counterwithin{table}{section}

여기에 이미지 설명을 입력하세요

\documentclass{elsarticle}
\usepackage{cleveref} % for '\cref' command
\begin{document}

\section{Introduction}

\noindent
Cross-references to \cref{app:hello,app:world,eq:pyth,fig:here,tab:there}. 


\appendix

\makeatletter
\def\@seccntformat#1{\@ifundefined{#1@cntformat}%
   {\csname the#1\endcsname\space}%    default
   {\csname #1@cntformat\endcsname}}%  enable individual control
\newcommand\section@cntformat{\appendixname\thesection.\space} % section-level
\makeatother
\renewcommand{\thesection}{S\arabic{section}}
\counterwithin{equation}{section}
\counterwithin{figure}{section}
\counterwithin{table}{section}

\section{Hello} \label{app:hello}
\begin{equation}\label{eq:pyth} a^2+b^2=c^2 \end{equation}
\begin{figure}[h] \caption{A figure caption}\label{fig:here} \end{figure}

\section{World} \label{app:world}
\begin{table}[h] \caption{A table caption}\label{tab:there} \end{table}

\end{document}

답변2

나는 동의한다Mico의 분석\appendixin 에 대한 코드가 elsarticle.cls끔찍하다는 것입니다.

하지만 문서 중간에 나오는 복잡한 코드에는 동의하지 않습니다. 또한 Mico의 제안에 일부 변경이 필요해 보이지만 그의 아이디어는 평소와 같이 매우 좋습니다.

\documentclass{elsarticle}
\usepackage{cleveref} % for '\cref' command

\makeatletter
\newif\if@els@appendix
\renewcommand\appendix{\par
  \global\@els@appendixtrue
  \setcounter{section}{0}%
  \setcounter{subsection}{0}%
  \setcounter{equation}{0}%
  \counterwithin{figure}{section}%
  \counterwithin{table}{section}%
  \counterwithin{equation}{section}%
  \gdef\thesection{S\arabic{section}}% <--- HERE THE NUMBERING FORMAT
  \addtocontents{toc}{\string\let\string\numberline\string\tmptocnumberline}{}{}
}
\NewCommandCopy{\els@seccntformat}{\@seccntformat}
\renewcommand{\@seccntformat}[1]{%
  \ifcsname format@#1\endcsname
    \csname format@#1\endcsname
  \else
    \els@seccntformat{#1}%
  \fi
}
\newcommand{\format@section}{%
  \if@els@appendix \appendixname\fi\els@seccntformat{section}%
}
\def\tmptocnumberline#1{%
   \settowidth\appnamewidth{\appendixname S00}%
   \hb@xt@\appnamewidth{\appendixname #1\hfill}%
}
\makeatother

\begin{document}

\tableofcontents

\section{Introduction}

Cross-references to \cref{app:hello,app:world,eq:pyth,fig:here,tab:there}. 

\appendix

\section{Hello} \label{app:hello}
\begin{equation}\label{eq:pyth} a^2+b^2=c^2 \end{equation}
\begin{figure}[htp] \caption{A figure caption}\label{fig:here} \end{figure}

\section{World} \label{app:world}
\begin{table}[htp] \caption{A table caption}\label{tab:there} \end{table}

\end{document}

정의된 클래스의 복사본을 사용하면 \@seccntformat출력의 일관성이 보장됩니다. 목차의 인쇄 방법도 와 유사하게 변경합니다 elsarticle.

부록의 번호도 "추상"하지 않았지만 정의된 위치가 명확하게 표시되어 있습니다.

이 접근 방식의 장점: 사본 편집자가 귀하의 스타일에 동의하지 않으면 서문에 추가된 코드를 제거하면 됩니다. 그러나 을 사용하게 되면 cleveref문서에서 몇 가지 변경 사항이 필요할 수 있습니다.

cleveref코드가 작동하는 데 꼭 필요한 것은 아닙니다.

여기에 이미지 설명을 입력하세요

답변3

\appendix
\setcounter{section}{18}%. is R, next will be S
\renewcommand{\thesection}{\Alph{section}}

관련 정보