Changes

Jump to navigation Jump to search
14,109 bytes added ,  08:47, 16 July 2018
m
Added a backslash to make the exemple compile
Titles define the structure of your document. Decide yourself, how deep you want to nest them:
<table>{| class=wikitable<tr bgcolor="#CCCCCC"><th>numbered</th><th>unnumbered</th></tr>! Numbered !! Unnumbered|- <tr><td><| {{cmd>|part</cmd></td><td>}} || &#151;</td></tr><tr><td><|-| {{cmd>|chapter</cmd></td><td><}} || {{cmd>|title</cmd></td></tr>}}|-<tr><td><| {{cmd>|section</cmd></td><td><}} || {{cmd>|subject</cmd></td></tr>}}|-<tr><td><| {{cmd>|subsection</}} || {{cmd></td><td><cmd>|subsubject</cmd></td></tr>}}|-<tr><td><| {{cmd>|subsubsection</cmd></td><td><}} || {{cmd>|subsubsubject</cmd></td></tr>}}|-<tr><td>| ...</td><td>|| ...</td></tr></table>|}
The "unnumbered" versions don't appear in a table of contents! But you can switch off To change that, see the numbering section on [[#Unnumbered_titles_in_table_of_contents|Unnumbered titles in the table of contents]]. Also note that in the "numbered" versions with <cmd>setuphead</cmd> to get front matter of the document, all titles are unnumbered by default. The titles from the 'numbered'category still show up in the table of contents, though, andthe titles from the 'unnumbered'category still don' a toc (confusing?)t.
===Referencing Titles===
Every heading command can take an optional parameter as reference:
 
<texcode>
\title[hasselt-by-night]{Hasselt by night}
</texcode>
The bracket pair is optional and used for internal [[References]]. If you want to refer to thisheader you type for example 
<texcode>
\at{page}[hasselt-by-night].
</texcode>
 See {{cmd|at}}. Note that reference labels are limited to ASCII characters in traditional TeX.This limitation has been removed in ConTeXt mkiv. ==New MkIV Sectioning== ConTeXt MkIV adds several new commands which supersede the older {{cmd|chapter}}, {{cmd|section}} etc. The new commands are more verbose, but also more flexible, and allow better support for tagged-PDF, XML and ePUB output. {| class=wikitable! Traditional !! New|-| {{cmd|part}} || {{cmd|startpart}}|- | {{cmd|chapter}} || {{cmd|startchapter}}|-| {{cmd|section}} || {{cmd|startsection}}|-| {{cmd|subsection}} || {{cmd|startsubsection}}|-| {{cmd|subsubsection}} || {{cmd|startsubsubsection}}|-| {{cmd|title}} || {{cmd|starttitle}}|-| {{cmd|subject}} || {{cmd|startsubject}}|-| ... || ...|} Each of these start-commands has a corresponding stop-command which should be used at the end of the section. For example: <context mode=mkiv source=yes text=produces>% mode=mkiv\setuppapersize[A5] \section[sec:old]{Old Section} This is an old-style \ConTeXt\ section. \startsection [ title={New Section}, reference=sec:new, ] This is a new-style section.\stopsection</context> The following keys are available for the start-commands: {| class=wikitable! Key !! Description|-| reference= || The reference key for cross-referencing (see with {{cmd|at}}, {{cmd|in}} etc.)|-| title= || The title of the section|-| list= || The title to show in the table of contents, if different|-| bookmark= || The title to show in the PDF bookmarks, if different|-| marking= || The title to use in the section marking, if different|-| label= || ?|} It is also possible to set per-section variables, and retrieve them with the {{cmd|structureuservariable}} command: <cmdcontext mode=mkiv source=yes text=produces>at% mode=mkiv\setuppapersize[A5] \startchapter[title={Foo Bar}][foo=bar] foo is \quote{\structureuservariable{foo}} \stopchapter </cmdcontext>)
==Titling Style==
see <{{cmd>|setuphead</cmd> }} and some enhanced samples below. A FAQ is, how to get a line under the pageheader:
A FAQ is how to get a line under the title:
<texcode>
\setupbackgroundssetupheader[header][text][bottomframeafter=on\hrule]
</texcode>
To make the section numbers appear as characters, do
 
<texcode>
\setupsection[section-3][bodypartconversion=Character]
</texcode>
 
