如何制作“共享”词汇表?

如何制作“共享”词汇表?

假设我想写一份报告,从两个学科领域的角度讨论某个主题。这两个学科领域都使用某些特定领域的术语,这些术语可能对类似概念使用不同的术语,对不同概念使用相同的术语,等等。我想编写一些“共享”词汇表或本体,收集这些术语及其解释。

举个例子,我们可以讨论火车和飞机,并生成如下列表:

Trains           | Explanation                                  | Planes
------------------------------------------------------------------------
Train            | A means of mass transportation that is       | Plane
                 | steered by a train driver/pilot              |
------------------------------------------------------------------------
Train driver     | The person who steers a train/plane          | Pilot
------------------------------------------------------------------------
Passenger        | A person travelling in a train/plane without | Passenger
                 | steering it themselves                       |
------------------------------------------------------------------------
Platform         | The place where a train/plane stops to let   | Gate
                 | passengers enter and exit                    |
------------------------------------------------------------------------
...

我希望能够在我的报告中引用两个字段中的术语,即如果我写类似\term{Plane}或 的内容\term{Train},它应该指向我表中的同一行。这一点与双语词汇表的解决方案不同,在双语词汇表中,您通常只使用一个术语,而另一种语言的术语仅供在词汇表中参考,并且可能在第一次提到该术语时使用。

此外,分配应该是双向的,即无论读者查找“飞机”还是“火车”,他们都应该看到另一个领域中相应的术语。这种用法的用例是,只熟悉一个专业领域的读者通常只需查找他们不熟悉的领域的术语。然后他们应该能够立即看到这个术语与他们自己的领域有何关系,或者没有类似的概念。由于报告将由两个领域的专家撰写和阅读,因此这种分配也应该是双向的。别名示例这是一个例子,说明它应该如何不是工作,因为只有一个方向的引用,例如从拉丁语“Hercules”到希腊语“Herakles”,但不能再回到原来的方向。

当然,我不希望被迫亲自选择和分类相关项目。

我的直觉告诉我,这可能是词汇表包的一个案例。但是,我不知道如何解决这个问题,也不知道是否有其他或更好的包可以解决这个问题。所以任何提示都非常受欢迎!

答案1

我认为最简单的做法是plane为与飞机相关的术语设置一个键。火车术语存储在以下name字段中:

\documentclass{article}

\usepackage{array}
\usepackage[colorlinks]{hyperref}
\usepackage{glossaries}

\makeglossaries

\glsaddkey
 {plane}% new key name
 {}% default value if key not provided
 {\entryplane}% no link command
 {\Entryplane}% no link command with first letter changed to upper case
 {\plane}% link command
 {\Plane}% link command with first letter changed to uppercase
 {\PLANE}% link command with all caps

\newglossaryentry
{vehicle}% label
{name={train},% train
 plane={plane},% plane
 description={A means of mass transportation that is
  steered by a train driver/pilot}
}

\newglossaryentry
{driver}% label
{name={train driver},% train
 plane={pilot},% plane
 description={The person who steers a train/plane}
}

\newglossaryentry
{passenger}% label
{name={passenger},% train
 plane={passenger},% plane
 description={A person travelling in a train/plane without
  steering it themselves}
}

\newglossaryentry
{embark}% label
{name={platform},% train
 plane={gate},% plane
 description={The place where a train/plane stops to let
  passengers enter and exit}
}

\newglossarystyle{shared}%
{%
  \renewenvironment{theglossary}%
    {\begin{longtable}{l>{\raggedright}p{0.5\linewidth}l}}%
    {\end{longtable}}%
  \renewcommand*{\glsgroupheading}[1]{}%
  \renewcommand*{\glsgroupskip}{}%
  \renewcommand{\glossentry}[2]{%
    \glsentryitem{##1}\glstarget{##1}{\Glossentryname{##1}} &
    \glossentrydesc{##1} & \Entryplane{##1}\tabularnewline
  }%
  \renewcommand{\subglossentry}[1]{\glossentry}%
  \renewcommand*{\glossaryheader}{%
    \bfseries Trains&\bfseries Explanation&
    \bfseries Planes\tabularnewline\endhead}%
}

\begin{document}
Trains: \gls{vehicle}, \gls{driver}, \gls{passenger}, \gls{embark}.

Planes: \plane{vehicle}, \plane{driver}, \plane{passenger}, \plane{embark}.

\printglossary[style=shared]
\end{document}

构建过程是latex(或pdflatexxelatexlualatex视情况而定)makeglossaries(或makeglossaries-litelatex

name由于sort缺少该字段,因此将根据该字段进行排序。

文件图像

这是一个在字段中包含通用术语的版本,name其中有一个用于火车术语的额外键:

\documentclass{article}

\usepackage{array}
\usepackage[colorlinks]{hyperref}
\usepackage{glossaries}

\makeglossaries

\glsaddkey
 {plane}% new key name
 {}% default value if key not provided
 {\entryplane}% no link command
 {\Entryplane}% no link command with first letter changed to upper case
 {\plane}% link command
 {\Plane}% link command with first letter changed to uppercase
 {\PLANE}% link command with all caps

\glsaddkey
 {train}% new key name
 {}% default value if key not provided
 {\entrytrain}% no link command
 {\Entrytrain}% no link command with first letter changed to upper case
 {\train}% link command
 {\Train}% link command with first letter changed to uppercase
 {\TRAIN}% link command with all caps

\newglossaryentry
{vehicle}% label
{name={vehicle},% generic
 train={train},% train
 plane={plane},% plane
 description={A means of mass transportation that is
  steered by a train driver/pilot}
}

\newglossaryentry
{driver}% label
{name={driver},% generic
 train={train driver},% train
 plane={pilot},% plane
 description={The person who steers a train/plane}
}

\newglossaryentry
{passenger}% label
{name={passenger},% generic
 train={passenger},% train
 plane={passenger},% plane
 description={A person travelling in a train/plane without
  steering it themselves}
}

\newglossaryentry
{embark}% label
{name={embarkation point},% generic
 train={platform},% train
 plane={gate},% plane
 description={The place where a train/plane stops to let
  passengers enter and exit}
}

\newglossarystyle{shared}%
{%
  \renewenvironment{theglossary}%
    {\begin{longtable}{l>{\raggedright}p{0.5\linewidth}ll}}%
    {\end{longtable}}%
  \renewcommand*{\glsgroupheading}[1]{}%
  \renewcommand*{\glsgroupskip}{}%
  \renewcommand{\glossentry}[2]{%
    \glsentryitem{##1}\glstarget{##1}{\Glossentryname{##1}} &
    \glossentrydesc{##1} & \Entrytrain{##1} & \Entryplane{##1}\tabularnewline
  }%
  \renewcommand{\subglossentry}[1]{\glossentry}%
  \renewcommand*{\glossaryheader}{%
    \bfseries Generic&\bfseries Explanation&\bfseries Trains&
    \bfseries Planes\tabularnewline\endhead}%
}

\begin{document}
Generic: \gls{vehicle}, \gls{driver}, \gls{passenger}, \gls{embark}.

Trains: \train{vehicle}, \train{driver}, \train{passenger}, \train{embark}.

Planes: \plane{vehicle}, \plane{driver}, \plane{passenger}, \plane{embark}.

\printglossary[style=shared]
\end{document}

现在按通用术语排序:

文件图像

您还可以使用其他键来扩展此功能,例如,如果您想添加海事版本。只需确保该name键用于管理排序的术语,否则您sort也需要设置该键。

相关内容