如何生成像示例中的章节/部分/小节树的结构?

如何生成像示例中的章节/部分/小节树的结构?

我喜欢这样的结构(来自简介章节/部分)[忽略红色框]

期望输出

章节看起来像

实际章节

然而我得到的是这个

我的输出

主文件的 MWE 是

\documentclass[a4paper,11pt,oneside,chapterprefix=TRUE]{scrbook}
\usepackage{lipsum} % For generating dummy text
\usepackage[utf8]{inputenc}
\usepackage{scrlayer-scrpage}
\usepackage[pass,a4paper]{geometry}
\usepackage[nottoc]{tocbibind}
\usepackage[a4,frame,center]{crop}
\usepackage[T1]{fontenc}
\usepackage{setspace}
\usepackage[normalem]{ulem} % for underline with normalem option
\usepackage{ragged2e} % For justified text
%\usepackage{titlesec} % Suppress leading zero in section
\renewcommand{\thesection}{\arabic{section}}
\setcounter{secnumdepth}{3}
% Math packages
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{mathtools}
\usepackage{gensymb}
\usepackage{siunitx}
\usepackage{latexsym}
\usepackage{amsthm}
\usepackage{pdfpages}
\usepackage{url}
\usepackage{hyperref}
\usepackage{graphicx}
\usepackage{tabularx}
\usepackage{array}
\usepackage[inline]{asymptote}
\usepackage{eqparbox}
\usepackage[center]{caption}
\usepackage{subcaption}
\usepackage{float}
\usepackage[misc]{ifsym}
\usepackage{csquotes}
\usepackage[section]{placeins}
\usepackage{siunitx}
\usepackage{mdwmath}
\usepackage{mdwtab}
\usepackage{euler}
\usepackage{stmaryrd}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{enumerate}
\usepackage{titletoc}
\usepackage{makeidx}         % allows index generation
\usepackage{multicol}        % used for the two-column index
\usepackage[bottom]{footmisc}% places footnotes at page bottom
\usepackage{algorithm2e}
%Table packages
\usepackage[figuresright]{rotating}
\setlength{\rotFPtop}{0pt plus 1fil}
\usepackage{booktabs, makecell, multirow, tabularx}
\renewcommand{\theadfont}{\footnotesize\bfseries}
\renewcommand\theadgape{}
\newcolumntype{L}{>{\raggedright\arraybackslash}X}
\newcolumntype{P}[1]{>{\raggedright\arraybackslash}p{#1}}
\newenvironment{calligraphic}{\usefont{T1}{pzc}{m}{it}}{}
\newenvironment{conditions}
  {\par\vspace{\abovedisplayskip}\noindent\begin{tabular}{>{$}l<{$} @{${}={}$} l}}
  {\end{tabular}\par\vspace{\belowdisplayskip}}
% Add your abbreviations here
% Example
\hypersetup{
  colorlinks   = true, %Colours links instead of ugly boxes
  urlcolor     = blue, %Colour for external hyperlinks
  linkcolor    = blue, %Colour of internal links
  citecolor   = red %Colour of citations
}
\geometry{
  top=5cm,
  bottom=5cm,
  left=2cm,
  right=2cm,
  paperwidth=\textwidth,
  paperheight=\textheight
}

\makeindex

\begin{document}
\frontmatter
\KOMAoptions{open=left}
\clearpage
\setcounter{page}{1}
\tableofcontents
\listoftables
\listoffigures
\KOMAoptions{open=right}
\restoregeometry
\mainmatter
\clearpage
\pagestyle{plain}
\include{Introduction}
\end{document}

Introduction.tex 的代码是

\chapter*{Chapter 1}
\addcontentsline{toc}{chapter}{Introduction}
\section{Introduction}
\lipsum[1-3]
\subsection{Motivation}
\lipsum[3-5]
Write Motivation of the research work
\subsection{Contribution}
\lipsum[5-6]
Write the thesis contribution
\subsection{Organization of thesis}
\lipsum[2-3]
Brief description of chapters in the thesis.
\subsubsection{Chapter 2: Literature Survey}
\lipsum[1-2]
\subsubsection{Chapter 3:}
\lipsum[1-2]
\subsubsection{Chapter 4:}
\lipsum[1-2]
\subsubsection{Chapter 5:}
\lipsum[1-2]
\subsubsection{Chapter 6:}
\lipsum[1-2]
\subsubsection{Chapter 7:}
\lipsum[1-2] 

如果我也可以有页脚和页码,那就太好了 页脚

答案1

你想得太复杂了。你想要的是book带有包的标准类tocbibind或 KOMA-Script 类scrbook无类似包裹tocbibind) 包含选项listof=totoc(将 ... 列表添加到目录中)、选项chapterprefix(使章节带有“第十章”前缀行)和选项sfdefaults=false(不使用无衬线字体作为标题):

\documentclass[listof=totoc,chapterprefix,sfdefaults=false]{scrbook}
\usepackage{lipsum}
\usepackage{hyperref}

\begin{document}
\frontmatter
\tableofcontents
\listoftables
\listoffigures

\addchap{Acknowledgment}
\addchap{Abstract}
\mainmatter
\chapter{Introduction}
\lipsum[1-3]
\section{Motivation}
\lipsum[3-5]
Write Motivation of the research work
\section{Contribution}
\lipsum[5-6]
Write the thesis contribution
\section{Organization of thesis}
\lipsum[2-3]
Brief description of chapters in the thesis.
\subsection{Chapter 2: Literature Survey}
\lipsum[1-2]
\subsection{Chapter 3:}
\lipsum[1-2]
\subsection{Chapter 4:}
\lipsum[1-2]
\subsection{Chapter 5:}
\lipsum[1-2]
\subsection{Chapter 6:}
\lipsum[1-2]
\subsection{Chapter 7:}
\lipsum[1-2] 
\end{document}

内容

章节

页脚将是另一个问题。它确实可以使用来完成scrlayer-scrpage。如果您在执行此操作时遇到问题,请提出一个带有适当最小工作示例的新问题。

因此,至少从文档前言中删除导致错误消息的包以及所有未使用的包。并避免使用 等肮脏的黑客行为\chapter*{Chapter 1}。KOMA-Script 提供了很多配置选项和命令。有关更多信息,请参阅 KOMA-Script 手册。

相关内容