如何将各部分放在下一章的同一页上?(scrbook)

如何将各部分放在下一章的同一页上?(scrbook)

有没有办法将各部分的名称放在下一章的同一页上?我试过这样做,为了注意它的效果,我取消注释了注释行,你可以看到章节编号和名称的格式丢失了。有什么方法或技巧可以避免这种情况吗?提前感谢你的帮助。我的最小工作示例如下所示:

\documentclass[
]{scrbook}
\usepackage{xcolor}
\usepackage{graphicx}
\usepackage{minitoc}
\usepackage{setspace}
\usepackage{lmodern}

%%%** Decompose to appreciate the effect and in case it generates an error, compile twice.
%\RedeclareSectionCommand[
%beforeskip=\dimexpr-3.3\baselineskip-\parskip\relax,
%afterskip=\dimexpr3.3\baselineskip+\parskip\relax,
%style=chapter% no part page
%]{part}
%\renewcommand\partformat{\partname\ \thepart\autodot\enskip}

%\DeclareNewSectionCommand[
%beforeskip=-1sp,
%afterskip=1.725\baselineskip plus .115\baselineskip minus .192\baselineskip,
%style=section,% no page break before \firstchapterinpart
%level=\chapternumdepth,
%indent=0pt,
%tocindent=0pt,
%tocnumwidth=1.5em,
%font=\usekomafont{chapter},
%tocstyle=chapter,
%tocnumwidth=1.5em
%]{firstchapterinpart}

%\renewcommand\partformat{\partname\ \thepart\autodot\enskip}

%\makeatletter
%\let\c@firstchapterinpart\c@chapter% use the same counter for both chapter and firstchapterinpart
%\def\cl@firstchapterinpart{\cl@chapter}% use the same reset list as chapter
%\makeatother
%%%**

\begin{document}
\dominitoc
\tableofcontents    
    
    
\part{Name of The First Part..}
%\firstchapterinpart{Name of the First Chapter}
\chapter{Name of the First Chapter}
\minitoc
\section{Section 1.1}
Text goes here  
\subsection{Papers Submitted}
Text
    
\subsubsection{I want to go into the TOC}
Testing stuff out
    
\chapter{Another chapter from part one}
    
\minitoc
\section{Section ??? }
Text goes here
\subsection{Papers Submitted }
Text
\subsubsection{Section 1.1}
Testing stuff out
\part{Name of The Second Part..}
%\firstchapterinpart{Name of the first chapter of part 2}
\chapter{Name of the first chapter of part 2}   
\minitoc
\section{Section 1.1 why does it appear 3. if this belongs to chapter two?}
Text goes here
\subsection{Papers Submitted}
Text
\subsubsection{I want to go into the TOC}
Testing stuff out
\section{appreciate this}
\chapter{Other Chapter name}
\minitoc
\section{Section 1.1}
Text goes here
\subsection{Papers Submitted}
Text
\subsubsection{I want to go into the TOC}
Testing stuff out
\section{jjj}
\bibliographystyle{plain}
\bibliography{bibliography}
\end{document} 

你可能注意到了,英语不是我的母语。提前致歉,如果我的英语不好、不好、不完整,我深表歉意 :)

答案1

我无法重现章节编号和名称的丢失。但部分标题的格式发生了变化,部分第一章的本地目录丢失了。

这里建议使用包etoc来代替minitoc

\documentclass{scrbook}
\usepackage[T1]{fontenc}
\usepackage{lmodern}

\usepackage{etoc}
\AddToHook{cmd/tableofcontents/after}{% etoc style for locals TOC 
  \etocsettocstyle
  {\renewcommand{\baselinestretch}{1}\noindent\textbf{\contentsname}\\[-.7\baselineskip]\rule{\linewidth}{0.5pt}\vskip0.3\baselineskip}
  {\renewcommand{\baselinestretch}{1}\noindent\rule{\linewidth}{0.5pt}\vskip0.5\baselineskip}% 
}

