打印的 URL 很不方便,我刚刚注意到,有一个用于生成 QRCodes 的 LaTeX 包。
我认为使用 QRcodes 来辅助 URL 会很不错,因此我使用下面的代码在所有\url
使用 a 的地方的边缘生成 QRcode:
\usepackage{hyperref}
\usepackage{qrcode}
\let\oldUrl\url
\renewcommand*{\url}[1]{\oldUrl{#1}\marginpar{\qrcode[nolink]{#1}}}
首先:这种结果让我震惊,因为它很容易就实现了我想要达到的目标。
我想解决一个缺点:由于参考书目中的 URL 密度很高,所以并非所有的二维码都会出现在相关条目旁边。
因此,我想通过 URL 字段扩展参考书目条目的高度,以便它与边距中的二维码的高度相匹配。
这有点与“书目中的信息框“,但那里的信息框也没有为参考书目条目创建额外的空间。所以我想要一些类似于“垂直空间取决于边距的高度",但在参考书目中。
我用它biblatex
来编纂我的参考书目。
妇女权利委员会:
\documentclass[]{article}
\begin{filecontents}{\jobname.bib}
@misc{example1,
title = {Example.com},
url = {http://example.com}
}
@misc{example2,
title = {Example.com},
url = {http://example.com}
}
@misc{example3,
title = {Example.com},
url = {http://example.com}
}
@misc{example4,
title = {Example.com},
url = {http://example.com}
}
@misc{example5,
title = {Example.com},
url = {http://example.com}
}
\end{filecontents}
\usepackage[backend=biber,sorting=nyt,style=ieee]{biblatex}
\addbibresource{\jobname}
\usepackage{qrcode}
\let\oldUrl\url
\renewcommand*{\url}[1]{\oldUrl{#1}\marginpar{\qrcode[nolink]{#1}}}
\begin{document}
\nocite{*}
~ % Type something....
\printbibliography
\end{document}
答案1
您可以将所有条目用固定高度的二维码包裹起来\parbox
:
\documentclass[]{article}
\begin{filecontents}{\jobname.bib}
@misc{example1,
title = {Example.com},
url = {http://example.com}
}
@misc{example2,
title = {Example.com},
url = {http://example.com}
}
@misc{example3,
title = {Example.com},
url = {http://example.com}
}
@misc{example4,
title = {Example.com},
url = {http://example.com}
}
@misc{example5,
title = {Example.com}
}
@misc{example6,
title = {Example.com},
url = {http://example.com}
}
\end{filecontents}
\usepackage[backend=biber,sorting=nyt,style=ieee]{biblatex}
\addbibresource{\jobname}
\DeclareBibliographyDriver{misc}{%
\iffieldundef{url}{%
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\usebibmacro{author/editor+others/translator+others}%
\setunit{\labelnamepunct}\newblock
\usebibmacro{title}%
\newunit
\printlist{language}%
\newunit\newblock
\usebibmacro{byauthor}%
\newunit\newblock
\usebibmacro{byeditor+others}%
\newunit\newblock
\printfield{howpublished}%
\newunit\newblock
\printfield{type}%
\newunit
\printfield{version}%
\newunit
\printfield{note}%
\newunit\newblock
\usebibmacro{organization+location+date}%
\newunit\newblock
\usebibmacro{doi+eprint+url}%
\newunit\newblock
\usebibmacro{addendum+pubstate}%
\setunit{\bibpagerefpunct}\newblock
\usebibmacro{pageref}%
\newunit\newblock
\iftoggle{bbx:related}
{\usebibmacro{related:init}%
\usebibmacro{related}}
{}%
\usebibmacro{finentry}
}{%
\marginpar{\vskip-10pt\qrcode[nolink]{\strfield{url}}}%
\parbox[t][2.5cm][t]{\dimexpr\linewidth-3pt\relax}{%
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\usebibmacro{author/editor+others/translator+others}%
\setunit{\labelnamepunct}\newblock
\usebibmacro{title}%
\newunit
\printlist{language}%
\newunit\newblock
\usebibmacro{byauthor}%
\newunit\newblock
\usebibmacro{byeditor+others}%
\newunit\newblock
\printfield{howpublished}%
\newunit\newblock
\printfield{type}%
\newunit
\printfield{version}%
\newunit
\printfield{note}%
\newunit\newblock
\usebibmacro{organization+location+date}%
\newunit\newblock
\usebibmacro{doi+eprint+url}%
\newunit\newblock
\usebibmacro{addendum+pubstate}%
\setunit{\bibpagerefpunct}\newblock
\usebibmacro{pageref}%
\newunit\newblock
\iftoggle{bbx:related}
{\usebibmacro{related:init}%
\usebibmacro{related}}
{}%
\usebibmacro{finentry}
}%end parbox
}
}
\usepackage{qrcode}
\begin{document}
\nocite{*}
~ % Type something....
\printbibliography
\end{document}