这是一个奇怪的现象。我必须做一些有趣的解决方法才能让它发挥一点作用,但我们还有另一个绊脚石。
我一直在努力创建一个使用大型 .ind 文件的单独文档(使用 makeindex 从串联的小型单独 .idx 文件创建的索引),其想法是我最终将拥有一个指示子文档的单个文档,并且索引数据出现的页码。
为此,我必须定义一个收集所有索引条目的命令,如下所示:
\newcommand{\myindexer}[3]
{\index{myindex}{#1 : #2.#3!\href{\doctitle.pdf}}}
结果是 myindex.idx 文件中的索引条目如下:
\indexentry{IndexedItemA : 55.iii!\href{Volume 1.pdf}{Volume 1.pdf}}{30}}
\indexentry{IndexedItemB : 23.vi!\href{Volume 3.pdf}{Volume 3.pdf}}{114}}
然而,在尝试创建目标 PDF 的超引用时存在问题。为了在特定页面打开 PDF,需要采用以下格式(感谢本板上的其他人指出了 hyperref 包中的 #page.xx 语法):
\href{FILENAME#page.XX}{Link Text}
wihch 意味着需要使用散列标记声明 myindex 时,包含在 \newcommand 的输出流中,可能使用转义哈希标记 # as:
\newcommand{\myindexer}[3]
{\index{myindex}{#1 : #2.#3!\href{\doctitle.pdf\#page.\thepage}}}
或根据我发现 某处 的某些片段,使用双哈希标记 as:
\newcommand{\myindexer}[3]
{\index{myindex}{#1 : #2.#3!\href{\doctitle.pdf##page.\thepage}}}
前者导致在为正在索引的多个文档编译 Latex 源期间出现以下错误:
! Illegal parameter number in definition of \@gtempa.
<to be read again>
\thepage
l.31 \myindex{IndexedItemA}{55}{iii}
而后者会导致生成的 myindex.idx 文件中出现不需要的反斜杠:
\indexentry{IndexedItemA : 55.iii!\href {Volume 1.pdf\#page.33}{Volume 1}}{33}
这会导致目标 PDF 无法正确打开。
知道如何强制 new 命令输出哈希标记以支持 PDF 的超链接吗?
This is a strange one. I've had to do some interesting workarounds to get it to function even a little bit, but we have another stumbling block.
I've been struggling to create a separate document which employs a large .ind file (index created using makeindex from catenated, small individual .idx files), the idea being that I will eventually have a single document which indicates the SUB-documents and page numbers where the indexed data occurs.
To this end, I've had to define a command which collects all index entries as:
\newcommand{\myindexer}[3]
{\index{myindex}{#1 : #2.#3!\href{\doctitle.pdf}}}
The result is index entries in the myindex.idx file as:
\indexentry{IndexedItemA : 55.iii!\href{Volume 1.pdf}{Volume 1.pdf}}{30}}
\indexentry{IndexedItemB : 23.vi!\href{Volume 3.pdf}{Volume 3.pdf}}{114}}
Yet, the problem exists in trying to create a hyperref to the target PDF. In order to open a PDF at a specific page, the following format needs to be employed (thanks to someone else on this board for pointing out the #page.xx syntax in the hyperref package):
\href{FILENAME#page.XX}{Link Text}
wihch means that a hash mark needs to be included in the output stream of the \newcommand when myindex is declared, possibly using an escaped hash mark # as:
\newcommand{\myindexer}[3]
{\index{myindex}{#1 : #2.#3!\href{\doctitle.pdf\#page.\thepage}}}
or according to some fragment I found somewhere using a double-hash mark as:
\newcommand{\myindexer}[3]
{\index{myindex}{#1 : #2.#3!\href{\doctitle.pdf##page.\thepage}}}
The former results in the following error during compilation of the latex source for the multiple documents being indexed:
! Illegal parameter number in definition of \@gtempa.
<to be read again>
\thepage
l.31 \myindex{IndexedItemA}{55}{iii}
While the latter results in an unwanted backslash in the resulting myindex.idx file as:
\indexentry{IndexedItemA : 55.iii!\href {Volume 1.pdf\#page.33}{Volume 1}}{33}
which results in the target PDF not opening correctly.
Any idea how the newcommand can be forced to output the hash mark to support hyperlinking of PDFs in this way?
发布评论
评论(2)
将
\href
包装在\protect
中怎么样?What about wrapping the
\href
in\protect
?你可以交换#和%的catcode:
然后用%来标记参数:
之后恢复通常的catcodes:
这有点笨拙,但即使某些东西干扰了通常的转义机制,它也应该可以工作,并且它允许在点
\myindexer< 处扩展
\href
使用/代码>。You can swap the catcode of # and %:
Then use % to mark parameters:
After that, restore the usual catcodes:
This is kind of clumsy, but it should work even if something interferes with usual escaping mechanisms, and it allows
\href
to be exanded at the point\myindexer
is used.