我目前正在撰写论文,并使用预制模板来设计我的章节标题(修改于 nr 26http://zoonek.free.fr/LaTeX/LaTeX_samples_chapter/0.html,感谢 Vincent Zoonekynd)。
我对结果非常满意,但我想减少每个新章节中第一个章节名称和第二个章节名称之间的垂直间距,例如减少/删除“第 1 章”和“简介”之间的垂直间距。
有人能帮忙吗?我的部分代码如下(太多了,无法全部包含):
\documentclass[a4paper,12pt,twoside]{book}
\usepackage[utf8]{inputenc}
\usepackage{fourier}
\usepackage{lipsum}
\setlength{\parskip}{1em} % style paragraphs
\setlength{\parindent}{0} % style paragraphs
\usepackage[margin=2.5cm]{geometry}
\makeatletter
\def\thickhrulefill{\leavevmode \leaders \hrule height 1ex \hfill \kern \z@}
\def\@makechapterhead#1{%
\vspace*{-10\p@} % Distance top(?)
{\parindent \z@ \raggedleft \reset@font
\scshape \@chapapp{} \thechapter
\par\nobreak
\interlinepenalty\@M
\Huge \bfseries #1\par\nobreak
\vspace*{-30\p@} % Distance to line(?)
\hrulefill
\par\nobreak
\vskip 50\p@ % Distance to text(?)
}}
\def\@makeschapterhead#1{%
\vspace*{10\p@}%
{\parindent \z@ \raggedleft \reset@font
\scshape \vphantom{\@chapapp{} \thechapter}
\par\nobreak
\interlinepenalty\@M
\Huge \bfseries #1\par\nobreak
%\vspace*{1\p@}%
\hrulefill
\par\nobreak
\vskip 100\p@
}}
\begin{document}
\chapter{Introduction}
\lipsum[1-2]
\end{document}
答案1
\vspace{-6pt}
一种可能性是在代码中的两个位置 放置一个负空格 ( )。6pt
您可以使用0.5\baselineskip
或值 来代替{-10\p@}
,以防您稍后更改字体大小。
\documentclass[a4paper,12pt,twoside]{book}
\usepackage[utf8]{inputenc}
\usepackage{fourier} % Not necessary for the MWE to compile
\usepackage{lipsum}
\setlength{\parskip}{1em} % style paragraphs
\setlength{\parindent}{0em} % style paragraphs. Added `em` to avoid error
\usepackage[margin=2.5cm]{geometry}
\makeatletter
\def\thickhrulefill{\leavevmode \leaders \hrule height 1ex \hfill \kern \z@}
\def\@makechapterhead#1{%
\vspace*{-10\p@} % Distance top(?)
{\parindent \z@ \raggedleft \reset@font
\scshape \@chapapp{} \thechapter
\par\vspace*{-10\p@}% %Reduce the distance between chapter number and chapter title
\nobreak
\interlinepenalty\@M
\Huge \bfseries #1\par\nobreak
\vspace*{-30\p@} % Distance to line(?)
\hrulefill
\par\nobreak
\vskip 50\p@ % Distance to text(?)
}}
\def\@makeschapterhead#1{%
\vspace*{10\p@}%
{\parindent \z@ \raggedleft \reset@font
\scshape \vphantom{\@chapapp{} \thechapter}
\par\vspace*{-10\p@}% %Reduce the distance between chapter number and chapter title
\nobreak
\interlinepenalty\@M
\Huge \bfseries #1\par\nobreak
\vspace*{-30\p@}% % uncommented and change to `-30\p@` for consistency
\hrulefill
\par\nobreak
\vskip 50\p@% % change from 100\p@ for consistency
}}
\begin{document}
\chapter{Introduction}
\lipsum[1-2]
\end{document}
另外两处空间不一致,我已改正。
答案2
这是一个解决方案,适用于编号和未编号的章节。请注意,两种情况下章节标题和文本之间的垂直距离存在奇怪的差异。这是想要的吗?
\documentclass[a4paper,12pt,twoside, openany]{book}
\usepackage[utf8]{inputenc}
\usepackage{fourier}
\usepackage{lipsum}
\setlength{\parskip}{1em} % style paragraphs
\setlength{\parindent}{0pt} % style paragraphs
\usepackage[margin=2.5cm]{geometry}
\makeatletter
\def\thickhrulefill{\leavevmode \leaders \hrule height 1ex \hfill \kern \z@}
\def\@makechapterhead#1{%
\vspace*{-10\p@} % Distance top(?)
{\parindent \z@ \raggedleft \reset@font
\scshape \@chapapp{} \thechapter \vspace*{-10\p@}
\par\nobreak
\interlinepenalty\@M
\Huge \bfseries #1\par\nobreak
\vspace*{-30\p@} % Distance to line(?)
\hrulefill
\par\nobreak
\vskip 50\p@ % Distance to text(?)
}}
\def\@makeschapterhead#1{%
\vspace*{10\p@}%
{\parindent \z@ \raggedleft \reset@font
\scshape \vphantom{\@chapapp{} \thechapter}\vspace*{\dimexpr -10pt - 1.57ex \relax}
\par\nobreak
\interlinepenalty\@M
\Huge \bfseries #1\par\nobreak
\vspace*{-30\p@}%
\hrulefill
\par\nobreak
\vskip 100\p@
}}
\begin{document}
\chapter{Introduction}
\lipsum[1-2]
\chapter*{Introduction}
\lipsum[1-2]
\end{document}