6

I am currently migrating from xltabular to tabularray. As part of that I want to adapt my custom glossary style for List of Symbols and List of Abbreviations (same style).

This is my old code:

% tables
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{xltabular}
\usepackage{tabularray}
\addto\captionsngerman{
    \DefTblrTemplate{contfoot-text}{default}{Fortsetzung auf der n\"achsten Seite}
    \DefTblrTemplate{conthead-text}{default}{(fortgesetzt)}
}

% glossaries \usepackage[ abbreviations, nonumberlist, record, symbols ]{glossaries-extra} \GlsXtrLoadResources[ src=glossaries, not-match={entrytype=symbol} ] \GlsXtrLoadResources[ selection=all, src=glossaries, type=symbols, match={entrytype=symbol} ] \newglossarystyle{customlong}{ \setglossarystyle{long} \renewenvironment{theglossary}{\xltabular{\textwidth}{llX}}{\endxltabular} \renewcommand{\glossentry}[2]{ \glsentryitem{##1}\textbf{\glstarget{##1}{\glossentryname{##1}}} & \multicolumn{2}{X}{\glossentrydesc{##1}}\ } \renewcommand{\subglossentry}[3]{ & \glssubentryitem{##2}\glstarget{##2}{\strut} & \glossentrydesc{##2}\ } \ifglsnogroupskip \renewcommand{\glsgroupskip}{}% \else \renewcommand{\glsgroupskip}{\}% \fi }

I would like to get rid of:

\usepackage{booktabs}
\usepackage{multirow}
\usepackage{xltabular}

Therefore, I need to adapt \newglossarystyle{customlong}{...}. This is my current state:

\newglossarystyle{customlong}{
    \setglossarystyle{long}
    \renewenvironment{theglossary}{
        \begin{longtblr}[
            entry=none,
            label=none
        ]{
            colspec={llX},
            hspan=minimal,
            stretch=1,
            width=\textwidth
        }
    }{\end{longtblr}}
    \renewcommand{\glossentry}[2]{
        \glsentryitem{##1}\textbf{\glstarget{##1}{\glossentryname{##1}}} & \SetCell[c=2]{l}\glossentrydesc{##1}\\
    }
    \renewcommand{\subglossentry}[3]{
        & \glssubentryitem{##2}\glstarget{##2}{\strut} & \glossentrydesc{##2}\\
    }
    \ifglsnogroupskip
        \renewcommand*{\glsgroupskip}{}%
    \else
        \renewcommand*{\glsgroupskip}{\\}%
    \fi
}

Compilation fails with 'Misplaced alignment tab character &.'. When I replace & with \& in \renewcommand{\glossentry}[2]{...} and \renewcommand{\subglossentry}[3]{...}, the compilation is successful but the output obviously contains '&'.

I assume that this error is related to the following content of the package documentation of tabularray:

"In contrast to traditional tabular environment, tabularray environments need to see every & and \ when splitting the table body with l3regex. And you can not put cell text inside any table command defined with \NewTableCommand. But you could use outer key expand to make tabularray expand every occurrence of a specified macro once before splitting the table body. Note that you can not expand a command defined with \NewDocumentCommand." (https://ftp.gwdg.de/pub/ctan/macros/latex/contrib/tabularray/tabularray.pdf, p. 30)

This would mean that I need to expand \renewcommand{\glossentry}[2]{...} and \renewcommand{\subglossentry}[3]{...}. I have no idea how to achieve that. Can someone help?

Thanks in advance.

Edit 1: M(N)WE

This is my current code which prints '&'. Some unrelated contents have been removed. I build with latexmk.

main.tex

\documentclass{scrbook}

\usepackage{tabularray}

\usepackage[ abbreviations, nonumberlist, record, symbols ]{glossaries-extra} \GlsXtrLoadResources[ src=glossaries, not-match={entrytype=symbol} ] \GlsXtrLoadResources[ selection=all, src=glossaries, type=symbols, match={entrytype=symbol} ] \newglossarystyle{customlong}{ \setglossarystyle{long} \renewenvironment{theglossary}{ \begin{longtblr}[ entry=none, label=none ]{ colspec={llX}, hspan=minimal, stretch=1, width=\textwidth } }{\end{longtblr}} \renewcommand{\glossentry}[2]{ \glsentryitem{##1}\textbf{\glstarget{##1}{\glossentryname{##1}}} & \SetCell[c=2]{l}\glossentrydesc{##1}\ } \renewcommand{\subglossentry}[3]{ & \glssubentryitem{##2}\glstarget{##2}{\strut} & \glossentrydesc{##2}\ } \ifglsnogroupskip \renewcommand{\glsgroupskip}{}% \else \renewcommand{\glsgroupskip}{\}% \fi } \newglossarystyle{customindex}{ \setglossarystyle{index} \renewcommand{\glstreeitem}{\parindent0pt\par} \renewcommand{\glstreepredesc}{\par\glstreeitem\parindent40pt\hangindent40pt} }

\begin{document} \frontmatter \printunsrtabbreviations[style=customlong] \printunsrtsymbols[style=customlong]

\mainmatter

\appendix

\backmatter
        \printunsrtglossary[style=customindex]

\end{document}

glossaries.bib

@entry{gls-uml,
    name        = {Unified Modeling Language},
    description = {\enquote{A specification defining a graphical language for visualizing, specifying, constructing, and documenting the artifacts of distributed object systems.}\footnote{\url{https://www.omg.org/spec/UML}, aufgerufen am 20.02.2023}.}
}

@abbreviation{auv, description = {\gls{gls-auv}}, short = {AUV}, long = {Autonomous Underwater Vehicle} }

@symbol{v-desired, name = {\ensuremath{\overrightarrow{v_{desired}}}}, description = {Wunschgeschwindigkeit} }

.latexmkrc

@default_files = ('main');

$pdf_mode = 4; $dvi_mode = 0; $postscript_mode = 0;

$lualatex = 'lualatex -synctex=1 -interaction=nonstopmode %O %S';

push @generated_exts, 'glstex', 'glg';

$clean_ext .= ' %R.bbl %R.glstex %R.lol %R.run.xml %R-1.glstex ';

add_cus_dep( 'aux', 'glstex', 0, 'run_bib2gls' );

sub run_bib2gls { if ($silent) { my $ret = system "bib2gls --silent --group $[0]"; } else { my $ret = system "bib2gls --group $[0]"; }

    my ( $base, $path ) = fileparse( $_[0] );
    if ( $path && -e "$base.glstex" ) {
            rename "$base.glstex", "$path$base.glstex";
    }

    # Analyze log file.
    local *LOG;
    $LOG = "$_[0].glg";
    if ( !$ret && -e $LOG ) {
            open LOG, "<$LOG";
            while (<LOG>) {
                    if (/^Reading (.*\.bib)\s$/) {
                            rdb_ensure_file( $rule, $1 );
                    }
            }
            close LOG;
    }
    return $ret;

}

0 Answers0