
В настоящее время у меня проблема с написанием аббревиатур с несколькими столбцами и заголовком столбца. Мне удалось написать аббревиатуры только с заголовками столбцов, но не могу понять, как написать их в нескольких столбцах. Это 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}