如何在標題中實現帶有標題描述的多列詞彙表?

如何在標題中實現帶有標題描述的多列詞彙表?

我目前在編寫具有多個列和列標題的首字母縮寫時遇到問題。我已經設法只用列標題編寫首字母縮略詞,但不知道如何在多列中編寫它們。這是 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的版本mcols。此longtable環境不允許在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}

詞彙表的圖像

相關內容