我正在尝试更改使用 \section 时文本开始出现的页面顶部的距离,以便它与我仅使用常规格式(不在部分中)时的距离相匹配。下面是代码示例。据我所知,将标题间距的第二个参数更改为负值应该可以解决我的问题,但无论我将第二个参数设置为什么(正值或负值),似乎都没有发生任何事情。基本上,我想让第一页看起来与第二页相同。有什么想法吗?
\documentclass[10pt]{article}
\usepackage[margin=1in]{geometry}
\usepackage{hyperref}
\usepackage{mathpazo}
\linespread{1.05}
\usepackage{titlesec}
\titleformat*{\section}{\centering\LARGE\bfseries}
\titlespacing*{\section}{0pt}{0pt}{-6pt}
\setcounter{secnumdepth}{0}
\begin{document}
\section{This is the first line of my example that should start at the same height as it does on page 2}
\centering{\large This second line is perfect where it is on both pages}
\newpage
\centering{
\LARGE \textbf{This is the first line of my example that should start at the same height as it does on page 2}\\
\large This second line is perfect where it is on both pages}
\end{document}
答案1
下面只是一个肮脏的伎俩,它打破了部分标题内的支柱;然而,它确实使两个页面看起来完全相同(用 检查\tracingoutput
):
\documentclass[a4paper]{article}
\usepackage[margin=1in]{geometry}
\usepackage{mathpazo}
\usepackage{titlesec}
\usepackage{hyperref}
\linespread{1.05}
\titleformat*{\section}{%
\centering\LARGE\bfseries
\setbox \strutbox \null
% \showbox\strutbox
}
\titlespacing*{\section}{0pt}{0pt}{0pt}
\setcounter{secnumdepth}{0}
% \showboxbreadth = 1000
% \showboxdepth = 10
% \tracingoutput = 1
\begin{document}
\section{This is the first line of my example that should start at the same height as it does on page 2}
{\centering\large This second line is perfect where it is on both pages\par}
% \showlists
\newpage
{\centering
\LARGE \textbf{This is the first line of my example that should start at the
same height as it does on page 2}\par
\large This second line is perfect where it is on both pages\par}
% \showlists
\end{document}
(笔记:我整理了 OP 代码中的几个我昨晚没有注意到的地方。)您可能喜欢取消注释诊断命令以准确检查发生了什么。