https://wiki.contextgarden.net/api.php?action=feedcontributions&user=Philexander&feedformat=atomWiki - User contributions [en]2024-03-29T12:41:00ZUser contributionsMediaWiki 1.34.1https://wiki.contextgarden.net/index.php?title=Command/setuptyping&diff=31299Command/setuptyping2020-09-03T12:13:31Z<p>Philexander: </p>
<hr />
<div>{{Reference<br />
|name=setuptyping<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] (autogenerated) ==<br />
<syntax>setuptyping</syntax><br />
<br />
<syntax>setuptyping</syntax><br />
<br />
== Description == <br />
Changes options for displaying verbatim text. When called with a single argument, this command changes the options for the default typing environment as created with {{cmd|starttyping}}. When the optional argument is given, it identifies a specific typing environment (as created with {{cmd|definetyping}}).<br />
<br />
{{cmd|setuptyping}} can be used multiple times to change options and options will stay in effect until the end of file.<br />
<br />
Note that {{cmd|setuptyping}} also affects the display of the {{cmd|typefile}} command.<br />
<br />
* space<br />
** fixed: Lines will not be broken, even if too long (may cause "overfull hbox" message)<br />
<br />
* lines<br />
** no (default): no hyphenation<br />
** yes: no hyphenation and left aligned text (align key is ignored)<br />
** hyphenated: hyphenation<br />
<br />
* range<br />
** {2,5}: line 2 to 5<br />
** {2,+3}: line 2 to 5<br />
** {label:start,label:end}: from label:start to label:end (comments in code)<br />
<br />
* strip<br />
** yes: Remove leading white space while keeping relative indentation between lines.<br />
<br />
The <code>option</code> option is for the type of colorization. E.g., to turn off colorization in <code>\startLUA</code> blocks:<br />
<pre><br />
\setuptyping[LUA][option=]<br />
</pre><br />
<br />
== Example ==<br />
<br />
Note that background=screen,backgroundscreen=.8 is depricated in MKIV and should be replaced by something like background=color,backgroundcolor=lightgray.<br />
<br />
<context source=yes><br />
\setuptyping<br />
[before={\startframedtext[width=\makeupwidth,<br />
background=screen,<br />
backgroundscreen=.8]},<br />
after={\stopframedtext}]<br />
<br />
\starttext<br />
\starttyping<br />
This is a \test{}<br />
and everything<br />
is printed just as I write it<br />
\stoptyping<br />
\stoptext<br />
</context><br />
<br />
== See also ==<br />
* {{cmd|typefile}} to print files verbatim<br />
* {{cmd|starttyping}} to print lines verbatim<br />
* {{cmd|definetyping}} to define a custom typing environment<br />
* {{src|buff-ver.mkiv}} source code<br />
* {{cmd|setuplinenumbering}}<br />
<br />
== Help from ConTeXt-Mailinglist/Forum ==<br />
All issues with:<br />
{{Forum|{{SUBPAGENAME}}}}<br />
<br />
[[Category:Command/Verbatim Text|setuptyping]]</div>Philexanderhttps://wiki.contextgarden.net/index.php?title=Command/setuptyping&diff=22838Command/setuptyping2015-05-25T09:54:54Z<p>Philexander: </p>
<hr />
<div>{{Reference<br />
|name=setuptyping<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd">\setuptyping<span class="first" style="color:red;">[...]</span><span class="second" >[...,...=...,...]</span></td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[...]</td><br />
<td>file typing name </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Command/keyword:space|space]]</td><br />
<td>[[Command/value:on|on]] [[Command/value:off|off]] [[Command/value:fixed|fixed]] </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Command/keyword:page|page]]</td><br />
<td>[[Command/value:yes|yes]] [[Command/value:no|no]] </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Command/keyword:option|option]]</td><br />
<td>[[Command/value:slanted|slanted]] [[Command/value:normal|normal]] [[Command/value:commands|commands]] [[Command/value:color|color]] [[Command/value:none|none]] </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Command/keyword:text|text]]</td><br />
<td>[[Command/value:yes|yes]] [[Command/value:no|no]] </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Command/keyword:icommand|icommand]]</td><br />
<td>[[Command/value:command|command]] </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Command/keyword:vcommand|vcommand]]</td><br />
<td>[[Command/value:command|command]] </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Command/keyword:ccommand|ccommand]]</td><br />
<td>[[Command/value:command|command]] </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Command/keyword:before|before]]</td><br />
<td>[[Command/value:command|command]] </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Command/keyword:after|after]]</td><br />
<td>[[Command/value:command|command]] </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Command/keyword:margin|margin]]</td><br />
<td>[[Command/value:dimension|dimension]] [[Command/value:standard|standard]] [[Command/value:yes|yes]] [[Command/value:no|no]] </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Command/keyword:evenmargin|evenmargin]]</td><br />
<td>[[Command/value:dimension|dimension]] </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Command/keyword:oddmargin|oddmargin]]</td><br />
<td>[[Command/value:dimension|dimension]] </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Command/keyword:blank|blank]]</td><br />
<td>[[Command/value:dimension|dimension]] [[Command/value:small|small]] [[Command/value:medium|medium]] [[Command/value:big|big]] [[Command/value:standard|standard]] [[Command/value:halfline|halfline]] [[Command/value:line|line]] </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Command/keyword:escape|escape]]</td><br />
<td>[[Command/value:character|character]] </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Command/keyword:tab|tab]]</td><br />
<td>[[Command/value:number|number]] [[Command/value:yes|yes]] [[Command/value:no|no]] </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Command/keyword:indentnext|indentnext]]</td><br />
<td>[[Command/value:yes|yes]] [[Command/value:no|no]] </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Command/keyword:style|style]]</td><br />
<td>[[Command/value:normal|normal]] [[Command/value:bold|bold]] [[Command/value:slanted|slanted]] [[Command/value:boldslanted|boldslanted]] [[Command/value:type|type]] [[Command/value:cap|cap]] [[Command/value:small...|small...]] [[Command/value:command|command]] </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Command/keyword:color|color]]</td><br />
<td>[[Command/value:name|name]] </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Command/keyword:palet|palet]]</td><br />
<td>[[Command/value:name|name]] </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Command/keyword:lines|lines]]</td><br />
<td>[[Command/value:yes|yes]] [[Command/value:no|no]] [[Command/value:hyphenated|hyphenated]] </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Command/keyword:empty|empty]]</td><br />
<td>[[Command/value:yes|yes]] [[Command/value:all|all]] [[Command/value:no|no]] </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Command/keyword:numbering|numbering]]</td><br />
<td>[[Command/value:line|line]] [[Command/value:file|file]] [[Command/value:no|no]] </td><br />
</tr><br />
</table><br />
<br />
== Description == <br />
Changes options for displaying verbatim text. When called with a single argument, this command changes the options for the default typing environment as created with {{cmd|starttyping}}. When the optional argument is given, it identifies a specific typing environment (as created with {{cmd|definetyping}}).<br />
<br />
{{cmd|setuptyping}} can be used multiple times to change options and options will stay in effect until the end of file.<br />
<br />
Note that {{cmd|setuptyping}} also affects the display of the {{cmd|typefile}} command.<br />
<br />
* space<br />
** fixed: Lines will not be broken, even if too long (may cause "overfull hbox" message)<br />
<br />
* lines<br />
** no (default): no hyphenation<br />
** yes: no hyphenation and left aligned text (align key is ignored)<br />
** hyphenated: hyphenation<br />
<br />
== Example ==<br />
<br />
Note that background=screen,backgroundscreen=.8 is depricated in MKIV and should be replaced by something like background=color,backgroundcolor=lightgray.<br />
<br />
<context source=yes><br />
\setuptyping<br />
[before={\startframedtext[width=\makeupwidth,<br />
background=screen,<br />
backgroundscreen=.8]},<br />
after={\stopframedtext}]<br />
<br />
\starttext<br />
\starttyping<br />
This is a \test{}<br />
and everything<br />
is printed just as I write it<br />
\stoptyping<br />
\stoptext<br />
</context><br />
<br />
== See also ==<br />
* {{cmd|typefile}} to print files verbatim<br />
* {{cmd|starttyping}} to print lines verbatim<br />
* {{cmd|definetyping}} to define a custom typing environment<br />
<br />
== Help from ConTeXt-Mailinglist/Forum ==<br />
All issues with:<br />
{{Forum|{{SUBPAGENAME}}}}<br />
<br />
[[Category:Command/Verbatim Text|setuptyping]]</div>Philexanderhttps://wiki.contextgarden.net/index.php?title=Command/setupbackground&diff=22836Command/setupbackground2015-05-25T09:50:51Z<p>Philexander: </p>
<hr />
<div>{{Reference<br />
|name=setupbackground<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd">\setupbackground<span class="first" >[...,...=...,...]</span></td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:leftoffset|leftoffset]]</td><br />
<td>[[Command/value:dimension|dimension]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:rightoffset|rightoffset]]</td><br />
<td>[[Command/value:dimension|dimension]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:topoffset|topoffset]]</td><br />
<td>[[Command/value:dimension|dimension]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:bottomoffset|bottomoffset]]</td><br />
<td>[[Command/value:dimension|dimension]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:before|before]]</td><br />
<td>[[Command/value:command|command]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:after|after]]</td><br />
<td>[[Command/value:command|command]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:state|state]]</td><br />
<td>[[Command/value:start|start]] [[Command/value:stop|stop]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[...,...=...,...]</td><br />
<td>see [[Command/setupframed|\setupframed]] </td><br />
</tr><br />
</table><br />
<br />
<br />
== Description == <br />
<br />
<br />
== Example ==<br />
<texcode><br />
\setupbackground<br />
[frame=on]<br />
</texcode><br />
<br />
== Example ==<br />
<texcode><br />
\setupbackground<br />
[background=color, backgroundcolor=blue]<br />
</texcode><br />
<br />
<br />
== See also ==<br />
<!-- something like {{cmd|goto}} --><br />
<br />
== Help from ConTeXt-Mailinglist/Forum ==<br />
All issues with:<br />
{{Forum|{{SUBPAGENAME}}}}<br />
<br />
[[Category:Command/Backgrounds|setupbackground]]</div>Philexanderhttps://wiki.contextgarden.net/index.php?title=Command/definetyping&diff=22835Command/definetyping2015-05-25T09:49:40Z<p>Philexander: </p>
<hr />
<div>{{Reference<br />
|name=definetyping<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd">\definetyping<span class="first" >[...]</span><span class="second" >[...,...=...,...]</span></td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[...]</td><br />
<td>file typing name </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[...,...=...,...]</td><br />
<td>see [[Command/setuptyping|\setuptyping]] </td><br />
</tr><br />
</table><br />
<br />
<br />
== Description == <br />
Defines a new typing environment and the corresponding <tt>\start</tt> and <tt>\stop</tt> commands. The first argument is the name of the typing environment, the second argument are the options to apply for this environment.<br />
<br />
Note that difference with {{cmd|setuptyping}}: {{cmd|definetyping}} defines a new typing environment, while {{cmd|setuptyping}} changes the options of an existing typing environment (including the default environment that you get when using {{cmd|starttyping}}).<br />
<br />
<br />
<br />
<br />
== Example ==<br />
<br />
<texcode><br />
\definetyping<br />
[TTinput]<br />
[before={\startframedtext[width=\makeupwidth,<br />
background=color,<br />
backgroundcolor=lightgray]},<br />
after={\stopframedtext}]<br />
\starttext<br />
\startTTinput<br />
test<br />
\stopTTinput<br />
\stoptext<br />
</texcode><br />
<br />
== See also ==<br />
{{cmd|setuptyping}}<br />
<br />
== Help from ConTeXt-Mailinglist/Forum ==<br />
All issues with:<br />
{{Forum|{{SUBPAGENAME}}}}<br />
<br />
[[Category:Command/Verbatim Text|definetyping]]</div>Philexanderhttps://wiki.contextgarden.net/index.php?title=TextBackground&diff=22834TextBackground2015-05-25T09:48:10Z<p>Philexander: </p>
<hr />
<div>< [[Main Page]] | [[Visuals]] ><br />
<br />
{{todo|Add more examples of usage of textbackgrounds.}}<br />
<br />
Pages, paragraphs, words can have a background: color or screen. Note that screen is depricated in MKIV.<br />
<br />
(See, eventually, the [[manual:details.pdf| details]] manual for further explanations.)<br />
<br />
== What if textbackground doesn't work? ==<br />
<br />
The textbackground commands require [[write18]] to be enabled; see that page for more information.<br />
<br />
== Example: multi-page backgrounded text ==<br />
<br />
Perhaps one might like to offset examples from the running text, or signal to the reader that the following paragraphs contain secondary, detailed information that is of interest only to the specialists. This can be achieved using textbackground.<br />
<br />
In contrast, [[Framed]] creates text blocks that do not span columns or pages.<br />
<br />
In the following example, we also reduce the textwidth and bodyfont size.<br />
<context source="yes"><br />
\setupcolors[state=start]<br />
<br />
\definetextbackground[secondary][<br />
location=paragraph,<br />
background=color,backgroundcolor=middlegray,<br />
leftoffset=.5\bodyfontsize,rightoffset=.5\bodyfontsize,<br />
topoffset=.5\bodyfontsize,bottomoffset=.5\bodyfontsize,<br />
before={\startnarrower\switchtobodyfont[small]},<br />
after={\stopnarrower},<br />
frame=off]<br />
<br />
\starttext<br />
<br />
\input knuth<br />
<br />
\startsecondary<br />
\input knuth<br />
\stopsecondary<br />
<br />
\input knuth<br />
<br />
\stoptext<br />
</context><br />
<br />
{{todo|The background does not show here using the live, online conTeXt processor. Why?}}<br />
<br />
== backgroundoffset ==<br />
<br />
The options left, right, top, bottomoffset can be replaced by backgroundoffset yielding a different result:<br />
<br />
<context source="yes"><br />
\runMPgraphicsfalse %Needed because the wiki runs MkII and write18 is not enabled<br />
<br />
\setupcolors[state=start]<br />
<br />
\definetextbackground[secondary][<br />
location=paragraph,<br />
background=color,backgroundcolor=middlegray,<br />
backgroundoffset=.5\bodyfontsize,<br />
before={\startnarrower\switchtobodyfont[small]},<br />
after={\stopnarrower},<br />
frame=off]<br />
<br />
\starttext<br />
<br />
\input knuth<br />
<br />
\startsecondary<br />
\input knuth<br />
\stopsecondary<br />
<br />
\input knuth<br />
<br />
\stoptext<br />
</context><br />
<br />
== Example: dashed underbar (by WS, 4/2011) ==<br />
<br />
<context source="yes"><br />
\runMPgraphicsfalse % This is needed because the wiki runs MkII and write18 is not enabled.<br />
\setuppapersize[B5]<br />
\setupbodyfont[10pt]<br />
<br />
\definetextbackground<br />
[dashed]<br />
[ location=text,<br />
framecolor=black,<br />
alternative=1,<br />
voffset=-\strutdp,<br />
background=,<br />
frame=off,<br />
dash=1]<br />
<br />
\starttext<br />
\startdashed\input ward \stopdashed<br />
\stoptext<br />
</context></div>Philexanderhttps://wiki.contextgarden.net/index.php?title=Proceedings_style&diff=22833Proceedings style2015-05-25T09:46:57Z<p>Philexander: </p>
<hr />
<div>< [[Sample_documents]]<br />
<br />
I made this in 2008 for some political seminary proceedings (Klingberger Reihe Nr.5, [http://verlag.unitarier.de/?menu=0-2-3 Verlag Deutsche Unitarier]). Every chapter is by an other author, and the author must show up in the table of contents, so there's a special handling of chapter titles using newish and undocumented <cmd>startsectionworld</cmd> - thanks to Wolfgang Schuster!<br />
<br />
This one works only with XeTeX/LuaTeX. Use UTF-8 encoding!<br />
<br />
--[[User:Hraban|Hraban]] 22:24, 28 April 2008 (CEST)<br />
<br />
One year later, "Klingberger Reihe Nr.6" was published. Since I switched to MkIV (continuous beta), some setups weren't working any longer. Maybe some could have been easier before... This one worked with betas from mid of May 2009.<br />
<br />
--[[User:Hraban|Hraban]] 19:54, 19 May 2009 (UTC)<br />
<br />
==Environment==<br />
<texcode><br />
\startenvironment env_proceedings<br />
\project project_proceedings<br />
<br />
\version [final] % final, temporary, concept<br />
\mainlanguage [de] % German<br />
<br />
\setuptolerance [{verytolerant, verystrict}] % page breaking<br />
<br />
%% Fonts<br />
<br />
\definefontfeature[default][default][expansion=quality,protrusion=quality]<br />
\setupalign[hz,hanging]<br />
<br />
\starttypescript [fiee] [gyr-mix]<br />
\definetypeface [gyr-mix] [rm] [serif] [schola]<br />
\definetypeface [gyr-mix] [ss] [sans] [heros]<br />
\definetypeface [gyr-mix] [tt] [mono] [modern]<br />
\definetypeface [gyr-mix] [mm] [math] [sans]<br />
\stoptypescript<br />
\usetypescript [fiee][gyr-mix]<br />
\setupbodyfont [gyr-mix,rm,8pt]<br />
\setupbodyfontenvironment [default][em=italic] % use italic as em, not slanted<br />
<br />
% some shortcuts<br />
\def\TextBig{\switchtobodyfont[gyr-mix, rm, 10pt]}<br />
\def\TextNormal{\switchtobodyfont[gyr-mix, rm, 8pt]}<br />
\def\TextSmall{\switchtobodyfont[gyr-mix, rm, 6pt]}<br />
\def\TextSmallSans{\switchtobodyfont[gyr-mix, ss, 6pt]}<br />
<br />
<br />
%% Layout<br />
<br />
\setuppapersize [A5][A5]<br />
% for imposition use:<br />
%\setuppapersize [A5][A4,landscape]<br />
%\setuparranging [2UP]<br />
<br />
\setuplayout [location=middle,<br />
alternative=doublesided,<br />
grid=yes,<br />
backspace=15mm,<br />
leftmargin=5mm, leftmargindistance=0mm,<br />
rightmargin=18mm, rightmargindistance=0mm,<br />
topspace=8mm, header=10mm, <br />
footer=10mm,<br />
width=115mm, height=192mm<br />
]<br />
<br />
% Pagination<br />
\setuppagenumbering[<br />
alternative=doublesided,<br />
location={header,right},<br />
style={\ss\tfx},<br />
way=bypart,<br />
sectionnumber=no,<br />
strut=yes, state=stop]<br />
<br />
\setupsectionblock[frontpart][page=no, number=no]<br />
\setupsectionblock[bodypart][page=yes]<br />
%\setupsectionblock[appendix][page=no]<br />
\setupsectionblock[backpart][page=yes]<br />
<br />
%% Chapter Titling<br />
<br />
\define\ChapterAuthor<br />
{\doiftext{\theChapterAuthor}<br />
{\rm\tf\theChapterAuthor\crlf\vskip0.25em}}<br />
<br />
\define\ChapterTitle<br />
{{\ss\bfb\theChapterTitle}}<br />
<br />
\define\ChapterSubTitle<br />
{\doiftext{\theChapterSubTitle}<br />
{\crlf\vskip0.2em\ss\bf\theChapterSubTitle}}<br />
<br />
\define[2]\ChapterCommand{\marking[chapter]{\theChapterTitle}%<br />
\vbox{\ChapterAuthor\ChapterTitle\ChapterSubTitle}}<br />
<br />
\let\theChapterAuthor\relax<br />
\let\theChapterTitle\relax<br />
\let\theChapterSubTitle\relax<br />
<br />
\define[3]\Title%<br />
{\def\theChapterAuthor{#1}%<br />
\def\theChapterTitle{#2}%<br />
\def\theChapterSubTitle{#3}%<br />
\doiftextelse{#1}{\chapter{#1: #2}}{\chapter{#2}}}<br />
<br />
% use this like \Title{Name Author}{Article Title}{Article Subtitle}<br />
<br />
\setuphead[chapter][<br />
header=no,<br />
command=\ChapterCommand, <br />
page=yes,<br />
number=no,<br />
align={flushleft,nothyphenated,verytolerant}, <br />
style=,]<br />
\setuphead[title][<br />
page=yes, <br />
number=no, <br />
align={flushleft,nothyphenated,verytolerant}, <br />
command=,<br />
style={\ss\bfb}, <br />
before={}, after={\blank}]<br />
\setuphead[section][<br />
page=no, <br />
number=no, <br />
align={flushleft,nothyphenated,verytolerant}, <br />
style={\ss\bf}, <br />
before={\blank}, after={\blank}]<br />
\setuphead[subsection][<br />
page=no, <br />
number=no, <br />
align={flushleft,nothyphenated,verytolerant}, <br />
style={\ss\tf}, <br />
before={\blank}, after={\vskip0.5em}]<br />
<br />
<br />
%% ToC<br />
\definecombinedlist [inhalt]<br />
[chapter]<br />
[level=chapter, placehead=no, <br />
criterium=all, alternative=b,<br />
offset=none]<br />
\setupcombinedlist [inhalt]<br />
[partnumber=no,sectionnumber=no,headnumber=no,numbercommand=\relax]<br />
<br />
%% Index<br />
<br />
\def\Tindex#1{\index{#1}#1}<br />
<br />
\def\MyIndexLine#1{#1\hfill}<br />
\setupregister[index][n=2, balance=no, indicator=no, pagestyle=normal, textcommand=\MyIndexLine]<br />
<br />
% selector (undocumented feature)<br />
% use like \select{title}{First Version}{Second Version}<br />
% depending on the setup, either version is used<br />
% very helpful for different versions of titles in t.o.c. and headers<br />
\defineselector[title][max=2,n=2]<br />
\setupselector[title][n=1]<br />
<br />
%% Misc<br />
<br />
% Header<br />
\setupheader[text][state=stop,style={\ss\tfx},%<br />
frame=off,bottomframe=on]<br />
<br />
\setupheadertexts[text][{\setupselector[title][n=2]\getmarking[chapter]}][pagenumber]<br />
<br />
\setupmarking[chapter][limittext={}] <br />
<br />
% Color & Background<br />
\setupinteraction[state=stop, color=black, style={\tf}]<br />
\setupcolors[state=start, rgb=no, cmyk=yes, overprint=yes]<br />
\definecolor[gray][k=.1]<br />
\setupbackground[<br />
background=color, backgroundcolor=lightgray, <br />
leftoffset=1em, rightoffset=1em,<br />
topoffset=0.5em, bottomoffset=0.5em]<br />
<br />
% Tables and Lists<br />
\setupTABLE[frame=off, split=yes]<br />
\setuptabulate[indentnext=no, align=right]<br />
\setupitemgroup[itemize][packed][indentnext=no]<br />
<br />
\setupnote[footnote][%<br />
way=bypage, <br />
numberconversion=set 2, % use asterisk, dagger etc. for footnotes per page<br />
prefix=no]<br />
<br />
\setupexternalfigures[directory={img},width=\textwidth] % all figures are in ./img<br />
<br />
\setupindenting[yes, small, next]<br />
<br />
\stopenvironment<br />
</texcode><br />
<br />
==Product==<br />
<texcode><br />
\startproduct prd_KR06<br />
\project project_proceedings<br />
<br />
%% PDF Setup<br />
<br />
\input spec-tst<br />
\setupinteraction[state=start,<br />
author={Hraban},<br />
title={Sample Proceedings},<br />
subtitle={}<br />
]<br />
<br />
%% leader<br />
<br />
\startfrontmatter<br />
\component c_00_titlepage<br />
\component c_00_imprint<br />
\stopfrontmatter<br />
<br />
%% Content<br />
<br />
\startbodymatter<br />
<br />
\setuppagenumbering[state=start]<br />
% ToC<br />
{<br />
\setuppagenumbering[location=] % switch off page numbering on ToC page<br />
<br />
% neither chapter nor title seems to work here, same with \completeinhalt <br />
{\noindent\ss\bfb Inhalt}<br />
\blank[3*big]<br />
<br />
\placeinhalt % ToC<br />
<br />
\page[left]<br />
}<br />
<br />
\setupheader[text][state=start]<br />
<br />
% each component is one chapter<br />
\component c_01_vorwort<br />
\component c_02_programm<br />
\component c_03_freiheit<br />
% etc.<br />
<br />
\setupheader[text][state=stop]<br />
<br />
\stopbodymatter<br />
<br />
%% Appendix<br />
<br />
\startbackmatter<br />
%\completeindex<br />
\component c_99_advertising<br />
\stopbackmatter<br />
\stopproduct<br />
</texcode><br />
<br />
== Sample Components==<br />
<br />
===Chapter===<br />
<texcode><br />
\startcomponent c_00_sample<br />
\product prd_KR06<br />
\project project_proceedings<br />
<br />
\language[en]<br />
<br />
\Title%<br />
{Author}%<br />
{Sample title}%<br />
{and subtitle}<br />
<br />
\input tufte<br />
<br />
\stopcomponent<br />
</texcode><br />
<br />
===Title page===<br />
<texcode><br />
\startcomponent c_00_titlepage<br />
\product prd_KR05<br />
\project project_proceedings<br />
<br />
<br />
\TextBig<br />
\setuppagenumbering[state=stop]<br />
<br />
\framed[height=\textheight, width=\textwidth, frame=on, align=center]{%<br />
\startlines<br />
<br />
{\sc Klingberger Reihe Nr.\,}5<br />
<br />
\vfill<br />
<br />
{\bfa Wertekonsens in Europa}<br />
<br />
Die grundgesetzliche Behinderung<br />
der Integration in Deutschland<br />
<br />
\blank<br />
<br />
{\bfa Consensus on Values in Europe}<br />
<br />
The Constitutional Obstruction<br />
of Integration in Germany<br />
<br />
\vfill<br />
<br />
\vfill<br />
<br />
\framed[frame=off, width=\textwidth, align=middle]{\externalfigure[JBK_logo.pdf][width=30mm]}<br />
<br />
Jugend- und Bildungsstätte Klingberg<br />
<br />
\stoplines<br />
}<br />
\stopcomponent<br />
</texcode><br />
<br />
===Imprint===<br />
<texcode><br />
\startcomponent c_00_imprint<br />
\product prd_KR06<br />
\project project_proceedings<br />
<br />
\page<br />
\TextNormal<br />
<br />
{\tfx<br />
\startlines<br />
Dedication, Funding<br />
\stoplines<br />
}<br />
<br />
\strut\vfill<br />
\framed[frame=off, align=bottom]{<br />
\startlines<br />
<br />
{\sc Klingberger Reihe Nr.\,}5<br />
<br />
{\tfx<br />
Publisher<br />
<br />
Copyright<br />
<br />
typeset by {\it fiëé visuëlle} using open source software (\TEX, \CONTEXT)<br />
<br />
printed in Germany<br />
<br />
ISBN 978-3-<br />
} % tfx<br />
\stoplines<br />
} % framed<br />
<br />
\stopcomponent<br />
</texcode><br />
<br />
<br />
[[Category:Sample documents]]</div>Philexanderhttps://wiki.contextgarden.net/index.php?title=Widgets&diff=22832Widgets2015-05-25T09:44:28Z<p>Philexander: </p>
<hr />
<div>< [[Visuals]] | [[Interaction]] ><br />
<br />
You can find more about interactive form elements in [http://www.pragma-ade.com/general/manuals/mwidget-s.pdf Widgets uncovered]. It’s written for MkII, but still mostly valid.<br />
<br />
At the moment all of the following examples are from <tt>mwidget</tt> manual. We will cook up our own later.<br />
<br />
=JavaScript=<br />
<br />
If you need to check or otherwise process the input of your forms, you need JavaScript to handle interaction. For simple forms without input validation, you can skip this section.<br />
<br />
<texcode><br />
\startJSpreamble {name}<br />
MyCounter = 0 ;<br />
\stopJSpreamble<br />
<br />
\startJScode {increment}<br />
MyCounter = MyCounter + 1 ; // or: ++MyCounter ;<br />
\stopJScode<br />
<br />
\goto {advance by one} [JS(increment)]<br />
</texcode><br />
<br />
'''Beware''', in MkIV (as of 2015-04-01) the JS code is only copied to the PDF if there is a \goto referencing one of the defined functions!<br />
<br />
You can pass values to a JS function:<br />
<br />
<texcode><br />
\startJScode {increment}<br />
MyCounter = MyCounter + JS_V_1 ;<br />
\stopJScode<br />
<br />
\goto {advance by five} [JS(increment{V{5}})]<br />
</texcode><br />
<br />
* V{} is verbose, defaults to string<br />
* S{} = as string<br />
* R{} = as reference<br />
* JS_V_n, JS_S_n, JS_R_n are the names of the variables<br />
* JS_N keeps the number of arguments<br />
<br />
== Documentation ==<br />
<br />
JavaScript in Acrobat is different than in a web context. Documentation is even more sparse that on ConTeXt ;)<br />
Debugging is only possible in Acrobat Pro, and also there very inconvenient.<br />
Additionally, Acrobat’s possibilities change with every version.<br />
<br />
* [http://www.adobe.com/devnet/acrobat/javascript.html JavaScript documentation at Adobe’s]<br />
* [http://help.adobe.com/livedocs/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/wwhelp/wwhimpl/js/html/wwhelp.htm?href=JS_Dev_Tools.72.1.html&accessible=true JavaScript API Reference for Acrobat 9]<br />
<br />
== Examples ==<br />
<br />
=== Setting a default value ===<br />
<br />
Here we set a date field to the current date on opening the document.<br />
Additionally we have a button that can hide/show a form field.<br />
<br />
<texcode><br />
\starttext<br />
\setupinteraction [state=start]<br />
<br />
\startJSpreamble {EXAMPLE}<br />
var d = new Date();<br />
var df = this.getField("CurDate");<br />
df.value = util.printd("dd.mm.yyyy", d);<br />
<br />
function toggleField(){<br />
var f = this.getField("CurDate");<br />
f.display = ! f.display;<br />
}<br />
\stopJSpreamble<br />
<br />
% this button makes no sense for the example, but in MkIV we need one \goto,<br />
% otherwise we get no JS into the PDF<br />
\goto{toggle}[JS(toggleField)]<br />
\blank<br />
<br />
\setupfield[shortString][reset,horizontal][height=5mm, width=50mm, frame=off, bottomframe=on]<br />
\definefield[CurDate][line][shortString][][JavaScript should replace this text with the current date]<br />
<br />
Current date: \field[CurDate]<br />
<br />
\stoptext<br />
</texcode><br />
<br />
=Fields=<br />
<br />
{{Explanation}}<br />
<br />
Relevant commands:<br />
* {{cmd|setupfield}}, {{cmd|setupfields}}<br />
* {{cmd|definefield|[name][type][setup name][content values][default content]}}<br />
* {{cmd|field|[name]}}<br />
* {{cmd|fillinfield}}<br />
* {{cmd|fillinline}}<br />
* {{cmd|fillintext}}<br />
* {{cmd|fillinrules}}<br />
<br />
Field types:<br />
* line: one line of text<br />
* text: more lines of text<br />
* radio: radiobutton (only one of a group can be active)<br />
* check: checkbox<br />
<br />
Beware, for fillinfields in MkIV you need {{code|\usemodule[fields]}}!<br />
They’re meant for clozes (texts with gaps, like in questionnaires).<br />
<br />
In MkIV (as of 2015-04-01) default values are always used verbatim, i.e. JS() doesn’t work.<br />
<br />
Other fields you must first define and then use. That might look complicated, but you can use the same field several times, and the contents will automatically repeat themselves if you need the same content at several places, even on different pages.<br />
<br />
==Text Entries==<br />
<br />
<texcode><br />
\fillinfield[name]{text that defines field length}<br />
</texcode><br />
<br />
or<br />
<br />
<context source=yes><br />
\setupfield[ShortLine][horizontal][width=2cm]<br />
\definefield [Email] [line] [ShortLine] [] [sample@contextgarden.net]<br />
\field [Email] [your email]<br />
</context><br />
<br />
==Radiobuttons==<br />
<br />
Sample from the manual: (Note that background=screen is depricated in MKIV and should be replaced by something like background=color,backgroundcolor=lightgray.)<br />
<br />
<texcode><br />
\setupfield [LogoSetup]<br />
[width=4cm,<br />
height=4cm,<br />
frame=off,<br />
background=screen]<br />
<br />
\definefield[Logos] [radio] [LogoSetup][ConTeXt,PPCHTEX,TeXUtil] [PPCHTEX]<br />
<br />
\definesubfield [ConTeXt] [] [ConTeXtLogo]<br />
\definesubfield [PPCHTEX] [] [PPCHTEXLogo]<br />
\definesubfield [TeXUtil] [] [TeXUtilLogo]<br />
<br />
\definesymbol [ConTeXtLogo] [{\externalfigure[mpcont.502]}]<br />
\definesymbol [PPCHTEXLogo] [{\externalfigure[mpcont.503]}]<br />
\definesymbol [TeXUtilLogo] [{\externalfigure[mpcont.504]}]<br />
<br />
\hbox to \hsize{\hss\field[ConTeXt]\hss\field[PPCHTEX]\hss\field[TeXUtil]\hss}<br />
</texcode><br />
<br />
==Checkboxes==<br />
<br />
<texcode><br />
\setupfield[setup 3]<br />
[width=2cm, height=2cm,<br />
rulethickness=3pt, corner=round, framecolor=red]<br />
<br />
\definesymbol [yes] [{\externalfigure[mpcont.502]}]<br />
\definesymbol [no] []<br />
\definefield [checkme][check] [setup 3] [yes,no] [no]<br />
\field[checkme]<br />
</texcode><br />
<br />
=Tricks=<br />
<br />
This helps debugging (MkII only!):<br />
<br />
<texcode><br />
\tracefieldstrue<br />
\showfields % typeset a table of field relations<br />
\logfields % logs field descriptions to a file fields.log<br />
</texcode><br />
<br />
=Samples=<br />
<br />
* [[Midgard PC sheet]] (RPG character sheet with lots of text fields in tables)</div>Philexanderhttps://wiki.contextgarden.net/index.php?title=Imposition&diff=22831Imposition2015-05-25T09:41:08Z<p>Philexander: </p>
<hr />
<div>< [[Structurals]] | [[Visuals]] ><br />
<br />
To impose means to place pages on a bigger sheet in such a way that one can fold and cut the sheet to get a booklet or something similar. Here are some examples:<br />
<br />
* Placing four A5 pages on both sides of an A4 sheet: 1 and 4 on the back, 2 and 3 on the front.<br />
* Placing 64 inner pages of a book on one printing sheet, to produce one signature.<br />
* One of those brochures made by folding an A4 sheet into three pieces. One could typeset this brochure as two pages with three columns each, or once could make six pages and impose them.<br />
* Printing address labels on an A4 sheet, eight labels per sheet.<br />
<br />
In general, imposition is accessed in ConTeXt using {{cmd|setuparranging}}, or from the command line as follows (mkiv and mkii, respectively):<br />
<pre><br />
context --pdfarrange=...<br />
texexec --pdfarrange=...</pre><br />
<br />
== Imposition schemas ==<br />
<br />
=== Default schemas ===<br />
<br />
ConTeXt has some built-in imposition schemas (see "arranging pages" in the manual):<br />
<br />
* 2UP : 2 pages next to each other, n sheets arranged for a single booklet<br />
* 2DOWN : 2 pages above each other, n sheets arranged for a single booklet<br />
* 2SIDE : 2 pages per form, side by side in pagination order, single sided only (no real imposition, only paper saving)<br />
* 2TOP : 2 pages above each other, single sided only<br />
* 2TOPSIDE: 2 odd pages on one side, two even pages verso, above each other<br />
* 2*2 : section: one sheet 2 x 2 pages = 4 pages (2 pages per form, for single sheets with front and back)<br />
* 2**2 : section: one sheet 2 x 2 pages = 4 pages (2 pages per form, for book ordering)<br />
* 2*4 : section: one sheet 2 x 4 pages = 8 pages (4 pages per form, 2x2 pages head to head)<br />
* 2*8 : section: one sheet 2 x 8 pages = 16 pages<br />
* 2*16 : section: one sheet 2 x 16 pages = 32 pages<br />
* 2*4*2 : section of 16 pages: 2 sheets, 4 pages front and backside<br />
* 2*2*4 : section of 16 pages: 4 sheets, 2 pages front and backside<br />
* XY : one sheet with x rows and y columns, you can control the number with {{cmd|setuppaper}}[nx=...,ny=...,dx=...,dy=...]<br />
<br />
"form" means "one side of a sheet".<br />
<br />
{{todo|some graphical examples}}<br />
<br />
===XY schema===<br />
<br />
Beware, you need to set up your XY arranging in the right order:<br />
<br />
<texcode><br />
\setuppapersize[A7][A4,landscape]<br />
\setuppaper[nx=4, ny=2] % must come before \setuparranging!<br />
\setuplayout[page][location=middle, marking=on]<br />
\setuparranging [XY]<br />
</texcode><br />
<br />
===Testing schemas===<br />
<br />
Here's a convenient test file to help choose a schema or write a new one:<br />
(Note that background=screen is depricated in MKIV and should be replaced by something like background=color,backgroundcolor=lightgray.)<br />
<br />
<context source=yes><br />
\setuppapersize[A9, landscape][A7, landscape] <br />
<br />
% the schema being tested<br />
\setuparranging [2*4] <br />
<br />
% text describing the schema being tested, to print on the pages<br />
\def\Style{[2*4]}<br />
<br />
% Visuals<br />
\setupbodyfont[ss,10pt]<br />
<br />
\setuplayout [margin=0pt, width=fit, header=2.8ex, footer=2.8ex] <br />
\setuppagenumbering [alternative=doublesided,location=footer]<br />
\setupheadertexts[\CONTEXT\ imposition test]<br />
<br />
\showframe<br />
\setupbackgrounds [text][text][background=screen,backgroundscreen=0.7] <br />
<br />
\setupcolors [state=start]<br />
% Where the block of pages is placed on the sheet <br />
% (Not relevant in this example, but relevant if there is space left over.)<br />
\setuplayout [location=middle,marking=on]<br />
<br />
\startbuffer[Fakepage]<br />
\strut<br />
\blank<br />
\midaligned{\Style}<br />
\vfill<br />
\midaligned{This is page \recurselevel}<br />
\vfill<br />
\stopbuffer<br />
<br />
\starttext<br />
\dorecurse{16}{\getbuffer[Fakepage]\page}<br />
\stoptext<br />
</context><br />
<br />
=== Rearranging existing PDF s===<br />
<br />
ConTeXt is also handy when you need to '''rearrange an existing pdf''' into a booklet. This is a trial-and-error solution by Mari for rearranging an A4 pdf file into 2*8 spreads on A3 sheet (-> A6 pages when printed and cut). <br />
Not sure about the margins on the final A6 pages (the original has equal left and right margins, some extra inside margin might be a good thing), but at least otherwise this seems to do the trick:<br />
<br />
<texcode><br />
\setuppapersize[A6][A3] %individual page A6 size, print size A3<br />
\setuparranging[2*8,rotated] %makes an 8 page gathering when folded (duplex printing!)<br />
\setuplayout<br />
[backspace=0pt,<br />
topspace=0pt,<br />
width=middle,<br />
height=middle,<br />
location=middle,<br />
header=0pt,<br />
footer=0pt]<br />
\setuppagenumbering[alternative=doublesided]<br />
<br />
\starttext<br />
<br />
\insertpages<br />
[original_file.pdf][width=0pt]<br />
<br />
\stoptext<br />
<br />
</texcode><br />
<br />
For proofing one sometimes wants to pick just some pages and when the original is A5, it is kind of handy to put them side-by-side for proofing. The command {{cmd|filterpages}} allows you to define exactly what pages are needed. Be warned, though, that the page numbers refer to the pages in the pdf file, not the page numbers. <br />
<br />
<texcode><br />
\setuppapersize[A5][A4] %individual page A5 size, print size A4<br />
\setuparranging[2SIDE,rotated] %2 pages side by side, rotated to landscape to fit portrait A4<br />
\setuplayout<br />
[backspace=0pt,<br />
topspace=0pt,<br />
width=middle,<br />
height=middle,<br />
location=middle,<br />
header=0pt,<br />
footer=0pt]<br />
\setuppagenumbering[alternative=doublesided]<br />
<br />
\starttext<br />
<br />
\filterpages<br />
[file.pdf][2,5,16:19][width=0pt] %picks pdf pages 2, 5, and 16-19.<br />
<br />
\stoptext<br />
</texcode><br />
<br />
For more information, see the article on [[Including pages from PDF documents]].<br />
<br />
<br />
<br />
== Cut marks ==<br />
<br />
ConTeXt also allows to place cut marks. This can be controlled using the <tt>marking</tt> option of {{cmd|setuplayout}}; possible values are:<br />
<br />
* '''on''' show cut marks and page number<br />
* '''screen''' ditto, but also print a grey-scale colour bar<br />
* '''colour''' ditto, but also print a colour bar<br />
* '''text''' print a text, defaults to `empty`<br />
<br />
The default settings are<br />
<br />
<texcode><br />
\def\pagecutmarksymbol {\the\realpageno}<br />
\def\pagecutmarklength {.5cm}<br />
\let\pagecutmarktoptext \empty<br />
\let\pagecutmarkbottomtext \empty<br />
</texcode><br />
<br />
To obtain register marks (or also called registration marks) you can use the small [http://archive.contextgarden.net/message/20070417.212628.76134ff7.en.html <tt>crop</tt> module] which was posted to the mailing list.<br />
<br />
== Caveat: common troubles ==<br />
<br />
Note that some features (e.g. table of contents, internal references) are always disabled in imposition mode. So, they will not be included in the pdf if you ask for imposition.<br />
To get rid of this you can use the "arrange" key for texexec. <br />
<br />
<texcode><br />
texexec --arrange yourFilename<br />
</texcode><br />
<br />
This will run the document at first without page arrangement and impose the pages in a separate run after table of contents etc are created.<br />
<br />
In '''SciTe/WinConTeXt''' you can run this command by choosing ''Process and Arrange'' in the ''Tools'' menu in SciTe.<br />
<br />
== Getting the last page of a Booklet ==<br />
<br />
When you use imposition to print a booklet you want to put something on the very last page, the <code>quadruple</code> pagebreak did not always fill the remaining pages until you get a quadruple number of pages.<br />
<br />
<texcode><br />
\unprotect<br />
<br />
\startvariables all<br />
nextquadruple: nextquadruple<br />
\stopvariables<br />
<br />
\installpagebreakhandler \v!nextquadruple<br />
{\ifdoublesided<br />
\!!counta\realpageno<br />
\!!countb\realpageno<br />
\advance\!!counta 4<br />
\divide\!!counta 4<br />
\multiply\!!counta 4<br />
\advance\!!countb 1<br />
\advance\!!counta-\!!countb<br />
\executepagebreakhandler\v!yes<br />
\dorecurse\!!counta{\executepagebreakhandler\v!empty}%<br />
\fi}<br />
<br />
\protect<br />
<br />
\setuppapersize[A5][A4]<br />
\setuparranging[2UP,rotated,doublesided]<br />
\setuppagenumbering[alternative=doublesided]<br />
<br />
\starttext<br />
<br />
\subject{Front Cover}<br />
<br />
\dorecurse{10}{\input tufte \par}<br />
<br />
\page[nextquadruple]<br />
<br />
Back Cover<br />
<br />
\stoptext<br />
</texcode><br />
<br />
== Getting to the Back Cover of a Booklet ==<br />
<br />
When using imposition to print an a5 booklet (a4 folded in half) John Devereux wanted to specify content for the back cover, independently of the actual number of pages in the booklet. Here is a way that worked (thanks to Wolfgang Schuster on the mailing list). \page[beforequadruple] gets to the inside back cover. Another \page gets to the outside back cover.<br />
<br />
<texcode><br />
\unprotect<br />
<br />
\startvariables all<br />
beforequadruple: beforequadruple<br />
\stopvariables<br />
<br />
\installpagebreakhandler \v!beforequadruple<br />
{\ifdoublesided<br />
\!!counta\realpageno<br />
\!!countb\realpageno<br />
\advance\!!counta 5<br />
\divide\!!counta 4<br />
\multiply\!!counta 4<br />
\advance\!!countb 2<br />
\advance\!!counta-\!!countb<br />
\executepagebreakhandler\v!yes<br />
\dorecurse\!!counta{\executepagebreakhandler\v!empty}%<br />
\fi}<br />
<br />
\protect<br />
<br />
\setuppapersize[A5][A4]<br />
\setuparranging[2UP,rotated,doublesided]<br />
\setuppagenumbering[alternative=doublesided]<br />
<br />
\starttext<br />
<br />
\subject Front Cover<br />
<br />
\dorecurse{10}{\input tufte \par}<br />
<br />
\page[beforequadruple]<br />
<br />
Imprint<br />
<br />
\page<br />
<br />
Back Cover<br />
<br />
\stoptext<br />
</texcode><br />
<br />
== Imposition by signatures ==<br />
<br />
Sometimes you want a booklet, but the pages are too many to be folded together. This is true especially when the number of pages rises above 80. So you need to pass the output PDF to an imposer, like pdfjam or psbook or pdfpages. The problem is that you need to get the "right" number of pages. <br />
<br />
E.g., if the original pages are 128, no problem, the signature is 64 and you can impose it without problems.<br />
<br />
But, if the original pages are 129, the optimal signature is 44, so<br />
you need to add 3 pages during the PDF compiling.<br />
<br />
First, create the following imposer.lua file<br />
<br />
<pre><br />
-- translated from perl to lua. Original code is in<br />
-- http://theanarchistlibrary.org/docs/altools-6.6.tar.gz<br />
<br />
local maxsignature = 80 -- define the maximum of the signature<br />
local minsignature = 20 -- define the minimum of the signature<br />
function optimize_signature(pages)<br />
local originalpages = pages<br />
-- be sure we don't mess up<br />
assert(numberpage ~= 0, "I can't work with 0 pages")<br />
<br />
--set needed pages to and and signature to 0<br />
local neededpages, signature = 0,0<br />
<br />
-- this means that we have to work with n*4, if not, add them to<br />
-- needed pages <br />
local modulo = pages % 4<br />
if modulo==0 then<br />
signature=pages<br />
else<br />
neededpages = 4 - modulo<br />
end<br />
<br />
-- add the needed pages to pages<br />
pages = pages + neededpages<br />
<br />
-- give a try with the signature<br />
signature = find_signature(pages)<br />
<br />
-- if the pages, are more than the max signature, find the right one<br />
if pages>maxsignature then<br />
while signature<minsignature do<br />
pages = pages + 4<br />
neededpages = 4 + neededpages<br />
signature = find_signature(pages)<br />
end<br />
end<br />
<br />
print("ImposerMessage:: Original pages: " .. originalpages .. "; " .. <br />
"Signature is " .. signature .. ", " ..<br />
neededpages .. " pages are needed, " .. <br />
pages .. " of output")<br />
-- let's do it<br />
tex.print("\\dorecurse{" .. neededpages .. "}{\\page[empty]}")<br />
<br />
end<br />
<br />
function find_signature(number)<br />
assert(number ~= 0, "I can't find the signature for 0 pages")<br />
assert((number % 4) == 0, "I suppose something is wrong, not a n*4")<br />
local i = maxsignature<br />
while i>0 do<br />
if (number % i) == 0 then<br />
return i<br />
end<br />
i = i - 4<br />
end<br />
end<br />
<br />
</pre><br />
<br />
The ImposerMessage is important if you want to pass the output of the ConTeXt run to a script to do the imposing.<br />
<br />
Then the master file<br />
<br />
<texcode><br />
\def\fillthesignature#1{<br />
\directlua{dofile("imposer.lua") <br />
optimize_signature(#1)}}<br />
\starttext<br />
<br />
\dorecurse{53}{<br />
\chapter{test}<br />
\input tufte<br />
\section{\the\realpageno}}<br />
<br />
<br />
\page[yes] % reset the page<br />
\fillthesignature{\the\realpageno}<br />
<br />
And this is the last page (the backcover)<br />
<br />
\stoptext<br />
<br />
</texcode><br />
<br />
You can find a complete script to emulate psbook (which needs a conversion from pdf to ps and back to pdf) and pdfbook (which use the latex package pdfpages) at http://gitorious.org/the-anarchist-library-tools/the-anarchist-library-tools/trees/master/context-imposition and consists of a perl script (with --help included), a ConTeXt module and an example.<br />
<br />
[[Category:ConTeXt-Issues]]<br />
<br />
{{Getting started navbox}}</div>Philexanderhttps://wiki.contextgarden.net/index.php?title=Imposition&diff=22830Imposition2015-05-25T09:39:56Z<p>Philexander: Undo revision 22829 by Philexander (talk)</p>
<hr />
<div>< [[Structurals]] | [[Visuals]] ><br />
<br />
To impose means to place pages on a bigger sheet in such a way that one can fold and cut the sheet to get a booklet or something similar. Here are some examples:<br />
<br />
* Placing four A5 pages on both sides of an A4 sheet: 1 and 4 on the back, 2 and 3 on the front.<br />
* Placing 64 inner pages of a book on one printing sheet, to produce one signature.<br />
* One of those brochures made by folding an A4 sheet into three pieces. One could typeset this brochure as two pages with three columns each, or once could make six pages and impose them.<br />
* Printing address labels on an A4 sheet, eight labels per sheet.<br />
<br />
In general, imposition is accessed in ConTeXt using {{cmd|setuparranging}}, or from the command line as follows (mkiv and mkii, respectively):<br />
<pre><br />
context --pdfarrange=...<br />
texexec --pdfarrange=...</pre><br />
<br />
== Imposition schemas ==<br />
<br />
=== Default schemas ===<br />
<br />
ConTeXt has some built-in imposition schemas (see "arranging pages" in the manual):<br />
<br />
* 2UP : 2 pages next to each other, n sheets arranged for a single booklet<br />
* 2DOWN : 2 pages above each other, n sheets arranged for a single booklet<br />
* 2SIDE : 2 pages per form, side by side in pagination order, single sided only (no real imposition, only paper saving)<br />
* 2TOP : 2 pages above each other, single sided only<br />
* 2TOPSIDE: 2 odd pages on one side, two even pages verso, above each other<br />
* 2*2 : section: one sheet 2 x 2 pages = 4 pages (2 pages per form, for single sheets with front and back)<br />
* 2**2 : section: one sheet 2 x 2 pages = 4 pages (2 pages per form, for book ordering)<br />
* 2*4 : section: one sheet 2 x 4 pages = 8 pages (4 pages per form, 2x2 pages head to head)<br />
* 2*8 : section: one sheet 2 x 8 pages = 16 pages<br />
* 2*16 : section: one sheet 2 x 16 pages = 32 pages<br />
* 2*4*2 : section of 16 pages: 2 sheets, 4 pages front and backside<br />
* 2*2*4 : section of 16 pages: 4 sheets, 2 pages front and backside<br />
* XY : one sheet with x rows and y columns, you can control the number with {{cmd|setuppaper}}[nx=...,ny=...,dx=...,dy=...]<br />
<br />
"form" means "one side of a sheet".<br />
<br />
{{todo|some graphical examples}}<br />
<br />
===XY schema===<br />
<br />
Beware, you need to set up your XY arranging in the right order:<br />
<br />
<texcode><br />
\setuppapersize[A7][A4,landscape]<br />
\setuppaper[nx=4, ny=2] % must come before \setuparranging!<br />
\setuplayout[page][location=middle, marking=on]<br />
\setuparranging [XY]<br />
</texcode><br />
<br />
===Testing schemas===<br />
<br />
Here's a convenient test file to help choose a schema or write a new one:<br />
<br />
<context source=yes><br />
\setuppapersize[A9, landscape][A7, landscape] <br />
<br />
% the schema being tested<br />
\setuparranging [2*4] <br />
<br />
% text describing the schema being tested, to print on the pages<br />
\def\Style{[2*4]}<br />
<br />
% Visuals<br />
\setupbodyfont[ss,10pt]<br />
<br />
\setuplayout [margin=0pt, width=fit, header=2.8ex, footer=2.8ex] <br />
\setuppagenumbering [alternative=doublesided,location=footer]<br />
\setupheadertexts[\CONTEXT\ imposition test]<br />
<br />
\showframe<br />
\setupbackgrounds [text][text][background=screen,backgroundscreen=0.7] <br />
<br />
\setupcolors [state=start]<br />
% Where the block of pages is placed on the sheet <br />
% (Not relevant in this example, but relevant if there is space left over.)<br />
\setuplayout [location=middle,marking=on]<br />
<br />
\startbuffer[Fakepage]<br />
\strut<br />
\blank<br />
\midaligned{\Style}<br />
\vfill<br />
\midaligned{This is page \recurselevel}<br />
\vfill<br />
\stopbuffer<br />
<br />
\starttext<br />
\dorecurse{16}{\getbuffer[Fakepage]\page}<br />
\stoptext<br />
</context><br />
<br />
=== Rearranging existing PDF s===<br />
<br />
ConTeXt is also handy when you need to '''rearrange an existing pdf''' into a booklet. This is a trial-and-error solution by Mari for rearranging an A4 pdf file into 2*8 spreads on A3 sheet (-> A6 pages when printed and cut). <br />
Not sure about the margins on the final A6 pages (the original has equal left and right margins, some extra inside margin might be a good thing), but at least otherwise this seems to do the trick:<br />
<br />
<texcode><br />
\setuppapersize[A6][A3] %individual page A6 size, print size A3<br />
\setuparranging[2*8,rotated] %makes an 8 page gathering when folded (duplex printing!)<br />
\setuplayout<br />
[backspace=0pt,<br />
topspace=0pt,<br />
width=middle,<br />
height=middle,<br />
location=middle,<br />
header=0pt,<br />
footer=0pt]<br />
\setuppagenumbering[alternative=doublesided]<br />
<br />
\starttext<br />
<br />
\insertpages<br />
[original_file.pdf][width=0pt]<br />
<br />
\stoptext<br />
<br />
</texcode><br />
<br />
For proofing one sometimes wants to pick just some pages and when the original is A5, it is kind of handy to put them side-by-side for proofing. The command {{cmd|filterpages}} allows you to define exactly what pages are needed. Be warned, though, that the page numbers refer to the pages in the pdf file, not the page numbers. <br />
<br />
<texcode><br />
\setuppapersize[A5][A4] %individual page A5 size, print size A4<br />
\setuparranging[2SIDE,rotated] %2 pages side by side, rotated to landscape to fit portrait A4<br />
\setuplayout<br />
[backspace=0pt,<br />
topspace=0pt,<br />
width=middle,<br />
height=middle,<br />
location=middle,<br />
header=0pt,<br />
footer=0pt]<br />
\setuppagenumbering[alternative=doublesided]<br />
<br />
\starttext<br />
<br />
\filterpages<br />
[file.pdf][2,5,16:19][width=0pt] %picks pdf pages 2, 5, and 16-19.<br />
<br />
\stoptext<br />
</texcode><br />
<br />
For more information, see the article on [[Including pages from PDF documents]].<br />
<br />
<br />
<br />
== Cut marks ==<br />
<br />
ConTeXt also allows to place cut marks. This can be controlled using the <tt>marking</tt> option of {{cmd|setuplayout}}; possible values are:<br />
<br />
* '''on''' show cut marks and page number<br />
* '''screen''' ditto, but also print a grey-scale colour bar<br />
* '''colour''' ditto, but also print a colour bar<br />
* '''text''' print a text, defaults to `empty`<br />
<br />
The default settings are<br />
<br />
<texcode><br />
\def\pagecutmarksymbol {\the\realpageno}<br />
\def\pagecutmarklength {.5cm}<br />
\let\pagecutmarktoptext \empty<br />
\let\pagecutmarkbottomtext \empty<br />
</texcode><br />
<br />
To obtain register marks (or also called registration marks) you can use the small [http://archive.contextgarden.net/message/20070417.212628.76134ff7.en.html <tt>crop</tt> module] which was posted to the mailing list.<br />
<br />
== Caveat: common troubles ==<br />
<br />
Note that some features (e.g. table of contents, internal references) are always disabled in imposition mode. So, they will not be included in the pdf if you ask for imposition.<br />
To get rid of this you can use the "arrange" key for texexec. <br />
<br />
<texcode><br />
texexec --arrange yourFilename<br />
</texcode><br />
<br />
This will run the document at first without page arrangement and impose the pages in a separate run after table of contents etc are created.<br />
<br />
In '''SciTe/WinConTeXt''' you can run this command by choosing ''Process and Arrange'' in the ''Tools'' menu in SciTe.<br />
<br />
== Getting the last page of a Booklet ==<br />
<br />
When you use imposition to print a booklet you want to put something on the very last page, the <code>quadruple</code> pagebreak did not always fill the remaining pages until you get a quadruple number of pages.<br />
<br />
<texcode><br />
\unprotect<br />
<br />
\startvariables all<br />
nextquadruple: nextquadruple<br />
\stopvariables<br />
<br />
\installpagebreakhandler \v!nextquadruple<br />
{\ifdoublesided<br />
\!!counta\realpageno<br />
\!!countb\realpageno<br />
\advance\!!counta 4<br />
\divide\!!counta 4<br />
\multiply\!!counta 4<br />
\advance\!!countb 1<br />
\advance\!!counta-\!!countb<br />
\executepagebreakhandler\v!yes<br />
\dorecurse\!!counta{\executepagebreakhandler\v!empty}%<br />
\fi}<br />
<br />
\protect<br />
<br />
\setuppapersize[A5][A4]<br />
\setuparranging[2UP,rotated,doublesided]<br />
\setuppagenumbering[alternative=doublesided]<br />
<br />
\starttext<br />
<br />
\subject{Front Cover}<br />
<br />
\dorecurse{10}{\input tufte \par}<br />
<br />
\page[nextquadruple]<br />
<br />
Back Cover<br />
<br />
\stoptext<br />
</texcode><br />
<br />
== Getting to the Back Cover of a Booklet ==<br />
<br />
When using imposition to print an a5 booklet (a4 folded in half) John Devereux wanted to specify content for the back cover, independently of the actual number of pages in the booklet. Here is a way that worked (thanks to Wolfgang Schuster on the mailing list). \page[beforequadruple] gets to the inside back cover. Another \page gets to the outside back cover.<br />
<br />
<texcode><br />
\unprotect<br />
<br />
\startvariables all<br />
beforequadruple: beforequadruple<br />
\stopvariables<br />
<br />
\installpagebreakhandler \v!beforequadruple<br />
{\ifdoublesided<br />
\!!counta\realpageno<br />
\!!countb\realpageno<br />
\advance\!!counta 5<br />
\divide\!!counta 4<br />
\multiply\!!counta 4<br />
\advance\!!countb 2<br />
\advance\!!counta-\!!countb<br />
\executepagebreakhandler\v!yes<br />
\dorecurse\!!counta{\executepagebreakhandler\v!empty}%<br />
\fi}<br />
<br />
\protect<br />
<br />
\setuppapersize[A5][A4]<br />
\setuparranging[2UP,rotated,doublesided]<br />
\setuppagenumbering[alternative=doublesided]<br />
<br />
\starttext<br />
<br />
\subject Front Cover<br />
<br />
\dorecurse{10}{\input tufte \par}<br />
<br />
\page[beforequadruple]<br />
<br />
Imprint<br />
<br />
\page<br />
<br />
Back Cover<br />
<br />
\stoptext<br />
</texcode><br />
<br />
== Imposition by signatures ==<br />
<br />
Sometimes you want a booklet, but the pages are too many to be folded together. This is true especially when the number of pages rises above 80. So you need to pass the output PDF to an imposer, like pdfjam or psbook or pdfpages. The problem is that you need to get the "right" number of pages. <br />
<br />
E.g., if the original pages are 128, no problem, the signature is 64 and you can impose it without problems.<br />
<br />
But, if the original pages are 129, the optimal signature is 44, so<br />
you need to add 3 pages during the PDF compiling.<br />
<br />
First, create the following imposer.lua file<br />
<br />
<pre><br />
-- translated from perl to lua. Original code is in<br />
-- http://theanarchistlibrary.org/docs/altools-6.6.tar.gz<br />
<br />
local maxsignature = 80 -- define the maximum of the signature<br />
local minsignature = 20 -- define the minimum of the signature<br />
function optimize_signature(pages)<br />
local originalpages = pages<br />
-- be sure we don't mess up<br />
assert(numberpage ~= 0, "I can't work with 0 pages")<br />
<br />
--set needed pages to and and signature to 0<br />
local neededpages, signature = 0,0<br />
<br />
-- this means that we have to work with n*4, if not, add them to<br />
-- needed pages <br />
local modulo = pages % 4<br />
if modulo==0 then<br />
signature=pages<br />
else<br />
neededpages = 4 - modulo<br />
end<br />
<br />
-- add the needed pages to pages<br />
pages = pages + neededpages<br />
<br />
-- give a try with the signature<br />
signature = find_signature(pages)<br />
<br />
-- if the pages, are more than the max signature, find the right one<br />
if pages>maxsignature then<br />
while signature<minsignature do<br />
pages = pages + 4<br />
neededpages = 4 + neededpages<br />
signature = find_signature(pages)<br />
end<br />
end<br />
<br />
print("ImposerMessage:: Original pages: " .. originalpages .. "; " .. <br />
"Signature is " .. signature .. ", " ..<br />
neededpages .. " pages are needed, " .. <br />
pages .. " of output")<br />
-- let's do it<br />
tex.print("\\dorecurse{" .. neededpages .. "}{\\page[empty]}")<br />
<br />
end<br />
<br />
function find_signature(number)<br />
assert(number ~= 0, "I can't find the signature for 0 pages")<br />
assert((number % 4) == 0, "I suppose something is wrong, not a n*4")<br />
local i = maxsignature<br />
while i>0 do<br />
if (number % i) == 0 then<br />
return i<br />
end<br />
i = i - 4<br />
end<br />
end<br />
<br />
</pre><br />
<br />
The ImposerMessage is important if you want to pass the output of the ConTeXt run to a script to do the imposing.<br />
<br />
Then the master file<br />
<br />
<texcode><br />
\def\fillthesignature#1{<br />
\directlua{dofile("imposer.lua") <br />
optimize_signature(#1)}}<br />
\starttext<br />
<br />
\dorecurse{53}{<br />
\chapter{test}<br />
\input tufte<br />
\section{\the\realpageno}}<br />
<br />
<br />
\page[yes] % reset the page<br />
\fillthesignature{\the\realpageno}<br />
<br />
And this is the last page (the backcover)<br />
<br />
\stoptext<br />
<br />
</texcode><br />
<br />
You can find a complete script to emulate psbook (which needs a conversion from pdf to ps and back to pdf) and pdfbook (which use the latex package pdfpages) at http://gitorious.org/the-anarchist-library-tools/the-anarchist-library-tools/trees/master/context-imposition and consists of a perl script (with --help included), a ConTeXt module and an example.<br />
<br />
[[Category:ConTeXt-Issues]]<br />
<br />
{{Getting started navbox}}</div>Philexanderhttps://wiki.contextgarden.net/index.php?title=Imposition&diff=22829Imposition2015-05-25T09:38:35Z<p>Philexander: </p>
<hr />
<div>< [[Structurals]] | [[Visuals]] ><br />
<br />
To impose means to place pages on a bigger sheet in such a way that one can fold and cut the sheet to get a booklet or something similar. Here are some examples:<br />
<br />
* Placing four A5 pages on both sides of an A4 sheet: 1 and 4 on the back, 2 and 3 on the front.<br />
* Placing 64 inner pages of a book on one printing sheet, to produce one signature.<br />
* One of those brochures made by folding an A4 sheet into three pieces. One could typeset this brochure as two pages with three columns each, or once could make six pages and impose them.<br />
* Printing address labels on an A4 sheet, eight labels per sheet.<br />
<br />
In general, imposition is accessed in ConTeXt using {{cmd|setuparranging}}, or from the command line as follows (mkiv and mkii, respectively):<br />
<pre><br />
context --pdfarrange=...<br />
texexec --pdfarrange=...</pre><br />
<br />
== Imposition schemas ==<br />
<br />
=== Default schemas ===<br />
<br />
ConTeXt has some built-in imposition schemas (see "arranging pages" in the manual):<br />
<br />
* 2UP : 2 pages next to each other, n sheets arranged for a single booklet<br />
* 2DOWN : 2 pages above each other, n sheets arranged for a single booklet<br />
* 2SIDE : 2 pages per form, side by side in pagination order, single sided only (no real imposition, only paper saving)<br />
* 2TOP : 2 pages above each other, single sided only<br />
* 2TOPSIDE: 2 odd pages on one side, two even pages verso, above each other<br />
* 2*2 : section: one sheet 2 x 2 pages = 4 pages (2 pages per form, for single sheets with front and back)<br />
* 2**2 : section: one sheet 2 x 2 pages = 4 pages (2 pages per form, for book ordering)<br />
* 2*4 : section: one sheet 2 x 4 pages = 8 pages (4 pages per form, 2x2 pages head to head)<br />
* 2*8 : section: one sheet 2 x 8 pages = 16 pages<br />
* 2*16 : section: one sheet 2 x 16 pages = 32 pages<br />
* 2*4*2 : section of 16 pages: 2 sheets, 4 pages front and backside<br />
* 2*2*4 : section of 16 pages: 4 sheets, 2 pages front and backside<br />
* XY : one sheet with x rows and y columns, you can control the number with {{cmd|setuppaper}}[nx=...,ny=...,dx=...,dy=...]<br />
<br />
"form" means "one side of a sheet".<br />
<br />
{{todo|some graphical examples}}<br />
<br />
===XY schema===<br />
<br />
Beware, you need to set up your XY arranging in the right order:<br />
<br />
<texcode><br />
\setuppapersize[A7][A4,landscape]<br />
\setuppaper[nx=4, ny=2] % must come before \setuparranging!<br />
\setuplayout[page][location=middle, marking=on]<br />
\setuparranging [XY]<br />
</texcode><br />
<br />
===Testing schemas===<br />
<br />
Here's a convenient test file to help choose a schema or write a new one:<br />
<br />
<context source=yes><br />
\setuppapersize[A9, landscape][A7, landscape] <br />
<br />
% the schema being tested<br />
\setuparranging [2*4] <br />
<br />
% text describing the schema being tested, to print on the pages<br />
\def\Style{[2*4]}<br />
<br />
% Visuals<br />
\setupbodyfont[ss,10pt]<br />
<br />
\setuplayout [margin=0pt, width=fit, header=2.8ex, footer=2.8ex] <br />
\setuppagenumbering [alternative=doublesided,location=footer]<br />
\setupheadertexts[\CONTEXT\ imposition test]<br />
<br />
\showframe<br />
\setupbackgrounds [text][text][background=color,backgroundcolor=lightgray] <br />
<br />
\setupcolors [state=start]<br />
% Where the block of pages is placed on the sheet <br />
% (Not relevant in this example, but relevant if there is space left over.)<br />
\setuplayout [location=middle,marking=on]<br />
<br />
\startbuffer[Fakepage]<br />
\strut<br />
\blank<br />
\midaligned{\Style}<br />
\vfill<br />
\midaligned{This is page \recurselevel}<br />
\vfill<br />
\stopbuffer<br />
<br />
\starttext<br />
\dorecurse{16}{\getbuffer[Fakepage]\page}<br />
\stoptext<br />
</context><br />
<br />
=== Rearranging existing PDF s===<br />
<br />
ConTeXt is also handy when you need to '''rearrange an existing pdf''' into a booklet. This is a trial-and-error solution by Mari for rearranging an A4 pdf file into 2*8 spreads on A3 sheet (-> A6 pages when printed and cut). <br />
Not sure about the margins on the final A6 pages (the original has equal left and right margins, some extra inside margin might be a good thing), but at least otherwise this seems to do the trick:<br />
<br />
<texcode><br />
\setuppapersize[A6][A3] %individual page A6 size, print size A3<br />
\setuparranging[2*8,rotated] %makes an 8 page gathering when folded (duplex printing!)<br />
\setuplayout<br />
[backspace=0pt,<br />
topspace=0pt,<br />
width=middle,<br />
height=middle,<br />
location=middle,<br />
header=0pt,<br />
footer=0pt]<br />
\setuppagenumbering[alternative=doublesided]<br />
<br />
\starttext<br />
<br />
\insertpages<br />
[original_file.pdf][width=0pt]<br />
<br />
\stoptext<br />
<br />
</texcode><br />
<br />
For proofing one sometimes wants to pick just some pages and when the original is A5, it is kind of handy to put them side-by-side for proofing. The command {{cmd|filterpages}} allows you to define exactly what pages are needed. Be warned, though, that the page numbers refer to the pages in the pdf file, not the page numbers. <br />
<br />
<texcode><br />
\setuppapersize[A5][A4] %individual page A5 size, print size A4<br />
\setuparranging[2SIDE,rotated] %2 pages side by side, rotated to landscape to fit portrait A4<br />
\setuplayout<br />
[backspace=0pt,<br />
topspace=0pt,<br />
width=middle,<br />
height=middle,<br />
location=middle,<br />
header=0pt,<br />
footer=0pt]<br />
\setuppagenumbering[alternative=doublesided]<br />
<br />
\starttext<br />
<br />
\filterpages<br />
[file.pdf][2,5,16:19][width=0pt] %picks pdf pages 2, 5, and 16-19.<br />
<br />
\stoptext<br />
</texcode><br />
<br />
For more information, see the article on [[Including pages from PDF documents]].<br />
<br />
<br />
<br />
== Cut marks ==<br />
<br />
ConTeXt also allows to place cut marks. This can be controlled using the <tt>marking</tt> option of {{cmd|setuplayout}}; possible values are:<br />
<br />
* '''on''' show cut marks and page number<br />
* '''screen''' ditto, but also print a grey-scale colour bar<br />
* '''colour''' ditto, but also print a colour bar<br />
* '''text''' print a text, defaults to `empty`<br />
<br />
The default settings are<br />
<br />
<texcode><br />
\def\pagecutmarksymbol {\the\realpageno}<br />
\def\pagecutmarklength {.5cm}<br />
\let\pagecutmarktoptext \empty<br />
\let\pagecutmarkbottomtext \empty<br />
</texcode><br />
<br />
To obtain register marks (or also called registration marks) you can use the small [http://archive.contextgarden.net/message/20070417.212628.76134ff7.en.html <tt>crop</tt> module] which was posted to the mailing list.<br />
<br />
== Caveat: common troubles ==<br />
<br />
Note that some features (e.g. table of contents, internal references) are always disabled in imposition mode. So, they will not be included in the pdf if you ask for imposition.<br />
To get rid of this you can use the "arrange" key for texexec. <br />
<br />
<texcode><br />
texexec --arrange yourFilename<br />
</texcode><br />
<br />
This will run the document at first without page arrangement and impose the pages in a separate run after table of contents etc are created.<br />
<br />
In '''SciTe/WinConTeXt''' you can run this command by choosing ''Process and Arrange'' in the ''Tools'' menu in SciTe.<br />
<br />
== Getting the last page of a Booklet ==<br />
<br />
When you use imposition to print a booklet you want to put something on the very last page, the <code>quadruple</code> pagebreak did not always fill the remaining pages until you get a quadruple number of pages.<br />
<br />
<texcode><br />
\unprotect<br />
<br />
\startvariables all<br />
nextquadruple: nextquadruple<br />
\stopvariables<br />
<br />
\installpagebreakhandler \v!nextquadruple<br />
{\ifdoublesided<br />
\!!counta\realpageno<br />
\!!countb\realpageno<br />
\advance\!!counta 4<br />
\divide\!!counta 4<br />
\multiply\!!counta 4<br />
\advance\!!countb 1<br />
\advance\!!counta-\!!countb<br />
\executepagebreakhandler\v!yes<br />
\dorecurse\!!counta{\executepagebreakhandler\v!empty}%<br />
\fi}<br />
<br />
\protect<br />
<br />
\setuppapersize[A5][A4]<br />
\setuparranging[2UP,rotated,doublesided]<br />
\setuppagenumbering[alternative=doublesided]<br />
<br />
\starttext<br />
<br />
\subject{Front Cover}<br />
<br />
\dorecurse{10}{\input tufte \par}<br />
<br />
\page[nextquadruple]<br />
<br />
Back Cover<br />
<br />
\stoptext<br />
</texcode><br />
<br />
== Getting to the Back Cover of a Booklet ==<br />
<br />
When using imposition to print an a5 booklet (a4 folded in half) John Devereux wanted to specify content for the back cover, independently of the actual number of pages in the booklet. Here is a way that worked (thanks to Wolfgang Schuster on the mailing list). \page[beforequadruple] gets to the inside back cover. Another \page gets to the outside back cover.<br />
<br />
<texcode><br />
\unprotect<br />
<br />
\startvariables all<br />
beforequadruple: beforequadruple<br />
\stopvariables<br />
<br />
\installpagebreakhandler \v!beforequadruple<br />
{\ifdoublesided<br />
\!!counta\realpageno<br />
\!!countb\realpageno<br />
\advance\!!counta 5<br />
\divide\!!counta 4<br />
\multiply\!!counta 4<br />
\advance\!!countb 2<br />
\advance\!!counta-\!!countb<br />
\executepagebreakhandler\v!yes<br />
\dorecurse\!!counta{\executepagebreakhandler\v!empty}%<br />
\fi}<br />
<br />
\protect<br />
<br />
\setuppapersize[A5][A4]<br />
\setuparranging[2UP,rotated,doublesided]<br />
\setuppagenumbering[alternative=doublesided]<br />
<br />
\starttext<br />
<br />
\subject Front Cover<br />
<br />
\dorecurse{10}{\input tufte \par}<br />
<br />
\page[beforequadruple]<br />
<br />
Imprint<br />
<br />
\page<br />
<br />
Back Cover<br />
<br />
\stoptext<br />
</texcode><br />
<br />
== Imposition by signatures ==<br />
<br />
Sometimes you want a booklet, but the pages are too many to be folded together. This is true especially when the number of pages rises above 80. So you need to pass the output PDF to an imposer, like pdfjam or psbook or pdfpages. The problem is that you need to get the "right" number of pages. <br />
<br />
E.g., if the original pages are 128, no problem, the signature is 64 and you can impose it without problems.<br />
<br />
But, if the original pages are 129, the optimal signature is 44, so<br />
you need to add 3 pages during the PDF compiling.<br />
<br />
First, create the following imposer.lua file<br />
<br />
<pre><br />
-- translated from perl to lua. Original code is in<br />
-- http://theanarchistlibrary.org/docs/altools-6.6.tar.gz<br />
<br />
local maxsignature = 80 -- define the maximum of the signature<br />
local minsignature = 20 -- define the minimum of the signature<br />
function optimize_signature(pages)<br />
local originalpages = pages<br />
-- be sure we don't mess up<br />
assert(numberpage ~= 0, "I can't work with 0 pages")<br />
<br />
--set needed pages to and and signature to 0<br />
local neededpages, signature = 0,0<br />
<br />
-- this means that we have to work with n*4, if not, add them to<br />
-- needed pages <br />
local modulo = pages % 4<br />
if modulo==0 then<br />
signature=pages<br />
else<br />
neededpages = 4 - modulo<br />
end<br />
<br />
-- add the needed pages to pages<br />
pages = pages + neededpages<br />
<br />
-- give a try with the signature<br />
signature = find_signature(pages)<br />
<br />
-- if the pages, are more than the max signature, find the right one<br />
if pages>maxsignature then<br />
while signature<minsignature do<br />
pages = pages + 4<br />
neededpages = 4 + neededpages<br />
signature = find_signature(pages)<br />
end<br />
end<br />
<br />
print("ImposerMessage:: Original pages: " .. originalpages .. "; " .. <br />
"Signature is " .. signature .. ", " ..<br />
neededpages .. " pages are needed, " .. <br />
pages .. " of output")<br />
-- let's do it<br />
tex.print("\\dorecurse{" .. neededpages .. "}{\\page[empty]}")<br />
<br />
end<br />
<br />
function find_signature(number)<br />
assert(number ~= 0, "I can't find the signature for 0 pages")<br />
assert((number % 4) == 0, "I suppose something is wrong, not a n*4")<br />
local i = maxsignature<br />
while i>0 do<br />
if (number % i) == 0 then<br />
return i<br />
end<br />
i = i - 4<br />
end<br />
end<br />
<br />
</pre><br />
<br />
The ImposerMessage is important if you want to pass the output of the ConTeXt run to a script to do the imposing.<br />
<br />
Then the master file<br />
<br />
<texcode><br />
\def\fillthesignature#1{<br />
\directlua{dofile("imposer.lua") <br />
optimize_signature(#1)}}<br />
\starttext<br />
<br />
\dorecurse{53}{<br />
\chapter{test}<br />
\input tufte<br />
\section{\the\realpageno}}<br />
<br />
<br />
\page[yes] % reset the page<br />
\fillthesignature{\the\realpageno}<br />
<br />
And this is the last page (the backcover)<br />
<br />
\stoptext<br />
<br />
</texcode><br />
<br />
You can find a complete script to emulate psbook (which needs a conversion from pdf to ps and back to pdf) and pdfbook (which use the latex package pdfpages) at http://gitorious.org/the-anarchist-library-tools/the-anarchist-library-tools/trees/master/context-imposition and consists of a perl script (with --help included), a ConTeXt module and an example.<br />
<br />
[[Category:ConTeXt-Issues]]<br />
<br />
{{Getting started navbox}}</div>Philexanderhttps://wiki.contextgarden.net/index.php?title=Changes&diff=22828Changes2015-05-25T09:36:45Z<p>Philexander: </p>
<hr />
<div>< [[Sample documents]]<br />
<br />
At my work, we have to add some sort of revision history to certain documents. This is also an example for the use of \getparameters (see [[Commands with KeyVal arguments]]).<br />
<br />
A downloadable version of the macro is available [[media:Changes.tex|here]], and a PDF example of the output [[media:Changes.pdf|here]].<br />
<br />
Note that background=screen is depricated and should be replaced by something like background=color,backgroundcolor=gray.<br />
<br />
<texcode><br />
\useregime[il1]<br />
\enableregime[il1]<br />
\useencoding[ffr]<br />
\definehspace[fr][:][.16667em]<br />
\definehspace[fr][;][.16667em]<br />
\definehspace[fr][!][.16667em]<br />
\definehspace[fr][?][.16667em]<br />
\mainlanguage[fr]<br />
\newdimen\BigWidth \BigWidth=18cm<br />
\setupscreens[screen=0.85]<br />
\setupcolors[state=start]<br />
\setupheadertexts[Rév.: \the\RevC]<br />
\def\Vfil{\vskip0pt plus3fil\relax}<br />
\def\In[#1,#2]{\ifx#1\empty\else\in[#1]\fi\if\relax#2\else, \In[#2]\fi}<br />
\def\BigTitle{\centerline{\framed[width=\BigWidth,offset=2mm,<br />
background=screen]{\bfb\setupinterlinespace\cbox{Title}}}}<br />
\def\Auteur{Peter}<br />
<br />
\def\startChanges{\hbox to \hsize\bgroup\hss\SetTableToWidth{\BigWidth}%<br />
\starttable[s1 | c | c | p(95mm) | p(17mm) | p(37mm) |]<br />
\HL\BL[5]\AR\VL Rv.\VL Date\VL Origine de la mise à jour\VL modifié\VL<br />
Auteur\VL\AR\HL}<br />
\def\stopChanges{\stoptable\hss\egroup}\newcount\RevC<br />
\def\Changes[#1]{%<br />
\getgparameters[Changes][Date=,Labels=,#1]% Auteur, Modif, Labels, Date<br />
\doifundefined{ChangesAuteur}{\gdef\ChangesAuteur{\Auteur}}%<br />
\doifundefined{ChangesModif}{\gdef\ChangesModif{First version}}%<br />
\ifnum\RevC=0 \BigTitle \vskip0.5ex \Vfil \startChanges \fi<br />
\global\advance\RevC by 1 \VL \the\RevC \VL \ChangesDate \VL<br />
\ChangesModif \VL \expandafter\In\expandafter[\ChangesLabels,\relax]\VL<br />
\ChangesAuteur \VL\AR\HL}<br />
\def\Destinataires#1{\stopChanges\Vfil<br />
\def\temp{#1}\ifx\temp\empty\else\noindenting Destinataires:\crlf#1\blank\fi<br />
\centerline{\SetTableToWidth{\BigWidth}%<br />
\bf\starttable[| c | c | c |]<br />
\HL\BL[3]\AR\VL Approbateur\VL Date\VL Visa\VL\AR\HL<br />
\VL\vbox to 2cm{}\VL\VL\VL\AR\HL<br />
\stoptable}\par\page\completecontent}<br />
<br />
\starttext<br />
\Changes[Date=1/2/2004]<br />
\Changes[Date=3/4/2004,Modif=Some modifications,Labels={sec:S1,sec:S2},<br />
Auteur=Jérôme]<br />
\Changes[Date=5/6/2004,Modif=Some other modifications,Labels=sec:S2]<br />
%<br />
\Destinataires{Peter, Olivier}<br />
<br />
\section[sec:S1]{A section}<br />
some text<br />
\subsection{Bla}<br />
\subsection{Bla}<br />
<br />
\section[sec:S2]{Another section}<br />
some text<br />
\stoptext<br />
</texcode><br />
<br />
[[Category:Sample documents]]</div>Philexanderhttps://wiki.contextgarden.net/index.php?title=Modules&diff=22827Modules2015-05-25T09:32:30Z<p>Philexander: </p>
<hr />
<div> < [[The ConTeXt Way]]<br />
<br />
Modules are extensions to ConTeXt's core functions.<br />
<br />
There are not as many modules for ConTeXt as packages for LaTeX, because a lot of LaTeX package features are in ConTeXt's core.<br />
<br />
==Installation==<br />
<br />
===Basics===<br />
<br />
The installation of extra files in TeX (called modules in ConTeXt) can be difficult<br />
for people who are new to TeX or are not themselves interested in TeX programming.<br />
<br />
According to the TDS (TeX directory structure) and the ConTeXt developers,<br />
user-written files reside under the path<br />
<br />
$TEXMF/tex/context/third/<modulename>/<files><br />
<br />
In the private TeX directory ($TEXMF), directories can have the names<br />
<br />
* texmf-local<br />
* texmf-extra<br />
* texmf-project<br />
<br />
but their existence depends on the TeX distribution; among these, texmf-local is the most common.<br />
<br />
===Installation by hand===<br />
<br />
When you want to install a new module which is available as file only create<br />
the subdirectories in the way described above and place the file there, for<br />
modules which are available as zip files with precreated subdorectories you<br />
can unzip the archive in the top-level directory (e.g. texmf-local/) and all<br />
files are on the correct place.<br />
<br />
After the files are placed at the right place you have to update TeX's database<br />
to let it know where it can find the files, this is done for MkII with<br />
<br />
mktexlsr (command name depends on the TeX distribution)<br />
<br />
and for MkIV with<br />
<br />
context --generate<br />
<br />
===ConTeXt standalone===<br />
<br />
Users of the ConTeXt standalone (formerly "minimals") distribution don't have to download the module files and unzip them in the local directory, because they can use the <tt>first-setup</tt> script for this.<br />
<br />
To install for example the simpleslides modules you write<br />
<br />
first-setup.sh --modules="t-simpleslides"<br />
<br />
To install more modules at the same time write<br />
<br />
first-setup.sh --modules="t-simpleslides,t-french"<br />
<br />
The complete list of availables modules in standalone is:<br />
<br />
* [http://modules.contextgarden.net/account t-account] draw T-accounts<br />
* [http://modules.contextgarden.net/algorithmic t-algorithmic] like LaTeX algorithmic<br />
* [http://modules.contextgarden.net/animation t-animation] create animations<br />
* [http://modules.contextgarden.net/annotation t-annotation] todo lists<br />
* [http://modules.contextgarden.net/t-bnf t-bnf] BNF grammar<br />
* [http://modules.contextgarden.net/chromato t-chromato] chromatograms<br />
* [http://modules.contextgarden.net/cmscbf t-cmscbf] bold small caps<br />
* [http://modules.contextgarden.net/cmttbf t-cmttbf] bold typewriter<br />
* [http://modules.contextgarden.net/t-construction-plan t-construction-plan] figures with defined scale<br />
* [http://modules.contextgarden.net/t-degrade t-degrade] degrading JPEG images<br />
* [http://modules.contextgarden.net/fancybreak t-fancybreak] thought breaks<br />
* [http://modules.contextgarden.net/filter t-filter] run external programs on inline code<br />
* [http://modules.contextgarden.net/fixme t-fixme] like LaTeX fixme<br />
* [http://modules.contextgarden.net/t-french t-french]<br />
* [http://modules.contextgarden.net/fullpage t-fullpage]<br />
* [http://modules.contextgarden.net/games t-games] board games<br />
* [http://modules.contextgarden.net/gantt t-gantt] Gantt charts<br />
* [http://modules.contextgarden.net/gnuplot t-gnuplot] include GNUplot graphics<br />
* [http://modules.contextgarden.net/t-layout t-layout]<br />
* [http://modules.contextgarden.net/letter t-letter] formal letters<br />
* [http://modules.contextgarden.net/t-lettrine t-lettrine] decorative paragraph starts (initials)<br />
* [http://modules.contextgarden.net/t-lilypond t-lilypond] include musical scores with GNU LilyPond<br />
* [http://modules.contextgarden.net/mathsets t-mathsets] mathematical sets, probabilities etc.<br />
* [http://modules.contextgarden.net/pararef t-pararef] {{cmd|startParagraph|link=no}}, for paragraphs as ‘thought blocks’ that may contain more than one 'TeX paragraph'. These paragraphs are numbered and can be referenced. See [[Paragraph Referencing]].<br />
* t-pgfplots<br />
* [http://modules.contextgarden.net/ruby t-ruby] Ruby markup (for Chinese, not programming language)<br />
* [http://modules.contextgarden.net/simplefonts t-simplefonts] simplified font mechanism<br />
* [http://modules.contextgarden.net/simpleslides t-simpleslides] presentations<br />
* [http://modules.contextgarden.net/typearea t-typearea] like LaTeX/KoMa typearea<br />
* [http://modules.contextgarden.net/typescripts t-typescripts] collection of typescripts<br />
* [http://modules.contextgarden.net/urwgaramond t-urwgaramond]<br />
* [http://modules.contextgarden.net/urwgothic t-urwgothic]<br />
* [http://modules.contextgarden.net/vim t-vim] syntax highlighting using vim’s syntax files<br />
<br />
(some of these are obsolete...)<br />
<br />
===TeX Live===<br />
<br />
TeX Live is a large TeX distribution for most Linux and BSD based operating systems. It provides binaries and many other files necessary to run TeX and its flavors. Many ConTeXt modules are included.<br />
<br />
The following modules are available:<br />
<br />
* context-account<br />
* context-bnf<br />
* context-chromato<br />
* context-construction-plan<br />
* context-degrade<br />
* context-french<br />
* context-games<br />
* context-gantt<br />
* context-gnuplot<br />
* context-letter<br />
* context-lettrine<br />
* context-lilypond<br />
* context-mathsets<br />
* context-simpleslides<br />
* context-taspresent<br />
* context-typearea<br />
* context-vim<br />
<br />
==Usage==<br />
<br />
When you load a module with <code>\usemodule[modulename]</code> ConTeXt looks for a file with the following names:<br />
<br />
* m-modulaname (core module)<br />
* p-modulename (private module)<br />
* s-modulename (ConTeXt style file)<br />
* x-modulename (XML module)<br />
* t-modulename (Third party module)<br />
* modulename<br />
<br />
Once a file is found ConTeXt stops the search and loads the found file (only once).<br />
<br />
When you have two file with the same name but different prefixes you can tell ConTeXt which file it should load with<br />
<br />
<code>\usemodule[<prefix>][modulename]</code> <br />
<br />
==Included Modules==<br />
<br />
* {{code|bibl-bib.lua}} ({{src|bibl-bib.mkiv}}): [[Bibliography]] (maintained by Taco)<br />
* {{code|m-arabtex}} ({{src|m-arabtex.mkii}}): loading of Lagally's [[Arabian and Hebrew|ArabTeX]]<br />
* {{code|m-barcodes}} ({{src|m-barcodes.mkiv}}): generate barcodes using PStricks. You should probably use m-zint instead.<br />
* {{code|m-chart}} ({{src|m-chart.lua}} {{src|m-chart.mkii}} {{src|m-chart.mkvi}}): [[Flow Charts]]<br />
* {{code|m-chemic}} ({{src|m-chemic.mkii}} {{src|m-chemic.mkiv}}): [[Chemistry|PPCHTeX]] (chemical structure formulae) <br />
* {{code|m-cweb}} ({{src|m-cweb.tex}}): [[CWEB]] pretty printing<br />
* {{code|m-database}} ({{src|m-database.lua}} {{src|m-database.mkii}} {{src|m-database.mkiv}}): creating simple tables (or forwarding data to user-defined commands) using [[m-database|comma/space/tab-separated values]]<br />
* {{code|m-datastrc}} ({{src|m-datastrc.tex}}):<br />
* {{code|m-directives}} ({{src|m-directives.mkiv}}):<br />
* {{code|m-dratex}} ({{src|m-dratex.mkii}}): loading of DraTeX<br />
* {{code|m-edtsnc}} ({{src|m-edtsnc.mkii}}): support for editor synchronization, will replace m-pdfsync<br />
* {{code|m-educat}} ({{src|m-educat.tex}}): educational additions (for settings school tests or questionaires)<br />
* {{code|m-fields}} ({{src|m-fields.mkiv}}):<br />
* {{code|m-format}} ({{src|m-format.tex}}):<br />
* <strike>[[source:m-gamma.tex|m-gamma]]: [[Aleph|Omega]] support</strike><br />
* {{code|m-graph}} ({{src|m-graph.mkii}} {{src|m-graph.mkiv}}): support for [[MetaPost]] graph module<br />
* {{code|m-ipsum}} ({{src|m-ipsum.mkiv}}): lorem ipsum filler text<br />
* {{code|m-layout}} ({{src|m-layout.tex}}): defines some [[Layout]] presets<br />
* {{code|m-level}} ({{src|m-level.mkii}}): module for catching nesting errors<br />
* {{code|m-logcategories}} ({{src|m-logcategories.mkiv}}):<br />
* {{code|m-markdown}} ({{src|m-markdown.lua}} {{src|m-markdown.mkiv}}):<br />
* {{code|m-mathcrap}} ({{src|m-mathcrap.mkiv}}):<br />
* {{code|m-mkii}} ({{src|m-mkii.mkiv}}):<br />
* {{code|m-mkivhacks}} ({{src|m-mkivhacks.mkiv}}):<br />
* {{code|m-morse}} ({{src|m-morse.mkvi}}):<br />
* {{code|m-narrowtt}} ({{src|m-narrowtt.tex}}): using a narrower [[Latin Modern]] font for verbatim<br />
* {{code|m-newmat}} ({{src|m-newmat.tex}}): support for some AMSmath features, is loaded by [[Math with amsl|amsl]], see [[Math with newmat]]<br />
* {{code|m-ntb-to-xtb}} ({{src|m-ntb-to-xtb.mkiv}}):<br />
* {{code|m-obsolete}} ({{src|m-obsolete.mkii}} {{src|m-obsolete.mkiv}}):<br />
* {{code|m-oldfun}} ({{src|m-oldfun.mkiv}}):<br />
* {{code|m-oldnum}} ({{src|m-oldnum.mkiv}}):<br />
* {{code|m-pdfsnc}} ({{src|m-pdfsnc.mkii}}): editor/PDF synchronization support (used by iTeXMac and TeXShop)<br />
* {{code|m-pictex}} ({{src|m-pictex.tex}}): needed for [[PicTeX]] without eTeX<br />
* <strike>[[source:m-plus.tex|m-plus]]: loads some extra features (currently empty)</strike><br />
* {{code|m-pstricks}} ({{src|m-pstricks.lua}} {{src|m-pstricks.mkii}} {{src|m-pstricks.mkiv}}):<br />
* {{code|m-punk}} ({{src|m-punk.mkiv}}):<br />
* <strike>[[source:m-quest.tex|m-quest]]: module for fill-in forms<br />
* (dutch only)</strike><br />
* {{code|m-r}} ({{src|m-r.tex}}): typing and executing [http://www.r-project.org/ R] scripts<br />
* {{code|m-spreadsheet}} ({{src|m-spreadsheet.lua}} {{src|m-spreadsheet.mkiv}}):<br />
* {{code|m-steps}} ({{src|m-steps.lua}} {{src|m-steps.mkii}} {{src|m-steps.mkvi}}): Step Charts, see [[XML]] step charts<br />
* {{code|m-streams}} ({{src|m-streams.tex}}): Synchronised typesetting from different sources<br />
* {{code|m-subsub}} ({{src|m-subsub.tex}}): Defines 5 extra sectioning levels<br />
* {{code|m-tex4ht}} ({{src|m-tex4ht.mkii}}): convert a ConTeXt document to html, more about it on [[tex4ht]]<br />
* {{code|m-timing}} ({{src|m-timing.mkiv}}):<br />
* {{code|m-trackers}} ({{src|m-trackers.mkiv}}):<br />
* {{code|m-translate}} ({{src|m-translate.mkiv}}):<br />
* {{code|m-units}} ({{src|m-units.mkii}} {{src|m-units.mkiv}}): Structured input of values with [[units]]<br />
* {{code|m-visual}} ({{src|m-visual.mkii}} {{src|m-visual.mkiv}}): [[Visual Debugging]] (described in [[This Way]] no.7 [[magazine:0007|Faking Text and More]])<br />
* {{code|m-zint}} ({{src|m-zint.mkiv}}): Generate barcodes using [http://www.zint.org.uk zint.exe]<br />
<br />
==Contributed Modules==<br />
For a list of contributed modules see [http://tlcontrib.metatex.org/ tlcontrib] and/or [http://modules.contextgarden.net the modules section] on contextgarden.net.<br />
<br />
{{todo|list more modules or none of them}}<br />
<br />
* [[Extended description|xdesc]] (extended description, e.g. for epigrams)<br />
* [[Math with nath|nath]] (natural math, see [[Math]])<br />
* [[Math with amsl|amsl]] (AMSmath, see [[Math]])<br />
* [[Gnuplot]]: support for direct inclusion of Gnuplot graphs out of the source (the module has been removed from the main distribution and will be included into third party modules again when ready)<br />
<br />
File names of included modules start with "m-", but third party (contributed) modules should start with "t-".<br />
<br />
In order to install a contributed module, copy its directory into <code>$TEXMF/tex/context/third</code> then run <code>luatools --generate</code>.<br />
<br />
==Special Purpose Modules==<br />
The following modules implement special formatting requirement for journals or magazines. These modules are distributed with ConTeXt, so you need not download anything.<br />
<br />
* [[Modules/MyWay|MyWay]] User documentation on ConTeXt<br />
* [[Modules/Pracjourn|pracjourn]] Articles for [http://tug.org/pracjourn/ The PracTeX Journal]<br />
* [[Modules/Maps|maps]] Articles for [http://www.ntg.nl/maps.html MAPS], the publication of NTG (Nederlandstalige TeX Gebruikersgroep or Netherlands TeX Group)<br />
<br />
==Modules writing guidelines==<br />
<br />
===Module requirements===<br />
All modules should start with a block containing ''meta information'' about that module.<br />
There is a [[module template]] available to help setting up that header correctly.<br />
<br />
Do not forget to specify a ''license'' as the permitted modes of distribution<br />
depend on which one you choose.<br />
The [http://wiki.contextgarden.net/Read_Me#The_Code ConTeXt sources] are licensed<br />
either under GPLv2 or the LPPL, so you might want to stick to these or a more permissive<br />
license.<br />
(Choose one: [http://www.opensource.org/].)<br />
Including the full text of your license in your source repo is best practice.<br />
<br />
In order to avoid ''conflicting macros'' it is essential for a module that it adhere <br />
to the [[Module_Namespaces|namespace convention]].<br />
After releasing a module its namespace[s] should be registered in the [[Module_Namespaces#List_of_Module_Namespaces|list]] for other module authors to know.<br />
<br />
===XML Interface file===<br />
Each module should have an associated XML specification file<br />
(as in [http://source.contextgarden.net/tex/context/interface/cont-en.xml /tex/context/interface/cont-en.xml]).<br />
Its purpose is a comprehensive listing of the optional and non-optional<br />
arguments that a macro defined in the module accepts.<br />
From the interface a good deal of documentation can be auto-generated,<br />
as are for instance the [http://pragma-ade.com/general/qrcs/setup-en.pdf ConTeXt Quick Reference]<br />
and the initial input of the [http://wiki.contextgarden.net/Category:Reference/en Command Reference],<br />
which itself started as a wikification of the now obsolete ''TeXShow''.<br />
<br />
When documenting your module, you can use<br />
<texcode><br />
\usemodule[int-load] %Allow xml parsing <br />
\loadsetups[m-name-of-your-module.xml] % to load the file with definitions<br />
\setup{nameofyourcommand}<br />
</texcode><br />
<br />
An example:<br />
<context source="yes"><br />
\setuppapersize[A5]<br />
\usemodule[int-load]<br />
\loadsetups<br />
\setup{externalfigure}<br />
</context><br />
<br />
By default, this places a frame around the setup. If you want to get gray background, as in the context documentation, add the following<br />
<br />
<texcode><br />
\setupframedtexts<br />
[setuptext]<br />
[background=color,<br />
backgroundcolor=lightgray,<br />
frame=off]<br />
</texcode><br />
<br />
Apart from the existing XML files in the ConTeXt tree there is little<br />
documentation online, so feel free to relay your questions to<br />
the [[Mailing list|mailing list]].<br />
<br />
===Self-documenting source code===<br />
Source files are supposed to contain explanatory comments that document<br />
implementation details and other peculiarities the reader should be<br />
aware of.<br />
In <tt>.tex</tt> files (and other files containing primarily TeX code, e.g.<br />
<tt>.mki[iv]</tt>) any line beginning with the comment leader <tt>%D</tt><br />
will be treated as such a docstring.<br />
Formatting is done via ordinary TeX commands.<br />
In Lua files (e.g. <tt>.cld</tt>) multi-line comments start with<br />
<tt>--[[ldx--</tt> and end with <tt>--ldx]]--</tt>.<br />
Text inside those delimiters can be formatted using basic ''HTML'' tags.<br />
Ordinary comments are still treated as part of the source and therefore<br />
they will be typeset inside the listing.<br />
<br />
Docstrings, though they appear to the [Lua]TeX interpreter as ordinary<br />
comments, allow for pretty printing source code when used with two<br />
dedicated modules:<br />
* [[source:x-ldx.ctx|<tt>x-ldx.ctx</tt>]] for Lua files, and<br />
* [[source:s-mod.ctx|<tt>s-mod.ctx</tt>]] for TeX files.<br />
Thus, in order to generate the documentation for the<br />
[https://bitbucket.org/wolfs/simplefonts/src ''simplefonts'']<br />
module you first have to chdir to the <tt>files</tt> subdirectory of<br />
your checkout.<br />
Next you run the pretty printer on its main file<br />
<pre><br />
context --ctx=s-mod t-simplefonts.tex<br />
</pre><br />
to get a <tt>t-simplefonts.pdf</tt> which contains the &ndash; sparse<br />
&ndash; annotations in serif and the actual code as colorful listing.<br />
Likewise the processing of Lua code, e.g. <tt>[[source:font-def.lua|font-def.lua]]</tt> from<br />
the main ConTeXt tree:<br />
<pre><br />
context --ctx=x-ldx font-def.lua<br />
</pre><br />
Which should generate a font-def.pdf in your current directory.<br />
<br />
(The autogenerated documentation of all ConTeXt sources has been<br />
made available by Luigi at [http://foundry.supelec.fr/gf/project/modules/].<br />
Go there for examples of the output.)<br />
<br />
===Legacy modules disclaimer===<br />
<!-- This info is obsolete, the section could be kicked out, doesn’t it? --><br />
Prior to release ''2005.05.25'', ConTeXt silently truncated all file names in <cmd>usemodule</cmd> commands to 8 characters long and lowercased them to "prevent cross platform problems with filenames". Thus, module files that are to be used with older versions of ConTeXt must have filenames that fit those restrictions, or they will (somewhat cryptically) not be found.</div>Philexanderhttps://wiki.contextgarden.net/index.php?title=Command/groupedcommand&diff=22748Command/groupedcommand2015-02-10T10:11:03Z<p>Philexander: </p>
<hr />
<div>{{Reference<br />
|name=groupedcommand<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd">\groupedcommand<!--<br />
--><span class="first">{...}</span><!--<br />
--><span class="second">{...}</span><!--<br />
--></td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">{...}</td><br />
<td>''before''</td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">{...}</td><br />
<td>''after''</td><br />
</tr><br />
</table><br />
<br />
== Description == <br />
<br />
{{cmd|groupedcommand}} is used for defining commands that might receive a verbatim environment as their argument, or a block wrapped in {{cmd|bgroup|...\egroup}}.<br />
<br />
<texcode><br />
\def\dostuff{\groupedcommand{...before...}{...after...}}<br />
</texcode><br />
<br />
is a robust implementation of the more naïve pattern<br />
<br />
<texcode><br />
\def\dostuff#1{...before...#1...after...}<br />
</texcode><br />
<br />
The first problem with the naïve approach: the tokens that form <code>#1</code> are fixed the the moment the argument is read in. Normally this is no problem, but e.g. verbatim environments adapt the catcodes of characters and therefore are not always happy with already fixed tokens.<br />
<br />
Another problem arises when the argument is grouped not by <code>{}</code> but by {{cmd|bgroup}} and {{cmd|egroup}}. Such an argument fails, because the {{cmd|bgroup}} is seen as the argument (which is quite normal).<br />
<br />
If you use <code>\groupedcommand</code>, the argument is identified and processed correctly.<br />
<br />
== Example ==<br />
<br />
<texcode><br />
% Don't write this<br />
\def\cite#1%<br />
{\rightquote\rightquote#1\leftquote\leftquote}<br />
<br />
% Write this, instead.<br />
\def\cite%<br />
{\groupedcommand{\rightquote\rightquote}{\leftquote\leftquote}}<br />
</texcode><br />
<br />
Another example, where the item to process is a paragraph:<br />
<br />
<texcode><br />
\def\BoldRaggedCenter%<br />
{\groupedcommand{\raggedcenter\bf}{\par}}<br />
</texcode><br />
<br />
== See also ==<br />
* {{src|syst-ext.mkii}}<br />
<br />
== Help from ConTeXt-Mailinglist/Forum ==<br />
All issues with:<br />
{{Forum|{{SUBPAGENAME}}}}<br />
<br />
[[Category:Command/Internals|groupedcommand]]</div>Philexanderhttps://wiki.contextgarden.net/index.php?title=Command/groupedcommand&diff=22747Command/groupedcommand2015-02-10T10:06:57Z<p>Philexander: </p>
<hr />
<div>{{Reference<br />
|name=groupedcommand<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd">\groupedcommand<!--<br />
--><span class="first">{...}</span><!--<br />
--><span class="second">{...}</span><!--<br />
--></td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">{...}</td><br />
<td>''before''</td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">{...}</td><br />
<td>''after''</td><br />
</tr><br />
</table><br />
<br />
== Description == <br />
<br />
{{cmd|groupedcommand}} is used for defining commands that might receive a verbatim environment as their argument, or a block wrapped in {{cmd|bgroup|...\egroup}}.<br />
<br />
<texcode><br />
\def\dostuff{\groupedcommand{...before...}{...after...}}<br />
</texcode><br />
<br />
is a robust implementation of the more naïve pattern<br />
<br />
<texcode><br />
\def\dostuff#1{...before...#1..;after...}<br />
</texcode><br />
<br />
The first problem with the naïve approach: the tokens that form <code>#1</code> are fixed the the moment the argument is read in. Normally this is no problem, but e.g. verbatim environments adapt the catcodes of characters and therefore are not always happy with already fixed tokens.<br />
<br />
Another problem arises when the argument is grouped not by <code>{}</code> but by {{cmd|bgroup}} and {{cmd|egroup}}. Such an argument fails, because the {{cmd|bgroup}} is seen as the argument (which is quite normal).<br />
<br />
If you use <code>\groupedcommand</code>, the argument is identified and processed correctly.<br />
<br />
== Example ==<br />
<br />
<texcode><br />
% Don't write this<br />
\def\cite#1%<br />
{\rightquote\rightquote#1\leftquote\leftquote}<br />
<br />
% Write this, instead.<br />
\def\cite%<br />
{\groupedcommand{\rightquote\rightquote}{\leftquote\leftquote}}<br />
</texcode><br />
<br />
Another example, where the item to process is a paragraph:<br />
<br />
<texcode><br />
\def\BoldRaggedCenter%<br />
{\groupedcommand{\raggedcenter\bf}{\par}}<br />
</texcode><br />
<br />
== See also ==<br />
* {{src|syst-ext.mkii}}<br />
<br />
== Help from ConTeXt-Mailinglist/Forum ==<br />
All issues with:<br />
{{Forum|{{SUBPAGENAME}}}}<br />
<br />
[[Category:Command/Internals|groupedcommand]]</div>Philexander