使用 loadglsentries 时未反映词汇表条目

使用 loadglsentries 时未反映词汇表条目

当我尝试\loadglsentries从我创建的单独词汇表文件中 时,它们不会反映在文档中。另一方面,当我将 包含\newglossaryentry在 中时main.tex,它们会反映出来。我也检查了文件,它在每次构建时都会被修改,但它只显示当我将 包含在我的文件中.glo时添加的旧条目。\newglossaryentrymain.tex

\documentclass[12pt,a4paper]{report}
\usepackage{enumitem}%to make itemize bold
\usepackage{graphicx}
\usepackage[export]{adjustbox}
\usepackage{filecontents}
\usepackage{hyperref}
\usepackage{titlesec}
\usepackage{textcomp}
\usepackage{lipsum}
\usepackage{fixltx2e}
\usepackage{changepage}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage[nottoc,notlot,notlof]{tocbibind}
\usepackage{sectsty}
\usepackage[labelfont=bf]{caption}% to make image caption bold
\usepackage{color,soul}
\setcounter{secnumdepth}{5}
\usepackage{amssymb}% http://ctan.org/pkg/amssymb
\usepackage{pifont}
\usepackage[english]{babel}
\usepackage[toc, nonumberlist]{glossaries}
\usepackage[backend=biber,style=alphabetic,sorting=ynt]{biblatex}
\addbibresource{references.bib}

\nocite{*}
\hypersetup{
    colorlinks,
    citecolor=black,
    filecolor=black,
    linkcolor=black,
    urlcolor=blue
}

\newlist{arrowlist}{itemize}{1}
\setlist[arrowlist]{label=$\Rightarrow$}
\graphicspath{{./images/}}

% to setup the chapter formatting
\titleformat{\chapter}[display]
{\normalfont\huge\bfseries}{\chaptertitlename\ \thechapter}{8pt}{\LARGE }
\titlespacing*{\chapter}{0pt}{0pt}{8pt}

\renewcommand{\baselinestretch}{1.5}
\newenvironment{dedication}
\loadglsentries{abbreviations.tex}
\makeglossaries


    \begin{document}    
    \cleardoublepage
    \pagenumbering{roman}
    \chapter*{Abstract}
    \input{Abstract}

    \tableofcontents
    \cleardoublepage

    \addcontentsline{toc}{chapter}{List of Figures}
    \listoffigures

    \cleardoublepage
    \addcontentsline{toc}{chapter}{List of Tables}
    \listoftables
    \cleardoublepage
    \pagenumbering{arabic}
    \chapter{Introduction}
    \addtocontents{toc}{\setcounter{tocdepth}{2}}
    \input{Chapter1}

    \chapter{Literature Review and Background into EDDL}\label{ch:chapter 2}
    \addtocontents{toc}{\setcounter{tocdepth}{3}}
    \input{Chapter2}


    \chapter{Methodology}
    \addtocontents{toc}{\setcounter{tocdepth}{2}}
    \input{Chapter4}

    \chapter{Observations}
    \addtocontents{toc}{\setcounter{tocdepth}{2}}
    \input{Chapter5}

    \chapter{Conclusion}
    \addtocontents{toc}{\setcounter{tocdepth}{2}}
    \input{Chapter6}

    \chapter{Future Scope}
    \addtocontents{toc}{\setcounter{tocdepth}{2}}
    \input{Chapter7}

\printbibliography[title=References]
\glsaddall
\printglossary[title=Abbreviations]
\end{document}

我的abbreviations.tex文件看起来像这样

\newglossaryentry{opcua}{name={OPC UA},description={Open Platform Communications Unified Architecture}}

\newglossaryentry{eddl}{name={EDDL},description={Electronic Device Description Language}}

\newglossaryentry{fdt}{name={FDT},description={Field Device Tool (frame application)}}

\newglossaryentry{dtm}{name={DTM},description={Device Type Manager (device driver)}}

\newglossaryentry{fdi}{name={FDI},description={Field Device Integration}}

