我已设法获取biblatex
并biber
包含包含 URL 的参考书目项目的二维码 - 如下所示:
\documentclass{scrartcl}
\begin{filecontents*}[overwrite]{\jobname.bib}
@book { texlive-home,
shorthand = {TLD1},
author = {The TeX User Group},
title = {TeX Live},
note = {some text to make the entry appear more voluminous},
url = {https://www.tug.org/texlive/}
}
\end{filecontents*}
\begin{filecontents*}[overwrite]{biblatex.cfg}
\DeclareFieldFormat
[book]
{url}{\par{\scriptsize\ttfamily\url{#1}}\par\vspace{1.5mm}\qrcode{#1}\vspace{3mm}}
\end{filecontents*}
\usepackage{qrcode}
\usepackage[style=alphabetic]{biblatex}
\appto{\biburlsetup}{\renewcommand*{\UrlFont}{\scriptsize\ttfamily}}
\addbibresource{\jobname.bib}
\begin{document}
\nocite{*}
\printbibliography
\end{document}
这可行,但浪费了大量空间:
我希望二维码位于条目的右侧,如下所示:
在文档中我可能会使用一个简单的tabular
环境来实现这一点,但我所能创建的只是令人印象深刻的错误消息。有人能给我指明正确的方向吗?
答案1
如果你更喜欢真正的表格书目,你可能想看看biblatex-ext-tabular
我的biblatex-ext
捆。
使用表格的优点是您将始终有足够的空间放置二维码。
\documentclass{scrartcl}
\usepackage{qrcode}
\usepackage[style=alphabetic]{biblatex}
\usepackage{biblatex-ext-tabular}
\usepackage{longtable}
\usepackage{array}
\newcolumntype{L}[1]{%
>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}p{#1}}
\DeclareFieldFormat{qrurl}{%
\raisebox{\dimeval{-\height+\ht\strutbox}}{\qrcode{#1}}}
\defbibtabular{bibtabular}
{\setlength{\LTpre}{0pt}%
\setlength{\LTpost}{0pt}%
\renewcommand*{\arraystretch}{2}%
\begin{longtable}{%
@{}
L{\labelalphawidth}
L{\dimexpr0.7\textwidth-0.7\labelalphawidth\relax}
L{\dimexpr0.3\textwidth-0.3\labelalphawidth\relax}
@{}}}
{\end{longtable}}
{\anchorlang{%
\printtext[labelalphawidth]{%
\printfield{labelprefix}%
\printfield{labelalpha}%
\printfield{extraalpha}}} &
\driver{} &
\plain{\printfield[qrurl]{url}}
\\}
\begin{filecontents*}{\jobname.bib}
@book{texlive-home,
shorthand = {TLD1},
author = {The TeX User Group},
title = {TeX Live},
note = {some text to make the entry appear more voluminous},
url = {https://www.tug.org/texlive/}
}
\end{filecontents*}
\addbibresource{\jobname.bib}
\addbibresource{biblatex-examples.bib}
\begin{document}
\nocite{texlive-home,sigfridsson,worman,geer,nussbaum,ctan}
\printbibtabular
\end{document}
答案2
您将必须调整尺寸,但是这样的方法应该可以起作用。
\documentclass{scrartcl}
\usepackage{qrcode}
\usepackage[style=alphabetic,url=false]{biblatex}
\appto{\biburlsetup}{\renewcommand*{\UrlFont}{\scriptsize\ttfamily}}
\addbibresource{biblatex-examples.bib}
\usepackage{lipsum}
\DeclareFieldFormat
{qrurl}{\qrcode{#1}}
\renewbibmacro{begentry}{\makebox[0pt][l]{\hspace*{\linewidth}\quad\raisebox{\dimeval{-\height+\ht\strutbox}}[0pt][0pt]{\printfield[qrurl]{url}}}}
\defbibenvironment{bibliography}
{\list
{\printtext[labelalphawidth]{%
\printfield{labelprefix}%
\printfield{labelalpha}%
\printfield{extraalpha}}}
{\setlength{\labelwidth}{\labelalphawidth}%
\setlength\rightmargin{3cm}% %<------- adapt ...
\setlength{\leftmargin}{\labelwidth}%
\setlength{\labelsep}{\biblabelsep}%
\addtolength{\leftmargin}{\labelsep}%
\setlength{\itemsep}{\bibitemsep}%
\setlength{\parsep}{\bibparsep}}%
\renewcommand*{\makelabel}[1]{##1\hss}}
{\endlist}
{\item}
\begin{document}
\lipsum[1]
\cite{ctan,doody}
\printbibliography
\end{document}