我从下面获取了低级 TeX 代码在书中定义抽象环境定义了摘要的环境。但是,当我将它放入我的作品中时,我使用的notitlepage
选项会导致摘要垂直对齐到顶部。如下所示,摘要文本与可用宽度不对齐;左右两侧都有空白。
现在,我希望整个摘要(标题和文本)垂直对齐到文本主体的中心,并完全对齐文本以尽可能节省空间。
以下是代码:
\documentclass[notitlepage]{book}
\usepackage[no-math]{fontspec}
\usepackage[inline]{enumitem}
\usepackage{blindtext}
\usepackage[showframe]{geometry}
\usepackage{tocloft}
\usepackage{etoolbox}
\patchcmd{\frontmatter}{\pagenumbering{roman}}{\pagenumbering{Roman}}{}{}
% ===== Define abstract environment =====
\makeatletter
\if@titlepage
\newenvironment{abstract}{%
\titlepage
\null\vfil
\@beginparpenalty\@lowpenalty
\begin{center}%
\bfseries \abstractname
\@endparpenalty\@M
\end{center}}%
{\par\vfil\null\endtitlepage}
\else
\newenvironment{abstract}{%
\if@twocolumn
\section*{\abstractname}%
\else
\small
\begin{center}%
{\bfseries \abstractname\vspace{-.5em}\vspace{\z@}}%
\end{center}%
\quotation
\fi}
{\if@twocolumn\else\endquotation\fi}
\fi
\makeatother
\begin{document}
\frontmatter
\pagestyle{plain}
\tableofcontents
\pagestyle{headings}
\cleardoublepage
\begin{abstract}
\thispagestyle{plain}
\blindtext
\end{abstract}
\phantomsection \addcontentsline{toc}{chapter}{\abstractname}
\cleardoublepage
\phantomsection \addcontentsline{toc}{chapter}{\listfigurename}
\listoffigures
\cleardoublepage
\phantomsection \addcontentsline{toc}{chapter}{\listtablename}
\listoftables
\mainmatter
\Blinddocument
\Blinddocument
\Blinddocument
\end{document}
答案1
永远不要只是复制/粘贴代码。你需要先理解它。
\documentclass[notitlepage]{book}
%\usepackage[no-math]{fontspec}
\usepackage[inline]{enumitem}
\usepackage{blindtext}
\usepackage[showframe]{geometry}
\usepackage{tocloft}
\usepackage{etoolbox}
\patchcmd{\frontmatter}{\pagenumbering{roman}}{\pagenumbering{Roman}}{}{}
% ===== Define abstract environment =====
\newenvironment{abstract}{%
\clearpage
\vspace*{\fill}
\small
\begin{center}%
{\bfseries Abstract}
\phantomsection \addcontentsline{toc}{chapter}{Abstract}
\thispagestyle{plain}
\end{center}%
}
{\vspace*{\fill}
}
\begin{document}
\frontmatter
\pagestyle{plain}
\tableofcontents
\pagestyle{headings}
\cleardoublepage
\begin{abstract}
\blindtext
\end{abstract}
\cleardoublepage
\phantomsection \addcontentsline{toc}{chapter}{\listfigurename}
\listoffigures
\cleardoublepage
\phantomsection \addcontentsline{toc}{chapter}{\listtablename}
\listoftables
\mainmatter
\Blinddocument
\Blinddocument
\Blinddocument
\end{document}