如何实现带有标题内标题描述的多列词汇表?

如何实现带有标题内标题描述的多列词汇表?

我目前无法编写具有多列和列标题的首字母缩略词。我设法只编写了带有列标题的首字母缩略词,但不知道如何将它们写入多列中。这是 MWE:

\documentclass[a4paper,openany]{report}


 \usepackage[breaklinks,draft]{hyperref}


 \usepackage[acronym,section,nopostdot,nonumberlist,nogroupskip,nostyles] 
 {glossaries}

 \usepackage{glossary-mcols}

 \makeglossaries

 \begin{document}

 \newglossaryentry{cur}{name=cur, description={Just a random name.}}

 \newglossaryentry{mmee}{name=mmee, description={Just a random name.}}

 \newglossaryentry{fsda}{name=fs, description={Just a random name.}}

 \newglossaryentry{dcsc}{name=ddad, description={Just a random name.}}

 \newglossaryentry{ccs}{name=adax, description={Just a random name.}}

 \newglossaryentry{ccc}{name=acDc, description={Just a random name.}}

 \newglossaryentry{vfvv}{name=gegfvv, description={Just a random name.}}

 \newglossaryentry{fvafv}{name=gdgdfv, description={Just a random name.}}

 \newglossaryentry{bgbb}{name=gegvf, description={Just a random name.}}

 \newglossaryentry{gfvfv}{name=qefrwfav, description={Just a random name.}}


 \gls{cur}

 \gls{mmee}

 \gls{fsda}

 \gls{dcsc}

 \gls{ccs}

 \gls{ccc}

 \gls{vfvv}

 \gls{fvafv}

 \gls{gfvfv}

 \gls{bgbb}

 \printglossary[style=mcolindex,title=List of Acronyms]


 \end{document}

输出为: 現在的圖片

但我希望结果是: 期望结果

答案1

不可能有样式long的版本mcolslongtable环境不允许在multicols环境中使用,也不能在twocolumn模式中使用(无论是与类选项一起使用\twocolumn还是作为类选项使用)。

实现它的最简单方法是使用longtable四列(两对首字母缩略词和描述):

\documentclass[a4paper,openany]{report}

 \usepackage{array}
 \usepackage{longtable}
 \usepackage[breaklinks,draft]{hyperref}
 \usepackage[acronym,section,nostyles,entrycounter] 
 {glossaries}

 \makeglossaries

\newlength\descwidth
\setlength{\descwidth}{0.25\textwidth}
\renewcommand*{\glsentrycounterlabel}{}%