The <code>section-3</code> corresponds to <code>section</code>. Similarly,
<code>section-1</code> corresponds to <code>part</code>, <code>section-2</code> corresponds to <code>chapter</code> and so on.
==Titling Alignment==
<texcode>
\setuphead[chapter][align={flushleft, nothyphenated, verytolerant}] % "flushleft" is the same as "right"
</texcode>
===Using colors in chapters and sections===
If you want you may have colors on your document's chapters or sections.
To do that you should use <code>\{{cmd|setuphead</code>}}.Take a look at the following example:
<texcode>
\stoptext
 
</texcode>
\definehead[myheader][section]
\setuphead [myheader] [numberstyle=bold, textstyle=cap, before=\hairline\blank, after=\nowhitespace\hairline]
\myheader[hasselt-ref]{Hasselt makes headlines}
</texcode>
A new header <{{cmd>|myheader</cmd> }} is defined and it inherits the properties of <{{cmd>|section</cmd> }} (title, subject, whatever).You can "''define" '' several headers at once!
==Formatting Titles with <{{cmd>|setuphead</cmd>}}==
<The following parameters to {{cmd>|setuphead</cmd> accepts a number of parameters which }} change the style of the heading. At least the following commands are available:
<table>{| class=wikitable<tr bgcolor="#CCCCCC"><th>text</th><th>number</th></tr>|-! Text !! Number|-<tr><td><tt>| textstyle</tt></td><td><tt>| numberstyle</tt></td></tr><tr><td><tt>|-| textcommand</tt></td><td><tt>| numbercommand</tt></td></tr><tr><td><tt>|-| deeptextcommand</tt></td><td><tt>| deepnumbercommand</tt></td></tr></table>|-|}
Quite obviously, the number-commands work on the chapter/section/etc. number, their text counterparts change the text itself. However, there are differences between <tt>style</tt>, <tt>command</tt> and <tt>deepcommand</tt>.
The <tt>style</tt> variants accept a style (<tt>bold</tt>, <tt>cap</tt>, etc.) or a font switch (<{{cmd>|em</cmd>}}, <{{cmd>|tfx</cmd>}}, etc). <tt>texstyletextstyle</tt> prepends the text with the associated style. <tt>textcommand</tt> is a command name which is given the text (with all markup) as a parameter. <tt>deeptextcommand</tt> is similar to <tt>textcommand</tt> but it acts only on the text (not on the markup).
So, if we have <{{cmd>|title|2={A story}</cmd>}}, the different parameters have the following results:
<table>{||- <tr><td><tt>| textstyle=\em</tt></td><td><tt>| =></tt></td><td><tt>| \em A story</tt></td></tr><tr><td><tt>|- | textstyle=\em, textcommand=\uppercase</tt></td><td><tt>| =></tt></td><td><tt>| \uppercase{\em A story}</tt></td><td><tt>| =></tt></td><td><tt>| \em A STORY</tt></td></tr><tr><td><tt>|- | textstyle=\em, deeptextcommand=\uppercase</tt></td><td><tt>| =></tt></td><td><tt>| \em\uppercase{A story}</tt></td><td><tt>| =></tt></td><td><tt>| \em A STORY</tt></td></tr></table>|-|}
What is the difference between <tt>textcommand</tt> and <tt>deeptextcommand</tt>, then? With this example there is very little difference, as <tt>uppercase</tt> knows how to handle markup. Sometimes this is not the case. For example, an almost similar command <tt>WORD</tt> is not compatible with <tt>textcommand</tt>, because it wreaks havoc with markup:
<table>{| |-<tr><td><tt>| textstyle=\em, textcommand=\WORD</tt></td><td><tt>| =></tt></td><td><tt>| \WORD{\em A story}</tt></td><td><tt>| =></tt></td><td><tt>| \EM A STORY</tt></td></tr><tr><td><tt>|-| textstyle=\em, deeptextcommand=\WORD</tt></td><td><tt>| =></tt></td><td><tt>| \em\WORD{A story}</tt></td><td><tt>| =></tt></td><td><tt>| \em A STORY</tt></td></tr></table>|-|}
In this case using <tt>deeptextcommand</tt> is the correct solution for capitalizing headers. (Using <{{cmd>|uppercase</cmd> }} works in this specific case, but only if you stick to Latin 1 or Anglo-Saxon characters. Other languages will suffer from lowercase accented characters, like CAFé.) Use {{cmd|setuphead}}<tt>[part][conversion=Romannumerals]</tt>, for example, to employ analternative numbering scheme.
=== Truly empty pagebreak before chapters ===
 Using <{{cmd>|setuppagenumbering|2=[alternative=doublesided]</cmd> }} makes the chapters start on the right page. However, the blank page is not truely truly empty, it contains headers and footers. To get truely truly empty pages, use the following
