
부품 번호를 약어로 바꾸고 싶습니다. 예를 들어, 다음 MWE의 부분 대수와 관련하여 ALG.1
대신 첫 번째 장이 호출되기를 원합니다 I.1
(고려된 부분의 모든 장에 대해 동일하게).
약어는 ALG
이상적으로 명령의 선택적 인수일 수 있습니다 \part
.
MWE :
\documentclass[oneside]{scrbook}
%reset chapter for each part
\makeatletter
\@addtoreset{chapter}{part}
\makeatother
\renewcommand{\thechapter}{\thepart\arabic{chapter}}
\begin{document}
\part{Algebra} %\part[ALG]{Algebra} ?
\chapter{Chap 1}
\part{Analysis}
\chapter{Chap 1}
\part{Geometry}
\chapter{Chap 1}
\end{document}
답변1
\acropart
다음은 명령 바로 뒤에 명령을 사용하는 간단한 솔루션입니다 \part
.
\documentclass[oneside]{scrbook}
\counterwithin*{chapter}{part}
\makeatletter
\DeclareRobustCommand\acropart[1]{\gdef\@acropart{#1}}
\renewcommand{\thechapter}{\@acropart.~\arabic{chapter}}
\makeatother
\makeatother
\begin{document}
\part{Algebra} %\part[ALG]{Algebra} ?
\acropart{ALG}
\chapter{Chapter the first}
\chapter{Chapter the second}
\part{Analysis}
\acropart{ANAL}
\chapter{Chapter the first}
\part{Geometry}
\acropart{GEOM}
\chapter{Chapter the first}
\end{document}
답변2
문제의 MWE에는 이미 \thechapter
. 부품 카운터를 \thepart
필요한 약어가 포함된 새 매크로로 교체하여 추가로 사용자 정의할 수 있습니다.
\part
의 이전 정의 에 대한 선택적 인수를 사용하여 이를 설정하려면 \part
와 같은 다른 매크로에 저장한 \oldpart
다음 \part
선택적 인수를 허용하도록 재정의하고 이를 매크로에 저장한 다음 \oldpart
기본 인수를 처리할 매크로를 호출합니다. 비슷하다\def의 선택적 인수. 선택적 인수의 기본값은 이며 \thepart
, 라벨이 없는 부품에 로마 부품 번호를 사용하여 번호를 매길 수 있습니다.
목차를 인쇄할 때 장 레이블이 기본 너비에 맞지 않는 경우 이 문제는 를 사용하여 해결할 수 있습니다 \RedeclareSectionCommand
.
MWE:
\documentclass[oneside]{scrbook}
\RedeclareSectionCommand[
tocnumwidth=1.5cm
]{chapter}
\let\oldpart\part
\renewcommand\part[1][\thepart]{\def\partacr{#1}\oldpart}
%reset chapter for each part
\makeatletter
\@addtoreset{chapter}{part}
\makeatother
\renewcommand{\thechapter}{\partacr.\arabic{chapter}}
\begin{document}
\tableofcontents
\part[ALG]{Algebra}
\chapter{Chap 1}
\chapter{Chap 2}
\part{Geometry}
\chapter{Chap 1}
\chapter{Chap 2}
\end{document}
결과:
답변3
이와 같이?
\documentclass[oneside]{scrbook}
%reset chapter for each part
\makeatletter
\@addtoreset{chapter}{part}
\makeatother
\newcommand{\prt}[2]{\part{#2}
\renewcommand{\thechapter}{#1\arabic{chapter}}}
\usepackage{tocloft}
\renewcommand\cftchapnumwidth{1.2cm} %<-- For tableofcontents
\begin{document}
\tableofcontents
\prt{ALG}{Algebra} %\part[ALG]{Algebra} ?
\chapter{Chap 1}
\prt{ANA}{Analysis}
\chapter{Chap 1}
\prt{GEO}{Geometry}
\chapter{Chap 1}
\end{document}