为什么 listoffigures 中的引用会打印 .bib 条目的标签?

为什么 listoffigures 中的引用会打印 .bib 条目的标签?

我想为我的图表创建引文,并使引文仅作为简短引用(如果之前没有引用,那么它\printbibliography也应该被添加到正常输出中)。通常这样做没问题。

但是在我的文档中,如果参考书目条目之前没有在普通文本中引用过,它就不会打印正确的引文(也不会添加到参考书目中),而只会打印标签(?!)以粗体显示参考书目条目。我可以在\phantom环境中的普通文本中引用它以避免这种情况,但这绝对不是一个好的解决方案。

在 MWE 中它运行良好...也许我的文档中有一些我忽略的东西,但是在所有打印标签而不是引用的情况下的共同点是,它们都是在文档中第一次被引用(它们也都有类型online)。

\documentclass{article}
\usepackage{graphicx}
\usepackage[backend=biber,style=verbose-ibid,hyperref=false]{biblatex}
\addbibresource{mwe.bib}

\newbibmacro*{shrtcite}{%
  \usebibmacro{cite:citepages}%
  \iffieldundef{shorthand}
    {\usebibmacro{cite:short}}
    {\usebibmacro{cite:shorthand}}}

\DeclareCiteCommand{\shrtcite}
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{shrtcite}}
  {\multicitedelim}
  {\usebibmacro{cite:postnote}}


\begin{filecontents}{mwe.bib}
@Book{knuth1986,
    Title                    = {The \TeX book},
    Author                   = {Donald~Ervin Knuth},
    Publisher                = {Addison-Wesley},
    Year                     = {1986}
}
\end{filecontents}

\begin{document}

\begin{figure}
    \centering
    \includegraphics[scale=0.2]{example-image-a}
    \caption[{\shrtcite[][5]{knuth1986}}]{This is a caption}
\end{figure}

\printbibliography
\listoffigures
\end{document}

对我来说这似乎很奇怪,如果有人知道一种通常与我最初的目标不同且更好的方法(仅出现在图形列表中的图形的引用),请帮助我。

答案1

biblatex明确禁用目录、图片列表和表格列表中所谓的“引用请求”。这意味着当某项内容被引用时,该引用不会记录在和.bcf文件中.aux。通常这是理想的,因为它可以避免数字样式的问题,并且sorting=noneunsrt在 BibTeX 中)引用的编号低于预期,因为它出现在目录或图片列表中(编号时忽略图片列表标题中的引用)。通常,发送到 ToC、LoF、LoT 的文本会在其他地方再次排版,此时引用请求就会被记录下来。

如果您仅在可选参数中引用特定条目,则\caption该引用将仅在 LoF/LoT 中排版,因此仅在引用请求不受尊重的上下文中。

因此,这是一种预期行为,当然不会改变。恐怕您必须手动发送引用请求。这通常是通过\nocite(外部的可选参数\caption),例如

\caption[{\shrtcite[][5]{knuth1986}}]{This is a caption}\nocite{knuth1986}

但您可以将其包装在一个方便的命令中以减少痛苦。

\documentclass{article}
\usepackage{graphicx}
\usepackage[backend=biber,style=verbose-ibid,hyperref=false]{biblatex}

\newbibmacro*{shrtcite}{%
  \usebibmacro{cite:citepages}%
  \iffieldundef{shorthand}
    {\usebibmacro{cite:short}}
    {\usebibmacro{cite:shorthand}}}

\DeclareCiteCommand{\shrtcite}
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{shrtcite}}
  {\multicitedelim}
  {\usebibmacro{cite:postnote}}

\newcommand*{\captioncite}[3][]{%
  \caption[{\shrtcite[][#1]{#2}}]{#3}\nocite{#2}}

\addbibresource{biblatex-examples.bib}

\begin{document}
\begin{figure}
    \centering
    \includegraphics[scale=0.2]{example-image-a}
    \captioncite[5]{sigfridsson}{A caption}
\end{figure}

\printbibliography
\listoffigures
\end{document}

LoF 和参考书目中的工作引用


如果您总是\shrtcite在此上下文中使用 (only),那么您可以选择\shrtcite重新启用引用请求。这无法通过通常的将布尔值添加到预编码中的方式实现(因为只有当引用数据可用时才会执行预编码,但只有引用请求成功时才可用引用数据),因此我们必须找到另一种方法并通过包装器格式获取它。

\documentclass{article}
\usepackage{graphicx}
\usepackage[backend=biber,style=verbose-ibid,hyperref=false]{biblatex}

\newbibmacro*{shrtcite}{%
  \usebibmacro{cite:citepages}%
  \iffieldundef{shorthand}
    {\usebibmacro{cite:short}}
    {\usebibmacro{cite:shorthand}}}

\newrobustcmd*{\mkciterequesttrue}[1]{{\booltrue{citerequest}#1}}

\DeclareCiteCommand{\shrtcite}[\mkciterequesttrue]
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{shrtcite}}
  {\multicitedelim}
  {\usebibmacro{cite:postnote}}

\addbibresource{biblatex-examples.bib}

\begin{document}
\begin{figure}
    \centering
    \includegraphics[scale=0.2]{example-image-a}
    \caption[{\shrtcite[5]{sigfridsson}}]{A caption}
\end{figure}

\printbibliography
\listoffigures
\end{document}

您发表的 MWEhttps://tex.stackexchange.com/revisions/541549/3通过两次引用发现了一个与biblatex禁用“引用请求”有关的非常模糊的错误,该错误应在下一个版本中修复biblatexhttps://github.com/plk/biblatex/commit/a821b82a76f34c24eac1225b2c5208c71c87081a)。该错误不会改变我们在此面临的根本问题,也不会影响此处提出的解决方法。

相关内容