1

In my paper I have two abbreviation lists: 1) Acronyms for certain expressions through glossaries package (eg. APR = Annual Percentage Rate) and 2) Abbreviations of legal documents through biblatex package by means of shorthands inside .bib file (eg. Consumer Protection Act = CPA).

As it is supposed to be, if I put the expressions \printbiblist{shorthand} and \printglossary[type=\acronymtype,style=long] I'll get two list of abbreviations.

However, I want to have a single (unified) one. It is possible to do that taking into account that I use two different packages?

1
  • Mhhh, I don't think you can get those two very different packages to produce one shared list between them. But I would be interested to be proven wrong.
    – moewe
    Feb 24, 2016 at 16:38

1 Answer 1

2

I don't think you can make the two very different packages work together in a way that they can print a shared list.

But we can fake the entire thing with biblatex. We will implement an @acronym and a @glossary type. The functionality is a very limited rip-off of glossaries' feature set. The idea can certainly be improved quite a lot, so this should be seen as a proof of concept.

We need a new data model (see How can I create entirely new data types with BibLaTeX/Biber?)

\ProvidesFile{fakeglossaries.dbx}[2016/02/24\space fake basic functionalities of the glossaries package using biblatex]
\DeclareDatamodelEntrytypes{glossary}
\DeclareDatamodelEntrytypes{acronym}
\DeclareDatamodelFields[type=field,datatype=literal]{
  name,
  plural,
  description,
  short,
  shortplural,
  long,
  longplural,
}

\DeclareDatamodelEntryfields[glossary]{
  name,
  plural,
  description,
}
\DeclareDatamodelEntryfields[acronym]{
  short,
  shortplural,
  long,
  longplural,
}

Then we need to make sure our new types are handled correctly. With

\ExecuteBibliographyOptions[glossary,acronym]{skipbib=true}

\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map{
      \pertype{acronym}
      \step[fieldsource=short]
      \step[fieldset=shorthand, origfieldval]
    }
    \map{
      \pertype{glossary}
      \step[fieldsource=name]
      \step[fieldset=shorthand, origfieldval]
    }
  }
}

they don't appear in the bibliography but get a shorthand so they go to the list of shorthands.

Output is controlled with

