对于我的班级文本文档,book
我以摘要开始每个新章节。此摘要部分的格式设计为摘要标题相对于摘要文本缩进,例如:
Abstract
Insert text here
摘要被设计为一个带有NewDocumentEnvironment
命令的环境。
然而,当该titlesec
包包含在文档中时,抽象标题的缩进将被删除。
我怎样才能保持摘要标题中的缩进,或者怎样才能告诉titlesec
包不要触碰节标题格式?
包含该titlesec
包是因为我想自定义章节标题(且仅章节标题)。
MWE(切换titlesec
包来检查缩进):
\documentclass{book}
\usepackage{titlesec}
\usepackage{xparse}
\usepackage{changepage}
\usepackage{blindtext}
\usepackage[T1]{fontenc} % Output font encoding for international characters
\NewDocumentEnvironment{ChapterAbstract}{}
{
% Change the margins of the abstract relative to the regular text
\begin{adjustwidth}{15pt}{15pt}
\nointerlineskip\leavevmode % Necessary addition due to the macro expansion of adjustwidth. Solves the 'missing item' error
\section*{\indent\scshape\large abstract} % Smallcaps abstract title in \large fontsize with an indentation
\itshape
}
{
\end{adjustwidth}
}
\begin{document}
\chapter{Chapter title test here}
\begin{ChapterAbstract}
\blindtext
\end{ChapterAbstract}
\section{Test section}
\blindtext
\end{document}
答案1
titlesec
在节标题内设置\parindent
为,因此在 MWE 中引入了缩进。您可以使用以下方式手动插入相同长度的空格来获得相同的效果:0pt
\indent
0pt
\hspace
\documentclass{book}
\usepackage{titlesec}
\usepackage{xparse}
\usepackage{changepage}
\usepackage{blindtext}
\usepackage[T1]{fontenc} % Output font encoding for international characters
\NewDocumentEnvironment{ChapterAbstract}{}
{
% Change the margins of the abstract relative to the regular text
\begin{adjustwidth}{15pt}{15pt}
\nointerlineskip\leavevmode % Necessary addition due to the macro expansion of adjustwidth. Solves the 'missing item' error
\section*{\hspace{15pt}\scshape\large abstract} % Smallcaps abstract title in \large fontsize with an indentation
\itshape
}
{
\end{adjustwidth}
}
\begin{document}
\chapter{Chapter title test here}
\begin{ChapterAbstract}
\blindtext
\end{ChapterAbstract}
\section{Test section}
\blindtext
\end{document}