繁体   English   中英

删除 LaTeX 中的章节边距

[英]Remove chapter margin in LaTeX

我对 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 package 的方法给了我一堆错误。 我用的是背书。

改变

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

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

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

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

\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}

在此处输入图像描述

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM