0

I have created a custom \citedoi{} command based off biblatex's \citeurl{} command that is working fine. I can then put the \citedoi{} within a box near images or other things that need citations that are not in-text. I have tried to create a parbox to contain the doi in-text so it consumes the least amount of space (the font size is \tiny and it takes too much space within a line as can be seen in the images). I want to wrap the doi within a box over two \tiny lines so that it reduces the space between the prior and after words.

The motivation for this is that my PhD supervisor likes to have the doi's at the immediate location in addition to a bibliography at the end of presentation slides. I created a command to use for annotating purposes \scitedoi{} and the failed \itcitedoi{} for use within text:

\newcommand\scitedoi[1]{{\color{blue}\tiny\citedoi{#1}}}
\newcommand\itcitedoi[1]{\parbox{1.5cm}{\color{blue}\tiny\citedoi{#1}}}

When using just \scitedoi{} the beamer frame looks like this:

How the doi currently looks

When also using the \itcitedoi{} command it goes off into the margin:

parbox attempt

Ideally, I would like for the \itcitedoi{} command to be treated as text (if that makes sense?) and for text to go around it as it normally would for a word. I know that the text, even being \tiny, will increase the gap between lines where used but this is fine.

Does anyone know how I can achieve putting the \citedoi{} within a box that spans and wraps the doi over two \tiny lines using parbox or anything similar please?

MWE:

\begin{filecontents}[overwrite]{ref.bib}
@Article{M2020,
  author = {Mehandia, Seema and Sharma, S. C. and Arya, Shailendra Kumar},
  journal = {Biotechnol. Rep. (Amst)},
  title = {Isolation and characterization of an alkali and thermostable laccase},
  doi = {10.1016/j.btre.2019.e00413},
}
@Article{Mn2009,
  author = {Murugesan, Kumarasamy and Kim, Young-Mo and Jeon, Jong-Rok and Chang, Yoon-Seok},
  journal = {J Hazard Mater.},
  title = {Effect of metal ions on reactive dye decolorization by laccase from Ganoderma lucidum.},
  doi = {10.1016/j.jhazmat.2009.02.075},
}
\end{filecontents}

\documentclass[hyperref={colorlinks=false}]{beamer}

\usepackage[backend=biber, style=numeric]{biblatex} \usepackage{xurl}

\addbibresource{ref.bib}

% Custom \citedoi command adapted from \citeurl \DeclareFieldFormat{citedoi}{\href{https://doi.org/#1}{#1}}

\DeclareCiteCommand{\citedoi} {\boolfalse{citetracker}% \boolfalse{pagetracker}% \usebibmacro{prenote}} {\printfield[citedoi]{doi}} {\multicitedelim} {\usebibmacro{postnote}}

\newcommand\scitedoi[1]{{\color{blue}\tiny\citedoi{#1}}}

\newcommand\itcitedoi[1]{\parbox{1.5cm}{\color{blue}\tiny\citedoi{#1}}}

\begin{document}

\begin{frame} \frametitle{Unreproducible} This text is just text and nothing more as I just need filler text \scitedoi{M2020} that spans a few lines on this beamer presentation. This text is just text and nothing more \itcitedoi{Mn2009} as I just need filler text that spans a few lines on this beamer presentation. This text is just text and nothing more as I just need filler text that spans a few lines on this beamer presentation. \end{frame}

\begin{frame} \printbibliography \end{frame}

\end{document}

I am compiling with:

% arara: pdflatex: {options: [-halt-on-error]}
% arara: biber
% arara: pdflatex: {options: [-halt-on-error]}
JamesT
  • 3,169
  • 1
    Just an idea: try using a QR code. – Oleg Lobachev Oct 15 '22 at 00:02
  • @OlegLobachev I have implemented a solution using QR codes that I am really happy with, thank you for the suggestion! – JamesT Oct 15 '22 at 01:07
  • 1
    sorry to answer you here but I couldn't find a way to contact you since I cant comment under your comment (missing reputation). I read your answer to this question and I think that style looks awesome! My only problem is if I change anything in my style-patterns.txt file it won't change anything in my editor! Again, sorry to have to answer you under this post but maybe you have an idea? – Athena Nov 30 '22 at 19:07
  • @Athena hey sorry for the delay in replying, it depends on how you're doing it and probably the OS you're using, are you removing the original unedited style-patterns.txt from the folder? It should load it automatically, that's what it did with mine, I'm using TeXworks version 0.6.6 on Windows 10 - maybe there is an issue with Linux/Mac and I could improve the answer if you can provide more details please – JamesT Dec 03 '22 at 01:20

2 Answers2

2

Not sure if the effect you get in the MWE is exactly what you want to achieve, but you'll want to use \nolinkurl in your field format for citedoi. Otherwise LaTeX is unable to offer line breaks inside the DOI, because it cannot be hyphenated like normal words.

\documentclass[hyperref={colorlinks=false}]{beamer}

\usepackage[backend=biber, style=numeric]{biblatex} \usepackage{xurl}

\DeclareFieldFormat{citedoi}{\href{https://doi.org/#1}{\nolinkurl{#1}}}

\DeclareCiteCommand{\citedoi} {\boolfalse{citetracker}% \boolfalse{pagetracker}% \usebibmacro{prenote}} {\printfield[citedoi]{doi}} {\multicitedelim} {\usebibmacro{postnote}}

\newcommand\scitedoi[1]{{\color{blue}\tiny\citedoi{#1}}} \newcommand\itcitedoi[1]{\parbox{1.5cm}{\color{blue}\tiny\citedoi{#1}}}

\begin{filecontents}{\jobname.bib} @article{M2020, author = {Mehandia, Seema and Sharma, S. C. and Arya, Shailendra Kumar}, journal = {Biotechnol. Rep. (Amst)}, title = {Isolation and characterization of an alkali and thermostable laccase}, doi = {10.1016/j.btre.2019.e00413}, } @article{Mn2009, author = {Murugesan, Kumarasamy and Kim, Young-Mo and Jeon, Jong-Rok and Chang, Yoon-Seok}, journal = {J Hazard Mater.}, title = {Effect of metal ions on reactive dye decolorization by laccase from Ganoderma lucidum.}, doi = {10.1016/j.jhazmat.2009.02.075}, } \end{filecontents} \addbibresource{\jobname.bib}

\begin{document}

\begin{frame} \frametitle{Unreproducible} This text is just text and nothing more as I just need filler text \scitedoi{M2020} that spans a few lines on this beamer presentation. This text is just text and nothing more \itcitedoi{Mn2009} as I just need filler text that spans a few lines on this beamer presentation. This text is just text and nothing more as I just need filler text that spans a few lines on this beamer presentation. \end{frame}

\begin{frame} \printbibliography \end{frame}

\end{document}

Three-line DOI.

moewe
  • 175,683
  • I did not know of that option \nolinkurl, I think I should read the biblatex manual more thoroughly next time, thanks again – JamesT Oct 15 '22 at 11:53
1

The answer by @moewe answered my question but I also want to add an answer showing the suggestion by @Oleg Lobachev to use QR codes with the qrcode package. Adapting the answer by Martin H to calculate the text height (so to make a QR code with an appropriate height) gives this as the output:

enter image description here

with a hyperlinked QR code set to the text height. Thanks for the suggestion and thanks for the accepted answer, both are useful for my needs.

% arara: pdflatex: {options: [-halt-on-error]}
% arara: biber
% arara: pdflatex: {options: [-halt-on-error]}

\begin{filecontents}[overwrite]{ref.bib} @Article{M2020, author = {Mehandia, Seema and Sharma, S. C. and Arya, Shailendra Kumar}, journal = {Biotechnol. Rep. (Amst)}, title = {Isolation and characterization of an alkali and thermostable laccase}, doi = {10.1016/j.btre.2019.e00413}, } @Article{Mn2009, author = {Murugesan, Kumarasamy and Kim, Young-Mo and Jeon, Jong-Rok and Chang, Yoon-Seok}, journal = {J Hazard Mater.}, title = {Effect of metal ions on reactive dye decolorization by laccase from Ganoderma lucidum.}, doi = {10.1016/j.jhazmat.2009.02.075}, } \end{filecontents}

\documentclass[hyperref={colorlinks=false}]{beamer}

\usepackage[backend=biber, style=numeric]{biblatex} \usepackage{qrcode}

\addbibresource{ref.bib}

% Custom \qrdoi command adapted from \citeurl following the suggestion by Oleg Lobachev

\DeclareFieldFormat{qrdoi}{\qrcode{https://doi.org/#1}}

\DeclareCiteCommand{\qrdoi} {\boolfalse{citetracker}% \boolfalse{pagetracker}% \usebibmacro{prenote}} {\printfield[qrdoi]{doi}} {\multicitedelim} {\usebibmacro{postnote}}

\newcommand\scitedoi[1]{{\color{blue}\tiny\citedoi{#1}}}

\newcommand\itcitedoi[1]{(\parbox{1.5cm}{\color{blue}\tiny\citedoi{#1}})}

\begin{document}

\begin{frame} \frametitle{Unreproducible}

\newlength{\myl} \settoheight{\myl}{test text} \qrset{link, height=1.5\myl}

This text is just text and nothing more as I just need filler text that spans a few lines on (\qrdoi{M2020}) this beamer presentation. This text is just text and nothing more as I just need filler text that spans a few lines on this beamer presentation. This text is just text and nothing more as I just need filler text that spans a few lines on this beamer presentation. \end{frame}

\begin{frame} \printbibliography \end{frame}

\end{document}

There is probably a better or more recent method to calculate the text height but this works.

JamesT
  • 3,169