Multiple parents aren't supported by glossaries
. If you have hyperlinks, there would be an ambiguity as to which glossary entry commands like \gls
would link to. There are however ways to get around it.
Approach 1:
Define two entries with the same name but different parents and use the relevant one in the context of its given parent. This works best if you don't have a location list. Example:
% arara: pdflatex
% arara: makeglossaries
% arara: pdflatex
% arara: pdflatex
\documentclass{article}
\usepackage[colorlinks]{hyperref}
\usepackage[style=index,nonumberlist]{glossaries}
\makeglossaries
\newglossaryentry{parent1}
{%
name={parent 1},%
description={First parent}%
}
\newglossaryentry{parent2}
{%
name={parent 2},%
description={Second parent}%
}
\newglossaryentry{child1}
{%
name={sample},
description={an example},%
parent={parent1}%
}
\newglossaryentry{child2}
{%
name={sample},%
description={an example},%
parent={parent2}%
}
\begin{document}
Reference \gls{child1} in the context of \gls{parent1}.
Reference \gls{child2} in the context of \gls{parent2}.
\printglossaries
\end{document}
The first reference links to the entry under First parent
. The second reference links to the entry under Second parent
.
Approach 2:
This approach is more advanced. It stores a list of labels with which a child entry is associated and defines \mgls
to iterate through the list using \glsadd
for all except the final label for which it uses \gls
. Example:
% arara: pdflatex
% arara: makeglossaries
% arara: pdflatex
% arara: pdflatex
\documentclass{article}
\usepackage{etoolbox}
\usepackage[colorlinks]{hyperref}
\usepackage[style=index]{glossaries}
\makeglossaries
\newglossaryentry{parent1}
{%
name={parent 1},%
description={First parent}%
}
\newglossaryentry{parent2}
{%
name={parent 2},%
description={Second parent}%
}
\newcommand{\dochild}[3]{%
\listcsadd{#2.labels}{#3.#2}%
\newglossaryentry{#3.#2}%
{%
#1,parent={#3}%
}%
}
% syntax: \addchild{label}{parent list}{key=val list}
\newcommand*{\addchild}[3]{%
\csdef{#1.labels}{}%
\forcsvlist{\dochild{#3}{#1}}{#2}%
}
\newcommand*{\mgls}[2][]{%
\def\glslastlabel{}%
\forlistcsloop
{%
\ifdefempty{\glslastlabel}{}{\glsadd[#1]{\glslastlabel}}%
\def\glslastlabel
}%
{#2.labels}%
\gls[#1]{\glslastlabel}%
}
\newcommand*{\mglsadd}[2][]{%
\forlistcsloop
{%
\glsadd[#1]%
}%
{#2.labels}%
}
\addchild{sample}{parent1,parent2}%
{%
name={sample},%
description={an example}%
}
\begin{document}
\mgls{sample}.
\printglossaries
\end{document}
Here \mgls
will link to the entry under the last named parent used when the child entry was defined with \addchild
.
If you would rather link to a different glossary entry, you can use \mglsadd
and explicitly use \gls
with the label in the form parent.
child. Like this:
% arara: pdflatex
% arara: makeglossaries
% arara: pdflatex
% arara: pdflatex
\documentclass{article}
\usepackage{etoolbox}
\usepackage[colorlinks]{hyperref}
\usepackage[style=index]{glossaries}
\makeglossaries
\newglossaryentry{parent1}
{%
name={parent 1},%
description={First parent}%
}
\newglossaryentry{parent2}
{%
name={parent 2},%
description={Second parent}%
}
\newcommand{\dochild}[3]{%
\listcsadd{#2.labels}{#3.#2}%
\newglossaryentry{#3.#2}%
{%
#1,parent={#3}%
}%
}
% syntax: \addchild{label}{parent list}{key=val list}
\newcommand*{\addchild}[3]{%
\csdef{#1.labels}{}%
\forcsvlist{\dochild{#3}{#1}}{#2}%
}
\newcommand*{\mgls}[2][]{%
\def\glslastlabel{}%
\forlistcsloop
{%
\ifdefempty{\glslastlabel}{}{\glsadd[#1]{\glslastlabel}}%
\def\glslastlabel
}%
{#2.labels}%
\gls[#1]{\glslastlabel}%
}
\newcommand*{\mglsadd}[2][]{%
\forlistcsloop
{%
\glsadd[#1]%
}%
{#2.labels}%
}
\addchild{sample}{parent1,parent2}%
{%
name={sample},%
description={an example}%
}
\begin{document}
\mglsadd{sample}\gls{parent1.sample}.
\printglossaries
\end{document}
This produces the same looking result as previously, but now the sample entry links to the entry under the first parent instead of the second parent.
You could move the entry after printing the first glossary:
\documentclass{scrreprt}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[section=subsection]{glossaries}
\newglossary{No1}{1i}{1o} {Glossary 1}
\newglossary{No2}{2i}{2o}{Glossary 2}
\newglossaryentry{1}{type=No1,name=Entry1,description=Desc1}
\newglossaryentry{2}{type=No2,name=Entry2,description=Desc2}
\newglossaryentry{3}{type=No1,name=Entry3,description=Desc3}
\makeglossaries
\begin{document}
\section{Section 1}
\printglossary[type=No1]
\gls{1},\gls{3}
\section{Section 2}
\glsmoveentry{3}{No2}
\printglossary[type=No2]
\gls{2},\gls{3}
\end{document}
Note that I'm not sure if this will have untoward side-effects. Caveat emptor...
Best Answer
It seems to me that you want a style for your acronyms that looks like
long3col
but without page numbers.So, define a new style for acronyms
and then delete the line
After that, replace
with
MWE:
Output (List of acronyms)