6

Printed URLs are inconvenient and i just noticed, that there is a LaTeX package to generate QRCodes.

I think using QRcodes to aid with URLs could turn out quite nice, so i used the code below to generate a QRcode in the margin everywhere a \url is used:

\usepackage{hyperref}
\usepackage{qrcode}
\let\oldUrl\url
\renewcommand*{\url}[1]{\oldUrl{#1}\marginpar{\qrcode[nolink]{#1}}}

First of all: The result of this kind of blew my mind, because it very easily did, what i wanted to achieve.

There is one drawback i would like to solve: Because of the high density of URLs in the Bibliography not all QRcodes do appear next to the related entry.

So I would like to extend the height of a bibliography entry with an URL field, so that it matches the height of the QRcode in the margin.

This is kindof related to "Info boxes in bibliography", but there the info boxes also did not create extra space for the bibliography entry. So i want something similiar to "Vertical space depending on height of marginpar", but in the bibliography.

I'm using biblatex for my bibliography.

Margin height does not match height of bibliography entry

The MWE:

\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}
4

You could wrap all entries with a QR code in a \parbox of fixed height:

\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}

enter image description here

|improve this answer|||||
  • I tried that. Also tried to add that space by changing the bibliography representation of the url field or using AtEveryBibitem(or something like that), but as you can see from your screenshot, that attempt produces irregular spacing for entrys without an URL field. also it will add the space even when the bibliography entry was long enough to cover the full height of the qrcode, so it will only work, when the bibliography entry has only 1 line. – MaPePeR Aug 1 '16 at 18:34
  • @MaPePeR So what layout do you suggest? Should all entries be spaces equally, even if they don't have a code? – samcarter_is_at_topanswers.xyz Aug 2 '16 at 11:31
  • I think the best option would be if it would be aligned like a table with 2 columns, so the height of each entry is the maximum of either the bibliography entry or the qrcode. Also the qrcode should probably be aligned with the top of the entry. \marginnote with AtEveryBibitem allows to align the qrcode at the top of the entry, but i have not yet found a way to specify a minimum height for the entry. (If there is a qrcode the entry should be at least as high as the height of the qrcode) – MaPePeR Aug 2 '16 at 12:37
  • Another layout option would be to add the qrcode to the bilbiography left aligned and let the text of the entry flow around it. I was not able to achieve that, because when i inserted the qrcode next to the text only the first line of the entry would be next to the qrcode. – MaPePeR Aug 2 '16 at 12:40
  • @MaPePeR see the new version. I don't think it's likely, that the item will be longer than the code, but in case you want to implement this, see tex.stackexchange.com/questions/215442/… for boxes of minimum height. – samcarter_is_at_topanswers.xyz Aug 2 '16 at 15:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.