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

如何在LaTeX中为所有缩写词创建单独的定义文件?

解决方案

1. 创建独立的缩写词定义文件

新建acronyms.tex文件,将所有缩写词定义集中放入:

% acronyms.tex
\newacronym{WLAN}{WLAN}{Wireless Local Area Network}
\newacronym{LAN}{LAN}{Local Area Network}

2. 修改主文档导入缩写词文件

在主文档的序言部分(\begin{document}之前)添加\input{acronyms.tex},确保缩写词在使用前完成定义:

\documentclass{scrbook}
\usepackage[acronym]{glossaries}
\makeglossaries

% 导入统一的缩写词定义
\input{acronyms.tex}

\begin{document}
\mainmatter
\printglossary[type=\acronymtype]
\include{ch1}
\include{ch2}
\end{document}

3. 清理章节文件中的冗余定义

删除各章节里的\newacronym语句,修改后的章节文件如下:

ch1.tex:

\chapter{ch1}
\acrfull{WLAN} is used as a trial for my example and problem

ch2.tex:

\chapter{ch2}
\acrfull{LAN} is used as a trial for my example and problem

4. 正确编译流程

要生成完整的缩写词表,需按以下顺序编译:

  • 第一次编译主文档(例如使用pdflatex 主文档名.tex)
  • 运行makeglossaries 主文档名(注意不要带.tex后缀)
  • 再次编译主文档两次,确保缩写词表内容正确显示

内容的提问来源于stack exchange,提问作者Sanchit Jain

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.10 09:15:33