0

I would like to add some glossaries from files. I have got two files of glossaries. I want to add them into my file but not in the same part of my document. When I add them all words are just in one list of words. But I do not want to get them together. I want to print each content of every file independently.

Thanks for help.

\documentclass[10pt,a5paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[main=english, slovak]{babel}
\usepackage{glossaries}

%---
\makeglossaries
\input{file1.txt}
\input{file2.txt}

\begin{document}

some text

\printglossaries % I want to print words from file file1.txt here.
%\glsaddall

some text

\printglossaries % I want to print words from file file2.txt here.

\end{document} 

The example of content of files file1.txt and file2.txt. List of words.

 \newglossaryentry{electrics}
 {
 name={electrics},
 description={ rozvod elektriny, elektrina }
 }

 \newglossaryentry{light}
 {
 name={light},
 description={ svetlo $\bullet$ lampa $\bullet$ zapaľovač  },
 plural={lights}
 }
4
  • Probably this solution might be of some help: tex.stackexchange.com/a/126889/117534. For the code in your question to be more helpful (in making your question more explicit), it would be good to give us examples of what is in file1 and file2. – Troy Jul 29 '17 at 5:37
  • @Troy No, the link does not answer my question. – Ľubomír Masarovič Jul 29 '17 at 5:55
  • Why not? Just load them into different glossaries, and print them separately with printglossary[type=...] instead of printglossaries.. – Troy Jul 29 '17 at 6:02
  • @Troy Will you show it to me, please? – Ľubomír Masarovič Jul 29 '17 at 6:05
2
\begin{filecontents*}{file1.txt}% Only to include some sample glossary entries for testing.. Not required in actual code.
     \newglossaryentry{electrics}
    {
        name={electrics},
        description={ rozvod elektriny, elektrina }
    }

    \newglossaryentry{light}
    {
        name={light},
        description={ svetlo $\bullet$ lampa $\bullet$ zapaľovač  },
        plural={lights}
    }
\end{filecontents*}

\begin{filecontents*}{file2.txt}% Only to include some sample glossary entries for testing.. Not required in actual code.
    \newglossaryentry{electrics_2}
    {
        name={electrics},
        description={ rozvod elektriny, elektrina }
    }

    \newglossaryentry{light_2}
    {
        name={light},
        description={ svetlo $\bullet$ lampa $\bullet$ zapaľovač  },
        plural={lights}
    }
\end{filecontents*}

\documentclass[10pt,a5paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[main=english, slovak]{babel}
\usepackage[nomain]{glossaries}% Turn off main glossary (if you don't have one)

% Create two new glossaries (so you can customize them to your liking)
\newglossary[nlg]{gloss1}{not}{ntn}{Glossary 1} 
\newglossary[slg]{gloss2}{sot}{stn}{Glossary 2}

\makeglossaries
\loadglsentries[gloss1]{file1.txt} % Load file1 contents into Glossary 1
\loadglsentries[gloss2]{file2.txt} % Load file2 contents into Glossary 2

\begin{document}
\glsaddall % Just to add all glossary entries, for exemplary purposes
some text

\printglossary[type=gloss1] % I want to print words from file file1.txt here.

\clearpage
some text

\printglossary[type=gloss2] % I want to print words from file file2.txt here.

\end{document}

page 1:

page1

page 2:

page 2

This is essentially the answer given in https://tex.stackexchange.com/a/126889/117534.

Loading the two files into separate glossaries will allow you to print them independently of each other. Note that I used \printglossary[type=...] instead of \printglossaries. The latter prints ALL your glossaries, which is not what you want. The former allows you to specify which glossary to print, at the point you specify in the code.

0

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.