如何获取脚注规则的绝对 y 位置(高度)?
我想(使用 TikZ)绘制一个从命令到页面文本末尾的框,而不考虑脚注。此位置不固定:它取决于脚注的数量。
这是一个存在问题的小型工作示例。
\documentclass[12pt,a4paper,twoside,openright,oldfontcommands]{memoir}
\usepackage{tikzpagenodes}
\usepackage{lipsum}
\usetikzlibrary{calc,tikzmark,positioning}
\definecolor{cpp}{RGB}{0,0,0}
\newcommand{\createline}{
\pgfmark{begincreateline}
\begin{tikzpicture}[remember picture,overlay]
\path ({pic cs:begincreateline}-| current page text area.west) ++(0pt,-0.5em) coordinate(A);
\path (current page text area.south west) coordinate(B); % should be until the footrule!
\fill[color=black] ($(A) + (-.2cm, 0pt)$) rectangle ($(B) + (-.7cm, 0pt)$);
\end{tikzpicture}
}%
\begin{document}
\mainmatter
\lipsum[1-1]
\createline
Some text with footnote\footnote{Text}. Another footnote\footnote{Other}.
\lipsum[3-7]
\end{document}
答案1
修改后\footnoterule
在左侧添加一个 tikzmark。实际线位于基线上方 3pt-2.6pt 处。
您可能还会看一下\iftikzmark
,但在这种情况下这不应该是问题。
\documentclass[12pt,a4paper,twoside,openright,oldfontcommands]{memoir}
\usepackage{tikzpagenodes}
\usepackage{lipsum}
\usetikzlibrary{calc,tikzmark,positioning}
\usepackage{etoolbox}
\pretocmd{\footnoterule}{\pgfmark{footrule\thepage}}{}{FAILED}
\definecolor{cpp}{RGB}{0,0,0}
\newcommand{\createline}{%
\pgfmark{begincreateline\thepage}%
\begin{tikzpicture}[remember picture,overlay]
\path ({pic cs:begincreateline\thepage}-| current page text area.west) ++(0pt,-0.5em) coordinate(A);
\path (pic cs:footrule\thepage) coordinate(B); % should be until the footrule!
\fill[color=black] ($(A) + (-.2cm, 0pt)$) rectangle ($(B) + (-.7cm, 3pt)$);
\end{tikzpicture}%
}%
\begin{document}
\mainmatter
\lipsum[1-1]
\createline
Some text with footnote\footnote{Text}. Another footnote\footnote{Other}.
\lipsum[3-7]
\end{document}