\DeclareFieldFormat[glossary]{name}{\ifcapital{\MakeCapital{#1}}{#1}}
\DeclareFieldFormat[glossary]{plural}{\ifcapital{\MakeCapital{#1}}{#1}}
\DeclareFieldFormat[glossary]{description}{\ifcapital{\MakeCapital{#1}}{#1}}

\DeclareFieldFormat[acronym]{short}{\mkbibacro{#1}}
\DeclareFieldFormat[acronym]{long}{\ifcapital{\MakeCapital{#1}}{#1}}
\DeclareFieldFormat[acronym]{longplural}{\ifcapital{\MakeCapital{#1}}{#1}}

\DeclareBibliographyDriver{acronym}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \printfield{long}%
  \setunit{\bibpagerefpunct}\newblock
  \usebibmacro{pageref}%
  \newunit\newblock
  \iftoggle{bbx:related}
    {\usebibmacro{related:init}%
     \usebibmacro{related}}
    {}%
  \usebibmacro{finentry}}

\DeclareBibliographyDriver{glossary}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \printfield{description}%
  \setunit{\bibpagerefpunct}\newblock
  \usebibmacro{pageref}%
  \newunit\newblock
  \iftoggle{bbx:related}
    {\usebibmacro{related:init}%
     \usebibmacro{related}}
    {}%
  \usebibmacro{finentry}}

\newbibmacro{fakegls}{%
  \ifentrytype{glossary}
    {\printfield{name}}
    {\ifentrytype{acronym}
       {\ifciteseen
          {\printfield{short}}
          {\printfield{long}}}}}

\newbibmacro{fakeglspl}{%
  \ifentrytype{glossary}
    {\iffieldundef{plural}
       {\printfield{name}s}
       {\printfield{plural}}}
    {\ifentrytype{acronym}
       {\ifciteseen
          {\iffieldundef{shortplural}
             {\printfield{short}s}
             {\printfield{shortplural}}}
          {\iffieldundef{longplural}
            {\printfield{long}s}
            {\printfield{longplural}}}}}}

And finally the top-level commands are implemented

\DeclareCiteCommand{\fakegls}
  {\usebibmacro{prenote}}
  {\usebibmacro{fakegls}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareCiteCommand{\fakeglspl}
  {\usebibmacro{prenote}}
  {\usebibmacro{fakeglspl}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\newrobustcmd*{\Fakegls}{\bibsentence\fakegls}
\newrobustcmd*{\Fakeglspl}{\bibsentence\fakeglspl}

MWE

\documentclass[a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[british]{babel}
\usepackage{csquotes}
\usepackage{filecontents}

\begin{filecontents}{fakeglossaries.dbx}
\ProvidesFile{fakeglossaries.dbx}[2016/02/24\space fake basic functionalities of the glossaries package using biblatex]
\DeclareDatamodelEntrytypes{glossary}
\DeclareDatamodelEntrytypes{acronym}
\DeclareDatamodelFields[type=field,datatype=literal]{
  name,
  plural,
  description,
  short,
  shortplural,
  long,
  longplural,
}

\DeclareDatamodelEntryfields[glossary]{
  name,
  plural,
  description,
}
\DeclareDatamodelEntryfields[acronym]{
  short,
  shortplural,
  long,
  longplural,
}
\end{filecontents}

\usepackage[style=authoryear,backend=biber,citetracker,datamodel=fakeglossaries]{biblatex}

\begin{filecontents}{\jobname.bib}
@glossary{potato,
  name        = {potato},
  plural      = {potatoes},
  description = {starchy tuber},
}
@glossary{cauliflower,
  name        = {cauliflower},
  description = {Cabbage with a College Education},
}
@acronym{dm,
  short      = {DM},
  long       = {diagonal matrix},
  longplural = {diagonal matrices},
}
@acronym{lkw,
  short      = {LKW},
  shortplural= {LKW},
  long       = {Lastkraftwagen},
  longplural = {Lastkraftwagen},
}
\end{filecontents}
\addbibresource{biblatex-examples.bib}
\addbibresource{\jobname.bib}

\ExecuteBibliographyOptions[glossary,acronym]{skipbib=true}

\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map{
      \pertype{acronym}
      \step[fieldsource=short]
      \step[fieldset=shorthand, origfieldval]
    }
    \map{
      \pertype{glossary}
      \step[fieldsource=name]
      \step[fieldset=shorthand, origfieldval]
    }
  }
}

\DeclareFieldFormat[glossary]{name}{\ifcapital{\MakeCapital{#1}}{#1}}
\DeclareFieldFormat[glossary]{plural}{\ifcapital{\MakeCapital{#1}}{#1}}
\DeclareFieldFormat[glossary]{description}{\ifcapital{\MakeCapital{#1}}{#1}}

\DeclareFieldFormat[acronym]{short}{\mkbibacro{#1}}
\DeclareFieldFormat[acronym]{long}{\ifcapital{\MakeCapital{#1}}{#1}}
\DeclareFieldFormat[acronym]{longplural}{\ifcapital{\MakeCapital{#1}}{#1}}

\DeclareBibliographyDriver{acronym}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \printfield{long}%
  \setunit{\bibpagerefpunct}\newblock
  \usebibmacro{pageref}%
  \newunit\newblock
  \iftoggle{bbx:related}
    {\usebibmacro{related:init}%
     \usebibmacro{related}}
    {}%
  \usebibmacro{finentry}}

\DeclareBibliographyDriver{glossary}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \printfield{description}%
  \setunit{\bibpagerefpunct}\newblock
  \usebibmacro{pageref}%
  \newunit\newblock
  \iftoggle{bbx:related}
    {\usebibmacro{related:init}%
     \usebibmacro{related}}
    {}%
  \usebibmacro{finentry}}

\newbibmacro{fakegls}{%
  \ifentrytype{glossary}
    {\printfield{name}}
    {\ifentrytype{acronym}
       {\ifciteseen
          {\printfield{short}}
          {\printfield{long}}}}}

\newbibmacro{fakeglspl}{%
  \ifentrytype{glossary}
    {\iffieldundef{plural}
       {\printfield{name}s}
       {\printfield{plural}}}
    {\ifentrytype{acronym}
       {\ifciteseen
          {\iffieldundef{shortplural}
             {\printfield{short}s}
             {\printfield{shortplural}}}
          {\iffieldundef{longplural}
            {\printfield{long}s}
            {\printfield{longplural}}}}}}


\DeclareCiteCommand{\fakegls}
  {\usebibmacro{prenote}}
  {\usebibmacro{fakegls}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareCiteCommand{\fakeglspl}
  {\usebibmacro{prenote}}
  {\usebibmacro{fakeglspl}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\newrobustcmd*{\Fakegls}{\bibsentence\fakegls}
\newrobustcmd*{\Fakeglspl}{\bibsentence\fakeglspl}

\begin{document}
Lorem\footcite{sigfridsson,kant:kpv} ipsum

\Fakegls{potato}, \fakegls{dm}, \fakegls{dm}, \fakegls{lkw}, \fakegls{lkw}

\citereset \Fakeglspl{potato}, \fakeglspl{dm}, \fakeglspl{dm}, \fakeglspl{lkw}, \fakeglspl{lkw}

\printbiblist{shorthand}
\printbibliography
\end{document}

example output

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .