我正在寻找一种方法来改变页面样式第一的chapter
使用 KOMA-Class的发生scrreprt
。如果更改自动发生而无需用户交互,那么这将是理想的,这样我就可以隐藏自定义类中的逻辑myownclass
。
\documentclass{scrreprt}
% \documentclass{myonwclass}
\usepackage[T1]{fontenc}
\usepackage{blindtext}
\author{Max Mustermann}
\title{SE Question}
\date{\today}
\begin{document}
% No page numbering wanted here
\pagenumbering{Roman} % Just for demo
\maketitle
\tableofcontents
\listoffigures
\listoftables
% Change page style automically
% No need to print \pagenumbering or whatever
\chapter{The first chapter has appeared}
\pagenumbering{arabic} % Start counting page number and show them
\Blinddocument
\end{document}
如果有可能就好了没有引入一个新的命令,如\frontmatter
或\mainmatter
。
答案1
假设切换到阿拉伯页码应该在您可以修补的第一个编号章节\chapterlinesformat
进行\chapterlineswithprefixformat
:
\documentclass{scrreprt}
\usepackage[T1]{fontenc}
\usepackage{blindtext}
\usepackage{xpatch}
\xpretocmd{\chapterlinesformat}{%
\autoswitchtoarabicpagenumbering{#1}{#2}%
}{}{\PatchFailed}
\xpretocmd{\chapterlineswithprefixformat}{%
\autoswitchtoarabicpagenumbering{#1}{#2}%
}{}{\PatchFailed}
\makeatletter
\newcommand*{\autoswitchtoarabicpagenumbering}[2]{%
\ifstr{#1}{chapter}{%
\IfArgIsEmpty{#2}{}{\pagenumbering{arabic}}%
}%
\global\let\autoswitchtoarabicpagenumbering\@gobbletwo
}
\makeatother
\pagenumbering{Roman}
\author{Max Mustermann}
\title{SE Question}
\date{\today}
\begin{document}
\maketitle
\tableofcontents
\listoffigures
\listoftables
% Change page style automically
% No need to print \pagenumbering or whatever
\chapter{The first chapter has appeared}
\Blinddocument
\end{document}
不过,我建议不要这样做,而是使用scrbook
而不是并使用和scrreprt
进行切换:\frontmatter
\mainmatter
\documentclass[oneside]{scrbook}
\usepackage[T1]{fontenc}
\usepackage{blindtext}
\usepackage{xpatch}
\xpatchcmd{\frontmatter}{roman}{Roman}{}{\PatchFailed}% use uppercase Roman
% page numbers instead of lowercase
\author{Max Mustermann}
\title{SE Question}
\date{\today}
\begin{document}
\frontmatter
\maketitle
\tableofcontents
\listoffigures
\listoftables
\mainmatter
\chapter{The first chapter has appeared}
\Blinddocument
\end{document}
此解决方案使您能够更好地控制如何以及在何处对不同文档段进行所需的更改。