我遇到了以下问题:当我编译代码时,第一个文本页面顶部的 vmargin(位于第 1 章标题的正上方)比应有的要大。在后续页面上,一切都符合预期。
由于我之前搜索过,我猜测这与 titlesec 包和我对标题间距的修改有关,但我无法解释为什么这个额外的边距只出现在第一章上方。遗憾的是,我在其他地方找不到确切的问题,而且我对 LaTeX 也不是很熟练。
我的代码如下:
\documentclass[12pt]{report}
\usepackage[a4paper,hmargin={3cm,3cm},vmargin={3cm,3cm}]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{lmodern} %better font look in .pdf
\usepackage{tabularx}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{lipsum}
\usepackage{setspace} %set spacing between lines
\onehalfspacing
\usepackage{titlesec} %other chapter style
\titleformat{\chapter}
{\normalfont\LARGE\bfseries}{\thechapter}{1em}{}
\titlespacing*{\chapter}{0pt}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex}
\usepackage{etoolbox} %no new page for chapters
\makeatletter
\patchcmd{\chapter}{\if@openright\cleardoublepage\else\clearpage\fi}{}{}{}
\makeatother
\usepackage{hyperref} %clickable table of contents
\hypersetup{colorlinks, citecolor=black, filecolor=black, linkcolor=black, urlcolor=black}
\usepackage{csquotes} %ensure correct quotes (necessary for biblatex)
\usepackage[authordate,maxcitenames=2,backend=biber]{biblatex-chicago} %references, citations
\addbibresource{references.bib}
\usepackage{chngcntr} %count figures etc. continuously
\counterwithout{figure}{chapter}
\counterwithout{footnote}{chapter}
\usepackage{caption} %center captions
\title{Title}
\author{mich0r}
\date{\today}
\begin{document}
\maketitle
\pagenumbering{roman}
\tableofcontents
\clearpage
\setcounter{page}{0}
\pagenumbering{arabic}
\chapter{One}
\lipsum{10}
\chapter{Two}
\end{document}
观察到的差异如下图所示。左页的边距比以下页面的边距大:
!https://i.stack.imgur.com/7YtwG.jpg
我知道这只是光学问题,但这个问题确实困扰了我不少。任何帮助我都感激不尽!
答案1
class
只需更改即可chapter
。无需修补。我借此机会简化了传递给几何的参数,并 hyperref
在最后加载,这是应该的(cleveref
是一个例外,但您不使用它)。
\documentclass[12pt]{report}
\usepackage[a4paper, margin = 3cm, showframe]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{lmodern} %better font look in .pdf
\usepackage{tabularx}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{lipsum}
\usepackage{setspace} %set spacing between lines
\onehalfspacing
\usepackage{titlesec} %other chapter style
\titleformat{\chapter}
{\normalfont\LARGE\bfseries}{\thechapter}{1em}{}
\titlespacing*{\chapter}{0pt}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex}
\titleclass{\chapter}{straight}%no new page for chapters
\usepackage{etoolbox}
\usepackage{csquotes} %ensure correct quotes (necessary for biblatex)
\usepackage[authordate,maxcitenames=2,backend=biber]{biblatex-chicago} %references, citations
\addbibresource{references.bib}
\usepackage{chngcntr} %count figures etc. continuously
\counterwithout{figure}{chapter}
\counterwithout{footnote}{chapter}
\usepackage{caption} %center captions
\usepackage{hyperref} %clickable table of contents
\hypersetup{colorlinks, citecolor=black, filecolor=black, linkcolor=black, urlcolor=black}
\title{Title}
\author{mich0r}
\date{\today}
\begin{document}
\maketitle
\pagenumbering{roman}
\tableofcontents
\clearpage
\setcounter{page}{0}
\pagenumbering{arabic}
\chapter{One}
\lipsum[10]
\chapter{Two}
\lipsum[11]
\end{document}