来自 Microtype 文档的示例

来自 Microtype 文档的示例

在深入探索与 LuaTeX 相关的 microtype 包时,我偶然发现了这个看似无害的第 18 页,来自microtype.pdf 2.5 beta-08

在此处输入图片描述

正如页边空白处的蓝色注释所暗示的那样,单击鼠标即可显示字距和间距

在此处输入图片描述

最后的惊喜来自于点击文本中的单词。

在此处输入图片描述

这真是太棒了!当然,我想知道它是如何完成的。由于它是官方软件包文档,我立即找到了 dtx。然而,它并没有那么容易地揭示它的魔力。dtx 中的相关部分是:

\begin{verbatim}
\SetTracking
  [ no ligatures  = {"\anchorarrow{nolig}"f},
    spacing       = {60"\anchorarrow{ispace}"0*,-1"\anchorarrow{istretch}"00*,"\anchorarrow{ishrink}"},
    outer spacing = {4"\anchorarrow{ospace}"50,2"\anchorarrow{ostretch}"50,1"anchorarrow{oshrink}"50},
    outer kerning = {"\anchorarrow{okernbegin}"*,"\anchorarrow{okernend}"*} ]
  { encoding = * }
  { 1"\anchorarrow{lsamount}"60 }
\end{verbatim}
 and then write:
\begin{verbatim}
Stop \textls{stealing sheep}!
\end{verbatim}

this is the (typographically dubious) outcome:

\lssample

\noindent
While the word `Stop' is not letterspaced, the space between the letters in
the other two words is expanded by the \showarrow[tracking]{tracking~amount}{red}
of 160/1000\,em\,=\allowbreak\,0.16\,em.

当然,宏的定义是找不到的。相反,序言中的“附加材料”部分显示

\InputIfFileExists{microtype-lssample.dtx}

它在另一个文件中,不幸的是没有包含在 .zip 中。所以问题仍然悬而未决。这是如何实现的。dtx 中的宏暗示这里有一个通用的解决方案。我怀疑这里有一些 Tikz 叠加魔法在起作用。但由于位置直到页面排版后才确定,箭头必须以某种方式出现在之后。然后如何将信息传递给 pdf 查看器,以便通过单击单词来切换它们?


编辑:根据 Martin Schröder 的指示,我了解到 PDF 格式自 1.5 版起支持“层”,这里称为可选内容组 (OCG)。在comp.text.tex 上的旧线程(2007)Michael Ritzert 提供了他ocg.sty直接在 LaTeX 中创建它们的方法。甚至还有一个不错的TeXample 上的演示这表明切换是通过 Acrobat Reader 执行的 JavaScript 片段实现的。还有一个相当新的包ocgtools。剩下的问题是如何获取页面中的锚点并让箭头在排版材料上交叉?

答案1

我猜你问的是微类型文档中的层/OCG 的实现。据我所知,这是不是通过 pgf 完成。检查microtype.dtxv1.66 中第 517 行之后的代码,并查看注释

% the samples in the introduction, utilising nested optional content groups (aka. layers):

他在那里实现了可选内容。

答案2

好吧,像往常一样,一切都在那里,就在眼前...我的 pgfmanual 很旧,当前的 pgfmanual 有一个16.13 Referencing Nodes Outside the Current Pictures以 开头的 部分16.13.1 Referencing a Node in a Different Picture,第 75.3.2 节解释了幕后细节。

答案3

这是一个很晚的答案,但我认为我的答案提供了一些新的和有用的内容。

OP 写道

当然,宏的定义是找不到的。相反,序言中的“附加材料”部分显示

\InputIfFileExists{microtype-lssample.dtx}

它在另一个文件中,不幸的是没有包含在 .zip 中。所以问题仍然悬而未决。这是如何实现的。

我遇到了同样的问题,并在以下位置找到了以下提示microtype.dtx

 *** Typesetting the documentation ***
(skipped lines)
#  (3) Extract microtype-lssample.dtx and microtype-logo.dtx from
#      microtype.pdf (ie., from the file you are about to recreate ...).
#      This can be done, eg., with Adobe Reader or with the pdftk tool.

PS:这两个文件的内容,主要是一些PDF文字,记录在microtype.pdfA和B部分。

PS2:软件包ocgx提供了高级抽象并与tikz和兼容beamer

相关内容