词汇表:第二次使用后不再出现缩写

词汇表:第二次使用后不再出现缩写

我想要两个词汇表:1)术语表 2)缩写表

在命名法中,有四列,在缩写中,有三列。

一切运行正常,只是从第二次使用开始缩写不再出现。

我使用的代码存在什么问题?

命名文件:INP-00-glossary.tex

内容:

\newacronym[user1={K}]{T}{\textit{T}}{temperature}

缩写文件:INP-01-glossary.tex

内容:

\newglossaryentry{MC}
{
  name={MC},
  description={Monte Carlo},
  first={\glsentrydesc{MC} (\glsentrytext{MC})}
}

梅威瑟:

\documentclass[12pt,a4paper,times]{report}


\usepackage{hhline}%double line in table
\usepackage{lipsum,appendix}
%\usepackage[backref=page]{hyperref}%creates a reference with additional text corresponding to the target's type
\usepackage{hyperref}
\hypersetup{
    bookmarks=true,         % show bookmarks bar?
    unicode=false,          % non-Latin characters in Acrobat’s bookmarks
    pdftoolbar=true,        % show Acrobat’s toolbar?
    pdfmenubar=true,        % show Acrobat’s menu?
    pdffitwindow=false,     % window fit to page when opened
    pdfstartview={FitH},    % fits the width of the page to the window
    pdftitle={My title},    % title
    pdfauthor={Author},     % author
    pdfsubject={Subject},   % subject of the document
    pdfcreator={Creator},   % creator of the document
    pdfproducer={Producer}, % producer of the document
    pdfkeywords={keyword1} {key2} {key3}, % list of keywords
    pdfnewwindow=true,      % links in new window
    colorlinks=true,       % false: boxed links; true: colored links
    linkcolor=black,          % red,color of internal links
    citecolor=black,        % color of links to bibliography
    filecolor=black,      % color of file links
    urlcolor=black,           % color of external links
    anchorcolor=black
}




\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}

%glossaries and acronym
\usepackage[acronym,xindy,sanitize=none,sort=def,toc,
numberline,indexonlyfirst,nomain]{glossaries} %nomain, if you define glossaries in a file, and you use \include{INP-00-glossary}


\newglossary[nlg]{nomenc}{not}{ntn}{Nomenclature}
\newglossary[slg]{abbrev}{sot}{stn}{Abbreviations}



