
ALG.1
パート番号を略語に置き換えたいと思います。たとえば、次の MWE のパート代数に関して、最初の章を ではなく と呼びたいと思います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}