
我想有选择地调整章节的起始位置。例如,
\documentclass[openany]{book}
\usepackage{lipsum}
\usepackage{pgfpages}
\pgfpagesuselayout{2 on 1}
\begin{document}
\thispagestyle{empty}
\Large
\chapter*{Chapter 1}
\lipsum[3]
\chapter*{Chapter 2}
\lipsum[3]
\chapter*{Chapter 3}
\lipsum[3]
\chapter*{Chapter 4}
\lipsum[3]
\end{document}
产生
例如,我怎样才能降低起点(比如说 60pt),但保持所有剩余章节的起点不变?如果涉及更多章节,我希望以后也能灵活地对其他个别章节执行相同的操作。我用 编译pdflatex
。请不要AddtoHookNext
。谢谢。
答案1
该titlesec
包提供了两个命令来分别格式化章节标题(和其他章节命令)和间距:\titleformat
和\titlespacing
。
\titleformat{⟨command⟩}[⟨shape⟩]{⟨format⟩}{⟨label⟩}{⟨sep⟩}{⟨before-code⟩}[⟨after-code⟩]
\titlespacing*{<command>}{<left margin>}{<vertical space before the title>}{<separation between title and text>}
然后您可以\titlespacing
有选择地应用,将其范围限制在目标章节内。
为了使其工作,\titleformat
必须先定义。在示例中,我们使用标准类使用的值:
\titleformat{\chapter}[display]
{\normalfont\huge\bfseries}{\chaptertitlename\ \thechapter}{20pt}{\Huge}
那么可以只申请第 2 章,例如\titlespacing*{\chapter}{0pt}{-20pt}{20pt}
\documentclass[openany]{book}
\usepackage{lipsum}
\usepackage{pgfpages}
\pgfpagesuselayout{2 on 1}
\usepackage{titlesec}
% definition of the standart classes
\titleformat{\chapter}[display]
{\normalfont\huge\bfseries}{\chaptertitlename\ \thechapter}{20pt}{\Huge}
\titlespacing*{\chapter}{0pt}{50pt}{38pt}
\usepackage{showframe}% ONLY to show the margins
\begin{document}
\thispagestyle{empty}
\Large
\chapter*{Chapter 1}
\lipsum[3]
{\titlespacing*{\chapter}{0pt}{-20pt}{20pt}
\chapter*{Chapter 2}
}
\lipsum[3]
\chapter*{Chapter 3}
\lipsum[3]
\chapter*{Chapter 4}
\lipsum[3]
\end{document}
答案2
您可以添加尾随可选参数,默认为正常的 50pt,用于说明距顶部边距的距离(减去\topskip
)。
\documentclass[openany]{book}
\usepackage{xpatch}
\usepackage{showframe}
\usepackage{lipsum}
\usepackage{pgfpages}
\pgfpagesuselayout{4 on 1}
\makeatletter
\xpatchcmd{\@makechapterhead}
{50\p@}
{\dimexpr\movechapter}
{}{}
\xpatchcmd{\@makeschapterhead}
{50\p@}
{\dimexpr\movechapter}
{}{}
\makeatother
\NewCommandCopy{\latexchapter}{\chapter} % may be \let\latexchapter\chapter
\newcommand{\movechapter}{}% initialize
\RenewDocumentCommand{\chapter}{sO{#3}mO{50pt}}{%
\begingroup
\renewcommand{\movechapter}{#4}%
\IfBooleanTF{#1}{\latexchapter*{#3}}{\latexchapter[#2]{#3}}%
\endgroup
}
\begin{document}
\chapter*{Chapter 1}
\lipsum[3]
\chapter*{Chapter 2}[-\topskip]
\lipsum[3]
\chapter*{Chapter 3}[20pt]
\lipsum[3]
\chapter*{Chapter 4}
\lipsum[3]
\end{document}