\newglossarystyle{pairedtable}%
{%
  \renewenvironment{theglossary}%
   {\begin{longtable}{l>{\raggedright}p{\descwidth}l>{\raggedright}p{\descwidth}}}%
   {\end{longtable}}%
    \renewcommand*{\glossaryheader}{%
    \bfseries \entryname & \bfseries
    \descriptionname &
    \bfseries \entryname & \bfseries
    \descriptionname
    \tabularnewline\endhead
   }%
  \renewcommand*{\glsgroupheading}[1]{}% no letter group headings
  \renewcommand*{\glsgroupskip}{}% no gap between letter groups
  \renewcommand{\glossentry}[2]{%
    \glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} &
    \glossentrydesc{##1}% number list omitted
    \ifodd\value{glossaryentry}\def\next{&}\else\def\next{\tabularnewline}\fi
    \next
  }%
  \renewcommand{\subglossentry}[3]{\glossentry{##2}{##3}}%
}

 \newglossaryentry{cur}{name=cur, description={Just a random name.}}

 \newglossaryentry{mmee}{name=mmee, description={Just a random
name.}}

 \newglossaryentry{fsda}{name=fs, description={Just a random name.}}

 \newglossaryentry{dcsc}{name=ddad, description={Just a random
name.}}

 \newglossaryentry{ccs}{name=adax, description={Just a random
name.}}

 \newglossaryentry{ccc}{name=acDc, description={Just a random
name.}}

 \newglossaryentry{vfvv}{name=gegfvv, description={Just a random
name.}}

 \newglossaryentry{fvafv}{name=gdgdfv, description={Just a random
name.}}

 \newglossaryentry{bgbb}{name=gegvf, description={Just a random
name.}}

 \newglossaryentry{gfvfv}{name=qefrwfav, description={Just a random
name.}}

 \begin{document}


 \gls{cur}

 \gls{mmee}

 \gls{fsda}

 \gls{dcsc}

 \gls{ccs}

 \gls{ccc}

 \gls{vfvv}

 \gls{fvafv}

 \gls{gfvfv}

 \gls{bgbb}

 \printglossary[style=pairedtable,title=List of Acronyms]

 \end{document}

不幸的是,由于表是按行构建的,所以顺序是错误的:

词汇表图片:按字母顺序从左到右。

没有简单的方法可以makeindex对条目进行排序以确保从上到下的排序。如果您只有少量条目,您可以手动进行排序并使用glossaries-extra's \printunstglossary(因为您不想要数字列表)。示例:

\documentclass[a4paper,openany]{report}

 \usepackage{array}
 \usepackage{longtable}
 \usepackage[breaklinks,draft]{hyperref}
 \usepackage[acronym,section,nostyles,entrycounter] 
 {glossaries-extra}

\newlength\descwidth
\setlength{\descwidth}{0.25\textwidth}
\renewcommand*{\glsentrycounterlabel}{}%

\newglossarystyle{pairedtable}%
{%
  \renewenvironment{theglossary}%
   {\begin{longtable}{l>{\raggedright}p{\descwidth}l>{\raggedright}p{\descwidth}}}%
   {\end{longtable}}%
    \renewcommand*{\glossaryheader}{%
    \bfseries \entryname & \bfseries
    \descriptionname &
    \bfseries \entryname & \bfseries
    \descriptionname
    \tabularnewline\endhead
   }%
  \renewcommand*{\glsgroupheading}[1]{}% no letter group headings
  \renewcommand*{\glsgroupskip}{}% no gap between letter groups
  \renewcommand{\glossentry}[2]{%
    \glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} &
    \glossentrydesc{##1}% number list omitted
    \ifodd\value{glossaryentry}\def\next{&}\else\def\next{\tabularnewline}\fi
    \next
  }%
  \renewcommand{\subglossentry}[3]{\glossentry{##2}{##3}}%
}

 \newglossaryentry{ccc}{name=acDc, description={Just a random
name.}}
 \newglossaryentry{fvafv}{name=gdgdfv, description={Just a random
name.}}
 \newglossaryentry{ccs}{name=adax, description={Just a random
name.}}
 \newglossaryentry{vfvv}{name=gegfvv, description={Just a random
name.}}
 \newglossaryentry{cur}{name=cur, description={Just a random name.}}
 \newglossaryentry{bgbb}{name=gegvf, description={Just a random
name.}}
 \newglossaryentry{dcsc}{name=ddad, description={Just a random
name.}}
 \newglossaryentry{mmee}{name=mmee, description={Just a random
name.}}
 \newglossaryentry{fsda}{name=fs, description={Just a random name.}}
 \newglossaryentry{gfvfv}{name=qefrwfav, description={Just a random
name.}}

 \begin{document}


 \gls{cur}

 \gls{mmee}

 \gls{fsda}

 \gls{dcsc}

 \gls{ccs}

 \gls{ccc}

 \gls{vfvv}

 \gls{fvafv}

 \gls{gfvfv}

 \gls{bgbb}

 \printunsrtglossary[style=pairedtable,title=List of Acronyms]

 \end{document}

词汇表的图像:条目从上到下成对排列。

如果您有很多条目,这不是特别方便。另一种方法是构建并排tabular环境,但您必须确定正确的行数。在下面的示例中,我加载了随包提供的测试条目glossaries来填充词汇表:

\documentclass[a4paper,openany]{report}

 \usepackage{array}
 \usepackage[breaklinks,draft]{hyperref}
 \usepackage[acronym,section,nostyles]{glossaries}

\makeglossaries

\loadglsentries[\acronymtype]{example-glossaries-acronym}% dummy entries

\newlength\descwidth
\setlength{\descwidth}{0.25\textwidth}

\newcounter{rowcount}

\newglossarystyle{table}%
{%
  \renewenvironment{theglossary}%
   {%
    \setcounter{rowcount}{0}%
    \begin{tabular}[t]{l>{\raggedright}p{\descwidth}}%
    \bfseries \entryname & \bfseries
    \descriptionname \tabularnewline
   }
   {\end{tabular}}%
   \renewcommand*{\glossaryheader}{}%
  \renewcommand*{\glsgroupheading}[1]{}% no letter group headings
  \renewcommand*{\glsgroupskip}{}% no gap between letter groups
  \renewcommand{\glossentry}[2]{%
    \stepcounter{rowcount}%
    \glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} &
    \glossentrydesc{##1}% number list omitted
    \ifnum\value{rowcount}=25 % 25 entries per column
      \def\next{%
        \end{tabular}\hfill
        \setcounter{rowcount}{0}%
        \begin{tabular}[t]{l>{\raggedright}p{\descwidth}}%
        \bfseries \entryname & \bfseries
        \descriptionname \tabularnewline
      }%
    \else
      \def\next{\tabularnewline}%
    \fi
    \next
  }%
  \renewcommand{\subglossentry}[3]{\glossentry{##2}{##3}}%
}

 \begin{document}
 \glsaddall

 \printglossary[type=\acronymtype,style=table,title=List of Acronyms]

 \end{document}

词汇表图片

相关内容