用語集: 2 回目以降は略語が表示されません

用語集: 2 回目以降は略語が表示されません

2つの用語集が必要です: 1) 命名法 2) 略語

命名法では 4 つの列があり、略語では 3 つの列があります。

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})}
}

MWE:

\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}

この変更により、glossaries パッケージ オプションからオプションを削除する必要もあります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出力

関連情報