![\GlsAddLocation 中的词汇表问题和位置类格式不正确](https://linux22.com/image/350651/%5CGlsAddLocation%20%E4%B8%AD%E7%9A%84%E8%AF%8D%E6%B1%87%E8%A1%A8%E9%97%AE%E9%A2%98%E5%92%8C%E4%BD%8D%E7%BD%AE%E7%B1%BB%E6%A0%BC%E5%BC%8F%E4%B8%8D%E6%AD%A3%E7%A1%AE.png)
在我的情况下,尝试使用包glossaries
会导致以下错误消息:
When starting user command "makeglossaries %": **Warning:** You may have forgotten to add a location class with \GlsAddLocation or you may have the format incorrect.
When starting PdfLaTeX: ! LaTeX Error: Something's wrong--perhaps a missing \item.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.27 \end{theglossary}
\glossarypostamble
Try typing <return> to proceed.
If that doesn't work, type X <return> to quit.
)
Package babel Info: Redefining ngerman shorthand "|
(babel) in language on input line 248.
Package babel Info: Redefining ngerman shorthand "~
(babel) in language on input line 248.
Package babel Info: Redefining ngerman shorthand "|
(babel) in language on input line 248.
Package babel Info: Redefining ngerman shorthand "~
(babel) in language on input line 248.
[6
]
问题是,即使没有我大学的预定义设计,一切都运行正常。有人能看出这里的问题是什么吗?
\documentclass[type=msc,accentcolor=tud9b, 11pt, bigchapter, table, draft]{tudthesis}
\usepackage[ngerman]{babel}
\usepackage{listings}
\usepackage{my_style}
\AtBeginDocument{\let\textlabel\label}
\usepackage{hyperref}
\usepackage[nonumberlist,toc,xindy]{glossaries}
\makeglossaries
\newglossaryentry{bbrot}{name=Butterbrot,
description={Brot mit Butter drauf}}
\glsaddall
\begin{document}
\thesistitle{A}{B}
\author{C. D.}
\date{\today}
\referee{Prof. Dr.}{}
\makeSzMthesistitle
\printglossary
Foo
\end{document}
它利用了my_style.sty:
\setinstitutionlogo{Abbildungen/logo_bs_j}
\parindent0mm
\lstset{ %
language=Matlab, % choose the language of the code
basicstyle=\footnotesize, % the size of the fonts that are used for the code
numbers=left, % where to put the line-numbers
numberstyle=\footnotesize, % the size of the fonts that are used for the line-numbers
stepnumber=5, % the step between two line-numbers. If it's 1 each line will be numbered
numbersep=5pt, % how far the line-numbers are from the code
backgroundcolor=\color{white}, % choose the background color. You must add \usepackage{color}
showspaces=false, % show spaces adding particular underscores
showstringspaces=false, % underline spaces within strings
showtabs=false, % show tabs within strings adding particular underscores
frame=single, % adds a frame around the code
tabsize=2, % sets default tabsize to 2 spaces
captionpos=b, % sets the caption-position to bottom
breaklines=true, % sets automatic line breaking
breakatwhitespace=false, % sets if automatic breaks should only happen at whitespace
escapeinside={\%*}{*)} % if you want to add a comment within your code
}
\gdef\TUD@thesis@referee{\PackageError{\@currname}{No '\noexpand\referee` given!\MessageBreak See documentation for details.}\@ehc}
\def\referee#1#2{\@ifnextchar[{\TUD@thesis@referee@three{#1}{#2}}{\TUD@thesis@referee@two{#1}{#2}}}
\def\TUD@thesis@referee@two#1#2{
\gdef\TUD@thesis@referee{#1\\#2}
}
\def\TUD@thesis@referee@three#1#2[#3]{
\gdef\TUD@thesis@referee{#1\\#2\\#3}
}
\newcommand{\makeSzMthesistitle}{% \TUD@thesis@subsubtitle{\ifTUD@thesis@phd\TUD@thesis@titletype\fi%
Masterarbeit von \@author\ifTUD@thesis@birthplace\ aus \ %
\TUD@thesis@birthplace\else\ifTUD@thesis@phd\PackageError{\@currname}{No '\noexpand\birthplace` given!\MessageBreak See documentation for details.}\@ehc\fi\fi\\%
Matrikelnummer: xxxxxxx%
\ifTUD@thesis@phd{ --- Darmstadt --- D 17}\fi%
}
\TUD@thesis@institution{\TUD@thesis@department\\%
\TUD@thesis@group}%
\TUD@thesis@uppertitleback{%
\vspace{15cm}
\begin{minipage}[b]{\textwidth}
\@author\\ % Verfasser
Matrikelnummer: xxxxxxx\\[\baselineskip]
%Art der Ausarbeitung\\ % Art der Arbeit
\@title\\ % Titel der Arbeit
\@subtitle\\[\baselineskip] % Untertitel
Eingereicht am: \@date\\[\baselineskip] %
Betreuung:\\
\TUD@thesis@referee\\%[\baselineskip] % Betreuung mit Abstand
\\
Technische Universität Darmstadt\\
Institut für Verkehr\\
Fachgebiet Bahnsysteme und Bahntechnik\\
Otto-Berndt-Straße 2\\
64287 Darmstadt
\end{minipage}
}%
\if@twoside\else
\@TUD@thesis@restonesidetrue
\@twosidetrue \@mparswitchtrue
\fi
\TUD@thesis@maketitle%
\if@TUD@thesis@restoneside
\@twosidefalse \@mparswitchfalse
\fi
}
非常感谢您的帮助!
答案1
我没有上过你的课,但从你的评论来看
.glo 文件表示
"(indexentry :tkey (("Butterbrot" "\\glossentry {bbrot}") ) :locref "{}{-1}" :attr "pageglsnumberformat" ) "
看起来好像您有一个无法识别的负页码xindy
。下面的 MWE 重现了错误:
\documentclass{article}
\usepackage[xindy]{glossaries-extra}
\makeglossaries
\newglossaryentry{bbrot}{name=Butterbrot,
description={Brot mit Butter drauf}}
\begin{document}
\setcounter{page}{-1}
\gls{bbrot}.
\printglossaries
\end{document}
文字xindy
记录(.glg
文件)显示以下警告:
WARNING: location-reference "{}{-1}" did not match any location-class! (ignored)
脚本makeglossaries
检测到此警告并在您的帖子中显示诊断消息:
You may have forgotten to add a location
class with \GlsAddLocation or you may have
the format incorrect.
(正如评论中提到的,这里有一个印刷错误,命令名称实际上是\GlsAddXdyLocation
。)语法是
\GlsAddXdyLocation[prefix]{name}{definition}
prefix
仅当文档使用hyperref
和时才需要可选参数\theH
柜台定义为字首\the
柜台。本例中前缀为空,name
部分为格式名称,部分为定义位置格式的代码definition
。xindy
xindy
识别"arabic-numbers"
为数字 0 到 9,但不允许使用符号 ( +
/ -
)。可以使用以下方法为负数页码添加新位置:
\documentclass{article}
\usepackage[xindy]{glossaries-extra}
\GlsAddXdyLocation{negativepage}{:sep "-" "arabic-numbers"}
\makeglossaries
\newglossaryentry{bbrot}{name=Butterbrot,
description={Brot mit Butter drauf}}
\begin{document}
\setcounter{page}{-1}
\gls{bbrot}.
\printglossaries
\end{document}
但是,文档的页码为负数确实有点奇怪。由于没有类文件,这只是猜测,但可能是计数器page
初始化为,并且仅在文档开头-1
设置为。在这种情况下,问题实际上可能是由于在序言中使用了,只需转到文档即可解决。1
\glsaddall
\glsaddall
\documentclass{article}
\usepackage[xindy]{glossaries-extra}
\makeglossaries
\newglossaryentry{bbrot}{name=Butterbrot,
description={Brot mit Butter drauf}}
\setcounter{page}{-1}
\begin{document}
\pagenumbering{arabic}
\glsaddall
\printglossaries
\end{document}
错误消息
! LaTeX Error: Something's wrong--perhaps a missing \item.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.27 \end{theglossary}
\glossarypostamble
是由空列表引起的。当你这样做时也会发生同样的事情
\begin{description}
\end{description}
这基本上就是当您使用其中一种list
样式但词汇表中没有条目时发生的情况(因为由于某些问题,所有条目已被xindy
/忽略makeindex
)。您需要.gls
在重建文档之前删除临时文件(在解决问题之后)。