\RedeclareSectionCommand[
  afterindent=false,
  beforeskip=\dimexpr3.3\baselineskip+\parskip\relax,
  afterskip=\dimexpr3.3\baselineskip+\parskip\relax,
  style=chapter% no part page
]{part}
\RenewDocumentCommand{\partformat}{}{\partname\ \thepart\autodot\enskip}
\NewCommandCopy{\originalchapterlinesformat}{\chapterlinesformat}
\RenewDocumentCommand{\chapterlinesformat}{mmm}{%
  \Ifstr{#1}{part}
    {\centering#2\par\vskip.5\baselineskip#3}% format of part headings
    {\originalchapterlinesformat{#1}{#2}{#3}}% original definition for other levels using style=chapter
}
%
\DeclareTOCStyleEntry[
  level:=chapter,
  indent:=chapter,
  numwidth:=chapter,
]{chapter}{firstchapterinpart}
\DeclareNewSectionCommand[
beforeskip=-1sp,
afterskip=1.725\baselineskip plus .115\baselineskip minus .192\baselineskip,
style=section,% no page break before \firstchapterinpart
level=\chapternumdepth,
indent=0pt,
font=\usekomafont{chapter}
]{firstchapterinpart}
\etocsetlevel{firstchapterinpart}{\chapternumdepth}

\makeatletter
\let\c@firstchapterinpart\c@chapter% use the same counter for both chapter and firstchapterinpart
\def\cl@firstchapterinpart{\cl@chapter}% use the same reset list as chapter
\makeatother

\begin{document}
\tableofcontents

\part{Name of The First Part..}
\firstchapterinpart{Name of the First Chapter}
%\chapter{Name of the First Chapter}
\localtableofcontents
\section{Section 1.1}
Text goes here  
\subsection{Papers Submitted}
Text
\subsubsection{I want to go into the TOC}
Testing stuff out
\chapter{Another chapter from part one}
\localtableofcontents
\section{Section ??? }
Text goes here
\subsection{Papers Submitted }
Text
\subsubsection{Section 1.1}
Testing stuff out

\part{Name of The Second Part..}
\firstchapterinpart{Name of the first chapter of part 2}
%\chapter{Name of the first chapter of part 2}
\localtableofcontents
\section{Section 1.1 why does it appear 3. if this belongs to chapter two?}
Text goes here
\subsection{Papers Submitted}
Text
\subsubsection{I want to go into the TOC}
Testing stuff out
\section{appreciate this}
\chapter{Other Chapter name}
\localtableofcontents
\section{Section 1.1}
Text goes here
\subsection{Papers Submitted}
Text
\subsubsection{I want to go into the TOC}
Testing stuff out
\section{jjj}
\end{document}

在此处输入图片描述


补充说明因为下面的评论:如果部分标题不应该有前缀行,请删除\chapterlinesformat上面代码中的重新定义:

\documentclass{scrbook}
\usepackage[T1]{fontenc}
\usepackage{lmodern}

\usepackage{etoc}
\AddToHook{cmd/tableofcontents/after}{% etoc style for locals TOC 
  \etocsettocstyle
  {\renewcommand{\baselinestretch}{1}\noindent\textbf{\contentsname}\\[-.7\baselineskip]\rule{\linewidth}{0.5pt}\vskip0.3\baselineskip}
  {\renewcommand{\baselinestretch}{1}\noindent\rule{\linewidth}{0.5pt}\vskip0.5\baselineskip}% 
}

\RedeclareSectionCommand[
  afterindent=false,
  beforeskip=\dimexpr3.3\baselineskip+\parskip\relax,
  afterskip=\dimexpr3.3\baselineskip+\parskip\relax,
  style=chapter% no part page
]{part}
\RenewDocumentCommand{\partformat}{}{\partname\ \thepart\autodot\enskip}

\DeclareTOCStyleEntry[
  level:=chapter,
  indent:=chapter,
  numwidth:=chapter,
]{chapter}{firstchapterinpart}
\DeclareNewSectionCommand[
beforeskip=-1sp,
afterskip=1.725\baselineskip plus .115\baselineskip minus .192\baselineskip,
style=section,% no page break before \firstchapterinpart
level=\chapternumdepth,
indent=0pt,
font=\usekomafont{chapter}
]{firstchapterinpart}
\etocsetlevel{firstchapterinpart}{\chapternumdepth}

\makeatletter
\let\c@firstchapterinpart\c@chapter% use the same counter for both chapter and firstchapterinpart
\def\cl@firstchapterinpart{\cl@chapter}% use the same reset list as chapter
\makeatother

\begin{document}
\tableofcontents

\part{Name of The First Part..}
\firstchapterinpart{Name of the First Chapter}
%\chapter{Name of the First Chapter}
\localtableofcontents
\section{Section 1.1}
Text goes here  
\subsection{Papers Submitted}
Text
\subsubsection{I want to go into the TOC}
Testing stuff out
\chapter{Another chapter from part one}
\localtableofcontents
\section{Section ??? }
Text goes here
\subsection{Papers Submitted }
Text
\subsubsection{Section 1.1}
Testing stuff out

\part{Name of The Second Part..}
\firstchapterinpart{Name of the first chapter of part 2}
%\chapter{Name of the first chapter of part 2}
\localtableofcontents
\section{Section 1.1 why does it appear 3. if this belongs to chapter two?}
Text goes here
\subsection{Papers Submitted}
Text
\subsubsection{I want to go into the TOC}
Testing stuff out
\section{appreciate this}
\chapter{Other Chapter name}
\localtableofcontents
\section{Section 1.1}
Text goes here
\subsection{Papers Submitted}
Text
\subsubsection{I want to go into the TOC}
Testing stuff out
\section{jjj}
\end{document}

在此处输入图片描述

相关内容