# Add plural to newdualentry from LaTeX/Glossary

LaTeX/Glossary suggets the following command for combining a glossary entry and an acryonym:

\usepackage{xparse}
\DeclareDocumentCommand{\newdualentry}{ O{} O{} m m m m } {
description={#6},#1
}
}


How can I add the plural to this command, so I can use \glspl{LED} showing LEDs? I know that appending a 's' is the default plural form, but I need a way to customize the plural. I tried the following with no luck

 \usepackage{xparse}
\DeclareDocumentCommand{\newdualentry}{ O{} O{} m m m m m } {
description={#6},plural={#7},#1
}
}


Thanks!

• Welcome to TeX.SX! Can you provide a compilable document instead of some fragments only? – user31729 Sep 10 '15 at 19:48
• Sorry, my document is just too big and there are so many configurations in it that I can't figure out how to shorten it. – zersaegen Sep 10 '15 at 19:59
• Please add some more details. I am not sure what you really want to achieve here. I am not sure about the two optional arguments in a row at the beginning. – user31729 Sep 10 '15 at 20:00

This works for me (However, a 7-arg command is difficult to remember!):

\documentclass{article}

\usepackage{xparse}

\usepackage[acronym]{glossaries}

\DeclareDocumentCommand{\newdualentry}{O{}D<>{}m m m m m } {
\newglossaryentry{gls-#3}{
name={#5},
description={#6},
plural={#7},
#1
}
}

\makeglossaries

\newdualentry{LED}{LED}{LED}{Light emitting diode}{LEDiodes}

\newdualentry{Ox}{Ox}{Ox}{male cow}{Oxen}

\begin{document}

Here is an entry: \gls{gls-LED} \glspl{gls-LED}

An some biology here: \gls{gls-Ox} \glspl{gls-Ox}

\printglossary[type=main]
\printglossary[type=acronym]

\end{document}


Edit Some notes on the design of the command about the optional arguments:

Say,you've got a small document like this

\documentclass{article}

\usepackage{xparse}

\DeclareDocumentCommand{\somecmd}{O{}O{}m}{%
Optional 1: #1

Optional 2: #2

mandatory: #3
}

\begin{document}

\somecmd[A][B]{C}

\somecmd[A]{C}

\somecmd[][B]{C}

\end{document}

1. The first call will assign A, B and C correctly to the relevant slots
2. The second call will use A for the 1st, C for the 3rd one --> the 2nd one is empty --> Is this correct? Yes and no, since it's not clear that A is meant for the 1st or the 2nd optional argument.
3. This call will explicitly leave the 1st one empty, the others are 'correct'

It's better to replace the 2nd optional argument style with D<>{} or similar tokens to make some difference. Or append the 2nd optional argument to the end of the list, being the 3rd argument here.

• Hi Christian, thanks for your reply. This works regarding the printing of the plural form. The problem now is, that I combine the acronym and glossary list: If I add the LED entry as you suggested, I would expect an acronym entry "LED Light emitting diode" AND a glossary entry with a description: "Light emitting diode - A small bulb that emits light." With your suggestion, the description is lost in my glossary, only the long form of the abbreviation is shown. I hope you understand what I mean. – zersaegen Sep 11 '15 at 8:03
• Got it! \newdualentry{LED}{LED}{Light emitting diode}{Description}{LEDiodes} works as expected; I just had to clean the TexStudio cache (help files etc.) Thanks! – zersaegen Sep 11 '15 at 8:12