我怎样才能让 \cite 打印@ONLINE 的 URL?

我怎样才能让 \cite 打印@ONLINE 的 URL?

我使用自定义环境{readon}在章节末尾提供一些额外的文章和网站供阅读。我该如何更改以便它还打印此列表中条目\cite的 URL ?@ONLINE

在此处输入图片描述

\documentclass{scrbook}

\usepackage[style=authortitle]{biblatex}
\addbibresource{\jobname.bib}

\usepackage{lipsum}

\begin{filecontents}{\jobname.bib}
   @Online{penalties,
     author  = {David Carlisle},
     title   = {What are penalties and which ones are defined?},
     date    = {2012-04-09},
     url     = {https://tex.stackexchange.com/a/51264/4918},
     urldate = {2017-06-28},
   }
   @Book{texbytopic,
     author  = {Eijkhout, Victor},
     title   = {\TeX{} by Topic},
     address = {Berlin},
     year    = {2014},
   }
\end{filecontents}

\newenvironment{readon}{%
   \par\bigskip\noindent
   \footnotesize
   \textbf{Further reading \dots}
   \begin{itemize}
}{
   \end{itemize}
}

\begin{document}

\lipsum[1-3]

\begin{readon}
   \item \cite[155\psqq]{texbytopic}
   \item \cite{penalties} [[add URL here]]
\end{readon}

\printbibliography

\end{document}

答案1

@online您可以修改引用宏以打印条目的 URL

\renewbibmacro*{cite}{%
  \iffieldundef{shorthand}
    {\ifnameundef{labelname}
       {}
       {\printnames{labelname}%
        \setunit{\printdelim{nametitledelim}}}%
     \usebibmacro{cite:title}}%
    {\usebibmacro{cite:shorthand}}%
  \usebibmacro{cite:url}}

\newbibmacro{cite:url}{%
  \ifentrytype{online}
    {\setunit{\addspace}%
     \printfield{url}}
    {}}

由于这修改了citebibmacro,因此解决方案特定于authoryear样式,但总体思路可应用于所有样式。

答案2

\usepackage[style=authortitle]{biblatex}
\addbibresource{\jobname.bib}
\DeclareFieldFormat{citeurl}{\ifentrytype{online}{[\url{#1}]}{}}

进而

\begin{readon}
    \item \cite[155\psqq]{texbytopic} \citeurl{texbytopic}
    \item \cite{penalties} \citeurl{penalties}
\end{readon}

在此处输入图片描述

相关内容