我正在尝试将系统范围的词汇表数据库(包含缩写词和定义)制作成一个包。
我的文件是:/usr/local/texlive/texmf-local/tex/latex/local/myglossary.sty
需要运行:
sudo texhash
以便 TeXLive 能够看到该文件。
当然,我每次都不需要所有的定义。所以我按域拆分定义。
文件:/usr/local/texlive/texmf-local/tex/latex/local/myglossary.sty
% myglossary.sty
% acronyms and definitions
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{myglossary}
\RequirePackage{glossaries}
\DeclareOption{computer}{\option@computer} %% Execute \option@computer if option computer
\newcommand\option@computer{%
\newacronym{w3c}{W3C}{World Wide Web Consortium}
\newglossaryentry{css}{%
name={CSS},%
description={Style sheet language used for describing the presentation semantics (the look and formatting) of a document written in a markup language.},%
plural={CSS}}
}
\ProcessOptions
\endinput
文件:~/Desktop/test/document.tex
:
% document.tex
\documentclass{minimal}
\usepackage[computer]{myglossary}% note the option "computer"
\begin{document}
\gls{w3c}
\gls{css}
\end{document}
编译使用:
pdflatex document.tex
错误是:
! Package glossaries Error: Glossary entry `w3c' has already been defined.
谢谢您的帮助。
答案1
我可能更愿意将该选项设置为布尔开关:
\documentclass{article}
\usepackage{filecontents}
\begin{filecontents}{myglossary.sty}
% myglossary.sty
% acronyms and definitions
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{myglossary}
\RequirePackage{glossaries}
\newif\if@myglossary@computer
\DeclareOption{computer}{\@myglossary@computertrue} %
\ProcessOptions
\if@myglossary@computer
\newacronym{w3c}{W3C}{World Wide Web Consortium}
\newglossaryentry{css}{%
name={CSS},%
description={Style sheet language used for describing the presentation semantics (the look and formatting) of a document written in a markup language.},%
plural={CSS}}
\fi
\endinput
\end{filecontents}
\usepackage[computer]{myglossary}% note the option "computer"
\makeglossaries
\begin{document}
\gls{w3c}
\gls{css}
\end{document}