我正在使用该memoir
课程。我希望列出关键术语/定义第一的在它们出现的章节中,然后再在最后的词汇表中。
但是,我不仅根本无法创建词汇表条目,而且也无法获得任何词汇表。
错误
任何地方使用 eg/gls{foo}
都会破坏所有内容。具体来说:
Package glossaries Error: Glossary entry `foo' has not been defined. ...em [agonist] the process by \gls{foo}
Overriding \printglossary
Overriding `theglossary' environment
...以及数十个跨越不同章节的Underfull \hbox (badness 10000)
内容Overfull (15.85847pt too wide)
in paragraph.
。
我已经竭尽全力地寻找解决方案,任何解决方案,但我所能找到的却没有解决问题:要么不够具体,无法解决这个确切的问题,要么我无法将其应用到我的文档中。
最小(非)工作示例
main.tex
\documentclass[11pt, oneside]{memoir}
\usepackage[utf8]{inputenc}
%%%%%%%%%% Packages %%%%%%%%%%
%%
\usepackage[acronym]{glossaries}
%% For starting tables on new page
\usepackage{afterpage}
%%
\usepackage[english]{babel}
%% For IEEE annotated bibliography
\usepackage[autocite=inline,
backend=biber,
style=ieee]{biblatex}
\addbibresource{./bibliography/annotated.bib}
%%
\usepackage{calc}
%% From TeX stackoverflow: "When using babel or polyglossia with biblatex, loading csquotes is recommended to ensure that quoted texts are typeset according to the rules of your main language."
\usepackage{csquotes}
%% For removing page numbers, headers, etc. from empty pages
\usepackage{emptypage}
%%
\usepackage{enumitem}
\setlist[description]{leftmargin=\parindent,labelindent=\parindent}
%% NSIN -- For removing page numbers on part pages
\usepackage{etoolbox}
\patchcmd{\part}{plain}{partstart}{}{}
\makeatletter
\patchcmd{\@maketitle}{\LARGE}{\fontsize{48pt}{24pt}\selectfont}{}{}
\makeatother
% For custom header configuration
\usepackage{fancyhdr}
%% For margins and page size
\usepackage[a4paper]{geometry}
%%
\usepackage{glossaries}
\makeglossaries
%%
\usepackage{hyperref}
%%
\usepackage{makecell}
%% NSIN
%\usepackage{soul}
%% For sublists
\setlist[itemize]{nosep}
\usepackage{outlines}
%% For breaking up into smaller, more manageable files
\usepackage{subfiles}
%% For underline and strikeout
\usepackage[normalem]{ulem}
%% For highlighting text (in conjunction with soul)
\usepackage[table]{xcolor}
%%% CONFIGURATION %%%
%% Used for subdividing citations into used and unused categories
\DeclareBibliographyCategory{cited}
\AtEveryCitekey{\addtocategory{cited}{\thefield{entrykey}}}
%%
\let\printglossary\relax
\let\theglossary\relax
\let\endtheglossary\relax
%%%%%%%%%% MACROS %%%%%%%%%%
%% Prepend word 'Chapter' to ToC chapters
\renewcommand\cftchaptername{\chaptername~}
% ceneter column
\newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}}
%% Bullets in front of description items
\let\Item\item
\newcommand\SpecialItem{\renewcommand\item[1][]{\Item[\textbullet~\bfseries##1]}}
\renewcommand\enddescription{\endlist\global\let\item\Item}
% Set Table of Contents title
\addto\captionsenglish{% Replace "english" with the language you use
\renewcommand{\contentsname}%
{Contents}%
}
% Set Table of Contents title
\addto\captionsenglish{% Replace "english" with the language you use
\renewcommand{\appendixname}%
{Appendix}%
}
%% fancyhdr stuff
\pagestyle{fancy}
\fancyhead{} % clear all fields
%% blankpage: blank page
\newcommand\blankpage{\newpage\mbox{}\thispagestyle{empty}\newpage}
%% sectionbreak: starts section on its own page
\newcommand{\sectionbreak}{\clearpage}
%% sectionbreak: starts section on its own page
%\newcommand{\subsectionbreak}{\hfill\\}
%% Used to make ToC chapters use upper-case Arabic numerals
\renewcommand{\thechapter}{\arabic{chapter}}
%% Used to make ToC sections and subsections use Roman numerals upper- and lower-case, resp.
\renewcommand{\thesection}{\Roman{section}.}
\renewcommand{\thesubsection}{\roman{subsection}.}
%\renewcommand{\thesubsubsection}{\roman{subsubsection}}
%% Set table length
%\setlength{\arrayrulewidth}{0.33mm}
%%%%%%%%%% FRONT MATTER %%%%%%%%%%
%% Set ToC and section numbering depth
\settocdepth{section}
\setsecnumdepth{section}
% append '\\ \normalsize{for email, hosting}' immediately after title for subtitle
\title{\HUGE{\bfseries Learnding is Fun}\\[\baselineskip] \LARGE{if ur LaTeX is gud}\vspace{5cm}%
}
\author{\Large by Anon Y. Mous}
\date{\LARGE 2021}
\nocite{*}
%%%%%%%%%% DOCUMENT %%%%%%%%%%
\begin{document}
\frontmatter
% Title Page
\maketitle
\thispagestyle{empty}
\blankpage
%
%\subfile{./chapters/front/abstract}
%\newpage
% Table of contents
\setcounter{page}{1}
\tableofcontents*
\listoffigures
\listoftables
%\renewcommand\Decide[1]{}
%\newpage
%
%\subfile{./chapters/front/acknowledgments}
%\newpage
\mainmatter
% chapters
\subfile{./chapters/ch01/ch01}
\subfile{./chapters/ch02/ch02}
\subfile{./chapters/ch03/ch03}
\subfile{./chapters/ch04/ch04}
\subfile{./chapters/ch05/ch05}
\subfile{./chapters/ch06/ch06}
\subfile{./chapters/ch07/ch07}
\subfile{./chapters/ch08/ch08}
\subfile{./chapters/ch09/ch09}
\subfile{./chapters/ch10/ch10}
\subfile{./chapters/ch11/ch11}
\subfile{./chapters/ch12/ch12}
\subfile{./chapters/ch13/ch13}
\subfile{./chapters/ch41/ch41}
% appendices
\subfile{./chapters/appendixA/appendix_a}
\backmatter
% glossaries
\printglossary
% bibliography
%\printbibliography[category=cited]
%\begingroup
%\renewcommand{\cleardoublepage}{}
%\printbibliography[title={Further Reading},notcategory=cited]
%\endgroup
\end{document}
具体章节(本例中为 11 章):
/chapters/ch11/ch11.tex
\documentclass[../../main.tex]{subfiles}
\addcontentsline{toc}{chapter}{Principles of Pharmacology}
\setcounter{chapter}{11}
\label{ch:chapter11}
\clearpage
\newglossaryentry{foo}{name=foo,description={unit of length}}
\begin{document}
\chapter{Principles of Pharmacology}
% putting \gls{foo} anywhere breaks everything
\section*{Definitions}
\begin{description}
\item [agonist] medication that causes stimulation of receptors.
\item [antagonist] medication that binds to a receptor and blocks other medications or chemicals from attaching there.
\item [capsule] gelatin shells filled with powdered or liquid medication.
\item [contraindications] when a medication would either harm the patient or have no positive effect.
\item [diaphoretic] sweating heavily.
\end{description}
\section*{Abbreviations}
\begin{description}[leftmargin=!,labelwidth=\widthof{\bfseries ABCDEF}]
\item [IM] intramuscular
\item [IN] intranasal
\item [IO] intraosseous
\item [IV] intravenous
\item [MDI] metered-dose inhaler
\item [PO] per oral
\item [PR] per rectum
\item [SC] subcutaneous
\item [SL] sublingual
\end{description}\hfill \\
我感觉自己仿佛身处“软件包/配置地狱”,软件包空间/生态系统非常混乱,要找到具体异常就像解开圣诞彩灯一样困难。在黑暗中。戴着厚厚的手套。在局部麻醉下。伴有脑震荡。
不用说我将非常感激任何帮助!
编辑#1
中的部分main.tex
\let\printglossary\relax
\let\theglossary\relax
\let\endtheglossary\relax
这是我之前尝试过的解决方案。谢谢您指出这一点!
因为有时,即使是我们中最细心 、最勤奋、最善意的人,在连续尝试一百万种解决方案时,他们也会忘记恢复第一百万分之一的解决方案!
解决方案
看回答(并且这寻求安装 perl 的帮助并在 Windows 中添加 PATH)。
第二个链接用于 TexMaker,但对于 TexStudio 的作用相同(就我而言)。
再次感谢西蒙·迪斯帕帮助我解决这个非常棘手的问题!
答案1
您可以通过以下方式打印词汇表:
从开始新建空目录 与ch11.tex
\documentclass[./main.tex]{subfiles}
\begin{document}
%\addcontentsline{toc}{chapter}{Principles of Pharmacology}
\setcounter{chapter}{10}
\label{ch:chapter11}
\clearpage
\newglossaryentry{foo}{name=foo,description={unit of length}}
\chapter{Principles of Pharmacology}
Putting \gls{foo} anywhere breaks everything
\section*{Definitions}
\begin{description}
\item [agonist] medication that causes stimulation of receptors.
\item [antagonist] medication that binds to a receptor and blocks other medications or chemicals from attaching there.
\item [capsule] gelatin shells filled with powdered or liquid medication.
\item [contraindications] when a medication would either harm the patient or have no positive effect.
\item [diaphoretic] sweating heavily.
\end{description}
\section*{Abbreviations}
\begin{description}[leftmargin=!,labelwidth=\widthof{\bfseries ABCDEF}]
\item [IM] intramuscular
\item [IN] intranasal
\item [IO] intraosseous
\item [IV] intravenous
\item [MDI] metered-dose inhaler
\item [PO] per oral
\item [PR] per rectum
\item [SC] subcutaneous
\item [SL] sublingual
\end{description}\hfill \\
\end{document}
并main.tex
在同一目录中包含一些注释行:
双重加载glossaries
%%%%%%%%%% Packages %%%%%%%%%%
%%
%%%\usepackage[acronym]{glossaries}
%%%\makeglossaries
而是只使用
%%%%
\usepackage{glossaries}
\makeglossaries
还评论了
%%
%\let\printglossary\relax
%\let\theglossary\relax
%\let\endtheglossary\relax
然后编译两次main.tex
+ 运行 makeglossaries.exe(makeglossaries main
从命令行,在 MikTeX 和 Texstudio 中按 F9)+ 再次编译。
第一次运行两次将生成一个包含 6 页的 PDF。最后一页将为空白。最后一次运行后将Glossary
在那里排版。
这是最终结果main.tex
\documentclass[11pt, oneside]{memoir}
\usepackage[utf8]{inputenc}
%%%%%%%%%% Packages %%%%%%%%%%
%%
%%%\usepackage[acronym]{glossaries}
%%%\makeglossaries
%% For starting tables on new page
\usepackage{afterpage}
%%
\usepackage[english]{babel}
%% For IEEE annotated bibliography
\usepackage[autocite=inline,
backend=biber,
style=ieee]{biblatex}
%\addbibresource{./bibliography/annotated.bib}
%%
\usepackage{calc}
%% From TeX stackoverflow: "When using babel or polyglossia with biblatex, loading csquotes is recommended to ensure that quoted texts are typeset according to the rules of your main language."
\usepackage{csquotes}
%% For removing page numbers, headers, etc. from empty pages
\usepackage{emptypage}
%%
\usepackage{enumitem}
\setlist[description]{leftmargin=\parindent,labelindent=\parindent}
%% NSIN -- For removing page numbers on part pages
\usepackage{etoolbox}
\patchcmd{\part}{plain}{partstart}{}{}
\makeatletter
\patchcmd{\@maketitle}{\LARGE}{\fontsize{48pt}{24pt}\selectfont}{}{}
\makeatother
% For custom header configuration
\usepackage{fancyhdr}
%% For margins and page size
\usepackage[a4paper]{geometry}
%%%%
\usepackage{glossaries}
\makeglossaries
%%
\usepackage{hyperref}
%%
\usepackage{makecell}
%% NSIN
%\usepackage{soul}
%% For sublists
\setlist[itemize]{nosep}
\usepackage{outlines}
%% For breaking up into smaller, more manageable files
\usepackage{subfiles}
%% For underline and strikeout
\usepackage[normalem]{ulem}
%% For highlighting text (in conjunction with soul)
\usepackage[table]{xcolor}
%%% CONFIGURATION %%%
%% Used for subdividing citations into used and unused categories
\DeclareBibliographyCategory{cited}
\AtEveryCitekey{\addtocategory{cited}{\thefield{entrykey}}}
%% !! what for?
%\let\printglossary\relax
%\let\theglossary\relax
%\let\endtheglossary\relax
%%%%%%%%%% MACROS %%%%%%%%%%
%% Prepend word 'Chapter' to ToC chapters
\renewcommand\cftchaptername{\chaptername~}
% ceneter column
\newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}}
%% Bullets in front of description items
\let\Item\item
\newcommand\SpecialItem{\renewcommand\item[1][]{\Item[\textbullet~\bfseries##1]}}
\renewcommand\enddescription{\endlist\global\let\item\Item}
% Set Table of Contents title
\addto\captionsenglish{% Replace "english" with the language you use
\renewcommand{\contentsname}%
{Contents}%
}
% Set Table of Contents title
\addto\captionsenglish{% Replace "english" with the language you use
\renewcommand{\appendixname}%
{Appendix}%
}
%% fancyhdr stuff
\pagestyle{fancy}
\fancyhead{} % clear all fields
%% blankpage: blank page
\newcommand\blankpage{\newpage\mbox{}\thispagestyle{empty}\newpage}
%% sectionbreak: starts section on its own page
\newcommand{\sectionbreak}{\clearpage}
%% sectionbreak: starts section on its own page
%\newcommand{\subsectionbreak}{\hfill\\}
%% Used to make ToC chapters use upper-case Arabic numerals
\renewcommand{\thechapter}{\arabic{chapter}}
%% Used to make ToC sections and subsections use Roman numerals upper- and lower-case, resp.
\renewcommand{\thesection}{\Roman{section}.}
\renewcommand{\thesubsection}{\roman{subsection}.}
%\renewcommand{\thesubsubsection}{\roman{subsubsection}}
%% Set table length
%\setlength{\arrayrulewidth}{0.33mm}
%%%%%%%%%% FRONT MATTER %%%%%%%%%%
%% Set ToC and section numbering depth
\settocdepth{section}
\setsecnumdepth{section}
% append '\\ \normalsize{for email, hosting}' immediately after title for subtitle
\title{\HUGE{\bfseries Learnding is Fun}\\[\baselineskip] \LARGE{if ur LaTeX is gud}\vspace{5cm}%
}
\author{\Large by Anon Y. Mous}
\date{\LARGE 2021}
\nocite{*}
%%%%%%%%%% DOCUMENT %%%%%%%%%%
\begin{document}
\frontmatter
% Title Page
\maketitle
\thispagestyle{empty}
\blankpage
%
%\subfile{./chapters/front/abstract}
%\newpage
% Table of contents
\setcounter{page}{1}
\tableofcontents*
\listoffigures
\listoftables
%\renewcommand\Decide[1]{}
%\newpage
%
%\subfile{./chapters/front/acknowledgments}
%\newpage
\mainmatter
% chapters
%\subfile{./chapters/ch01/ch01}
%\subfile{./chapters/ch02/ch02}
%\subfile{./chapters/ch03/ch03}
%\subfile{./chapters/ch04/ch04}
%\subfile{./chapters/ch05/ch05}
%\subfile{./chapters/ch06/ch06}
%\subfile{./chapters/ch07/ch07}
%\subfile{./chapters/ch08/ch08}
%\subfile{./chapters/ch09/ch09}
%\subfile{./chapters/ch10/ch10}
\subfile{./ch11}
%\subfile{./chapters/ch12/ch12}
%\subfile{./chapters/ch13/ch13}
%\subfile{./chapters/ch41/ch41}
% appendices
%\subfile{./chapters/appendixA/appendix_a}
\backmatter
% glossaries
\printglossary
% bibliography
%\printbibliography[category=cited]
%\begingroup
%\renewcommand{\cleardoublepage}{}
%\printbibliography[title={Further Reading},notcategory=cited]
%\endgroup
\end{document}
问题的主要根源(显然)是线路
%
\let\printglossary\relax
\let\theglossary\relax
\let\endtheglossary\relax
答案2
不是一个完整的答案,而更像是一个请求。我从未使用过该glossaries
软件包,但以下内容对我有用。
% glossprob.tex SE 586517 I HAVE NO IDEA PERHAPS IT'S MISUSE OF GLOSSARIES
\documentclass{memoir}
\usepackage[acronym]{glossaries}
\makeglossaries
\begin{document}
\newglossaryentry{foo}{name=foo,description={unit of length}}
Some text. Glossary entry \gls{foo}. More text.
\printglossary
\end{document}
没有打印词汇表,并且我无法从包装文档中清楚地了解如何完成词汇表(向作者致歉;文档很全面,但有点让人不知所措)。
我认为如果你真的做了 MWE,那将会非常有帮助最小,有点像上面的。例如,不需要所有子文件 --- 只需将精简版的代码ch11.tex
放入文档主体中。删除许多与词汇表无关的包和代码 --- 将 Chapter 添加到 ToC 条目之前是无关紧要的。等等。然后,确定问题的根源就会容易得多;是设置subfiles
错误glossaries
,还是……?
编辑
按照@SimonDispa 的回答和@daleif 的评论,我确实设法通过以下命令序列打印了一份词汇表。
pdflatex glossprob
pdflatex glossprob
makeglossaries glossprob
pdflatex glossprob