biblatex:citefield + url + href(超出 TeX 容量,抱歉 [输入堆栈大小=10000]。)

biblatex:citefield + url + href(超出 TeX 容量,抱歉 [输入堆栈大小=10000]。)
  • 是否有一种“现成的”方法可以在命令中使用参考书目条目的 url \href{}\citefield{}{}例如\href{\citefield{ctan}{url}}{link}
  • 下面的 MWE 给出错误 ( TeX capacity exceeded, sorry [input stack size=10000].)。
  • 我发现了一个8岁儿童相关问题但我希望现在有一个更简单的方法来做到这一点。

\documentclass{article}

\usepackage{biblatex}
\usepackage{hyperref}

\bibliography{biblatex-examples.bib}

\begin{document}

\begin{description}
\item[cite] \cite{ctan}
\item[citefield] \citefield{ctan}{url}
\item[href] \href{http://www.ctan.org}{link}
\item[href + citefield] %\href{\citefield{ctan}{url}}{link} % <-- Comment in/out to test.
\end{description}

\printbibliography

\end{document}

在此处输入图片描述


有关的

答案1

这里最好的方法取决于您的使用情况。

如果你想将文档中动态提供的任意文本链接到条目的 URL,解决方案来自使用存储在参考书目中的 URL 创建超链接?可能是可行的方法。

但如果你确实想链接.bib条目的一部分或可以通过编程生成的内容biblatex,那么你应该使用来自的方法从 .bib 条目中提取 URL 以用于 \href{}{} (可能使用 Biblatex)的最简单方法是什么?


在您的回答中,您总是只链接shorttitle。在这种情况下,您可以选择

\documentclass{article}
\usepackage{biblatex}
\usepackage{csquotes}
\usepackage[
  hidelinks,
  colorlinks = true,
  linkcolor = blue,
  urlcolor = blue,
  citecolor = red,
]{hyperref}

\DeclareFieldFormat{urllink}{\href{\thefield{url}}{#1}}
\DeclareCiteCommand{\titleurlcite}
  {\boolfalse{citetracker}%
   \boolfalse{pagetracker}%
   \usebibmacro{prenote}}
  {\ifciteindex
     {\indexfield{indextitle}}
     {}%
   \printfield[urllink]{labeltitle}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\begin{filecontents}{\jobname.bib}
@techreport{ISO_TS_16951_2021,
  type        = {Technical Specification (ISO/TS)},
  title       = {Road vehicles
                 -- Ergonomic aspects of transport information and control systems (TICS)
                 -- Procedures for determining priority of on-board messages presented to drivers},
  shorttitle  = {ISO/TS 16951:20216},
  url         = {https://www.iso.org/standard/81103.html},
  number      = {ISO/TS 16951:2021},
  institution = {International Organization for Standardization (ISO)},
  author      = {ISO},
  date        = {2021-03},
}
\end{filecontents}
\addbibresource{\jobname.bib}

\begin{document}
\titleurlcite{ISO_TS_16951_2021}

\printbibliography
\end{document}

链接的简称


如果您只需要在description环境中使用它,则可以使用 来biblatex生成它\printbibliography。 (同样,具体如何实现它在很大程度上取决于您的具体用例。这只是一种简单的实现方法。您可能需要或不需要进行一些调整才能使其按您希望的方式运行。)

\documentclass{article}
\usepackage{biblatex}
\usepackage{csquotes}
\usepackage[
  hidelinks,
  colorlinks = true,
  linkcolor = blue,
  urlcolor = blue,
  citecolor = red,
]{hyperref}

\DeclareFieldFormat{urllink}{\href{\thefield{url}}{#1}}

\newrobustcmd*{\localbibliographyalias}[2]{%
  \csedef{blx@bbx@#1}{%
    \expandafter\noexpand\csname blx@bbx@#2\endcsname}}

\defbibenvironment{standardslist}
  {\localbibliographyalias{report}{standardslist}%
   \list
     {\printfield[urllink]{shorttitle}}
     {\setlength{\labelwidth}{\bibhang}%
      \setlength{\leftmargin}{\labelwidth}%
      \setlength{\labelsep}{\biblabelsep}%
      \addtolength{\leftmargin}{\labelsep}%
      \setlength{\itemsep}{\bibitemsep}%
      \setlength{\parsep}{\bibparsep}}}
  {\endlist}
  {\item}

\defbibcheck{standardslist}{%
  \ifentrytype{report}
    {}
    {\skipentry}%
}

\DeclareBibliographyDriver{standardslist}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \printtext{The title of this document is}%
  \setunit{\addspace}%
  \usebibmacro{title}%
  \setunit{\addspace}%
  \printtext[brackets]{\usebibmacro{cite}}%
  \setunit{\bibpagerefpunct}\newblock
  \usebibmacro{pageref}%
  \newunit\newblock
  \iftoggle{bbx:related}
    {\usebibmacro{related:init}%
     \usebibmacro{related}}
    {}%
  \usebibmacro{finentry}}

\begin{filecontents}{\jobname.bib}
@techreport{ISO_TS_16951_2021,
  type = {Technical Specification (ISO/TS)},
  title = {Road vehicles -- Ergonomic aspects of transport information and control systems (TICS) -- Procedures for determining priority of on-board messages presented to drivers},
  shorttitle = {ISO/TS 16951:20216},
  url = {https://www.iso.org/standard/81103.html},
  number = {ISO/TS 16951:2021},
  institution = {International Organization for Standardization (ISO)},
  author = {{ISO}},
  date = {2021-03},
}
@techreport{ISO_15006_2011,
  type = {Standard},
  title = {Road vehicles -- Ergonomic aspects of transport information and control systems -- Specifications for in-vehicle auditory presentation},
  shorttitle = {ISO 15006:2011},
  url = {https://www.iso.org/standard/55322.html},
  number = {ISO 15006:2011},
  institution = {International Organization for Standardization (ISO)},
  author = {{ISO}},
  date = {2011-10},
}
@techreport{ISO_TR_12204_2012,
  type = {Technical Report (ISO/TR)},
  title = {Road vehicles — Ergonomic aspects of transport information and control systems — Introduction to integrating safety critical and time critical warning signals},
  shorttitle = {ISO/TR 12204:2012},
  url = {https://www.iso.org/standard/55322.html},
  number = {ISO/TR 12204:2012},
  institution = {International Organization for Standardization (ISO)},
  author = {{ISO}},
  date = {2012-11},
}
@techreport{ISO_TR_16352_2005,
  type = {Technical Report (ISO/TR)},
  title = {Road vehicles -- Ergonomic aspects of in-vehicle presentation for transport information and control systems -- Warning systems},
  shorttitle = {ISO/TR 16352:2005},
  url = {https://www.iso.org/standard/37859.html},
  number = {ISO/TR 16352:2005},
  institution = {International Organization for Standardization (ISO)},
  author = {{ISO}},
  date = {2005-12},
}
@techreport{ISO_15005_2017,
  type = {Standard},
  title = {Road vehicles -- Ergonomic aspects of transportation and control systems -- Dialogue management principles and compliance procedures},
  shorttitle = {ISO 15005:2017},
  url = {https://www.iso.org/standard/69238.html},
  number = {ISO 15005:2017},
  institution = {International Organization for Standardization (ISO)},
  author = {{ISO}},
  date = {2017-02},
}
@techreport{ISO_15007_2020,
  type = {Standard},
  title = {Road vehicles -— Measurement and analysis of driver visual behaviour with respect to transport information and control systems},
  shorttitle = {ISO 15007:2020},
  url = {https://www.iso.org/standard/63220.html},
  number = {ISO 15007:2020},
  institution = {International Organization for Standardization (ISO)},
  author = {{ISO}},
  date = {2011-10},
}
@techreport{ISO_15008_2017,
  type = {Standard},
  title = {Road vehicles -- Ergonomic aspects of transport information and control systems -- Specifications and test procedures for in-vehicle visual presentation},
  shorttitle = {ISO 15005:2017},
  url = {https://www.iso.org/standard/62784.html},
  number = {ISO 15008:2017},
  institution = {International Organization for Standardization (ISO)},
  author = {{ISO}},
  date = {2017-09},
}
@techreport{ISO_16673_2017,
  type = {Standard},
  title = {Road vehicles -- Ergonomic aspects of transport information and control systems -- Occlusion method to assess visual demand due to the use of in-vehicle systems},
  shorttitle = {ISO 16673:2017},
  url = {https://www.iso.org/standard/71508.html},
  number = {ISO 16673:2017},
  institution = {International Organization for Standardization (ISO)},
  author = {{ISO}},
  date = {2005-12},
}
@techreport{ISO_17287_2003,
  type = {Standard},
  title = {Road vehicles —- Ergonomic aspects of transport information and control systems —- Procedure for assessing suitability for use while driving},
  shorttitle = {ISO 17287:2003},
  url = {https://www.iso.org/standard/30597.html},
  number = {ISO 17287:2003},
  institution = {International Organization for Standardization (ISO)},
  author = {{ISO}},
  date = {2003-04},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\addbibresource{biblatex-examples.bib}

\begin{document}
\nocite{ISO_15006_2011,ISO_TR_16352_2005,ISO_TS_16951_2021,ISO_15005_2017,
  ISO_15006_2011,ISO_15007_2020,ISO_15008_2017,ISO_16673_2017,
  ISO_17287_2003,ISO_TR_12204_2012}

Lorem \autocite{sigfridsson,worman,geer,aksin,moraux}

\printbibliography[env=standardslist, check=standardslist, title=Lots of standards]
\printbibliography

\end{document}

标准书目

答案2

根据用户 moewe 的精彩评论和已有的答案,我现在使用他的代码。也许这对将来的参考有用。

\documentclass{article}
\usepackage{biblatex}
\usepackage{csquotes} % for \enquote
\usepackage[
    hidelinks,
    colorlinks = true,
    linkcolor = blue,
    urlcolor = blue,
    citecolor = red,
    ]{hyperref}

% Based on % https://tex.stackexchange.com/questions/467262/
\DeclareCiteCommand{\myCiteBibURL}
  {\boolfalse{citetracker}%
   \boolfalse{pagetracker}}
  {\iffieldundef{url}
     {\PackageWarning{biblatex}
        {The entry \thefield{entrykey} has no URL.\MessageBreak
         No link will be created}%
      \printfield{postnote}}
     {\href{\thefield{url}}
        {\iffieldundef{postnote}
           {\PackageWarning{biblatex}
              {Text argument missing,\MessageBreak
               using the title for entry\MessageBreak
               \thefield{entrykey}}%
            \printfield[citetitle]{labeltitle}}
           {\printfield{postnote}}}}}
  {}
  {}

\begin{filecontents}{\jobname.bib}
@techreport{ISO_TS_16951_2021,
  type = {Technical Specification (ISO/TS)},
  title = {Road vehicles -- Ergonomic aspects of transport information and control systems (TICS) -- Procedures for determining priority of on-board messages presented to drivers},
  shorttitle = {ISO/TS 16951:20216},
  url = {https://www.iso.org/standard/81103.html},
  number = {ISO/TS 16951:2021},
  institution = {International Organization for Standardization (ISO)},
  author = {{ISO}},
  date = {2021-03},
}

@techreport{ISO_15006_2011,
  type = {Standard},
  title = {Road vehicles -- Ergonomic aspects of transport information and control systems -- Specifications for in-vehicle auditory presentation},
  shorttitle = {ISO 15006:2011},
  url = {https://www.iso.org/standard/55322.html},
  number = {ISO 15006:2011},
  institution = {International Organization for Standardization (ISO)},
  author = {{ISO}},
  date = {2011-10},
}

@techreport{ISO_TR_12204_2012,
  type = {Technical Report (ISO/TR)},
  title = {Road vehicles — Ergonomic aspects of transport information and control systems — Introduction to integrating safety critical and time critical warning signals},
  shorttitle = {ISO/TR 12204:2012},
  url = {https://www.iso.org/standard/55322.html},
  number = {ISO/TR 12204:2012},
  institution = {International Organization for Standardization (ISO)},
  author = {{ISO}},
  date = {2012-11},
}

@techreport{ISO_TR_16352_2005,
  type = {Technical Report (ISO/TR)},
  title = {Road vehicles -- Ergonomic aspects of in-vehicle presentation for transport information and control systems -- Warning systems},
  shorttitle = {ISO/TR 16352:2005},
  url = {https://www.iso.org/standard/37859.html},
  number = {ISO/TR 16352:2005},
  institution = {International Organization for Standardization (ISO)},
  author = {{ISO}},
  date = {2005-12},
}

@techreport{ISO_15005_2017,
  type = {Standard},
  title = {Road vehicles -- Ergonomic aspects of transportation and control systems -- Dialogue management principles and compliance procedures},
  shorttitle = {ISO 15005:2017},
  url = {https://www.iso.org/standard/69238.html},
  number = {ISO 15005:2017},
  institution = {International Organization for Standardization (ISO)},
  author = {{ISO}},
  date = {2017-02},
}

@techreport{ISO_15007_2020,
  type = {Standard},
  title = {Road vehicles -— Measurement and analysis of driver visual behaviour with respect to transport information and control systems},
  shorttitle = {ISO 15007:2020},
  url = {https://www.iso.org/standard/63220.html},
  number = {ISO 15007:2020},
  institution = {International Organization for Standardization (ISO)},
  author = {{ISO}},
  date = {2011-10},
}

@techreport{ISO_15008_2017,
  type = {Standard},
  title = {Road vehicles -- Ergonomic aspects of transport information and control systems -- Specifications and test procedures for in-vehicle visual presentation},
  shorttitle = {ISO 15005:2017},
  url = {https://www.iso.org/standard/62784.html},
  number = {ISO 15008:2017},
  institution = {International Organization for Standardization (ISO)},
  author = {{ISO}},
  date = {2017-09},
}

@techreport{ISO_16673_2017,
  type = {Standard},
  title = {Road vehicles -- Ergonomic aspects of transport information and control systems -- Occlusion method to assess visual demand due to the use of in-vehicle systems},
  shorttitle = {ISO 16673:2017},
  url = {https://www.iso.org/standard/71508.html},
  number = {ISO 16673:2017},
  institution = {International Organization for Standardization (ISO)},
  author = {{ISO}},
  date = {2005-12},
}

@techreport{ISO_17287_2003,
  type = {Standard},
  title = {Road vehicles —- Ergonomic aspects of transport information and control systems —- Procedure for assessing suitability for use while driving},
  shorttitle = {ISO 17287:2003},
  url = {https://www.iso.org/standard/30597.html},
  number = {ISO 17287:2003},
  institution = {International Organization for Standardization (ISO)},
  author = {{ISO}},
  date = {2003-04},
}
\end{filecontents}
\addbibresource{\jobname.bib}

\begin{document}

\begin{description}
% \item[{\myCiteBibURL[]{}}] Text % <-- The additional "{}" inside the optional argumeny of the \item command is needed because of the "[]" of the \myCiteBibURL command.
\item[{\myCiteBibURL[\citefield{ISO_15006_2011}{shorttitle}]{ISO_15006_2011}}] The title of the document is \enquote{\citefield{ISO_15006_2011}{title}} \parencite{ISO_15006_2011}.
\item[{\myCiteBibURL[\citefield{ISO_TR_16352_2005}{shorttitle}]{ISO_TR_16352_2005}}] The title of the document is \enquote{\citefield{ISO_TR_16352_2005}{title}} \parencite{ISO_TR_16352_2005}. 
\item[{\myCiteBibURL[\citefield{ISO_TS_16951_2021}{shorttitle}]{ISO_TS_16951_2021}}] The title of the document is \enquote{\citefield{ISO_TS_16951_2021}{title}} \parencite{ISO_TS_16951_2021}.
\item[{\myCiteBibURL[\citefield{ISO_15005_2017}{shorttitle}]{ISO_15005_2017}}] The title of the document is \enquote{\citefield{ISO_15005_2017}{title}} \parencite{ISO_15005_2017}.
\item[{\myCiteBibURL[\citefield{ISO_15006_2011}{shorttitle}]{ISO_15006_2011}}] The title of the document is \enquote{\citefield{ISO_15006_2011}{title}} \parencite{ISO_15006_2011}.
\item[{\myCiteBibURL[\citefield{ISO_15007_2020}{shorttitle}]{ISO_15007_2020}}] The title of the document is \enquote{\citefield{ISO_15007_2020}{title}} \parencite{ISO_15007_2020}.
\item[{\myCiteBibURL[\citefield{ISO_15008_2017}{shorttitle}]{ISO_15008_2017}}] The title of the document is \enquote{\citefield{ISO_15008_2017}{title}} \parencite{ISO_15008_2017}.
\item[{\myCiteBibURL[\citefield{ISO_16673_2017}{shorttitle}]{ISO_16673_2017}}] The title of the document is \enquote{\citefield{ISO_16673_2017}{title}} \parencite{ISO_16673_2017}.
\item[{\myCiteBibURL[\citefield{ISO_17287_2003}{shorttitle}]{ISO_17287_2003}}] The title of the document is \enquote{\citefield{ISO_17287_2003}{title}} \parencite{ISO_17287_2003}.
\item[{\myCiteBibURL[\citefield{ISO_TR_12204_2012}{shorttitle}]{ISO_TR_12204_2012}}] The title of the document is \enquote{\citefield{ISO_TR_12204_2012}{title}} \parencite{ISO_TR_12204_2012}.
\end{description}

\printbibliography

\end{document}

在此处输入图片描述

在此处输入图片描述

相关内容