切换脚注规则

切换脚注规则

我有两种脚注,因此需要两种脚注规则。下面的 MnWE 描述了我想要看到的内容。

我可以通过取消注释该行来关闭标准规则

%\usepackage[norule]{footmisc}

但不知道如何有选择地启用它。

我很少会在一页上同时出现两种脚注,而且我的文档很少更改,因此黑客解决方案是可以接受的。

在此处输入图片描述

在此处输入图片描述

[ 在此处输入图片描述][3

\documentclass{memoir}

\pagestyle{ruled}

\setstocksize{2in}{5in} % for mwe
\settrimmedsize{2in}{5in} {*}
\setlrmarginsandblock{0.3in}{0.3in}{*}%%%%
\setulmarginsandblock{0.5in}{0.5in}{*}
\checkandfixthelayout
\fixpdflayout

%\usepackage[norule]{footmisc}

\newcommand{\biblio}[1]{%
\let\thempfn\relax% Remove footnote number printing mechanism
\footnotetext[0]{%
\hrule%
\vspace{0.1in}%
#1}% Print footnote text
}
\begin{document}

First page, with a biblio footnote. It should show just my hrule, and
no footnote rule.
\biblio{Bibiographic reference}

\newpage
Second page, with just an ordinary footnote. It should show the
ordinary footnote rule.
\footnote{This is an ordinary footnote.}

\newpage
Third page both a footnote and a biblio footnote. It should show both
the footnote rule and my hrule.
\footnote{This is an ordinary footnote.}
\biblio{Bibiographic reference}

\end{document}

答案1

也许是这样的?

norule选项footmisc确实重新定义\footnoterule为通常不执行任何操作,而只是应用跳过。

我已经引入了\newif\iffootnoterule条件,即每次检查,如果为真,则应用(by )\footnoterule的存储定义。\footnoterule\let\latex@@footnoterule\footnoterule

这样就可以用\footnoteruletrue或进行切换\footnoterulefalse

\documentclass{memoir}

\pagestyle{ruled}

\newif\iffootnoterule

\makeatletter
\AtBeginDocument{%
\let\latex@@footnoterule\footnoterule

\renewcommand\footnoterule{%
  \iffootnoterule
  \latex@@footnoterule%
  \else
  \advance\skip\footins 4\p@\@plus2\p@\relax%
  \fi
}
}
\makeatother

\setstocksize{2in}{5in} % for mwe
\settrimmedsize{2in}{5in} {*}
\setlrmarginsandblock{0.3in}{0.3in}{*}%%%%
\setulmarginsandblock{0.5in}{0.5in}{*}
\checkandfixthelayout
\fixpdflayout

%\usepackage[norule]{footmisc}

\newcommand{\biblio}[1]{%
\let\thempfn\relax% Remove footnote number printing mechanism
\footnotetext[0]{%
\hrule%
\vspace{0.1in}%
#1}% Print footnote text
}
\begin{document}

First page, with a biblio footnote. It should show just my hrule, and
no footnote rule.
\biblio{Bibiographic reference}

\newpage
\footnoteruletrue
Second page, with just an ordinary footnote. It should show the
ordinary footnote rule.
\footnote{This is an ordinary footnote.}

\newpage
Third page both a footnote and a biblio footnote. It should show both
the footnote rule and my hrule.
\footnote{This is an ordinary footnote.}
\biblio{Bibiographic reference}

\end{document}

编辑:这是一个更新版本,它可以自动管理脚注规则的存在/不存在,方法是在每页开始时禁用它,并在有实际脚注时启用它。它还会恢复脚注编号,并进行更广泛的测试。

\documentclass{memoir}

\pagestyle{ruled}

\setstocksize{2in}{5in} % for mwe
\settrimmedsize{2in}{5in} {*}
\setlrmarginsandblock{0.3in}{0.3in}{*}%%%%
\setulmarginsandblock{0.5in}{0.5in}{*}
\checkandfixthelayout
\fixpdflayout

\usepackage[perpage]{footmisc}

\newcommand{\biblio}[1]{%
\let\xxxx\thempfn
\let\thempfn\relax% Remove footnote number printing mechanism
\footnotetext[0]{%
\hrule%
\vspace{0.1in}%
#1}% Print footnote text
\let\thempfn\xxxx% Restore footnote number printing mechanism
}

\usepackage{bophook}

\newif\iffootnoterule

\makeatletter
\AtBeginDocument{%
\let\latex@@footnoterule\footnoterule

\renewcommand\footnoterule{%
  \iffootnoterule
  \latex@@footnoterule%
  \else
  \advance\skip\footins 4\p@\@plus2\p@\relax%
  \fi
}
}
\makeatother

\let\realfootnote\footnote

\renewcommand{\footnote}[1]{%
\global\footnoteruletrue
\realfootnote{#1}
}

\AtBeginPage{%
\global\footnoterulefalse
}
\begin{document}

First page, with a biblio footnote. It should show just my hrule, and
no footnote rule.
\biblio{Bibliographic reference}

\newpage
Second page, with two ordinary footnotes. It should show the
ordinary footnote rule.
\footnote{This is an ordinary footnote.}
\footnote{This is an another.}

\newpage
Third page with two footnotes and a biblio footnote. It should show both
the footnote rule and my hrule.
\footnote{This is an ordinary footnote.}
\footnote{This is an another.}
\biblio{Bibliographic reference}

\end{document}

相关内容