我没有找到太多关于如何在 koma 脚本文档中创建脚注样式的信息。这是我第一次尝试后得到的结果。我需要的更难,如下面的示例所示。有没有脚注专家可以帮忙?谢谢,Harald
\documentclass[pagesize,parskip=half,DIV=11]{scrartcl}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[german]{babel}
\usepackage{microtype}
\usepackage{blindtext}
\usepackage{lipsum}
%\usepackage{patchx}
\parindent 7mm
\newlength{\currentfnumwidth}
\makeatletter
\pretocmd{\@footnotetext}{%
\settowidth{\currentfnumwidth}{\footnotesize\bfseries\thefootnotemark\quad\enskip}%
\deffootnote[\currentfnumwidth]{0em}{1em}{%
\bfseries\thefootnotemark\quad\enskip
}%
}{}{}
\makeatother
\begin{document}
\lipsum[1]
\setcounter{footnote}{7}
Very small footnotemark.\footnote{\blindtext}
\setcounter{footnote}{887}
Much bigger footnotemark.\footnote{\blindtext}
\setcounter{footnote}{7}
This shows what I would need.\footnote{\blindtext}
\setcounter{footnote}{887}
This shows what I would need.\footnote{\blindtext}
\end{document}
答案1
目前还不清楚你想要什么。有几种可能性:
每个文档手动设置缩进:
\documentclass[pagesize,parskip=half,DIV=11]{scrartcl}[2022/05/01]% at least KOMA-Script 3.36 \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc}% shouldn't be needed any longer \usepackage[german]{babel} \usepackage{microtype} \usepackage{blindtext} \usepackage{lipsum} \parindent 7mm% Really, paragraph skip _and_ indent??? \newlength{\myfnumwidth} \AtBeginDocument{% becaue font initialization usually happens at \begin{document} \settowidth{\myfnumwidth}{\footnotesize\bfseries 888\enskip}% in this example 888 is the widest used number \deffootnote{\myfnumwidth}{\myfnumwidth}{\bfseries\thefootnotemark\enskip}% } \begin{document} \lipsum[1] \setcounter{footnote}{7} Very small footnotemark.\footnote{\blindtext} \setcounter{footnote}{887} Much bigger footnotemark.\footnote{\blindtext} \end{document}
根据脚注:
\documentclass[pagesize,parskip=half,DIV=11]{scrartcl}% at least KOMA-Script 3.36 \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc}% shouldn't be needed any longer \usepackage[german]{babel} \usepackage{microtype} \usepackage{blindtext} \usepackage{lipsum} \parindent 7mm% Really, paragraph skip _and_ indent??? \newlength{\myfnumwidth} \deffootnote{\myfnumwidth}{\myfnumwidth}{\bfseries\thefootnotemark\enskip}% \makeatletter \AddtoDoHook{footnote/text/begin}{% \settowidth{\myfnumwidth}{\footnotesize\bfseries\thefootnotemark\enskip}% use the needed width of the current number \@gobble} \makeatother \begin{document} \lipsum[1] \setcounter{footnote}{7} Very small footnotemark.\footnote{\blindtext} \setcounter{footnote}{887} Much bigger footnotemark.\footnote{\blindtext} \end{document}
每页自动设置缩进:
\documentclass[pagesize,parskip=half,DIV=11]{scrartcl}% at least KOMA-Script 3.36 \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc}% shouldn't be needed any longer \usepackage[german]{babel} \usepackage{microtype} \usepackage{blindtext} \usepackage{lipsum} \parindent 7mm% Really, paragraph skip _and_ indent??? \newlength{\myfnnumwidth} \deffootnote{\myfnnumwidth}{\myfnnumwidth}{\bfseries\thefootnotemark\enskip}% \makeatletter \AddtoDoHook{footnote/text/begin}{% \settowidth{\myfnnumwidth}{\footnotesize\bfseries\thefootnotemark\enskip}% \immediate\write\@auxout{\noexpand\global\noexpand\@namedef{fnnumwidth@\thepage}{\the\myfnnumwidth}}% store the current width for this page in the aux-file \@ifundefined{fnnumwidth@\thepage}{}{% if a width for this page has been stored \setlength{\myfnnumwidth}{\@nameuse{fnnumwidth@\thepage}}% use it }% \@gobble} \makeatother \begin{document} \lipsum[1-3] \setcounter{footnote}{7} Very small footnotemark.\footnote{\blindtext} Very small footnotemark.\footnote{\blindtext} \lipsum[1-3] Very small footnotemark.\footnote{\blindtext} Bigger footnotemark.\footnote{\blindtext} \lipsum[1-3] \setcounter{footnote}{98} Bigger footnotemark.\footnote{\blindtext} Much bigger footnotemark.\footnote{\blindtext} \setcounter{footnote}{887} Much, much bigger footnotemark.\footnote{\blindtext} \end{document}
请注意,最后一个例子需要至少两次 LaTeX 运行才能显示:
每份文件自动显示最后使用的脚注编号:
\documentclass[pagesize,parskip=half,DIV=11]{scrartcl}[2022/05/01]% at least KOMA-Script 3.36 \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc}% shouldn't be needed any longer \usepackage[german]{babel} \usepackage{microtype} \usepackage{blindtext} \usepackage{lipsum} \parindent 7mm% Really, paragraph skip _and_ indent??? \newlength{\myfnnumwidth} \deffootnote{\myfnnumwidth}{\myfnnumwidth}{\bfseries\thefootnotemark\enskip}% \makeatletter \AddToHook{enddocument/afterlastpage}{% after the final page \settowidth{\@tempdima}{\footnotesize\bfseries \thefootnotemark\enskip}% get the width of last footnote number \immediate\write\@auxout{\global\noexpand\myfnnumwidth\the\@tempdima\relax}% write it to aux file to be used in next LaTeX run } \makeatother \begin{document} \lipsum[1] \setcounter{footnote}{7} Very small footnotemark.\footnote{\blindtext} \lipsum[2-5] \setcounter{footnote}{887} Much bigger footnotemark.\footnote{\blindtext} \end{document}
此示例还需要至少两次 LaTeX 运行,如果最后一个脚注编号不是最宽的数字,则将失败。如果您的 LaTeX 早于 2020/10/01,则应将其替换
\AddToHook{enddocument/afterlastpage}
为\BeforeClosingMainAux
(有关 的更多信息,请参阅 KOMA-Script 手册\BeforeClosingMainAux
)。示例 3 与示例 1 的组合 = 脚注文本的静态缩进,但脚注编号在每页最宽脚注的宽度内自动右对齐:
\documentclass[pagesize,parskip=half,DIV=11]{scrartcl} \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc}% shouldn't be needed any longer \usepackage[german]{babel} \usepackage{microtype} \usepackage{blindtext} \usepackage{lipsum} \parindent 7mm% Really, paragraph skip _and_ indent??? \newlength{\myfnindent} \newlength{\myfnnumwidth} \deffootnote{\myfnindent}{\myfnindent}{% indent of footnote text and paragraphs \makebox[\myfnindent][l]{% inside this indent left align a \makebox[\myfnnumwidth][r]{% box of per page number width with right aligned \bfseries\thefootnotemark% bold footnote mark }% }% } \makeatletter \AddtoDoHook{footnote/text/begin}{% \settowidth{\myfnnumwidth}{\footnotesize\bfseries\thefootnotemark}% width of current footnote mark \immediate\write\@auxout{\noexpand\global\noexpand\@namedef{fnnumwidth@\thepage}{\the\myfnnumwidth}}% write it as current widest per page mark width to aux-file \@ifundefined{fnnumwidth@\thepage}{}{% if the aux file has had per page values for this page \setlength{\myfnnumwidth}{\@nameuse{fnnumwidth@\thepage}}% use (the last one) as current width of the number bix }% \@gobble% Because the do-hook code expects always has an argument. } \makeatletter \AtBeginDocument{% becaue font initialization usually happens at \begin{document} \settowidth{\myfnindent}{\footnotesize\bfseries 888\enskip}% In this example % 888 is the widest used number and this is % used to setup the footnote text indent. } \begin{document} \lipsum[1-3] \setcounter{footnote}{8} Very small footnotemark.\footnote{\blindtext} Very small footnotemark.\footnote{\blindtext} \lipsum[1-3] \setcounter{footnote}{98} Bigger footnotemark.\footnote{\blindtext} Much bigger footnotemark.\footnote{\blindtext} \setcounter{footnote}{887} Much, much bigger footnotemark.\footnote{\blindtext} \end{document}
示例 3 和示例 4 的组合:与上面相同,但自动检测最后一个脚注编号的宽度。为此,在示例 5 中只需替换
\AtBeginDocument{% becaue font initialization usually happens at \begin{document} \settowidth{\myfnindent}{\footnotesize\bfseries 888\enskip}% In this example % 888 is the widest used number and this is % used to setup the footnote text indent. }
经过
\AddToHook{enddocument/afterlastpage}{% after the final page \settowidth{\@tempdima}{\footnotesize\bfseries \thefootnotemark\enskip}% get the width of last footnote number \immediate\write\@auxout{\global\noexpand\myfnindent\the\@tempdima\relax}% write it to aux file to be used in next LaTeX run }
有关 的三个长度参数(一个可选,两个强制)的更多信息,请参阅 KOMA-Script 手册中的图 3.1 \deffootnote
。
有关 的更多信息,请参阅 KOMA-Script 手册第 12.8 节\AddtoDoHook
。
答案2
您要实现的目标可能在 KOMA 脚本手册中有描述。您可以通过texdoc scrguide
命令行获得整本书。查看第 3.14 节,那里有一些示例。
\documentclass[ngerman,parskip=half,DIV=11]{scrartcl} % pagesize no longer needed
\usepackage[T1]{fontenc}
%\usepackage[utf8]{inputenc} %% LaTeX is on UTF-8 as default since some years
\usepackage{babel}% put the language into the documentclass options
\usepackage{microtype}
\usepackage{blindtext}
%\usepackage{lipsum}
%\usepackage{patchx}
%\parindent 7mm
% \newlength{\currentfnumwidth}
% \makeatletter
% \pretocmd{\@footnotetext}{%
% \settowidth{\currentfnumwidth}{\footnotesize\bfseries\thefootnotemark\quad\enskip}%
% \deffootnote[\currentfnumwidth]{0em}{1em}{%
% \bfseries\thefootnotemark\quad\enskip
% }%
% }{}{}
% \makeatother
\deffootnote[2em]{2em}{0pt}{%
\makebox[2em][l]{\thefootnotemark}%
}
\begin{document}
\blindtext
\setcounter{footnote}{7}
Very small footnotemark.\footnote{\blindtext}
\setcounter{footnote}{887}
Much bigger footnotemark.\footnote{\blindtext}
\setcounter{footnote}{7}
This shows what I would need.\footnote{\blindtext}
\setcounter{footnote}{887}
This shows what I would need.\footnote{\blindtext}
\end{document}
结果: