有时,为了将标题文本与文本区域分开,我需要在标题文本下方画一条线。
\setuppagenumbering
[location=,
alternative=doublesided]
\definepagebreak
[chapterpagebreak]
[yes,header,footer,right]
\setuphead
[chapter]
[style=\bfc,
header={empty,nomarking},
page=chapterpagebreak]
\def\pageoddoreven{%
\ifodd\pagenumber
{\getmarking[sectionnumber]\hskip1em\getmarking[section][first]}
\else
{Chapter~\getmarking[chapternumber]\hskip1em\getmarking[chapter]}
\fi}
\setupheadertexts
[text][\pageoddoreven][pagenumber]
\setupheader
[style=bold,after=\thinrule]
\starttext
\chapter{First Chapter}
this is the first chapter
\page
the second page of the first chapter
\chapter{Second Chapter}
this is the second chapter
\page
the second page of the second chapter
\stoptext
但\thinrule
将跨越整个页面,这就是我想要的。
我想要一条仅横跨文本区域的线,不延伸到左右边缘。我该如何绘制这条线?
答案1
正如 Timothy Li 所说,Aditya 的解决方案在每一页上都画了线。可以定义一个只出现在有内容的页面上的页眉(或页脚)。就我的目的而言,我使用了页脚,但以下代码同样可以应用于页眉:
\setuphead[chapter][
header=empty,
]
% Define the appearance for the section name in the footer.
\defineframed[FooterSection][
frame=off,
topframe=on,
align=flushleft,
width=\makeupwidth,
rulethickness=1.6pt,
location=bottom,
foregroundstyle=\tfx\ss,
height=broad,
top={\blank[small]},
]
% Define the appearance of the page number in the footer.
\defineframed[FooterPage][
frame=off,
location=bottom,
foregroundstyle=\tfx\bold\ss,
]
% Include the section name and page number in the footer.
\setupfootertexts
[\FooterSection{\getmarking[section]}]
[\FooterPage{\pagenumber}]
\starttext
\startfrontmatter
\startstandardmakeup
\startalignment[middle]\tfa{Title Page}\stopalignment
\stopstandardmakeup
\setuppagenumbering[conversion=romannumerals]
\setcounter[userpage][1]
\completecontent
\stopfrontmatter
\startchapter [title=alpha] \stopchapter
\startsection[title=alphasec] \stopsection
\startchapter [title=beta] \stopchapter
\startsection[title=alphasec] \stopsection
\startchapter [title=gamma] \stopchapter
\startsection[title=alphasec] \stopsection
\stoptext
答案2
这是实现此目的的一种方法。另请注意,我清理了您设置标题文本的方式。
\setuplayout
[
header=\lineheight,
headerdistance=\lineheight,
]
\setuppagenumbering
[
location=,
alternative=doublesided,
]
\definepagebreak
[chapterpagebreak]
[yes,header,footer,right]
\setuphead
[chapter]
[
style=\bfc,
header=empty,
page=chapterpagebreak,
]
\setupheader[style=bold]
\setupheadertexts
[{\getmarking[sectionnumber]\hskip1em\getmarking[section][first]}]
[pagenumber]
[{Chapter~\getmarking[chapternumber]\hskip1em\getmarking[chapter]}]
[pagenumber]
\setupbackgrounds[header][text][bottomframe=on]
\starttext
\chapter{First Chapter}
this is the first chapter
\page
the second page of the first chapter
\chapter{Second Chapter}
this is the second chapter
\page
the second page of the second chapter
\stoptext
编辑要删除空白页上的页眉,请使用:
\unprotect
\installpagebreakmethod {reallyempty}
{\page_otr_flush_all_floats
\page_otr_command_next_page
\doifnot{\namedlayoutelementparameter\v!header\c!state}\v!stop{\setuplayoutelement[\v!header][\c!state=\v!high]}%
\doifnot{\namedlayoutelementparameter\v!footer\c!state}\v!stop{\setuplayoutelement[\v!footer][\c!state=\v!high]}%
\page_otr_insert_dummy_page}
\protect
\definepagebreak
[chapterpagebreak]
[yes,reallyempty,right]
\setuphead
[chapter]
[
style=\bfc,
header=high,
before={\blank[force,\the\headerheight]},
page=chapterpagebreak,
]