包含 3 列的词汇表会因缺少项目而出现错误

包含 3 列的词汇表会因缺少项目而出现错误

我尝试创建一个包含 3 列的词汇表,但不断出现以下错误:

Something's wrong--perhaps a missing \item. [...etentrycounter[]{page}\glsnumberformat{1}}}]

这是我的最小“工作”示例:

\documentclass{scrreprt}
\usepackage[T1]{fontenc} 
\usepackage[utf8]{inputenc}
\usepackage{siunitx}
\usepackage[nonumberlist]{glossaries}
\renewcommand*{\glspostdescription}{}
\makeglossaries

\newglossarystyle{iulstyle}{%
% put the glossary in a longtable environment:
\renewenvironment{theglossary}%
 {\begin{longtable}{lp{2cm}p{\glsdescwidth}}}%
 {\end{longtable}}%
% Set the table’s header: title row
\renewcommand*{\glossaryheader}{%
 \bfseries Zeichen & \bfseries Einheit & 
 \bfseries Beschreibung
 \\\endhead}%
% No table header:
\renewcommand*{\glossaryheader}{}%
% No heading between groups:
 \renewcommand*{\glsgroupheading}[1]{}%
% Main (level 0) entries displayed in a row optionally numbered:
 \renewcommand*{\glossaryentryfield}[3]{%
    \glstarget{##1}{##2}% Name
    & \glsentryuseri{##1}% Units
    & ##3% Description
    \\% end of row
 }}%

 %% Entry
\newglossaryentry{sym:A}{%
name={$F$},%
description={bar},%
user1={cm}%
}

 \begin{document}
 test: \gls{sym:A}


\setglossarystyle{iulstyle}
\setlength{\glsdescwidth}{0.6\textwidth}
\printglossary
\end{document}

编译是用 完成的makeglossaries

非常感谢您的帮助,Christian

答案1

你可能想将你的词汇表样式定义为

\newglossarystyle{iulstyle}{%
% put the glossary in a longtable environment:
\renewenvironment{theglossary}%
 {\begin{longtable}{lp{2cm}p{\glsdescwidth}}}%
 {\end{longtable}}%
% Set the table’s header: title row
\renewcommand*{\glossaryheader}{%
 \bfseries Zeichen & \bfseries Einheit &
 \bfseries Beschreibung
 \\\endhead}%
% No heading between groups:
 \renewcommand*{\glsgroupheading}[1]{}%
% Main (level 0) entries displayed in a row optionally numbered:
  \renewcommand{\glossentry}[2]{%
    \glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} &
    \glossentrydesc{##1} & \glsentryuseri{##1}\tabularnewline
  }%
}

要得到

在此处输入图片描述

平均能量损失

\documentclass{scrreprt}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{siunitx}
\usepackage[nonumberlist]{glossaries}
\renewcommand*{\glspostdescription}{}
\makeglossaries

\newglossarystyle{iulstyle}{%
% put the glossary in a longtable environment:
\renewenvironment{theglossary}%
 {\begin{longtable}{lp{2cm}p{\glsdescwidth}}}%
 {\end{longtable}}%
% Set the table’s header: title row
\renewcommand*{\glossaryheader}{%
 \bfseries Zeichen & \bfseries Einheit &
 \bfseries Beschreibung
 \\\endhead}%
% No heading between groups:
 \renewcommand*{\glsgroupheading}[1]{}%
% Main (level 0) entries displayed in a row optionally numbered:
  \renewcommand{\glossentry}[2]{%
    \glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} &
    \glossentrydesc{##1} & \glsentryuseri{##1}\tabularnewline
  }%
}

 %% Entry
\newglossaryentry{sym:A}{%
name={$F$},%
description={bar},%
user1={cm}%
}

 \begin{document}
 test: \gls{sym:A}


\setglossarystyle{iulstyle}
\setlength{\glsdescwidth}{0.6\textwidth}
\printglossary
\end{document} 

相关内容