使用 ConTeXt 自定义部分、章节和节标题

使用 ConTeXt 自定义部分、章节和节标题

考虑这个例子:

\definepagebreak
  [saut]
  [yes,header=empty]
  
\setuphead[part][page=saut,numberstyle= ,numbercommand={\uppercase},placehead=yes, alternative=middle,align=middle,
   before=\startstandardmakeup,
   after=\stopstandardmakeup,conversion=Romannumerals,style={\switchtobodyfont[60pt]}]
%
\define[1]\Dot{#1.}

\define[2]\myheadnumber{%
\startframedtext[frame=off,align=middle]
{\bf\ss\switchtobodyfont[30pt] #1 }
\vfill \blank[2cm]
{\switchtobodyfont[20pt] #2 }
\stopframedtext }
 \setuphead[chapter][command=\myheadnumber,align={middle,nothyphenated, verytolerant},header=empty,footer=empty,commandbefore={\blank[0.5em]},
commandafter={\blank[2cm]},alternative=middle]

\setuphead[section][align=middle,style=\bfc ,numbercommand=\Dot]

\starttext
\completecontent[creterium=all]

\startpart[title={My part title}]

\startchapter[title={my chapter title}]
\startsection[title={My section title}]

\dorecurse{5}{\input knuth}
\stopsection
\stopchapter
\stoppart
\startpart[title={My part title}]

\startchapter[title={my chapter title}]
\startsection[title={My section title}]

\dorecurse{5}{\input knuth}
\stopsection
\stopchapter
\stoppart
\stoptext

  1. 如何隐藏正文中的章节编号,并将其保留在目录中。
  2. 如何获得正确的章节编号(1 而不是 1.1)并将其居中 在此处输入图片描述

答案1

像这样?

% ConTeXt either uses assignments or process options
% head=empty will be ignored
\definepagebreak[saut]
    [yes,empty]

%1=on,0=off
% Reset parts
% DON'T reset chapter (so it be 1, 2, 3...)
% Reset sections

\definestructureresetset
    [default][1,0,1][1]

\setuphead
    [sectionresetset=default]

\setuphead[part]
    [page=saut,
    numberstyle=,
    placehead=yes,
    alternative=middle,
    before=\startstandardmakeup,
    after=\stopstandardmakeup,
    conversion=R,
    style={\switchtobodyfont[60pt]}]

\define[2]\myheadnumber%
{\startframedtext
    [location=middle,
    frame=off,
    align={middle,nothyphenated, verytolerant}]
{\bf\ss\switchtobodyfont[30pt]#1}
\blank[2cm]
{\switchtobodyfont[20pt]#2}
\stopframedtext}
\setuphead[chapter]
    [command=\myheadnumber,
    header=empty,
    footer=empty,
    commandbefore={\blank[0.5em]},
    commandafter={\blank[2cm]},
    sectionsegments=chapter, %So it isn't 1.1 but 1
    align=middle]

\setuphead[section]
    [align=middle,
    style=\bfc,
    sectionsegments=chapter:section, %Not 1.1.1, but 1.1
    numbercommand=\gobbleoneargument]

\starttext
\completecontent[criterium=all]

\startpart[title={My part title}]

\startchapter[title={My chapter title}]
\startsection[title={My section title}]

\dorecurse{5}{\input knuth}
\stopsection
\stopchapter
\stoppart
\startpart[title={My part title}]

\startchapter[title={My chapter title}]
\startsection[title={My section title}]

\dorecurse{5}{\input knuth}
\stopsection
\stopchapter
\stoppart

相关内容