You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

LaTeX无法将Listing名称改为Auflistung的问题求助

解决方案

以下是几种可行的修复方法,按优先级尝试:

方法1:调整命令位置(基础解决)

确保\renewcommand{\lstlistingname}{Auflistung}放在\usepackage{listings}之后,且在babel包加载之后(如果使用了德语babel)。若babel在文档开始时重置名称,改用\AtBeginDocument延迟执行:

\documentclass{scrreprt} % 或你使用的文档类
\usepackage[ngerman]{babel}
\usepackage{listings}

% 放在所有相关包加载之后
\renewcommand{\lstlistingname}{Auflistung}
% 若上述无效,替换为:
% \AtBeginDocument{\renewcommand{\lstlistingname}{Auflistung}}

\begin{document}
\begin{lstlisting}[caption=Beispielcode]
print("Hallo Welt")
\end{lstlisting}
\end{document}

方法2:使用KOMA-Script内置命令(针对KOMA类文档)

如果你使用的是KOMA-Script系列文档类(如scrreprt、scrartcl),用KOMA自带的\setcaptionname命令更可靠,它会适配babel的语言环境:

\documentclass{scrreprt}
\usepackage[ngerman]{babel}
\usepackage{listings}

% 针对德语环境设置listing的名称
\setcaptionname{ngerman}{lstlisting}{Auflistung}

\begin{document}
\begin{lstlisting}[caption=Beispielcode]
print("Hallo Welt")
\end{lstlisting}
\end{document}

方法3:检查冲突包

如果上述方法都无效,排查是否加载了其他可能覆盖名称的包(如cleveref、caption)。若使用caption包,可添加:

\usepackage{caption}
\captionsetup[lstlisting]{name=Auflistung}

内容的提问来源于stack exchange,提问作者ben b

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.19 21:00:54