編輯1:M(N)WE

編輯1:M(N)WE

我目前正在從 xltabular 遷移到 tabularray。作為其中的一部分,我想調整符號列表和縮寫列表的自訂術語表樣式(相同樣式)。

這是我的舊代碼:

% 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
}

我想擺脫:

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

因此,我需要適應\newglossarystyle{customlong}{...}。這是我目前的狀態:

\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
}

編譯失敗,並顯示「對齊製表符錯位 &.」。當我替換&\&in \renewcommand{\glossentry}[2]{...}and時\renewcommand{\subglossentry}[3]{...},編譯成功,但輸出顯然包含“&”。

我假設這個錯誤與tabularray的套件文件的以下內容有關:

「與傳統的表格環境相比,表格環境在使用l3regex 分割表格主體時需要看到每個& 和\。而且您不能將儲存格文字放入使用\NewTableCommand 定義的任何表格命令中。但是您可以使用外鍵擴充功能來使tabularray 在分割表體之前將指定巨集的每次出現展開一次。 (https://ftp.gwdg.de/pub/ctan/macros/latex/contrib/tabularray/tabularray.pdf,p。 30)

這意味著我需要擴展\renewcommand{\glossentry}[2]{...}\renewcommand{\subglossentry}[3]{...}.我不知道如何實現這一目標。有人可以幫忙嗎?

提前致謝。

編輯1:M(N)WE

這是我目前的程式碼,列印“&”。一些不相​​關的內容已被刪除。我用 構建latexmk

主文件

\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}

詞彙表.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;
}

相關內容