![使用外部词汇表文件和外部章节 tex 文件时 Main.tex 中的 printglossaries 出现问题](https://linux22.com/image/307730/%E4%BD%BF%E7%94%A8%E5%A4%96%E9%83%A8%E8%AF%8D%E6%B1%87%E8%A1%A8%E6%96%87%E4%BB%B6%E5%92%8C%E5%A4%96%E9%83%A8%E7%AB%A0%E8%8A%82%20tex%20%E6%96%87%E4%BB%B6%E6%97%B6%20Main.tex%20%E4%B8%AD%E7%9A%84%20printglossaries%20%E5%87%BA%E7%8E%B0%E9%97%AE%E9%A2%98.png)
我正在写一篇内容繁多的博士论文,分为几章。每章都有许多图表、缩写词、符号和方程式。因此,我决定将图表、章节文本、词汇表、缩写词和符号分成不同的文件夹。有一个 Main.tex 调用章节和词汇表。
所有论文条目的缩写都以词汇表和符号的形式收集在一个文件中。
事实上,编译后,效果很好,但词汇表、缩写词和符号列表没有出现。我观察到,如果\gls{ }
将它们放在 Main.tex 中,\printglossaries
效果会很好,但如果将它们放在其他文件夹中的不同章节文本中,则\printglossaries
不起作用。
抱歉。我尝试上传我的 MWE 好几次了。这是 Main.tex 的内容:
\documentclass[10pt,a4paper, twoside,titlepage]{report}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{sidecap}
\usepackage[left=4cm,right=3cm,top=3cm,bottom=2cm]{geometry}
\usepackage[hidelinks]{hyperref}
\usepackage[sort]{natbib}
\title{Title of Thesis}
\author{Name of author}
\date{Presentation date}
%Package for header and footer customization
\usepackage{fancyhdr}
\usepackage{chappg}
%Header customization
\pagestyle{fancy}
\fancyhf{}
\fancyhead[LE,RO]{\slshape \nouppercase{\leftmark}}
\fancyhead[RE,LO]{Author's name - PhD thesis title}
\fancyfoot[CE,CO]{\thepage}
\renewcommand{\headrulewidth}{1pt}
\renewcommand{\footrulewidth}{1pt}
%Additional counter for Table of content' depth control
\setcounter{tocdepth}{4}
\usepackage{setspace}
\onehalfspacing
\usepackage[acronym,toc]{glossaries}
\newglossary[slg]{symbols}{sym}{sbl}{List of Symbols}
\makeglossaries
\loadglsentries{Chapters/glosario}
\loadglsentries{Chapters/acronimos}
\loadglsentries{Chapters/simbolos}
\begin{document}
\tableofcontents
\input{Chapters/Chapter2}
\printglossaries
第 2 章放在另一个名为“Chapters”的文件夹中。glosario.tex、acronimos.tex 和 simbolos.tex 也放在文件夹 Chapters 中。
第2章内容如下:
\chapter{Governing Equations}
\label{Chapter2}
\section{Introduction}
\section{Near-wall treatment}
\subsection{Texto de tutorial}
The k- models, the RSM, and the \gls{les} model are primarily valid for turbulent core
flows (i.e., the flow in the regions somewhat far from walls). Consideration therefore
needs to be given as to how to make these models suitable for wall-bounded flows. The
Spalart-Allmaras and $ k-\omega $ models were designed to be applied throughout
the boundary layer, provided that the near-wall mesh resolution is sufficient.
\section{Diplomatic Memoirs}
When I was an \gls{attache}, I lived in a \gls{culdesac}, but
I didn't much care for it as I found there was a fair amount
of \gls{elitism} amongst my neighbours.
\section{Student Memoirs}
When I was a student I often left bits of electronic circuitry
in my pockets, such as \glspl{led} and \glspl{eeprom}, which
often ended up in the washing machine. The \glspl{led} didn't
fair too badly, but the \glspl{eeprom} frequently broke.
\section{Symbols}
The \gls{angstrom} is commonly used in structural biology,
whereas the \gls{ohm} is used in electronics.
glosario.tex 的内容为:% 以下定义将进入主词汇表
\newglossaryentry{culdesac}{name=cul-de-sac,description={passage
or street closed at one end},plural=culs-de-sac}
\newglossaryentry{elite}{name={\'e}lite,description={select
group or class},sort=elite}
\newglossaryentry{elitism}{name={\'e}litism,description={advocacy
of dominance by an \gls{elite}},sort=elitism}
\newglossaryentry{attache}{name=attach\'e,
description={person with special diplomatic responsibilities}}
acronimos.tex 的内容为:
% The following definitions will go in the list of acronyms
\newacronym{led}{LED}{light-emitting diode}
\newacronym{eeprom}{EEPROM}{electrically erasable programmable
read-only memory}
\newacronym{dsf}{DSF}{Deterministic Separated Flow}
\newacronym{les}{LES}{Large Eddy Simulation}
simbolos.tex 的内容为:
% The following definitions will go in the list of symbols
\newglossaryentry{ohm}{type=symbols,name=ohm,
symbol={\ensuremath{\Omega}},
description=unit of electrical resistance}
\newglossaryentry{angstrom}{type=symbols,name={\aa}ngstr\"om,
symbol={\AA},sort=angstrom,
description={non-SI unit of length}}
答案1
仅当使用类似命令时,词汇表信息才会写入外部文件\gls
。如果没有最小工作示例,很难确定,但如果您正在使用,\include
则可能您正在使用类似命令\includeonly
来仅选择性地包含章节。如果排除的文件包含类似命令,则\gls
在跳过文件时会跳过它们,这意味着它们不会被写入词汇表文件,也不会出现词汇表。
这是一个例子。主文件test.tex
:
\documentclass{report}
\usepackage{glossaries}
\makeglossaries
\loadglsentries{example-glossaries-brief}
\begin{document}
\include{chapters/test-ch1}
\include{chapters/test-ch2}
\include{chapters/test-ch3}
\printglossaries
\end{document}
目录(文件夹)中的chapters
文件是:
test-ch1.tex
:
\chapter{Sample}
\gls{lorem}
test-ch2.tex
:
\chapter{Another}
\gls{dolor}
test-ch3.tex
:
\chapter{No Glossary Entries Here}
现在文档的构建顺序如下:
pdflatex test
makeglossaries test
pdflatex test
将正确生成词汇表。但是,假设我现在添加
\includeonly{chapters/test-ch3}
到序言。这将排除使用命令的两章\gls
,仅包括不包含任何(或类似)命令的章节\gls
。这意味着没有任何内容写入词汇表。现在重新编译(重建)文档:
pdflatex test
makeglossaries test
这会产生一条错误消息makeglossaries
:
makeglossaries version 2.15 (2014-07-30)
added glossary type 'main' (glg,gls,glo)
Warning: File 'test.glo' is empty.
Have you used any entries defined in glossary 'main'?
Remember to use package option 'nomain' if you
don't want to use the main glossary.
这是因为尚未写入任何内容,test.glo
因为执行该写入的所有命令均已被跳过。
你应该怎么做?好吧,如果你排除了章节,这意味着你仍在处理文档,在这种情况下这并不重要。由于缺少一些章节,该文档已经是一个不完整的草稿,所以只需跳过这makeglossaries
一步,直到你准备好检查整个文档,而不仅仅是你正在处理的特定章节。一旦你回到包含包含词汇表参考的文件,然后回到构建词汇表。
编辑:另一种可能是您使用的版本太旧,makeglossaries
无法\@input
从文件中提取数据。此问题已在1.9 版.aux
中得到纠正(随v2.07 2010/07/10 一起发布)。makeglossaries
glossaries
答案2
我无法重现您的问题,因此这里有一个我认为与您的结构相似的 MWE。
主 Tex 文件:
\documentclass{report}
\usepackage[utf8]{inputenc}
\setlength\parindent{0pt}
%=========================================================================================================================================
% PACKAGES REQUIRED FOR GLOSSARIES
%=========================================================================================================================================
% Glossaries must be loaded before amsmath as per details in the following forum answer
% http://tex.stackexchange.com/questions/85696/what-causes-this-strange-interaction-between--and-amsmath
\usepackage[nogroupskip,toc,acronym]{glossaries} % must come after href
\usepackage{scrwfile}%http://www.dickimaw-books.com/cgi-bin/faq.cgi?action=view&categorylabel=glossaries#glsnewwriteexceeded
\makeglossaries
\newglossaryentry{ICPMS}{ type={acronym}, sort={inductively coupled plasma mass spectrometry}, name={ICPMS}, short={ICPMS}, long={inductively coupled plasma mass spectrometry}, first={inductively coupled plasma mass spectrometry (ICPMS)}, description={inductively coupled plasma mass spectrometry} }
\begin{document}
\part{Abbreviations in a full glossary example}
\input{src/a}
\part{Abbreviations repeated}
\glslocalresetall[acronym]
\input{src/b}
\part{glossaries}
\printglossary[type=acronym]
\end{document}
内容src/a.tex
\chapter{First}
\begin{itemize}
\item \gls{ICPMS}
\item this term is fully expanded and summarized on first use which displays \gls{ICPMS}
\item this both makes sense because \gls{ICPMS} has appeared multiple times and because this is exactly what is what the documentation describes.
\item This is likely exactly the situation glossaries was designed for...
\end{itemize}
内容src/b.tex
\chapter{next}
I have just reset the acronyms. And will use it again
\begin{itemize}
\item \gls{ICPMS}
\item \gls{ICPMS}
\end{itemize}
使用与主 tex 文件位于同一目录中的 bat 文件进行编译:
:CheckOS
IF "%PROCESSOR_ARCHITECTURE%"=="x86" (GOTO 32BIT) ELSE (GOTO 64BIT)
:64BIT
ECHO 64-bit compiling
SET MikTexPath=C:\Program Files\MiKTeX 2.9\miktex\bin\x64\
GOTO END
:32BIT
ECHO 32-bit compiling
SET MikTexPath=C:\Program Files\MiKTeX 2.9\miktex\bin\
GOTO END
:END
SET TeXCompilier=xelatex.exe
FOR %%A IN (*.tex) DO (
"%MikTexPath%%TeXCompilier%" "%%~nxA" &_
"%MikTexPath%makeindex.exe" -s "%%~nA.ist" -t "%%~nA.glg" -o "%%~nA.gls" "%%~nA.glo" &_
"%MikTexPath%makeindex.exe" -s "%%~nA.ist" -t "%%~nA.alg" -o "%%~nA.acr" "%%~nA.acn" &_
"%MikTexPath%%TeXCompilier%" "%%~nxA" &_
"%MikTexPath%%TeXCompilier%" "%%~nxA" &_
)