首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >删除LaTeX中的章节页边距

删除LaTeX中的章节页边距
EN

Stack Overflow用户
提问于 2021-03-09 00:31:52
回答 1查看 659关注 0票数 4

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

我什么都试过了,但我还是个新手,没办法。我的代码:

代码语言:javascript
复制
\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包的方法会给我一堆错误。我用的是上页。

改变

代码语言:javascript
复制
\documentclass[polish,12pt,oneside]{mwbk}

代码语言:javascript
复制
\documentclass[polish,12pt,oneside]{book}

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

EN

回答 1

Stack Overflow用户

发布于 2021-03-09 01:06:03

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

代码语言:javascript
复制
\SetSectionFormatting[breakbefore,wholewidth]{chapter}
        {0\p@}
        {\FormatRigidChapterHeading{6.4\baselineskip}{12\p@}%
           {\large\@chapapp\space}{\LARGE}}
        {1.6\baselineskip}

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

代码语言:javascript
复制
\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}

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66533559

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档