在我的文档中,有两个带有\em
命令和---
破折号的章节标题,它们被正确转换为斜体和文本中的破折号。但 PDF 书签无法正确创建:
\em
:如果我使用语法\em{text}
,则书签仅包含文本(如预期)。如果我使用{\em text}
,则整个字符串将按原样用于 PDF 书签中。---
:永远不会转换为长破折号。
如何才能正确获取\em
PDF---
书签?我不需要书签样式。以下是代码示例和屏幕截图(在 SumatraPDF 中):
\setupinteraction[state=start]
\placebookmarks[chapter, section][chapter, section]
\setupinteractionscreen[option=bookmark]
\setuptagging[state=start]
\starttext
\chapter[title={{\em Chapter} --- a note}]
Some paragraph.
\section{{\em A year from monday} --- from John Cage}
Some paragraph.
\chapter[title={\em{Chapter} --- another note}]
Some paragraph.
\section{\em{Silence} --- from John Cage}
Some paragraph.
\stoptext
截图(注意带有---
和\em
出现的书签):
答案1
要展开书签中的所有宏,您必须添加
\enabledirectives[references.bookmarks.preroll]
在您的文档中。我认为您不能在书签中使用连字,因为连字是字体的一部分。您可以做的是,直接---
使用 Unicode 字符—
(U+2014 EM DASH) 或相应的控制序列\emdash
。
另外,当你使用标签时,我认为你有使用对来表示章节、部分等。如果我不使用,\start...\stop
至少会向我显示错误的嵌套。pdfinfo
\start...\stop
\enabledirectives[references.bookmarks.preroll]
\setupinteraction[state=start]
\placebookmarks[chapter, section][chapter, section]
\setupinteractionscreen[option=bookmark]
\setuptagging[state=start]
\starttext
\startchapter[title={{\em Chapter} — a note}]
Some paragraph.
\startsection[title={{\em A year from monday} — from John Cage}]
Some paragraph.
\stopsection
\stopchapter
\startchapter[title={\emph{Chapter} \emdash\ another note}]
Some paragraph.
\startsection[title={\emph{Silence} \emdash\ from John Cage}]
Some paragraph.
\stopsection
\stopchapter
\stoptext
$ pdfinfo -struct-text test.pdf
Div
Sect "chapter"
Div
H (block)
"1"
H (block)
"Chapter— a note"
Div
"Some paragraph."
Sect "section"
Div
H (block)
"1.1"
H (block)
"A year from monday— from John Cage"
Div
"Some paragraph."
Sect "chapter"
Div
H (block)
"2"
H (block)
"Chapter— another note"
Div
"Some paragraph."
Sect "section"
Div
H (block)
"2.1"
H (block)
"Silence— from John Cage"
Div
"Some paragraph."