<texcode>
\definepagebreak [mychapterpagebreak] [yes,header,right] % [yes,header,left] % [yes,header,footer,right]
\setuphead [chapter] [page=mychapterpagebreak] % [page=Mychapterpagebreak,header=empty,footer=empty]
% \setupsectionblock[frontpart][page=chapter]% \setupsectionblock[bodypart][page=chapter]% \setupsectionblock[backpart][page=chapter]% \setupsectionblock[appendix][page=chapter]
\setuppagenumbering[alternative=doublesided,location={header,margin}] \setupheadertexts[{My special headertext}] \setupfootertexts[This is a text in the footer] % \setupbackgrounds[header][text][bottomframe=on]
\starttext \chapter {testA} \dorecurse{10}{\input tufte } \chapter {testB} \dorecurse{10}{\input tufte } \chapter {testC} \dorecurse{10}{\input tufte } \stoptext
</texcode>
Explaination '''Explanation''' (provided by Willi Egger on the mailing list)
* You define a new pagebreak rule. It has the name <code>mychapterpagebreak</code>. The options set read as: <code>pagebreak=yes</code>, placeheader, use a right page.
* You set options for the header of type chapter and use for the option page the before afore defined new pagebreak.* You might want to experiment with the commented lines and see what happens. For example, the <code>\{{cmd|setupsectionblock</code> }} commands will give a truly blank page (if needed) after the specified \{{code|1=stop*part }} command.
==== When using front, body, back matters and appendices ====
 
As Wolfgang explained on the mailing list, when using {{code|1=*frontmatter}}, {{code|1=*bodymatter}}, {{code|1=*backmatter}} and {{code|1=*appendices}}, you need to remove the page they create to get the page before a new chapter or part with no headers and footers.
 
<texcode>
\setupsectionblock[frontpart][page=]
\setupsectionblock[bodypart] [page=]
\setupsectionblock[backpart] [page=]
\setupsectionblock[appendix] [page=]
\definepagebreak[firstpagebreak][yes,header,footer,right]
\setuphead[chapter][page=firstpagebreak]
\setuppagenumbering[alternative=doublesided]
\starttext
\startfrontmatter
\chapter{front}
\stopfrontmatter
\startbodymatter
\chapter{body}
\stopbodymatter
\startappendices
\chapter{appendix}
\stopappendices
\startbackmatter
\chapter{back}
\stopbackmatter
\stoptext
</texcode>
== Independent Section Numbering ==
 
If you want section numbering to be independent of chapter numbering, use
<texcode>
\setuphead [chapter][resetnumber=no] \setupsection[section][previousnumber=no]</texcode> This is handled differently in mkiv (where "resetnumber=no" is silently ignored): <texcode>\definestructureresetset[default][1,1,0][1] % reset part, chapter, but not section\setuphead[sectionresetset=default]
</texcode>
==Unnumbered titles in table of contents==
 
Sometimes one wants an unnumbered chapter, say introduction, the following might do that trick:
 
<context source=yes>
\setuppapersize[A5]
 
\definehead [intro] [chapter]
\setuphead [intro] [number=no]
 
\definecombinedlist [content][intro,chapter,section]
\setuplist [intro] [headnumber=no]
 
\starttext
\completecontent
\startfrontmatter
\intro{No number}
\stopfrontmatter
 
\startbodymatter
\chapter{Has number}
\stopbodymatter
\stoptext
</context>
 
Note that just putting the introduction in the frontmatter already did the trick for me (on a recent MkIV).
 
An alternative approach:
<texcode>
\setuphead[title][
incrementnumber=yes, % keep an internal title counter+list
number=no] % don't display the counter
 
% Manually specify the composition of the section and subsection
% numbers, so subsection 1.1 in the second title won't appear as
% Subsection 2.1.1
\setuphead[section][sectionsegments=section]
\setuphead[subsection][sectionsegments=section:subsection]
 
% Redefine the toc list to include titles
\definecombinedlist[content][title, section]
</texcode>
 
== Complete Section Numbering ==
 
You might have documents in which your sections don’t follow the structure, such as in:
 
