我的问题是,正如以下 2 个 MWE 所示,我为词汇表指定的自定义列名将在加载 babel 时被覆盖。关联的 .bib 文件可以在末尾找到。
我该如何防止这种情况?我已经尝试改变 \renewcommand 提示的位置。
首先没有加载 Babel:
\documentclass[english, a4paper, 11pt, DIV=calc, headsepline, titlepage, bibliography=totocnumbered]{scrartcl}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{siunitx}
\usepackage[record, abbreviations, symbols, nonumberlist, hyperfirst=false, toc=false, stylemods={longextra}]{glossaries-extra}
\glsaddstoragekey{unit}{}{\glsentryunit}
\GlsXtrLoadResources[
src={bibfiles/symbols}, % data in symbols.bib
sort-field={name}, % sort by name field
sort={letter-nocase}, % case-insensitive letter sort
type=symbols, % put these terms in the symbols list
field-aliases={unit=symbol},% convert unit key to symbol
save-locations=false % don't save location lists
]
% change column headers:
\renewcommand{\entryname}{Symbol}
\renewcommand{\symbolname}{Unit}
\renewcommand{\glslongextraSymbolAlign}{l}
\begin{document}
\printunsrtglossary[type=symbols, style={long-name-sym-desc}]
\end{document}
结果正是我想要的:
现在当 babel 被激活时:
\documentclass[english, a4paper, 11pt, DIV=calc, headsepline, titlepage, bibliography=totocnumbered]{scrartcl}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{siunitx}
\usepackage[record, abbreviations, symbols, nonumberlist, hyperfirst=false, toc=false, stylemods={longextra}]{glossaries-extra}
\glsaddstoragekey{unit}{}{\glsentryunit}
\GlsXtrLoadResources[
src={bibfiles/symbols}, % data in symbols.bib
sort-field={name}, % sort by name field
sort={letter-nocase}, % case-insensitive letter sort
type=symbols, % put these terms in the symbols list
field-aliases={unit=symbol},% convert unit key to symbol
save-locations=false % don't save location lists
]
% change column headers:
\renewcommand{\entryname}{Symbol}
\renewcommand{\symbolname}{Unit}
\renewcommand{\glslongextraSymbolAlign}{l}
\begin{document}
\printunsrtglossary[type=symbols, style={long-name-sym-desc}]
\end{document}
我将获得以下信息:
关联的 bib 文件:
% Encoding: UTF-8
@symbol{alpha,
unit= {\si{\radian\per\second\squared}},
name = {\ensuremath{\alpha}},
description = {angular acceleration}
}
@symbol{x,
unit = {\si{m}},
name = {\ensuremath{x}},
description = {position}
}
@symbol{v,
unit = {\si{\metre\per\second}},
name = {\ensuremath{v}},
description = {velocity}
}
@symbol{a,
unit = {\si{\metre\per\second\squared}},
name = {\ensuremath{a}},
description = {acceleration}
}
@symbol{t,
unit = {\si{s}},
name = {\ensuremath{t}},
description = {time}
}
@symbol{F,
unit = {\si{N}},
name = {\ensuremath{F}},
description = {force}
}
答案1
用户@daleif 在评论中发布了一个实用示例。
为了便于阅读,我将其复制到这里:
babel 在文档开头进行覆盖。正确的方法是通过 \addto\captionsenglish{ 在此处添加您的重新定义 } 将您的更改添加到 babel 语言中
这是一个相关的例子:tex.stackexchange.com/a/373816/3929