嘿,
最近,我在对章节、节和小节进行编号时遇到了问题(可以找到这里)。现在看起来一切都正常了,但章节仍然存在问题。它们没有出现在目录中,我无法对它们进行编号。此外,当我尝试删除 \def\chapter 时,我的整个文档崩溃了... 帮助
\documentclass[paper=a4,fontsize=11pt,twoside=semi,usegeometry]{scrreprt}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{microtype}
\usepackage{amsmath,amsfonts,amsthm,amssymb}
\usepackage{newtxtext,newtxmath}
\usepackage{graphicx}
\setlength{\oddsidemargin}{5mm}
\setlength{\evensidemargin}{5mm}
\usepackage{blindtext}
\usepackage{titlesec}
\usepackage{fancyhdr}
\usepackage{tocloft}
\usepackage{ragged2e}
\setcounter{secnumdepth}{5}
\setcounter{tocdepth}{5}
\addtokomafont{disposition}{\rmfamily}
\RedeclareSectionCommand[
beforeskip=-1sp,
afterskip=.5cm,
font=\Huge
]{chapter}
\newcommand{\HRule}[1]{\rule{\linewidth}{#1}}
\makeatletter
\def\printtitle{}
\makeatother
\makeatletter
\def\printauthor{}
\makeatother
\def\afterpage{\null\newpage}
**\def\chapter**
\def\linestretch
\begin{document}
\printtitle
\printauthor
\include{Chapter}
\end{document}
答案1
我已注释掉您 MWE 中错误且不需要的行。请尝试以下示例是否适合您:
\documentclass[paper=a4,fontsize=11pt,twoside=semi]{scrreprt}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{microtype}
\usepackage{amsmath,amsfonts,amsthm,amssymb}
\usepackage{newtxtext,newtxmath}
\usepackage{graphicx}
%\setlength{\oddsidemargin}{5mm}% <- should be removed
%\setlength{\evensidemargin}{5mm}% <- should be removed
\usepackage{blindtext}% only for dummy text
%\usepackage{titlesec}% <- I suggest to remove this package
%\usepackage{fancyhdr}% <- I suggest to remove/replace this package
%\usepackage{tocloft}% <- I suggest to remove this package
\usepackage{ragged2e}
\setcounter{secnumdepth}{5}
\setcounter{tocdepth}{5}
\addtokomafont{disposition}{\rmfamily}
\RedeclareSectionCommand[
beforeskip=-1sp,
afterskip=.5cm,
font=\Huge
]{chapter}
\newcommand{\HRule}[1]{\rule{\linewidth}{#1}}
\makeatletter
\def\printtitle{{\Huge\centering prints title\par}}% <-changed
\def\printauthor{{\Huge\centering prints author\par}}% <- changed
\makeatother
%\def\afterpage{\null\newpage}% <- should be removed, there are other possibilities
%**\def\chapter**% <- should be removed
%\def\linestretch% <- should be removed
\begin{document}
\printtitle
\printauthor
\tableofcontents
\chapter{Chapter 1}
\Blindtext
\chapter{Chapter 2}
\Blindtext
\end{document}
关于您的\afterpage
命令:请说明您在哪里使用此命令。我确信还有其他可能性,例如\clearpage
,,,...\cleardoublepage
\cleardoubleoddpage