1

I'm using glossaries-extra with the bib2gls option on a big document (I tried to use the standard method, with \makeglossaries, but I got the insufficient write buffers error).

My problem is this: when using makeglossaries, the abbreviation styles withdesc and withoutdesc are correctly applied, thus on first use, the short and long forms are printed. But that's not the case when using bib2gls: only the short form is printed.

MWE (I took this one since the document I'm creating is for real big):

\documentclass{article}

\usepackage{polyglossia}
\setdefaultlanguage{spanish}

\usepackage[svgnames]{xcolor}
\usepackage{filecontents}

\usepackage[spanish]{varioref}
\usepackage{hyperref}
\usepackage{cleveref}

\hypersetup{
  colorlinks=true,
  citecolor=Crimson,
  linkcolor=Crimson,
  urlcolor=Crimson
}

\usepackage[record,acronym,postdot]{glossaries-extra}

\begin{filecontents}{terms.bib}
% Encoding: UTF-8
@entry{duck,
    name = {duck},
    category = {withdesc},
    description = {a waterbird with webbed feet}
}

@entry{parrot,
    name = {parrot},
    category = {withdesc},
    description = {mainly tropical bird with bright plumage}
}
\end{filecontents}
\GlsXtrLoadResources[src={terms}]

\begin{filecontents}{acros.bib}
% Encoding: UTF-8
@acronym{GNU,
    user1 = {{\textit{GNU No es Unix}\, en español}},
    plural = {{GNUs}},
    short = {{GNU}},
    category = {{withoutdesc}},
    long = {{GNU is Not Unix}}
}

@acronym{TTL,
    plural = {TTLs},
    short = {TTL},
    category = {withdesc},
    long = {{Time To Live}},
    description = {{Some value}}
}
\end{filecontents}
\GlsXtrLoadResources[src={acros}]

\setabbreviationstyle[withdesc]{long-short-user-desc}
\setabbreviationstyle[withoutdesc]{long-short-user}

\newglossarystyle{customAbbrevList}{%
    \setglossarystyle{listhypergroup}%
    \renewcommand*{\glossentry}[2]{%
        \item[\glsentryitem{##1}%
            \glstarget{##1}{\glossentryname{##1}}]%
        \glsifcategory{##1}{withoutdesc}{%
             --- \glsentrylong{##1}\ifglshasfield{\glsxtruserfield}{\glscurrententrylabel}{ (\!\glscurrentfieldvalue)}{}%
        }{%
            \mbox{}\par\nobreak\csuse{@afterheading}%
            \glossentrydesc{##1}%
        }%
        \glspostdescription\space ##2%
    }%
}

\newglossarystyle{customGloList}{%
    \setglossarystyle{listhypergroup}%
    \renewcommand*{\glossentry}[2]{%
        \item[\glsentryitem{##1}%
            \glstarget{##1}{\glossentryname{##1}}]%
        \glsifcategory{##1}{withoutdesc}%
        { ---}%
        {%
            {\mbox{}\par\nobreak\csuse{@afterheading}%
            \glossentrydesc{##1}}\glspostdescription%
        }%
        \space ##2%
    }%
}

\addto\captionsspanish{%
    \renewcommand*{\acronymname}{Abreviaturas}
    \renewcommand*{\glossaryname}{Glosario}
}

\begin{document}

A \gls{duck} and a \gls{parrot}. Lots of \glspl{duck}. Also, this is \gls{GNU}.

Again: a \gls{duck}, and a \gls{parrot} are part of \gls{GNU}.

We have some \gls{TTL}; again, \gls{TTL}.

\printunsrtglossary[type=main,style=customGloList]
\printunsrtglossary[type=acronym,style=customAbbrevList]

\end{document}

The output of compiling the above document with:

xelatex doc.tex
bib2gls doc
xelatex doc.tex

is this:

Output of compiling the document

What should I do to get the long and short form of the terms printed correctly on first use [example: Time To Live (TTL)]?

1

Abbreviation styles must be set before the abbreviations are defined. Since they are defined in the .glstex file input by \GlsXtrLoadResources they need to be set before that command:

\documentclass{article}

\usepackage{polyglossia}
\setdefaultlanguage{spanish}

\usepackage[svgnames]{xcolor}
\usepackage{filecontents}

\usepackage[spanish]{varioref}
\usepackage{hyperref}
\usepackage{cleveref}

\hypersetup{
  colorlinks=true,
  citecolor=Crimson,
  linkcolor=Crimson,
  urlcolor=Crimson
}

\usepackage[record,acronym,postdot]{glossaries-extra}

\begin{filecontents}{terms.bib}
% Encoding: UTF-8
@entry{duck,
    name = {duck},
    category = {withdesc},
    description = {a waterbird with webbed feet}
}

@entry{parrot,
    name = {parrot},
    category = {withdesc},
    description = {mainly tropical bird with bright plumage}
}
\end{filecontents}
\GlsXtrLoadResources[src={terms}]

\begin{filecontents}{acros.bib}
% Encoding: UTF-8
@acronym{GNU,
    user1 = {{\textit{GNU No es Unix}\, en español}},
    plural = {{GNUs}},
    short = {{GNU}},
    category = {{withoutdesc}},
    long = {{GNU is Not Unix}}
}

@acronym{TTL,
    plural = {TTLs},
    short = {TTL},
    category = {withdesc},
    long = {{Time To Live}},
    description = {{Some value}}
}
\end{filecontents}

\setabbreviationstyle[withdesc]{long-short-user-desc}
\setabbreviationstyle[withoutdesc]{long-short-user}

\GlsXtrLoadResources[src={acros}]

\newglossarystyle{customAbbrevList}{%
    \setglossarystyle{listhypergroup}%
    \renewcommand*{\glossentry}[2]{%
        \item[\glsentryitem{##1}%
            \glstarget{##1}{\glossentryname{##1}}]%
        \glsifcategory{##1}{withoutdesc}{%
             --- \glsentrylong{##1}\ifglshasfield{\glsxtruserfield}{\glscurrententrylabel}{ (\!\glscurrentfieldvalue)}{}%
        }{%
            \mbox{}\par\nobreak\csuse{@afterheading}%
            \glossentrydesc{##1}%
        }%
        \glspostdescription\space ##2%
    }%
}

\newglossarystyle{customGloList}{%
    \setglossarystyle{listhypergroup}%
    \renewcommand*{\glossentry}[2]{%
        \item[\glsentryitem{##1}%
            \glstarget{##1}{\glossentryname{##1}}]%
        \glsifcategory{##1}{withoutdesc}%
        { ---}%
        {%
            {\mbox{}\par\nobreak\csuse{@afterheading}%
            \glossentrydesc{##1}}\glspostdescription%
        }%
        \space ##2%
    }%
}

\addto\captionsspanish{%
    \renewcommand*{\acronymname}{Abreviaturas}
    \renewcommand*{\glossaryname}{Glosario}
}

\begin{document}

A \gls{duck} and a \gls{parrot}. Lots of \glspl{duck}. Also, this is \gls{GNU}.

Again: a \gls{duck}, and a \gls{parrot} are part of \gls{GNU}.

We have some \gls{TTL}; again, \gls{TTL}.

\printunsrtglossary[type=main,style=customGloList]
\printunsrtglossary[type=acronym,style=customAbbrevList]

\end{document}

image of document

  • Thank you! =) It works in the example. Unfortunately, I made the change in my big document, and in fact it worked to an extent: the first use is set correctly, but the glossaries won't show the long name version of the entries. Could the cause of this be the glossary styles customAbbrevList and customGloList? (The makeindex approach worked just fine before the change). – user101590 Nov 8 '17 at 14:38
  • I also think the issue could be the .latexmkrc file. Is running bib2gls necessary each time after running xelatex, or just one time? Thanks a lot for your patience! – user101590 Nov 8 '17 at 14:49
  • @JBFWP286 It's difficult to say without seeing the code. One thing I've just noticed is that you have plural instead of shortplural, which may confuse the style. Regarding your second comment, bib2gls needs to be run after xelatex whenever the definitions change (for example, if you modify the .bib file, add new instances of \gls etc, or if the page numbers change). – Nicola Talbot Nov 8 '17 at 14:52
  • Ok. I tried changing the tag plural for shortplural, to no avail. I'll send you a link via chat with the important files (the preamble); of course it won't compile, but I tought the same about seeing the code =( Thank you so much! – user101590 Nov 8 '17 at 15:24
  • 1
    @JBFWP286 That's okay. It's probably best to start using bib2gls on a new document rather than modifying a big existing one. – Nicola Talbot Nov 9 '17 at 11:19

Your Answer

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