Difference between revisions of "Command/setuphead"
m (add source link) |
|||
(25 intermediate revisions by 3 users not shown) | |||
Line 5: | Line 5: | ||
<cd:arguments> | <cd:arguments> | ||
<cd:keywords list="yes" optional="yes" ordinal="1"> | <cd:keywords list="yes" optional="yes" ordinal="1"> | ||
− | <cd:keywordsdoc></cd:keywordsdoc> | + | <cd:keywordsdoc>Section level, e.g. chapter, section, subsection or number (1=part, 2=chapter). Can be a list.</cd:keywordsdoc> |
<cd:constant type="cd:section"></cd:constant> | <cd:constant type="cd:section"></cd:constant> | ||
</cd:keywords> | </cd:keywords> | ||
Line 11: | Line 11: | ||
<cd:assignmentsdoc></cd:assignmentsdoc> | <cd:assignmentsdoc></cd:assignmentsdoc> | ||
<cd:parameter name="frontpartlabel"> | <cd:parameter name="frontpartlabel"> | ||
− | <cd:paramdoc></cd:paramdoc> | + | <cd:paramdoc>Prefix of this section if it appears in frontmatter.</cd:paramdoc> |
<cd:constant type="cd:name"></cd:constant> | <cd:constant type="cd:name"></cd:constant> | ||
</cd:parameter> | </cd:parameter> | ||
<cd:parameter name="bodypartlabel"> | <cd:parameter name="bodypartlabel"> | ||
− | <cd:paramdoc></cd:paramdoc> | + | <cd:paramdoc>Prefix of this section if it appears in bodymatter.</cd:paramdoc> |
<cd:constant type="cd:name"></cd:constant> | <cd:constant type="cd:name"></cd:constant> | ||
</cd:parameter> | </cd:parameter> | ||
<cd:parameter name="appendixlabel"> | <cd:parameter name="appendixlabel"> | ||
− | <cd:paramdoc></cd:paramdoc> | + | <cd:paramdoc>Prefix of this section if it appears in appendix.</cd:paramdoc> |
<cd:constant type="cd:name"></cd:constant> | <cd:constant type="cd:name"></cd:constant> | ||
</cd:parameter> | </cd:parameter> | ||
<cd:parameter name="backpartlabel"> | <cd:parameter name="backpartlabel"> | ||
− | <cd:paramdoc></cd:paramdoc> | + | <cd:paramdoc>Prefix of this section if it appears in backmatter.</cd:paramdoc> |
<cd:constant type="cd:name"></cd:constant> | <cd:constant type="cd:name"></cd:constant> | ||
</cd:parameter> | </cd:parameter> | ||
Line 42: | Line 42: | ||
</cd:parameter> | </cd:parameter> | ||
<cd:parameter name="sectionresetset"> | <cd:parameter name="sectionresetset"> | ||
− | <cd:paramdoc></cd:paramdoc> | + | <cd:paramdoc>Controls which section numbers get reset after a higher level section. See {{cmd|definestructureresetset}} or {{cmd|defineresetset}}.</cd:paramdoc> |
<cd:constant type="cd:name"></cd:constant> | <cd:constant type="cd:name"></cd:constant> | ||
</cd:parameter> | </cd:parameter> | ||
<cd:parameter name="sectionseparatorset"> | <cd:parameter name="sectionseparatorset"> | ||
− | <cd:paramdoc></cd:paramdoc> | + | <cd:paramdoc>Controls the characters between section number elements.See {{cmd|definestructureseparatorset}}.</cd:paramdoc> |
<cd:constant type="cd:name"></cd:constant> | <cd:constant type="cd:name"></cd:constant> | ||
</cd:parameter> | </cd:parameter> | ||
<cd:parameter name="sectionconversionset"> | <cd:parameter name="sectionconversionset"> | ||
− | <cd:paramdoc></cd:paramdoc> | + | <cd:paramdoc>Controls the number conversion of section number elements. See {{cmd|definestructureconversionset}}.</cd:paramdoc> |
<cd:constant type="cd:name"></cd:constant> | <cd:constant type="cd:name"></cd:constant> | ||
</cd:parameter> | </cd:parameter> | ||
<cd:parameter name="conversion"> | <cd:parameter name="conversion"> | ||
− | <cd:paramdoc></cd:paramdoc> | + | <cd:paramdoc>Number conversion setting, e.g. "romannumerals", see {{cmd|defineconversion}}.</cd:paramdoc> |
<cd:constant type="cd:name"></cd:constant> | <cd:constant type="cd:name"></cd:constant> | ||
</cd:parameter> | </cd:parameter> | ||
Line 68: | Line 68: | ||
</cd:parameter> | </cd:parameter> | ||
<cd:parameter name="sectionset"> | <cd:parameter name="sectionset"> | ||
− | <cd:paramdoc></cd:paramdoc> | + | <cd:paramdoc>Name of a section set (defined with {{cmd|defineprefixset}}) that sets the order of section segments (levels).</cd:paramdoc> |
<cd:constant type="cd:name"></cd:constant> | <cd:constant type="cd:name"></cd:constant> | ||
</cd:parameter> | </cd:parameter> | ||
<cd:parameter name="sectionsegments"> | <cd:parameter name="sectionsegments"> | ||
− | <cd:paramdoc> | + | <cd:paramdoc>Which heading level(s) should be included in numbering?</cd:paramdoc> |
<cd:constant type="cd:number"></cd:constant> | <cd:constant type="cd:number"></cd:constant> | ||
<cd:constant method="range" prefix="cd:number" type="cd:number"></cd:constant> | <cd:constant method="range" prefix="cd:number" type="cd:number"></cd:constant> | ||
<cd:constant method="range" prefix="cd:number" type="*"></cd:constant> | <cd:constant method="range" prefix="cd:number" type="*"></cd:constant> | ||
<cd:constant method="range" prefix="cd:number" type="all"></cd:constant> | <cd:constant method="range" prefix="cd:number" type="all"></cd:constant> | ||
− | <cd:constant type="cd:section"></cd:constant> | + | <cd:constant type="cd:section">only this level, e.g. "chapter"</cd:constant> |
− | <cd:constant method="range" prefix="cd:section" type="cd:section"></cd:constant> | + | <cd:constant method="range" prefix="cd:section" type="cd:section">range of levels, e.g. "chapter:subsubsection"</cd:constant> |
− | <cd:constant method="range" prefix="cd:section" type="*"></cd:constant> | + | <cd:constant method="range" prefix="cd:section" type="*">range of levels “this and all below”, e.g. "chapter:*"</cd:constant> |
<cd:constant method="range" prefix="cd:section" type="all"></cd:constant> | <cd:constant method="range" prefix="cd:section" type="all"></cd:constant> | ||
− | <cd:constant type="current"></cd:constant> | + | <cd:constant type="current">only the current level (makes sense if you use \setuphead with several levels)</cd:constant> |
</cd:parameter> | </cd:parameter> | ||
<cd:parameter name="referenceprefix"> | <cd:parameter name="referenceprefix"> | ||
Line 90: | Line 90: | ||
</cd:parameter> | </cd:parameter> | ||
<cd:parameter name="style"> | <cd:parameter name="style"> | ||
− | <cd:paramdoc>See manual [https://www.pragma-ade.com/general/manuals/ma-cb-en.pdf#page=81 Context: an excursion" section 33], Fonts and font switches, e.g. for large, bold, sans serif section headers use <code>style=\tfa\bf\ss</code>.</cd:paramdoc> | + | <cd:paramdoc>The style to use for the heading text and number. See manual [https://www.pragma-ade.com/general/manuals/ma-cb-en.pdf#page=81 Context: an excursion" section 33], Fonts and font switches, e.g. for large, bold, sans serif section headers use <code>style=\tfa\bf\ss</code>.</cd:paramdoc> |
− | <cd:constant type="cd:style"></cd:constant> | + | <cd:constant type="cd:style">style keywords ("boldface") or commands ("\ss\bf")</cd:constant> |
− | <cd:constant type="cd:command"></cd:constant> | + | <cd:constant type="cd:command">custom macro</cd:constant> |
</cd:parameter> | </cd:parameter> | ||
<cd:parameter name="color"> | <cd:parameter name="color"> | ||
− | <cd:paramdoc></cd:paramdoc> | + | <cd:paramdoc>Color to use for the heading text and number.</cd:paramdoc> |
− | <cd:constant type="cd:color"></cd:constant> | + | <cd:constant type="cd:color">defined color name</cd:constant> |
</cd:parameter> | </cd:parameter> | ||
<cd:parameter name="textstyle"> | <cd:parameter name="textstyle"> | ||
− | <cd:paramdoc></cd:paramdoc> | + | <cd:paramdoc>Style to use for the heading text.</cd:paramdoc> |
<cd:constant type="cd:style"></cd:constant> | <cd:constant type="cd:style"></cd:constant> | ||
<cd:constant type="cd:command"></cd:constant> | <cd:constant type="cd:command"></cd:constant> | ||
</cd:parameter> | </cd:parameter> | ||
<cd:parameter name="textcolor"> | <cd:parameter name="textcolor"> | ||
− | <cd:paramdoc></cd:paramdoc> | + | <cd:paramdoc>Color to use for the heading text.</cd:paramdoc> |
<cd:constant type="cd:color"></cd:constant> | <cd:constant type="cd:color"></cd:constant> | ||
</cd:parameter> | </cd:parameter> | ||
<cd:parameter name="numberstyle"> | <cd:parameter name="numberstyle"> | ||
− | <cd:paramdoc></cd:paramdoc> | + | <cd:paramdoc>Color to use for the heading number.</cd:paramdoc> |
<cd:constant type="cd:style"></cd:constant> | <cd:constant type="cd:style"></cd:constant> | ||
<cd:constant type="cd:command"></cd:constant> | <cd:constant type="cd:command"></cd:constant> | ||
</cd:parameter> | </cd:parameter> | ||
<cd:parameter name="numbercolor"> | <cd:parameter name="numbercolor"> | ||
− | <cd:paramdoc></cd:paramdoc> | + | <cd:paramdoc>Color to use for the heading number.</cd:paramdoc> |
<cd:constant type="cd:color"></cd:constant> | <cd:constant type="cd:color"></cd:constant> | ||
</cd:parameter> | </cd:parameter> | ||
Line 121: | Line 121: | ||
</cd:parameter> | </cd:parameter> | ||
<cd:parameter name="ownnumber"> | <cd:parameter name="ownnumber"> | ||
− | <cd:paramdoc></cd:paramdoc> | + | <cd:paramdoc>Set a custom section number; doesn’t change the numbering, e.g. the next chapter after <code>\startchapter[ownnumber=12]</code> will ''not'' get numbered 13.</cd:paramdoc> |
<cd:constant type="yes"></cd:constant> | <cd:constant type="yes"></cd:constant> | ||
<cd:constant default="yes" type="no"></cd:constant> | <cd:constant default="yes" type="no"></cd:constant> | ||
</cd:parameter> | </cd:parameter> | ||
<cd:parameter name="beforesection"> | <cd:parameter name="beforesection"> | ||
− | <cd:paramdoc></cd:paramdoc> | + | <cd:paramdoc>Command to run before the section.</cd:paramdoc> |
<cd:constant type="cd:command"></cd:constant> | <cd:constant type="cd:command"></cd:constant> | ||
</cd:parameter> | </cd:parameter> | ||
<cd:parameter name="aftersection"> | <cd:parameter name="aftersection"> | ||
− | <cd:paramdoc></cd:paramdoc> | + | <cd:paramdoc>Command to run after the section finishes e.g. at a <code>\stopchapter</code> statement.</cd:paramdoc> |
<cd:constant type="cd:command"></cd:constant> | <cd:constant type="cd:command"></cd:constant> | ||
</cd:parameter> | </cd:parameter> | ||
Line 154: | Line 154: | ||
<cd:parameter name="number"> | <cd:parameter name="number"> | ||
<cd:paramdoc></cd:paramdoc> | <cd:paramdoc></cd:paramdoc> | ||
− | <cd:constant default="yes" type="yes"> | + | <cd:constant default="yes" type="yes">Show number in chapter/section title</cd:constant> |
− | <cd:constant type="no">Do not | + | <cd:constant type="no">Do not show number in chapter/section title</cd:constant> |
</cd:parameter> | </cd:parameter> | ||
<cd:parameter name="page"> | <cd:parameter name="page"> | ||
Line 191: | Line 191: | ||
</cd:parameter> | </cd:parameter> | ||
<cd:parameter name="footer"> | <cd:parameter name="footer"> | ||
− | <cd:paramdoc></cd:paramdoc> | + | <cd:paramdoc>Set a particular footer style, see {{cmd|setupheader}}.</cd:paramdoc> |
<cd:constant type="start"></cd:constant> | <cd:constant type="start"></cd:constant> | ||
<cd:constant type="stop"></cd:constant> | <cd:constant type="stop"></cd:constant> | ||
Line 202: | Line 202: | ||
</cd:parameter> | </cd:parameter> | ||
<cd:parameter name="before"> | <cd:parameter name="before"> | ||
− | <cd:paramdoc></cd:paramdoc> | + | <cd:paramdoc>Command to run before the heading is written</cd:paramdoc> |
<cd:constant type="cd:command"></cd:constant> | <cd:constant type="cd:command"></cd:constant> | ||
</cd:parameter> | </cd:parameter> | ||
<cd:parameter name="after"> | <cd:parameter name="after"> | ||
− | <cd:paramdoc></cd:paramdoc> | + | <cd:paramdoc>Command to run after the heading is written, e.g. <code>after={\blank[3cm]}</code></cd:paramdoc> |
<cd:constant type="cd:command"></cd:constant> | <cd:constant type="cd:command"></cd:constant> | ||
</cd:parameter> | </cd:parameter> | ||
Line 215: | Line 215: | ||
<cd:parameter name="continue"> | <cd:parameter name="continue"> | ||
<cd:paramdoc></cd:paramdoc> | <cd:paramdoc></cd:paramdoc> | ||
− | <cd:constant default="yes" type="yes">If the section immediately follows a | + | <cd:constant default="yes" type="yes">If the section immediately follows a higher level section it will be on the same page even if page=yes.</cd:constant> |
− | <cd:constant type="no">If the section immediately follows a | + | <cd:constant type="no">If the section immediately follows a higher level section it will start on a new page.</cd:constant> |
</cd:parameter> | </cd:parameter> | ||
<cd:parameter name="aligntitle"> | <cd:parameter name="aligntitle"> | ||
Line 225: | Line 225: | ||
</cd:parameter> | </cd:parameter> | ||
<cd:parameter name="interlinespace"> | <cd:parameter name="interlinespace"> | ||
− | <cd:paramdoc></cd:paramdoc> | + | <cd:paramdoc>Set the line height differently from the body text, see {{cmd|setupinterlinespace}}.</cd:paramdoc> |
<cd:constant type="cd:name"></cd:constant> | <cd:constant type="cd:name"></cd:constant> | ||
</cd:parameter> | </cd:parameter> | ||
Line 238: | Line 238: | ||
</cd:parameter> | </cd:parameter> | ||
<cd:parameter name="grid"> | <cd:parameter name="grid"> | ||
− | <cd:paramdoc></cd:paramdoc> | + | <cd:paramdoc>How to vertically align this title in grid mode. Find examples in [https://www.pragma-ade.com/general/manuals/details.pdf details manual].</cd:paramdoc> |
<cd:constant type="normal"></cd:constant> | <cd:constant type="normal"></cd:constant> | ||
<cd:constant type="standard"></cd:constant> | <cd:constant type="standard"></cd:constant> | ||
Line 269: | Line 269: | ||
</cd:parameter> | </cd:parameter> | ||
<cd:parameter name="align"> | <cd:parameter name="align"> | ||
− | <cd:paramdoc></cd:paramdoc> | + | <cd:paramdoc>Alignment of the title text</cd:paramdoc> |
<cd:inherit name="setupalign"></cd:inherit> | <cd:inherit name="setupalign"></cd:inherit> | ||
</cd:parameter> | </cd:parameter> | ||
<cd:parameter name="tolerance"> | <cd:parameter name="tolerance"> | ||
− | <cd:paramdoc></cd:paramdoc> | + | <cd:paramdoc>Line breaking tolerance</cd:paramdoc> |
<cd:inherit name="setuptolerance"></cd:inherit> | <cd:inherit name="setuptolerance"></cd:inherit> | ||
</cd:parameter> | </cd:parameter> | ||
<cd:parameter name="strut"> | <cd:parameter name="strut"> | ||
− | <cd:paramdoc></cd:paramdoc> | + | <cd:paramdoc>Use a {{cmd|strut}} to ensure the full line height?</cd:paramdoc> |
<cd:constant default="yes" type="yes"></cd:constant> | <cd:constant default="yes" type="yes"></cd:constant> | ||
<cd:constant type="no"></cd:constant> | <cd:constant type="no"></cd:constant> | ||
</cd:parameter> | </cd:parameter> | ||
<cd:parameter name="hang"> | <cd:parameter name="hang"> | ||
− | <cd:paramdoc></cd:paramdoc> | + | <cd:paramdoc>Control protrusion (hanging)</cd:paramdoc> |
<cd:constant type="line"></cd:constant> | <cd:constant type="line"></cd:constant> | ||
<cd:constant type="broad"></cd:constant> | <cd:constant type="broad"></cd:constant> | ||
Line 294: | Line 294: | ||
</cd:parameter> | </cd:parameter> | ||
<cd:parameter name="indentnext"> | <cd:parameter name="indentnext"> | ||
− | <cd:paramdoc></cd:paramdoc> | + | <cd:paramdoc>Indent following paragraph?</cd:paramdoc> |
<cd:constant type="yes"></cd:constant> | <cd:constant type="yes"></cd:constant> | ||
<cd:constant type="no"></cd:constant> | <cd:constant type="no"></cd:constant> | ||
Line 314: | Line 314: | ||
</cd:parameter> | </cd:parameter> | ||
<cd:parameter name="width"> | <cd:parameter name="width"> | ||
− | <cd:paramdoc></cd:paramdoc> | + | <cd:paramdoc>Width of the whole title.</cd:paramdoc> |
<cd:constant type="cd:dimension"></cd:constant> | <cd:constant type="cd:dimension"></cd:constant> | ||
</cd:parameter> | </cd:parameter> | ||
<cd:parameter name="numberwidth"> | <cd:parameter name="numberwidth"> | ||
− | <cd:paramdoc></cd:paramdoc> | + | <cd:paramdoc>Width of the section number.</cd:paramdoc> |
<cd:constant type="cd:dimension"></cd:constant> | <cd:constant type="cd:dimension"></cd:constant> | ||
</cd:parameter> | </cd:parameter> | ||
<cd:parameter name="textwidth"> | <cd:parameter name="textwidth"> | ||
− | <cd:paramdoc></cd:paramdoc> | + | <cd:paramdoc>Width of the section title.</cd:paramdoc> |
<cd:constant type="cd:dimension"></cd:constant> | <cd:constant type="cd:dimension"></cd:constant> | ||
</cd:parameter> | </cd:parameter> | ||
Line 342: | Line 342: | ||
</cd:parameter> | </cd:parameter> | ||
<cd:parameter name="command"> | <cd:parameter name="command"> | ||
− | <cd:paramdoc></cd:paramdoc> | + | <cd:paramdoc>Command to use for typesetting the title; overrules all other styling. First argument is the number, second the title text.</cd:paramdoc> |
<cd:constant type="cd:twoarguments"></cd:constant> | <cd:constant type="cd:twoarguments"></cd:constant> | ||
</cd:parameter> | </cd:parameter> | ||
<cd:parameter name="textcommand"> | <cd:parameter name="textcommand"> | ||
− | <cd:paramdoc></cd:paramdoc> | + | <cd:paramdoc>Command to use for typesetting the text of the title; argument is the formatted text.</cd:paramdoc> |
<cd:constant type="cd:oneargument"></cd:constant> | <cd:constant type="cd:oneargument"></cd:constant> | ||
</cd:parameter> | </cd:parameter> | ||
<cd:parameter name="deeptextcommand"> | <cd:parameter name="deeptextcommand"> | ||
− | <cd:paramdoc></cd:paramdoc> | + | <cd:paramdoc>Like <tt>textcommand</tt>, but text is unformatted.</cd:paramdoc> |
<cd:constant type="cd:oneargument"></cd:constant> | <cd:constant type="cd:oneargument"></cd:constant> | ||
</cd:parameter> | </cd:parameter> | ||
<cd:parameter name="numbercommand"> | <cd:parameter name="numbercommand"> | ||
− | <cd:paramdoc></cd:paramdoc> | + | <cd:paramdoc>Command to use for typesetting the number of the title; argument is the formatted number.</cd:paramdoc> |
<cd:constant type="cd:oneargument"></cd:constant> | <cd:constant type="cd:oneargument"></cd:constant> | ||
</cd:parameter> | </cd:parameter> | ||
<cd:parameter name="deepnumbercommand"> | <cd:parameter name="deepnumbercommand"> | ||
− | <cd:paramdoc></cd:paramdoc> | + | <cd:paramdoc>Like <tt>numbercommand</tt>, but number is unformatted.</cd:paramdoc> |
<cd:constant type="cd:oneargument"></cd:constant> | <cd:constant type="cd:oneargument"></cd:constant> | ||
</cd:parameter> | </cd:parameter> | ||
Line 435: | Line 435: | ||
\mychapter{Animals} | \mychapter{Animals} | ||
\stoptext | \stoptext | ||
− | </context></cd:example><cd:example title="Inline headings similar to | + | </context></cd:example><cd:example title="Inline headings similar to LaTeX’s <code>\paragraph{}</code>">Modified from (https://tex.stackexchange.com/questions/375922/paragraph-title-in-context-similar-to-latex-paragraph). |
<context mode="mkiv" source="yes" text="produces"> | <context mode="mkiv" source="yes" text="produces"> | ||
Line 450: | Line 450: | ||
\input knuth | \input knuth | ||
\stopparagraph | \stopparagraph | ||
− | </context></cd:example><cd:example title="Setting label of a part"> | + | </context></cd:example><cd:example title="Setting label of a part">If you want parts to be labeled as "Part 1" etc., add <code>bodypartlabel=part</code>: |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
<context mode="mkiv" source="yes"> | <context mode="mkiv" source="yes"> | ||
Line 471: | Line 460: | ||
\stoptext | \stoptext | ||
</context> | </context> | ||
− | |||
− | |||
</cd:example><cd:example title="Example of hidden sections"><context mode="mkiv" source="yes" text="produces"> | </cd:example><cd:example title="Example of hidden sections"><context mode="mkiv" source="yes" text="produces"> | ||
\setupheadnumber[section] [8] | \setupheadnumber[section] [8] | ||
Line 537: | Line 524: | ||
</context> | </context> | ||
− | The command | + | The command {{cmd|pushbackground}} stores the values of the background which is modified. After the execution of \page[right] the old values of background are restored by {{cmd|popbackground}}. |
</cd:example><cd:example title="Special facing pages for chapters">On March 7, 2022, Julian asked on the mailing list about some method to place an image on the facing page of each chapter in a (double-sided) book. Chapters might also end on an even (equivalently, left) page, in which case, an empty right (odd) page should be introduced after so that the next chapter still has its image on its facing (left) page. (https://www.mail-archive.com/ntg-context@ntg.nl/msg101455.html) | </cd:example><cd:example title="Special facing pages for chapters">On March 7, 2022, Julian asked on the mailing list about some method to place an image on the facing page of each chapter in a (double-sided) book. Chapters might also end on an even (equivalently, left) page, in which case, an empty right (odd) page should be introduced after so that the next chapter still has its image on its facing (left) page. (https://www.mail-archive.com/ntg-context@ntg.nl/msg101455.html) | ||
Line 543: | Line 530: | ||
<context source="yes" text="which produces"> | <context source="yes" text="which produces"> | ||
− | % | + | % to render examples in the wiki |
− | \ | + | \definepapersize[sheet][width=24cm,height=24cm] |
− | \ | + | \definepapersize[page][width=6cm,height=6cm] |
− | \ | + | \setuppapersize[page][sheet] |
+ | \setuppaper[nx=4, ny=4] | ||
\setuparranging [XY] | \setuparranging [XY] | ||
\setupbodyfont[6pt] | \setupbodyfont[6pt] | ||
− | + | % actual example starts here | |
− | |||
\setupexternalfigures | \setupexternalfigures | ||
[location=default] | [location=default] | ||
Line 566: | Line 553: | ||
[chapter:insert] | [chapter:insert] | ||
[previouspage] | [previouspage] | ||
− | [pagestate=stop] | + | [pagestate=stop,width=\paperwidth] |
\setuphead | \setuphead | ||
Line 575: | Line 562: | ||
\starttext | \starttext | ||
− | \startchapter [title={Mill}] [image= | + | \startchapter [title={Cow}] [image=cow] |
− | \dorecurse{ | + | \dorecurse{2}{\samplefile{klein}} |
+ | \stopchapter | ||
+ | |||
+ | \startchapter [title={Mill}] [image=hacker] | ||
+ | \dorecurse{4}{\samplefile{lorem}} | ||
\stopchapter | \stopchapter | ||
\startchapter [title={Mill}] [image=mill] | \startchapter [title={Mill}] [image=mill] | ||
− | \dorecurse{2}{\samplefile{ | + | \dorecurse{2}{\samplefile{klein}} |
\stopchapter | \stopchapter | ||
+ | \stoptext | ||
+ | </context> | ||
+ | |||
+ | The source code is in {{src|page-inj.mklx}}.</cd:example><cd:example title="Different order of number elements">You need a new prefix-set to rearrange the order of the section numbers: | ||
+ | |||
+ | <context source="yes" text="produces"> | ||
+ | \defineprefixset [reverse-section] [section,chapter] [] | ||
+ | \defineprefixset [reverse-subsection] [subsection,section,chapter] [] | ||
+ | |||
+ | \setuphead[section][sectionset=reverse-section] | ||
+ | \setuphead[subsection][sectionset=reverse-subsection] | ||
+ | |||
+ | \starttext | ||
+ | |||
+ | \startchapter [title={A}] | ||
+ | |||
+ | \startsection [title={B}] | ||
+ | |||
+ | \startsubsection [title={C}] \stopsubsection | ||
+ | \startsubsection [title={D}] \stopsubsection | ||
+ | \startsubsection [title={E}] \stopsubsection | ||
+ | |||
+ | \stopsection | ||
+ | |||
+ | \startsection [title={F}] | ||
+ | |||
+ | \startsubsection [title={G}] \stopsubsection | ||
+ | \startsubsection [title={H}] \stopsubsection | ||
+ | \startsubsection [title={I}] \stopsubsection | ||
+ | |||
+ | \stopsection | ||
− | |||
− | |||
\stopchapter | \stopchapter | ||
\stoptext | \stoptext | ||
− | </context></cd:example></cd:examples> | + | </context> |
+ | |||
+ | (Example by Wolfgang Schuster on 2023-01-01)</cd:example><cd:example title="Leading zeros in section numbers">You can create your own conversion format: | ||
+ | |||
+ | <context source="yes" text="produces"> | ||
+ | \startluacode | ||
+ | interfaces.implement { | ||
+ | name = "FourDigits", | ||
+ | public = true, | ||
+ | arguments = "string", | ||
+ | actions = function(s) context("%04d",tonumber(s)) end | ||
+ | } | ||
+ | \stopluacode | ||
+ | |||
+ | \defineconversion [FourDigits] [\FourDigits] | ||
+ | |||
+ | \setuphead | ||
+ | [chapter] | ||
+ | [conversion=FourDigits] | ||
+ | |||
+ | \starttext | ||
+ | |||
+ | \startchapter [title={Chapter}] \stopchapter | ||
+ | |||
+ | \stoptext | ||
+ | </context> | ||
+ | |||
+ | (Example by Wolfgang Schuster on 2023-01-01)</cd:example></cd:examples> | ||
<cd:notes></cd:notes> | <cd:notes></cd:notes> | ||
<cd:seealso> | <cd:seealso> | ||
Line 596: | Line 643: | ||
<cd:commandref name="setuptolerance" originator="system"></cd:commandref> | <cd:commandref name="setuptolerance" originator="system"></cd:commandref> | ||
<cd:source file="strc-sec.mkiv" originator="system"></cd:source> | <cd:source file="strc-sec.mkiv" originator="system"></cd:source> | ||
− | <cd:wikipage originator="system" page="Category:Structure"></cd:wikipage></cd:seealso> | + | <cd:wikipage originator="system" page="Category:Structure"></cd:wikipage> |
+ | <cd:source file="page-inj.mklx">(page injections)</cd:source></cd:seealso> | ||
</cd:commandgroup> | </cd:commandgroup> |
Latest revision as of 15:02, 8 September 2023
Contents
- 1 \setuphead
- 1.1 Summary
- 1.2 Settings
- 1.3 Description
- 1.4 Examples
- 1.4.1 First example
- 1.4.2 Big space before a smaller space behind the heading
- 1.4.3 Setting label of a new section head
- 1.4.4 Inline headings similar to LaTeX’s \paragraph{}
- 1.4.5 Setting label of a part
- 1.4.6 Example of hidden sections
- 1.4.7 Modifying the page before a chapter
- 1.4.8 Special facing pages for chapters
- 1.4.9 Different order of number elements
- 1.4.10 Leading zeros in section numbers
- 1.5 Notes
- 1.6 See also
- 1.7 Help from ConTeXt-Mailinglist/Forum
\setuphead
Summary
Settings
\setuphead[...,...][...=...,...] | |
[...,...] | section |
frontpartlabel | name |
bodypartlabel | name |
appendixlabel | name |
backpartlabel | name |
expansion | yes no xml |
catcodes | name |
sectionresetset | name |
sectionseparatorset | name |
sectionconversionset | name |
conversion | name |
sectionstarter | command processor->command |
sectionstopper | command processor->command |
sectionset | name |
sectionsegments | number number:number number:* number:all section section:section section:* section:all current |
referenceprefix | + - text |
style | style command |
color | color |
textstyle | style command |
textcolor | color |
numberstyle | style command |
numbercolor | color |
coupling | section |
ownnumber | yes no |
beforesection | command |
aftersection | command |
insidesection | command |
incrementnumber | yes no list empty |
placehead | yes no hidden empty section |
number | yes no |
page | see \page |
marking | page reset |
header | start stop high none normal empty nomarking name |
text | start stop high none normal empty nomarking name |
footer | start stop high none normal empty nomarking name |
before | command |
after | command |
inbetween | command |
continue | yes no |
aligntitle | yes no float |
interlinespace | name |
interaction | list reference |
internalgrid | name |
grid | normal standard yes strict tolerant top bottom both broad fit first last high one low none line strut box min max middle math math:line math:halfline math:-line math:-halfline name |
align | see \setupalign |
tolerance | see \setuptolerance |
strut | yes no |
hang | line broad fit none number |
margin | dimension |
indentnext | yes no auto |
alternative | text paragraph normal margin inmargin top middle bottom reverse margintext name |
width | dimension |
numberwidth | dimension |
textwidth | dimension |
distance | dimension |
textdistance | dimension |
commandbefore | command |
commandafter | command |
command | twoarguments |
textcommand | oneargument |
deeptextcommand | oneargument |
numbercommand | oneargument |
deepnumbercommand | oneargument |
location | name |
criterium | strict positive all |
hidenumber | yes no |
Option | Explanation | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Section level, e.g. chapter, section, subsection or number (1=part, 2=chapter). Can be a list. | |||||||||||
frontpartlabel |
| ||||||||||
bodypartlabel |
| ||||||||||
appendixlabel |
| ||||||||||
backpartlabel |
| ||||||||||
expansion |
| ||||||||||
sectionresetset |
| ||||||||||
sectionseparatorset |
| ||||||||||
sectionconversionset |
| ||||||||||
conversion |
| ||||||||||
sectionset |
| ||||||||||
sectionsegments |
| ||||||||||
style |
| ||||||||||
color |
| ||||||||||
textstyle |
| ||||||||||
textcolor |
| ||||||||||
numberstyle |
| ||||||||||
numbercolor |
| ||||||||||
ownnumber |
| ||||||||||
beforesection |
| ||||||||||
aftersection |
| ||||||||||
number |
| ||||||||||
page |
| ||||||||||
header |
| ||||||||||
footer |
| ||||||||||
before |
| ||||||||||
after |
| ||||||||||
continue |
| ||||||||||
aligntitle |
| ||||||||||
interlinespace |
| ||||||||||
grid |
| ||||||||||
align |
| ||||||||||
tolerance |
| ||||||||||
strut |
| ||||||||||
hang |
| ||||||||||
indentnext |
| ||||||||||
width |
| ||||||||||
numberwidth |
| ||||||||||
textwidth |
| ||||||||||
command |
| ||||||||||
textcommand |
| ||||||||||
deeptextcommand |
| ||||||||||
numbercommand |
| ||||||||||
deepnumbercommand |
|
Description
These data can be processed for typesetting :
- add a dot between the text and the number,
- add a generic text before the "pure text"
- appearance can be different for the text if we use it in the headers / footers, or in the Table of Content.
- add vertical spaces before or after the text
- add rules before or after the whole section under the heading
- select if the title should appear on a right or a left page.
Examples
First example
\setuppapersize[A5] \setuplabeltext[chapter=CHAPTER~] \setuphead[chapter][ header=empty, alternative=middle, style=bold, numbercommand=\groupedcommand{}{\blank[2cm]}, after={\blank[3cm]}, ] \starttext \chapter{Title of chapter} The first paragraph begins 3 cm below the title. In this chapter, we will discuss... \stoptext
produces
Big space before a smaller space behind the heading
\setuphead [subject] [before={\blank[2*big]}, after={\blank[big]}, style=bold] \starttext \subject{Headline 1} text text text text text text text text text text text text text text text vtext text text text text text text text text text text text text\par \subject{Headline 2} text text text text text text text text text text text text text text text vtext text text text text text text text text text text text text\par \stoptext
produces
Setting label of a new section head
\definehead[mychapter][chapter][bodypartlabel=mychapter] \setuplabeltext[en][mychapter=My Chapter~] \starttext \mychapter{Animals} \stoptext
produces
Inline headings similar to LaTeX’s \paragraph{}
Modified from (https://tex.stackexchange.com/questions/375922/paragraph-title-in-context-similar-to-latex-paragraph).
\definehead[paragraph][subsubsubsubject] \setuphead [paragraph] [ textdistance=0pt, commandafter={.}, alternative=text, style=sc, ] \startparagraph[title=Knuth quote] \input knuth \stopparagraph
produces
Setting label of a part
If you want parts to be labeled as "Part 1" etc., add bodypartlabel=part
:
\setuphead[part][placehead=yes, bodypartlabel=part] \starttext \part{A part} \stoptext
\setupheadnumber[section] [8] \setupheadnumber[subsection] [3] \setupheadnumber[subsubsection][5] \setuphead[section,subsection][placehead=hidden] \setuphead[subsubsection] [placehead=yes] \starttext \section{} % hidden 8th section \subsection{} % hidden 3rd section \subsubsection{This is complete numbering of subsubsection} % view 9.4.6 subsubsection \stoptext
produces
Modifying the page before a chapter
Here is an example which shows how you can change the background color of an empty page before the chapter title.
% next five lines just to show the effect on this wiki \setuppapersize[A8][A5,landscape] \setuppaper[nx=4, ny=2] \setuplayout[page][location=middle, marking=on] \setuparranging [XY] \setupbodyfont[6pt] % actual example starts here \setuppagenumbering [alternative=doublesided] \startsetups [chapter:before] \doifoddpageelse {} {\pushbackground[page] \setupbackgrounds[page][background=color,backgroundcolor=gray] \page[right] \popbackground} \stopsetups \setuphead [chapter] [page=yes, before=\directsetup{chapter:before}] \starttext \startchapter[title={Knuth}] \dorecurse{2}{\samplefile{knuth}} \stopchapter \startchapter[title={Ward}] \dorecurse{1}{\samplefile{ward}} \stopchapter \startchapter[title={Zapf}] \dorecurse{2}{\samplefile{zapf}} \stopchapter \stoptext
produces
The command \pushbackground stores the values of the background which is modified. After the execution of \page[right] the old values of background are restored by \popbackground.
Special facing pages for chapters
On March 7, 2022, Julian asked on the mailing list about some method to place an image on the facing page of each chapter in a (double-sided) book. Chapters might also end on an even (equivalently, left) page, in which case, an empty right (odd) page should be introduced after so that the next chapter still has its image on its facing (left) page. (https://www.mail-archive.com/ntg-context@ntg.nl/msg101455.html)
In the discussion that ensued, Wolfgang posted the following elegant solution using \definepageinjection [slightly re-formatted from (https://www.mail-archive.com/ntg-context@ntg.nl/msg101462.html)] —
% to render examples in the wiki \definepapersize[sheet][width=24cm,height=24cm] \definepapersize[page][width=6cm,height=6cm] \setuppapersize[page][sheet] \setuppaper[nx=4, ny=4] \setuparranging [XY] \setupbodyfont[6pt] % actual example starts here \setupexternalfigures [location=default] \setuppagenumbering [alternative=doublesided] \definepageinjection [chapter:start] [empty] [page=left] \definepageinjection [chapter:insert] [previouspage] [pagestate=stop,width=\paperwidth] \setuphead [chapter] [beforesection={\pageinjection[chapter:start]}, insidesection={\pageinjection[chapter:insert][name=\structureuservariable{image}]}] \starttext \startchapter [title={Cow}] [image=cow] \dorecurse{2}{\samplefile{klein}} \stopchapter \startchapter [title={Mill}] [image=hacker] \dorecurse{4}{\samplefile{lorem}} \stopchapter \startchapter [title={Mill}] [image=mill] \dorecurse{2}{\samplefile{klein}} \stopchapter \stoptext
which produces
The source code is in page-inj.mklx.
Different order of number elements
You need a new prefix-set to rearrange the order of the section numbers:
\defineprefixset [reverse-section] [section,chapter] [] \defineprefixset [reverse-subsection] [subsection,section,chapter] [] \setuphead[section][sectionset=reverse-section] \setuphead[subsection][sectionset=reverse-subsection] \starttext \startchapter [title={A}] \startsection [title={B}] \startsubsection [title={C}] \stopsubsection \startsubsection [title={D}] \stopsubsection \startsubsection [title={E}] \stopsubsection \stopsection \startsection [title={F}] \startsubsection [title={G}] \stopsubsection \startsubsection [title={H}] \stopsubsection \startsubsection [title={I}] \stopsubsection \stopsection \stopchapter \stoptext
produces
(Example by Wolfgang Schuster on 2023-01-01)
Leading zeros in section numbers
You can create your own conversion format:
\startluacode interfaces.implement { name = "FourDigits", public = true, arguments = "string", actions = function(s) context("%04d",tonumber(s)) end } \stopluacode \defineconversion [FourDigits] [\FourDigits] \setuphead [chapter] [conversion=FourDigits] \starttext \startchapter [title={Chapter}] \stopchapter \stoptext
produces
(Example by Wolfgang Schuster on 2023-01-01)
Notes
See also
- \definehead
- \page
- \setupalign
- \setuptolerance
- strc-sec.mkiv
- page-inj.mklx (page injections)