我想从文件中添加一些词汇表。我有两个词汇表文件。我想将它们添加到我的文件中,但不在文档的同一部分。当我添加它们时,所有单词都只在一个单词列表中。但我不想把它们放在一起。我想单独打印每个文件的每个内容。
感谢帮助。
\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}
文件内容示例文件1.txt和文件2.txt. 单词列表。
\newglossaryentry{electrics}
{
name={electrics},
description={ rozvod elektriny, elektrina }
}
\newglossaryentry{light}
{
name={light},
description={ svetlo $\bullet$ lampa $\bullet$ zapaľovač },
plural={lights}
}
答案1
\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}
第 1 页:
第2页:
这基本上是给出的答案https://tex.stackexchange.com/a/126889/117534。
将两个文件加载到单独的词汇表中,可以让你独立打印它们。请注意,我使用的\printglossary[type=...]
是\printglossaries
。后者打印全部您的词汇表,但这并不是您想要的。前者允许您在代码中指定的位置指定要打印哪个词汇表。