5

我对 LaTeX 有一个大问题,因为我不能在新章节之前删除边距

截屏

我什么都试过了,但我很新,我没能做到。我的代码:

\documentclass[polish,12pt,oneside]{mwbk}
\usepackage[a4paper,includeheadfoot,inner=3.0cm,outer=2.5cm,top=3cm,bottom=3cm]{geometry}
\linespread{1.416}
\usepackage{lipsum}
\clubpenalty=10000
\widowpenalty=10000

\usepackage{fancyhdr}
\pagestyle{plain}
\setlength{\headsep}{2em}
\fancyhf{}
\fancyfoot[LE,RO]{\thepage}

\usepackage[utf8]{inputenc} 
\usepackage[polish]{babel}
\usepackage{polski}

\usepackage[pagebackref=false]{hyperref}
\bibliographystyle{plplain}
\usepackage{dirtree}
\usepackage{varwidth}
\usepackage[labelsep=period]{caption} 
\usepackage{pgfplots}
\pgfplotsset{compat=1.17}
\usepackage{subcaption}
\usepackage{float}
\usepackage{wasysym}


% THE CODE I'VE TRIED
\usepackage{etoolbox}% http://ctan.org/pkg/etoolbox
\makeatletter
% \patchcmd{<cmd>}{<search>}{<replace>}{<success>}{<failure>}
% --- Patch \chapter
\patchcmd{\@makechapterhead}{50\p@}{\chapheadtopskip}{}{}% Space from top of page to CHAPTER X
\patchcmd{\@makechapterhead}{20\p@}{\chapheadsep}{}{}% Space between CHAPTER X and CHAPTER TITLE
\patchcmd{\@makechapterhead}{40\p@}{\chapheadbelowskip}{}{}% Space between CHAPTER TITLE and text
% --- Patch \chapter*
\patchcmd{\@makeschapterhead}{50\p@}{\chapheadtopskip}{}{}% Space from top of page to CHAPTER TITLE
\patchcmd{\@makeschapterhead}{40\p@}{\chapheadbelowskip}{}{}% SPace between CHAPTER TITLE and text
\makeatother
% Set new lengths
\newlength{\chapheadtopskip}\setlength{\chapheadtopskip}{5pt}
\newlength{\chapheadsep}\setlength{\chapheadsep}{5pt}
\newlength{\chapheadbelowskip}\setlength{\chapheadbelowskip}{5pt}
% END THE CODE I'VE TRIED


\begin{document}

\selectlanguage{polish}

\addtocounter{page}{1}    
\setcounter{tocdepth}{1}  
\tableofcontents  

\setlength{\parskip}{0.5ex}


\chapter{Hardware}
\label{ch:hardware}

\section{Components}
\label{sec:components}
\lipsum[3-7]


\cleardoublepage
\phantomsection
\listoffigures

\end{document}

带有 titlesec 包的方法给了我一堆错误。我用的是背页。

改变

\documentclass[polish,12pt,oneside]{mwbk}

\documentclass[polish,12pt,oneside]{book}

有帮助,但会破坏另一种样式(如枚举列表等)

4

1 回答 1

3

您使用的类定义了章节格式

\SetSectionFormatting[breakbefore,wholewidth]{chapter}
        {0\p@}
        {\FormatRigidChapterHeading{6.4\baselineskip}{12\p@}%
           {\large\@chapapp\space}{\LARGE}}
        {1.6\baselineskip}

如果您使用 的值6.4,您可以调整章节标题上方的空间。

\documentclass[polish,12pt,oneside]{mwbk}
\usepackage[a4paper,includeheadfoot,inner=3.0cm,outer=2.5cm,top=3cm,bottom=3cm]{geometry}
\linespread{1.416}
\usepackage{lipsum}
\clubpenalty=10000
\widowpenalty=10000

\usepackage{fancyhdr}
\pagestyle{plain}
\setlength{\headsep}{2em}
\fancyhf{}
\fancyfoot[LE,RO]{\thepage}

\usepackage[utf8]{inputenc} 
\usepackage[polish]{babel}
\usepackage{polski}

\usepackage[pagebackref=false]{hyperref}
\bibliographystyle{plplain}
\usepackage{dirtree}
\usepackage{varwidth}
\usepackage[labelsep=period]{caption} 
\usepackage{pgfplots}
\pgfplotsset{compat=1.17}
\usepackage{subcaption}
\usepackage{float}
\usepackage{wasysym}


% THE CODE I'VE TRIED
\usepackage{etoolbox}% http://ctan.org/pkg/etoolbox
\makeatletter
% \patchcmd{<cmd>}{<search>}{<replace>}{<success>}{<failure>}
% --- Patch \chapter
\patchcmd{\@makechapterhead}{50\p@}{\chapheadtopskip}{}{}% Space from top of page to CHAPTER X
\patchcmd{\@makechapterhead}{20\p@}{\chapheadsep}{}{}% Space between CHAPTER X and CHAPTER TITLE
\patchcmd{\@makechapterhead}{40\p@}{\chapheadbelowskip}{}{}% Space between CHAPTER TITLE and text
% --- Patch \chapter*
\patchcmd{\@makeschapterhead}{0\p@}{\chapheadtopskip}{}{}% Space from top of page to CHAPTER TITLE
\patchcmd{\@makeschapterhead}{40\p@}{\chapheadbelowskip}{}{}% SPace between CHAPTER TITLE and text
\makeatother
% Set new lengths
\newlength{\chapheadtopskip}\setlength{\chapheadtopskip}{5pt}
\newlength{\chapheadsep}\setlength{\chapheadsep}{5pt}
\newlength{\chapheadbelowskip}\setlength{\chapheadbelowskip}{5pt}
% END THE CODE I'VE TRIED

\makeatletter
\SetSectionFormatting[breakbefore,wholewidth]{chapter}
        {0\p@}
        {\FormatRigidChapterHeading{0\baselineskip}{12\p@}%
           {\large\@chapapp\space}{\LARGE}}
        {1.6\baselineskip}
\makeatother

\begin{document}

\selectlanguage{polish}

\addtocounter{page}{1}    
\setcounter{tocdepth}{1}  
\tableofcontents  

\setlength{\parskip}{0.5ex}


\chapter{Hardware}
\label{ch:hardware}

\section{Components}
\label{sec:components}
\lipsum[3-7]


\cleardoublepage
\phantomsection
\listoffigures

\end{document}

在此处输入图像描述

于 2021-03-08T17:06:03.187 回答