我希望页眉链接到当前的开始\subject
,并且——因为我正在自动处理 XML 文档——我想在不手动输入主题标签的情况下执行此操作。(这可能还需要自动向主题添加标签。)是否有命令/关键字可以识别最后定义的主题头的位置?
\getmarking[subject]
获取主题标题。不幸的是,尝试设置标签时\reference[{\getmarking[subject]}]
出现错误。
最小示例:
% Smaller pages make examples nicer: \input-ing a quote
% will create multiple pages at once
\setuppapersize[A7][A7]
\setupinteraction[state=start]
%% I want people to be able to click this text to go to the start of the chapter
\setupheadertexts[{\sc \words \getmarking[subject]}][]
\setupheader[leftwidth=0.9\textwidth]
\setuppagenumbering[location={header,right}, style=os]
\setuphead[subject]
[header=high, % no header on the subject page
page=right,
% Keep track of the number (but don't print it)
% This is so we can include \subjects in the ToC
% (ToC not included in this example)
incrementnumber=yes,
number=no,
interaction=list, % link to the TOC
]
\starttext
\subject{Water}
\input bryson
\subject{America}
\input davis
\stoptext
答案1
首先是代码:
\setuppapersize [A7] [A7]
\setupinteraction [state=start, color=black, contrastcolor=black]
\setupheadertexts
[{\placelist
[subject]
[alternative=f, criterium=section]}]
[]
\setupheader [leftwidth=0.9\textwidth]
\setuphead [subject]
[page=right,
incrementnumber=yes]
\starttext
\subject{Water}
\input bryson
\subject{America}
\input davis
\stoptext
基本思路是将目录放在标题中,其中只有一个条目,即当前部分。根据您的要求,这可能就足够了。如果您需要更精细地控制列表位置,请使用以下代码:
\unprotect
\setupheadertexts
[{\placelist
[subject]
[\c!alternative=toc:section, \c!criterium=\v!section]}]
[]
\definelistalternative
[toc:section]
[\c!renderingsetup=list:toc:section]
\startsetups [list:toc:section]
\hbox\strc_lists_get_reference_attribute\v!all
{\currentlistentrytitle}
\stopsetups
\protect
需要\hbox
在设置中list:toc:section
启用交互。使用此方法,您可以完全控制并控制
\currentlistentrytitle
扩展到当前部分的超链接名称的宏。