2

I have used the approach in this question: Add Text/Comment into bibliography in order to print shorthands before my bibitems (that have them).

I want them on the same line, so I modified the code to use a spacing command \quad after each shorthand instead of a new \item:

\\AtEveryBibitem{\printfield{shorthand}\clearfield{shorthand}\quad}

But I would like to suppress the space that \quad generates before bibitems that do not have any shorthand to print.

Maybe there is a spacing command that will be suppressed if nothing is printed before it?

MWE:

\documentclass{book}
\usepackage[bibstyle=authoryear, backend=bibtex8]{biblatex}
\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
@book{Vismann2017Lagen-och-arkiv,
    Author = {Cornelia Vismann},
    Publisher = {Gl{\"a}nta produktion},
    Shorttitle = {Lagen och arkivet},
    Title = {Lagen och arkivet : Akternas mediehistoria},
    Year = {2017},
    }
@book{sou2018:25,
    Address = {Stockholm},
    Author = {Digitaliseringsr{\"a}ttsutredningen},
    Keywords = {sou},
    Publisher = {Norstedts juridik},
    Shorthand = {SOU 2018:25},
    Title = {Juridik som st{\"o}d f{\"o}r f{\"o}rvaltningens digitalisering},
    Year = {2018},  
}
\end{filecontents}
\addbibresource{\jobname.bib}

\AtEveryBibitem{\printfield{shorthand}\clearfield{shorthand}\quad}

\begin{document}
\nocite{Vismann2017Lagen-och-arkiv,sou2018:25}

\printbibliography[keyword=sou,title={Utredningsbet{\"a}nkanden}]
\nopagebreak
\printbibliography[notkeyword=sou]

\end{document}
trmdttr
  • 857

1 Answers1

1

Usually \setunit should help in situations like this. But there are two obstacles for \setunit here

  1. \AtEveryBibitem does not play nice with \setunit, you could use \renewbibmacro{begentry} instead (and indeed that is what I suggest).
  2. Even then \setunit will have issues when authors are replaced by a dash (the dash is typeset as is and not with \printtext, which means that the punctuation tracker is thrown off).

So my preferred solution

\renewbibmacro*{begentry}{%
  \printfield{shorthand}%
  \clearfield{shorthand}%
  \setunit{\quad}}

is out in this case. Hence I have to suggest the more awkward

\renewbibmacro*{begentry}{%
  \iffieldundef{shorthand}
    {}
    {\printfield{shorthand}%
     \clearfield{shorthand}%
     \quad}}

Which gives

\documentclass{article}
\usepackage[style=authoryear, backend=bibtex8]{biblatex}

\addbibresource{biblatex-examples.bib}

\renewbibmacro*{begentry}{%
  \iffieldundef{shorthand}
    {}
    {\printfield{shorthand}%
     \clearfield{shorthand}%
     \quad}}

\begin{document}
\nocite{knuth:ct:a,knuth:ct:b,kant:kpv,kant:ku}

\printbibliography
\end{document}

quad between the <code>shorthand</code> and the rest of the entry

BTW: Are you aware of \printbiblist{shorthand}? (Best used with Biber instead of BibTeX(8)).

\documentclass{article}
\usepackage[style=authoryear, backend=biber]{biblatex}

\addbibresource{biblatex-examples.bib}

\defbibcheck{noshorthand}{\iffieldundef{shorthand}{}{\skipentry}}

\begin{document}
\nocite{knuth:ct:a,knuth:ct:b,kant:kpv,kant:ku}

\printbiblist{shorthand}
\printbibliography[check=noshorthand]
\end{document}

Two bibliography lists: One list of shorthands, one normal bibliography. The list of shorthands has the shorthands as labels in the left margin.

moewe
  • 175,683