%custom glossary style
\newglossarystyle{long6col}{%  
 % put the glossary in a longtable environment:  
 \renewenvironment{theglossary}%  
  {\begin{longtable}{lp{\glsdescwidth}cccp{\glspagelistwidth}}}%  
  {\end{longtable}}%  
 % Set the table’s header:  
 \renewcommand*{\glossaryheader}{%  
  \bfseries Term & \bfseries Description & \bfseries Symbol &  
  \bfseries Units & \bfseries Dimensions & \bfseries Page List  
  \\\endhead}%  
 % No heading between groups:  
  \renewcommand*{\glsgroupheading}[1]{}%  
 % Main (level 0) entries displayed in a row optionally numbered:  
  \renewcommand*{\glossentry}[2]{%  
    \glsentryitem{##1}% Entry number if required  
    \glstarget{##1}{\glossentryname{##1}}% Name  
    & \glossentrydesc{##1}% Description  
    & \glossentrysymbol{##1}% Symbol  
    & \glsentryuseri{##1}% Units  
    & \glsentryuserii{##1}% Dimensions  
    & ##2% Page list  
    \tabularnewline % end of row  
  }%  
 % Similarly for sub-entries (no sub-entry numbers):  
 \renewcommand*{\subglossentry}[3]{%  
    % ignoring first argument (sub-level)  
    \glstarget{##2}{\glossentryname{##2}}% Name  
    & \glossentrydesc{##2}% Description  
    & \glossentrysymbol{##2}% Symbol  
    & \glsentryuseri{##2}% Units  
    & \glsentryuserii{##2}% Dimensions  
    & ##3% Page list  
    \tabularnewline % end of row  
  }%  
 % Nothing between groups:  
 \renewcommand*{\glsgroupskip}{}%  
}
%END: custom glossary style



%custom glossary1 style
\newglossarystyle{long6col1}{%
% put the glossary in a longtable environment:
\renewenvironment{theglossary}%
{\begin{longtable}{lp{\glsdescwidth}cccp{\glspagelistwidth}}}%
{\end{longtable}}%
% Set the table’s header:
\renewcommand
*
{\glossaryheader}{%
\bfseries Term & \bfseries Description & &
 & & \bfseries Page List
\\\endhead}%
% No heading between groups:
\renewcommand
*
{\glsgroupheading}[1]{}%
% Main (level 0) entries displayed in a row optionally numbered:
\renewcommand
*
{\glossaryentryfield}[5]{%
\glsentryitem{##1}% Entry number if required
\glstarget{##1}{##2}% Name
& ##3% Description
& ##4% Symbol
& \glsentryuseri{##1}% Units
& \glsentryuserii{##1}% Dimensions
& ##5% Page list
\\% end of row
}%
% Similarly for sub-entries (no sub-entry numbers):
\renewcommand
*
{\glossarysubentryfield}[6]{%
% ignoring first argument (sub-level)
\glstarget{##2}{##3}% Name
& ##4% Description
& ##5% Symbol
& \glsentryuseri{##2}% Units
& \glsentryuserii{##2}% Dimensions
& ##6% Page list
\\% end of row
}%
% Nothing between groups:
\renewcommand
*
{\glsgroupskip}{}%
}

%

\let\oldgls\gls
\renewcommand{\gls}[1]{%
  \ifglsused{#1}%
    {\glsentrylong{#1}}%
    {\oldgls{#1}}%
}


%END: custom glossary style


\renewcommand*{\glspostdescription}{}%removes dot at end
\glssetwidest{AAAAAAA}% widest name
\renewcommand*{\glsnamefont}[1]{\textmd{#1}}



\makeglossaries

%\loadglsentries[nomenc]{INP-00-glossary}
\let\oldacronymtype\acronymtype
\def\acronymtype{nomenc}
\loadglsentries[nomenc]{INP-00-glossary}
\let\acronymtype\oldacronymtype

\loadglsentries[abbrev]{INP-01-glossary}






\begin{document}
%\maketitle
\printglossary[style=long6col,type=nomenc]
\newpage
\printglossary[style=long6col1,type=abbrev]
\newpage

\gls{MC} used. another \gls{MC}

\gls{T} used , another \gls{T}


\end{document}

答案1

解决这个问题最简单的方法是消除一些不必要的复杂性。

首先,将 INP-01-glossary.tex 更改为:

\newacronym{MC}{MC}{Monte Carlo}

现在在后台\newacronym使用,您可以使用来执行此操作,但由于您的缩写本质上是首字母缩略词,我只会使用。\newglossaryentry\newglossaryentry\newacronym

其次,删除从重新定义开始的一些代码\gls。这就是这部分:

\let\oldgls\gls
\renewcommand{\gls}[1]{%
  \ifglsused{#1}%
    {\oldgls{#1}}%
    {\glsentrylong{#1}}%
}

\gls按照您希望的方式工作,并且允许您使用其他词汇表宏而不会出现任何不一致。

此外,您可以删除您的\acronymtype修改,使这部分:

\let\oldacronymtype\acronymtype
\def\acronymtype{nomenc}
\loadglsentries[nomenc]{INP-00-glossary}
\let\acronymtype\oldacronymtype

简单地:

\loadglsentries[nomenc]{INP-00-glossary}

通过此更改,您还需要acronym从词汇表包选项中删除该选项,否则当您运行 makeglossaries 时您将收到错误。


您的文档的 MWE 总计现在为:

\documentclass[12pt,a4paper,times]{report}
\usepackage{hhline}%double line in table
\usepackage{lipsum,appendix}
\usepackage{hyperref}
\hypersetup{
    bookmarks=true,         % show bookmarks bar?
    unicode=false,          % non-Latin characters in Acrobat’s bookmarks
    pdftoolbar=true,        % show Acrobat’s toolbar?
    pdfmenubar=true,        % show Acrobat’s menu?
    pdffitwindow=false,     % window fit to page when opened
    pdfstartview={FitH},    % fits the width of the page to the window
    pdftitle={My title},    % title
    pdfauthor={Author},     % author
    pdfsubject={Subject},   % subject of the document
    pdfcreator={Creator},   % creator of the document
    pdfproducer={Producer}, % producer of the document
    pdfkeywords={keyword1} {key2} {key3}, % list of keywords
    pdfnewwindow=true,      % links in new window
    colorlinks=true,       % false: boxed links; true: colored links
    linkcolor=black,          % red,color of internal links
    citecolor=black,        % color of links to bibliography
    filecolor=black,      % color of file links
    urlcolor=black,           % color of external links
    anchorcolor=black
}

\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}

\usepackage[xindy,sanitize=none,sort=def,toc,
numberline,indexonlyfirst,nomain]{glossaries}

\newglossary[nlg]{nomenc}{not}{ntn}{Nomenclature}
\newglossary[slg]{abbrev}{sot}{stn}{Abbreviations}

%custom glossary style
\newglossarystyle{long6col}{%
 % put the glossary in a longtable environment:
 \renewenvironment{theglossary}%
  {\begin{longtable}{lp{\glsdescwidth}cccp{\glspagelistwidth}}}%
  {\end{longtable}}%
 % Set the table’s header:
 \renewcommand*{\glossaryheader}{%
  \bfseries Term & \bfseries Description & \bfseries Symbol &
  \bfseries Units & \bfseries Dimensions & \bfseries Page List
  \\\endhead}%
 % No heading between groups:
  \renewcommand*{\glsgroupheading}[1]{}%
 % Main (level 0) entries displayed in a row optionally numbered:
  \renewcommand*{\glossentry}[2]{%
    \glsentryitem{##1}% Entry number if required
    \glstarget{##1}{\glossentryname{##1}}% Name
    & \glossentrydesc{##1}% Description
    & \glossentrysymbol{##1}% Symbol
    & \glsentryuseri{##1}% Units
    & \glsentryuserii{##1}% Dimensions
    & ##2% Page list
    \tabularnewline % end of row
  }%
 % Similarly for sub-entries (no sub-entry numbers):
 \renewcommand*{\subglossentry}[3]{%
    % ignoring first argument (sub-level)
    \glstarget{##2}{\glossentryname{##2}}% Name
    & \glossentrydesc{##2}% Description
    & \glossentrysymbol{##2}% Symbol
    & \glsentryuseri{##2}% Units
    & \glsentryuserii{##2}% Dimensions
    & ##3% Page list
    \tabularnewline % end of row
  }%
 % Nothing between groups:
 \renewcommand*{\glsgroupskip}{}%
}
%END: custom glossary style



%custom glossary1 style
\newglossarystyle{long6col1}{%
% put the glossary in a longtable environment:
\renewenvironment{theglossary}%
{\begin{longtable}{lp{\glsdescwidth}cccp{\glspagelistwidth}}}%
{\end{longtable}}%
% Set the table’s header:
\renewcommand
*
{\glossaryheader}{%
\bfseries Term & \bfseries Description & &
 & & \bfseries Page List
\\\endhead}%
% No heading between groups:
\renewcommand
*
{\glsgroupheading}[1]{}%
% Main (level 0) entries displayed in a row optionally numbered:
\renewcommand
*
{\glossaryentryfield}[5]{%
\glsentryitem{##1}% Entry number if required
\glstarget{##1}{##2}% Name
& ##3% Description
& ##4% Symbol
& \glsentryuseri{##1}% Units
& \glsentryuserii{##1}% Dimensions
& ##5% Page list
\\% end of row
}%
% Similarly for sub-entries (no sub-entry numbers):
\renewcommand
*
{\glossarysubentryfield}[6]{%
% ignoring first argument (sub-level)
\glstarget{##2}{##3}% Name
& ##4% Description
& ##5% Symbol
& \glsentryuseri{##2}% Units
& \glsentryuserii{##2}% Dimensions
& ##6% Page list
\\% end of row
}%
% Nothing between groups:
\renewcommand
*
{\glsgroupskip}{}%
}

%

%END: custom glossary style

\renewcommand*{\glspostdescription}{}%removes dot at end
\glssetwidest{AAAAAAA}% widest name
\renewcommand*{\glsnamefont}[1]{\textmd{#1}}

\makeglossaries

\loadglsentries[nomenc]{INP-00-glossary}
\loadglsentries[abbrev]{INP-01-glossary}

\begin{document}
%\maketitle

\printglossary[style=long6col,type=nomenc]
\newpage
\printglossary[style=long6col1,type=abbrev]
\newpage

\gls{MC} used. another \gls{MC}

\gls{T} used , another \gls{T}

\end{document}

制作(第 3 页):

mwe 输出

相关内容