![分组章节后的第一段缩进不正确](https://linux22.com/image/399307/%E5%88%86%E7%BB%84%E7%AB%A0%E8%8A%82%E5%90%8E%E7%9A%84%E7%AC%AC%E4%B8%80%E6%AE%B5%E7%BC%A9%E8%BF%9B%E4%B8%8D%E6%AD%A3%E7%A1%AE.png)
我有一个基于 KOMA 的文档,其中章节脚注和文本脚注的格式不同:
\documentclass{scrartcl}
\setlength\parindent{24pt}
\usepackage[symbol]{footmisc}
\usepackage{hyperref}
\begin{document}
\protected\def\hidefootnoteSec{\MakeUppercase{Section footnote.}} % https://tex.stackexchange.com/a/46532)
\begingroup%
\deffootnote[1em]{1.5em}{1em}{{\Large\thefootnotemark}\hspace*{.5em}}
\section[A section]{A section{\protect\NoHyper\protect\footnote[1]{\hidefootnoteSec}\protect\endNoHyper}}
\endgroup%
Test paragraph: should not be indented, but~due to~\verb|group| enclosing section it is.
Second test paragraph~\footnote{text footnote.}:~should be indented.
\end{document}
一般来说,此类文档中某一节的第一段不会缩进,但在这种情况下,\begingroup
…\endgroup
声明会导致 LaTeX 无法检测到section
第一段上方有声明。只需删除该组,格式也会影响下一个脚注。
当然,可以手动强制\noindent
添加第一段。但在这里,我正在寻找一种更自动化的解决方案,以便在更大的文档中,添加/删除新脚注或更改全局缩进时,无需始终记住此类添加。
是否可以自动检测这种带脚注的分组部分之后的第一个段落以便(不)缩进它?
答案1
您可以将脚注重新定义修补到\sectionlinesformat
(提供的KOMA-Script 命令scrartcl
):
\documentclass{scrartcl}
\setlength\parindent{24pt}
\usepackage{xpatch}
\xpretocmd{\sectionlinesformat}
{\ifstr{#1}{section}{\deffootnote[1em]{1.5em}{1em}{{\Large\thefootnotemark}\hspace*{.5em}}}{}}
{}{\PatchFailed}
\usepackage[symbol]{footmisc}
\usepackage{hyperref}
\begin{document}
\protected\def\hidefootnoteSec{\MakeUppercase{Section footnote.}} % https://tex.stackexchange.com/a/46532)
\section[A section]{A section{\protect\NoHyper\protect\footnote[1]{\hidefootnoteSec}\protect\endNoHyper}}
Test paragraph: should not be indented, but~due to~\verb|group| enclosing section it is.
Second test paragraph~\footnote{text footnote.}:~should be indented.
\end{document}
或者不带\hidefootnoteSec
:
\documentclass{scrartcl}
\setlength\parindent{24pt}
\usepackage{xpatch}
\xpretocmd{\sectionlinesformat}
{\ifstr{#1}{section}{\deffootnote[1em]{1.5em}{1em}{{\Large\thefootnotemark}\hspace*{.5em}}}{}}
{}{\PatchFailed}
\usepackage[symbol]{footmisc}
\usepackage{hyperref}
\begin{document}
\section[A section]{A section{\NoHyper\footnote[1]{\MakeUppercase{Section footnote.}}\endNoHyper}}
Test paragraph: should not be indented, but~due to~\verb|group| enclosing section it is.
Second test paragraph~\footnote{text footnote.}:~should be indented.
\end{document}
随着 KOMA-Script 3.27 版的预发布(可用这里)你也可以使用\AddtoDoHook
\documentclass{scrartcl}[2019/07/23]% needs at least prerelease 3.27.3175
\setlength\parindent{24pt}
\newcommand\sectionfootnote[1]{\deffootnote[1em]{1.5em}{1em}{{\Large\thefootnotemark}\hspace*{.5em}}}
\AddtoDoHook{heading/begingroup/section}{\sectionfootnote}
\usepackage[symbol]{footmisc}
\usepackage{hyperref}
\begin{document}
\section[A section]{A section{\NoHyper\footnote[1]{\MakeUppercase{Section footnote.}}\endNoHyper}}
Test paragraph: should not be indented, but~due to~\verb|group| enclosing section it is.
Second test paragraph~\footnote{text footnote.}:~should be indented.
\end{document}
或者\AddtoOneTimeDoHook
:
\documentclass{scrartcl}[2019/07/23]% needs at least prerelease 3.27.3175
\setlength\parindent{24pt}
\newcommand*\sectionfootnote[1]{\deffootnote[1em]{1.5em}{1em}{{\Large\thefootnotemark}\hspace*{.5em}}}
\usepackage[symbol]{footmisc}
\usepackage{hyperref}
\begin{document}
\AddtoOneTimeDoHook{heading/begingroup/section}{\sectionfootnote}% only for the next \section
\section[A section]{A section{\NoHyper\footnote[1]{\MakeUppercase{Section footnote.}}\endNoHyper}}
Test paragraph: should not be indented, but~due to~\verb|group| enclosing section it is.
Second test paragraph~\footnote{text footnote.}:~should be indented.
\end{document}