\newglossaryentry{gui}{name={GUI},description={Graphical User Interface}}

\newglossaryentry{iec}{name={IEC},description={International Electrotechnical Commission}}

\newglossaryentry{ne}{name={NE},description={NAMUR Empfehlungen}}

更新了代码。我现在已经发布了 main.tex 文件中的几乎全部代码。

答案1

原因是\newenvironment}{dedication}这是错误的,因为它\newenvironment需要另外两个参数。这些参数在使用时被抓住\loadglsentries{...}\makeglossaries结果是这些命令没有被调用,因为dedication到目前为止,在这段代码中根本没有使用。

我把它替换成了

 \newenvironment{dedication}{}{}

目前毫无用处(因为它什么也不做)

关于代码的一些注释:

  • fixltx2e自 2015 年 LaTeX 核心更新以来不再需要
  • hyperref应该是最后一个包
  • glossaries应该在之后hyperref

\documentclass[12pt,a4paper]{report}
\usepackage{amssymb}% http://ctan.org/pkg/amssymb
\usepackage{pifont}
\usepackage[english]{babel}
\usepackage[backend=biber,style=alphabetic,sorting=ynt]{biblatex}

\usepackage{enumitem}%to make itemize bold
\usepackage{graphicx}
\usepackage[export]{adjustbox}
\usepackage{filecontents}
\usepackage{titlesec}
\usepackage{textcomp}
\usepackage{lipsum}
\usepackage{fixltx2e} % Not really needed any longer since 2015 format 
\usepackage{changepage}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage[nottoc,notlot,notlof]{tocbibind}
\usepackage{sectsty}
\usepackage[labelfont=bf]{caption}% to make image caption bold
\usepackage{xcolor}
\usepackage{soul}
\setcounter{secnumdepth}{5}

\usepackage{hyperref}

\addbibresource{references.bib}

\nocite{*}
\hypersetup{
    colorlinks,
    citecolor=black,
    filecolor=black,
    linkcolor=black,
    urlcolor=blue
}

\newlist{arrowlist}{itemize}{1}
\setlist[arrowlist]{label=$\Rightarrow$}
\graphicspath{{./images/}}


\usepackage[toc, nonumberlist]{glossaries}

% to setup the chapter formatting
\titleformat{\chapter}[display]
{\normalfont\huge\bfseries}{\chaptertitlename\ \thechapter}{8pt}{\LARGE }
\titlespacing*{\chapter}{0pt}{0pt}{8pt}

\renewcommand{\baselinestretch}{1.5}
\newenvironment{dedication}{}{}

\loadglsentries{abbreviations}
\makeglossaries


    \begin{document}    
    \cleardoublepage
    \pagenumbering{roman}
    \chapter*{Abstract}
%    \input{Abstract}

    \tableofcontents
    \cleardoublepage

    \addcontentsline{toc}{chapter}{List of Figures}
    \listoffigures

    \cleardoublepage
    \addcontentsline{toc}{chapter}{List of Tables}
    \listoftables
    \cleardoublepage
    \pagenumbering{arabic}
    \chapter{Introduction}
    \addtocontents{toc}{\setcounter{tocdepth}{2}}
%    \input{Chapter1}

    \chapter{Literature Review and Background into EDDL}\label{ch:chapter 2}
    \addtocontents{toc}{\setcounter{tocdepth}{3}}
%    \input{Chapter2}


    \chapter{Methodology}
    \addtocontents{toc}{\setcounter{tocdepth}{2}}
%    \input{Chapter4}

    \chapter{Observations}
    \addtocontents{toc}{\setcounter{tocdepth}{2}}
%    \input{Chapter5}

    \chapter{Conclusion}
    \addtocontents{toc}{\setcounter{tocdepth}{2}}
%    \input{Chapter6}

    \chapter{Future Scope}
    \addtocontents{toc}{\setcounter{tocdepth}{2}}
%    \input{Chapter7}

\printbibliography[title=References]
\glsaddall
\printglossary[type=main,title=Abbreviations]
\end{document}

相关内容