<texcode>
\section{A}
%\subsection{B}
\subsubsection{C}
</texcode>
 
In that case, you would get <code>1 A</code> <code>1 C</code>. To enable complete section numbering, you would need in this case (using a beta after 2017.08.07 11:30):
 
<texcode>
\setuphead[subsection][criterium=all]
</texcode>
==Your Own Title Styles==
Sometimes the possibilities of <{{cmd>|setuphead</cmd> }} aren't enough. You can define your own styling commands, as shown in the following examples. ===Start the title in the margin=== This very simple example shows how to start a title within the margin, rather than at the text's edge <context source=yes>\setuppapersize[A5]\setuphead[chapter][alternative=margin] \chapter{Sample chapter} Number is in margin, not at text edge.</context> ===Chapter titles in new line===To have the chapter title simply in a new line a new command needs to be defined that takes care of this. It needs to be wrapped in {{cmd|framed}}. <context source=yes>\setuppapersize[A5]\setuplabeltext [en] [chapter=Chapter~]\define[2]\MyChapter {\framed[frame=off,width=broad,align=flushleft]{#1\\#2}}\setuphead [chapter] [command=\MyChapter]\chapter{Foo Bar}</context>
===Expanded chapter titles===
 
This example illustrates expanded chapter titles.
<texcodecontext source=yes>\defsetuppapersize[A5]\define[2]\MyChapterCommand#1#2% {\framed[frame=off, bottomframe=on, topframe=on] {\vbox{\headtext{chapter} #1\blank#2}}}% #1 is number, #2 is text% \vbox is needed for \blank to work
\setuphead[chapter][command=\MyChapterCommand, style={\ss\bfa}]
 
\setupheadtext[chapter=Chapter] % used by \headtext
</texcode>
so <tt>\chapter{My First Chapter}</tt> looks like:
<context>
\def\MyChapterCommand#1#2{\framed[frame=off, bottomframe=on, topframe=on]{\vbox{\headtext{chapter} #1\blank#2}}}
\setuphead[chapter][command=\MyChapterCommand, style={\ss\bfa}]
\setupheadtext[chapter=Chapter]
===Exercise numbers===
For a textbook, suppose that you collect the exercises in a section at the end of each chapter, with each exercise a subsection having a short title, and the exercises should be numbered only by the subsection (not 1.6.7 for example, just 7). The usage:
<texcode>
\exercise{Batteries}
What is the cost of energy from a 9V battery? From a wall socket (themains)?
</texcode>
<texcode>
\definehead[exercise][subsection]
 \setuphead [exercise] [style=italic, numbercommand={\determineheadnumber[subsection]\currentheadnumber\gobbleoneargument}]
</texcode>
===A complex graphical element under the chapter title===
<texcodecontext source=yes> \setupcolors[state=start]\startuseMPgraphic{HeaderDeco} numeric w, h, repeats; path p[]; w := OverlayWidth ; h := OverlayHeight ; repeats := abs(TextWidth/BodyFontSize); p[1] := unitsquare xscaled w yscaled h ; draw p[1] withcolor white; p[2] := fullcircle scaled BodyFontSize; p[3] := fullcircle scaled .25BodyFontSize; draw p[2] shifted (.5BodyFontSize,0); for i = 1 upto repeats: if odd i : filldraw p[3] shifted (i*BodyFontSize+.5BodyFontSize,0); else : draw p[2] shifted (i*BodyFontSize+.5BodyFontSize,0); fi; endfor;\stopuseMPgraphic \setuphead[chapter][command=\Myheader]\setupheadtext [chapter=Chapitre]\defineoverlay[HeaderDeco][\uniqueMPgraphic{HeaderDeco}] \def\Myheader#1#2{% \framedtext [width= \overlaywidth, height=6\bodyfontsize, background={foreground,HeaderDeco}, offset=0pt, strut=no, frame=off, align=middle]{% \headtext{chapter} #1 \blanksetuppapersize[smallA6] #2}} \starttext \chapter{Here we go!}\stoptext</texcode> It looks like: <context>
\setupcolors[state=start]
\startuseMPgraphic{HeaderDeco}
\defineoverlay[HeaderDeco][\uniqueMPgraphic{HeaderDeco}]
\defdefine[2]\Myheader#1#2{%
\framedtext
[width= \overlaywidth,
\chapter{Here we go!}
\stoptext
</context>
 
===Title page with special background===
 
If you want the title page of every chapter to have a special background (different from the background of normal pages), here's a very effective trick that Hans has provided on the mailing list. In addition, this will give every chapter its own color scheme (Mkiv only, hence won't compile on contextgarden):
 
<context source=yes>
\startMPinclusions
numeric MyTitlePageDone[] ;
\stopMPinclusions
 
\startuseMPgraphic{background:normal}
StartPage ;
fill (topboundary Page -- cycle) enlarged(0,5mm)
shifted (0,-5mm) withcolor blue ;
StopPage ;
\stopuseMPgraphic
 
\defineoverlay
[background:normal]
[\useMPgraphic{background:normal}]
 
\startuseMPgraphic{background:title}
if unknown MyTitlePageDone.\namedstructureuservariable{chapter}{mycolor} :
StartPage ;
fill ((topboundary Page --cycle) enlarged(0,5mm)) shifted (0,-20mm)
withcolor \MPcolor{color:title:\namedstructureuservariable{chapter}{mycolor}} ;
StopPage ;
MyTitlePageDone.\namedstructureuservariable{chapter}{mycolor} := 1 ;
fi ;
\stopuseMPgraphic
 
\defineoverlay
[background:title]
[\useMPgraphic{background:title}]
 
\setupbackgrounds
[page]
[background={background:normal,background:title}]
 
\definecolor [color:title:one] [red]
\definecolor [color:title:two] [blue]
 
\starttext
 
\startchapter[title=One][mycolor=one] \input tufte \page \input knuth \stopchapter
\startchapter[title=Two][mycolor=two] \input tufte \page \input knuth \stopchapter
 
\stoptext
 
</context>
It is sometimes wanted to place the title of a section/subject etc in the margin next to the section text (instead of above it).
This is achieved by the following setup:
 
<context source=yes>
\setuppapersize[A5]
\setuphead
[subject]
[alternative=text,distance=0pt,command=\MyHead,style=\sc]
 
\define[2]\MyHead{\inmargin{#1 #2}}
 
\starttext
 
\subject{First Subject}
\input weisman
 
\subject{Second Subject}
\input ward
 
\stoptext
</context>
 
See [http://www.ntg.nl/pipermail/ntg-context/2003/002053.html the mailing list thread] for more on this.
 
===Headings numbered independent of chapters or other headings===
 
If you want a heading that gets numbered without resetting at new sections or chapters (for example, for problems whose numbers increment throughout a book), here is a solution due to Hans [http://archive.contextgarden.net/message/20030415.153451.374310d8.en.html on the mailing list]:
<texcode>
% use a lower level head
 
\definehead
[Problem]
[subsubsubsection]
 
% cleaned up
 
\setuphead
[Problem]
[style=\ss\bf,
color=red,
before=\blank]
 
% use a label text
 
\setuplabeltext
[Problem=Problem ]
 
% use your own numbers
 
\setuphead
[subjectProblem][ownnumber=yes] % increment and feed \newcounter\ProblemNumber \def\problem#1%{\doglobal\increment\ProblemNumber\Problem{\ProblemNumber}{#1}} % nicer here \setuplist[Problem] [alternative=textc,distancecriterium=0ptall,commandwidth=2em,interaction=all] % the test \starttext List of Problems \blank[big] \MyHeadplacelist[Problem]\blank[big] \section{Tufte} \input tufte \problem{First problem} The first problem description. \section{Another Tufte} \input tufte \problem{Second problem} Second problem description.
\def\MyHead#1#2{\inmargin{#1 #2}}stoptext
</texcode>
===Chapter headers=== This (is an example of chapter headings with 'stylean enlarged shadow behind them, based on [http://archive.contextgarden.net/message/20041020.100630.d531bb1d.en.html 20/10/2004 a solution by Hans]. <context source=yes>\setuppapersize[A5] \useencoding[ffr]\mainlanguage[fr] \setupcolors[state=start] \scdefinefont[BigFontOne][Regular sa 3] %RegularSlanted sa 3(ori)%Sans sa 3:don' added in setupheadt work (pb accents) gives:\definefont[BigFontTwo][RegularBold sa 2] %%RegularSlanted \definecolor[BigColorOne][r=.86,g=.850,b=.54]\definecolor[BigColorTwo][r=.43,g=.425,b=.27]
<context>
\setuphead
[subjectchapter] [alternativetextcommand=\MyChapterText, color=BigColorTwo, style=\BigFontTwo] \def\MyChapterText#1{\rlap{\BigFontOne\BigColorOne#1}\kern15pt#1} \starttext \chapter[chap:ques]{Question} \stoptext</context> ===Figures in Headings=== This example shows how to completely replace the chapter textand number by an image: <context source="yes">\setuppapersize[A5]\setupexternalfigures[location=default] % needed only for the wiki to the find the figure \useexternalfigure[section-1][cow][width=5cm,distanceheight=1cm]\useexternalfigure[section-2][mill.png][width=5cm,height=1cm] \setuphead [section] [command=\MySectionCommand]\setuphead [subsection] [command=0pt] \define[2]\MySectionCommand% {\externalfigure[section-\currentheadnumber]} \starttext \section{One}\subsection{First subsection of Section One}\section{Two} \stoptext</context> There are a few snags though. MkII "forgets" to put the chapter in theTOC. So you have to set the <tt>deeptextcommand</tt> and<tt>deepnumbercommand</tt> separately instead (thus retaining thecommand that puts the chapter in the TOC),rather than setting theoverall <tt>command</tt>, if you need a complete TOC. <texcode>\setuphead [chapter] [deeptextcommand=\MyHeadMyChapterTextCommand,style deepnumbercommand=\gobbleoneargument] % hide chapter number \def\MyChapterTextCommand#1% {\externalfigure[chapter-\currentheadnumber][height=5cm]}</texcode> [http://archive.contextgarden.net/message/20050519.215526.df7c5cd1.html] Users of MkIV can safely rely on <tt>command</tt> and don't have to bother with the <tt>deep...command</tt> variants. However, {{cmd|currentheadnumber}} does not seem to return anything but 0. Thus, the following code is required to define <tt>\scMyChapterCommand</tt> when using MkIV: <texcode>\def\MyChapterCommand#1#2% {\externalfigure[chapter-\namedheadnumber{chapter}][height=5cm]}</texcode> [http://archive.contextgarden.net/message/20100817.102859.206d858e.en.html===Chapter head with absolute positioning of following text===
\def\MyHead#1#2{\inmargin{#1 #2}}No matter how many lines the chapter head runs to, the text will always start, e.g. 4cm below the top of the heading:
<context source=yes>
\setuppapersize[A6][A6]
\setupbodyfont[8pt]
\def\MyChapterCommand#1#2%
{\vbox to 4cm\bgroup
{#1\hskip.75em #2}
\vss
\egroup}
\setuphead[chapter][header=nomarking, command=\MyChapterCommand]
\starttext
\chapter{test} \input tufte
\stoptext
</context>
 
===Section head with underlining to width of last line===
 
A style called for section headings to be followed by a rule which extends only the width of the text. More tricky was the need to make sure that if the text ran onto another line, it was the length of the ''last'' line that was to be followed.
 
Hans came up with this cleverness, showing two alternate ways of doing it:
<context source="yes">\setuppapersize[A5] % ---- First solution ---- \def\FirstSolution#1#2% {\vbox\bgroup \setbox0\subjecthbox{First Subject#1}This is the text in the first subject \hsize. This is 4\textwidth \beginshapebox#2\endshapebox \gdef\SetLastLineWidth{\xdef\LastLineWidth{\the text in the first subject\wd\scratchbox}}% \reshapebox {\setbox\scratchbox\hbox{\unhbox\shapebox}% \SetLastLineWidth \globallet\SetLastLineWidth\relax \box\scratchbox}% \scratchdimen\dimexpr\wd0+.25em+\LastLineWidth\relaxThis % \setbox2\ruledvbox {\innerflushshapebox} % why is the text in the first subjectcorrection needed \setbox2\vbox {\vskip-\lineskip\innerflushshapebox} \setbox0\vbox to \ht2{\box0} \hbox{\box0\hskip. This is the text in the first subject25em\box2} \offinterlineskip \vskip.25ex \blackrule[width=\scratchdimen,height=1pt] \egroup} % ---- Second solution ---- \doglobal\newcounter\NextLinePos \def\SecondSolution#1#2%This is the text in the first subject {\vbox\bgroup \hsize. This is the text in the first subject4\textwidth \doglobal\increment\NextLinePos \setbox\scratchbox\hbox{#1} \hbox{\vtop{\copy\scratchbox}\hskip.25em\vtop{#2}}% \offinterlineskipThis is the text in the first subject \scratchdimen\dimexpr\wd\scratchbox+. This is the text in the first subject25em+ \MPx{e:npl:\NextLinePos}-\MPx{b:npl:\NextLinePos}\relax \vskip.25ex \blackrule[width=\scratchdimen,height=1pt] \egroup} \def\DoSecondSolution#1% {\bpos{npl:\NextLinePos}#1\epos{npl:\NextLinePos}} % ---- Trying it out solution ---- % \showstruts
\subject{Second Subject}starttextThis is the text in the second subject. This is the text in the second subject.\setuphead[section][command=\FirstSolution]This \section{is the text in the second subject. This is the text in the second subject. this nice or not}This \section{is this nice or not nice, that's the text in the second subject. This is the text in the second subject. This is the text in the second subject. This is the text in the second subject. question}
\setuphead[section][command=\SecondSolution,deeptextcommand=\DoSecondSolution]
\section{is this nice or not}
\section{is this nice or not nice, that's the question}
\stoptext
</context>
See As if that wasn't enough, Taco pointed out that {{cmd|lastlinewidth}}is the mailing easy route to finding the width of the last line. Use something like: <texcode>\optimizedisplayspacingtrue\setlastlinewidth % core-mat macro\global\advance\lastlinewidth-\hangindent\par % adjust\blackrule[width=\lastlinewidth,height=1pt]</texcode> === Flushing section head data without typesetting them in the text === The following is probably a very special case. Hoever suppose you need to place section information like the title e.g. in the topspace area. You want that the section is still displayed in the TOC, but you do not want that at the spot where {{cmd|startsection|2=[title=...,list thread =...]}} resides there is any trace of it. The command to be used to hide the section title is: <texcode>\setuphead [section] [httpplacehead=hidden] </texcode> Be aware that with this setting indeed the section title is not shown and no white space is inserted. However in this way also the list entry for the TOC is gone. What you can do in such cases is to use the following command in connection with the above mentioned setting<texcode>\setuptexttexts[{\placerawheaddata[section]} </texcode> What happens is that the information in the {{cmd|startsection|2=[title=...,list=...]}} command is passed to the texttexts, which are flushed at every page. In order to see when it is flushed you might place e.g. !!! in front of the {{cmd|placerawheaddata|2=[section]}}. The result is a complete TOC without any trace of the section heading in the text. '''Test:''' <texcode>\setuphead [section] [placehead=hidden, page=yes] \setuphead [subsection] [placehead=yes, page=yes, continue=yes, style=\it] \setuptexttexts[{\placerawheaddata[section]}] \starttext \placelist[section,subsection] \page \startsection[title=First section]  \startsubsection[title=First subsection] Lorem ipsum \dots \stopsubsection  \startsubsection[title=second subsection] Lorem ipsum \dots \stopsubsection \stopsection \startsection[title=Second section]  \startsubsection[title=First subsection] Lorem ipsum \dots \stopsubsection \stopsection \stoptext</texcode>  ===Section head without chapter number === If you only want the section number (in mark IV) in the section title you add   <texcode>\setuphead[section][sectionsegments=section]\starttext\chapter{Eric}\section{Foo 1}\subsection{Bar one}\section{Foo 2}\stoptext</wwwtexcode> But as once you changed one you have to change the lower ones.ntgSo you have to add the definition of sectionsegments in subsection, subsubsection, .nl.. <texcode>\setuphead[section][sectionsegments=section]\setuphead[subsection][sectionsegments=section:subsection]\setuphead[subsubsection][sectionsegments=section:subsubsection] \starttext\chapter{Eric}\section{Foo 1}\subsection{Bar one}\subsubsection{Barbar one }\subsubsection{Barbar two}\subsection{Bar two}\subsubsection{Barbar one}\subsubsection{Barbar two}\section{Foo 2}\subsection{Bar one}\subsubsection{Barbar one}\subsubsection{Barbar two}\stoptext</pipermailtexcode> It's not written here but you can also change the conversion of the numbering with  <texcode>\definestructureconversionset[mySet][A,R,n,n,a,r][n] \setuphead[chapter,section,subsection,subsubsection,subsubsubsection][sectionconversionset=mySet]</ntg-contexttexcode> The parameters in definestructureconversionset are the set name the codes for conversion (one for each level) the default conversion for the missing level You can find the conversions codes at [http:/2003/002053wiki.htmlcontextgarden.net/Conversions] [[Category:Fonts]][[Category:Graphics]][[Category:Text elements]] for more on this.
19

edits

Navigation menu