https://wiki.contextgarden.net/api.php?action=feedcontributions&user=Wolfgang+Schuster&feedformat=atomWiki - User contributions [en]2024-03-19T10:43:35ZUser contributionsMediaWiki 1.34.1https://wiki.contextgarden.net/index.php?title=File:correspondence.pdf&diff=32698File:correspondence.pdf2021-09-05T16:43:33Z<p>Wolfgang Schuster: Old version of the correspondence manual.</p>
<hr />
<div>== Summary ==<br />
Old version of the correspondence manual.</div>Wolfgang Schusterhttps://wiki.contextgarden.net/index.php?title=Documentation&diff=32629Documentation2021-07-11T18:37:55Z<p>Wolfgang Schuster: Removed duplicate of deprecated manuals</p>
<hr />
<div>__NOTOC__<br />
= The library =<br />
* ConTeXt and LuaTeX documentation is quite extensive. Start with '''Basics'''. The other manuals '''go into detail''' to understand the foundations, explore advanced features, modify or write features.<br />
* Old manuals are marked with an "deprecated" banner. They can help you find your way between the different versions.<br />
* You can also have a look to the other ConTeXt Community '''[[Web_resources|Web resources]]''' like [[Web_resources#Magazines|magazines]].<br />
<br />
<ul class="filter-links"><br />
<li></li><br />
<li>Basics</li><br />
<li>Fonts</li><br />
<li>Color</li><br />
<li>Graphics</li><br />
<li>Layout</li><br />
<li>Tables</li><br />
<li>Bibliography</li><br />
<li>Sciences</li><br />
<li>Interaction</li><br />
<li>Languages</li><br />
<li>ConTeXtTools</li><br />
<li>XML</li><br />
<li>Programming-DB</li><br />
<li>Development</li><br />
<li>TextEditors</li><br />
</ul><br />
<br />
<ul class="filter-sections"><br />
<li class="Basics">[[File:cont-enp.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/cont-enp.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/cont-enp.pdf ConTEXt reference manual 2001 – Complete, but never up-to-date, cleaned-up. (2001)]</div></li><br />
<li class="Basics">[[File:what-is-context.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/what-is-context.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/what-is-context.pdf What is ConTeXt? (2011)]</div></li><br />
<li class="Basics">[[File:contextref.jpg|100px|frameless|link=http://pmrb.free.fr/contextref.pdf]]<div style="padding-left:.5em; text-align:left;">[http://pmrb.free.fr/contextref.pdf ConTEXt reference manual 2013 - Complete, but never up-to-date, and not fully cleaned-up. (2013)]</div></li><br />
<li class="Basics">[[File:ma-cb-en.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/ma-cb-en.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/ma-cb-en.pdf ConTeXt Mark IV an excursion (2017)]</div></li><br />
<li class="Basics">[[File:setup-en.jpg|100px|frameless|link=http://www.pragma-ade.com/general/qrcs/setup-en.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/qrcs/setup-en.pdf ConTeXt commands reference - short syntax reference of all the commands (2020)]</div></li><br />
<li class="Basics">[[File:introCTX_esp.jpg|100px|frameless|link=https://raw.githubusercontent.com/contextgarden/not-so-short-introduction-to-context/main/es/introCTX_esp.pdf]]<div style="padding-left:.5em; text-align:left;">[https://raw.githubusercontent.com/contextgarden/not-so-short-introduction-to-context/main/es/introCTX_esp.pdf Una introducción (no demasiado breve) a ConTeXt Mark IV (2021)]</div></li><br />
<li class="Basics">[[File:introCTX_eng.jpg|100px|frameless|link=https://raw.githubusercontent.com/contextgarden/not-so-short-introduction-to-context/main/en/introCTX_eng.pdf]]<div style="padding-left:.5em; text-align:left;">[https://raw.githubusercontent.com/contextgarden/not-so-short-introduction-to-context/main/en/introCTX_eng.pdf A not so short introduction to ConTeXt Mark IV (2021)]</div></li><br />
<li class="Basics">[[File:introCTX_fra_s.jpg|100px|frameless|link=https://raw.githubusercontent.com/contextgarden/not-so-short-introduction-to-context/main/fr/introCTX_fra_s.pdf]]<div style="padding-left:.5em; text-align:left;">[https://raw.githubusercontent.com/contextgarden/not-so-short-introduction-to-context/main/fr/introCTX_fra_s.pdf Une courte introduction à ConTeXt (2021)]</div></li><br />
<li class="Fonts">[[File:fonts-mkiv.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/fonts-mkiv.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/fonts-mkiv.pdf Fonts out of ConTeXt – Almost everything about Fonts, processing and use (2016)]</div></li><br />
<li class="Color">[[File:msplit.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/msplit.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/msplit.pdf Colors separation (2002)]</div></li><br />
<li class="Color">[[File:colors-mkiv.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/colors-mkiv.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/colors-mkiv.pdf Coloring ConTeXt - Color spaces, profiles, transparency etc., also in MetaPost (2016)]</div></li><br />
<li class="Graphics">[[File:mchart.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/mchart.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/mchart.pdf Charts uncovered (1999)]</div></li><br />
<li class="Graphics">[[File:charts-mkiv.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/charts-mkiv.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/charts-mkiv.pdf Flowcharts (2016)]</div></li><br />
<li class="Graphics">[[File:metafun-p.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/metafun-p.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/metafun-p.pdf Metafun - For graphics, MetaPost is embedded (2017)]</div></li><br />
<li class="Graphics">[[File:nodes.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/nodes.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/nodes.pdf Nodes – Diagrams, graphical representations of relations, processes… (2018)]</div></li><br />
<li class="Graphics">[[File:rules-mkiv.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/rules-mkiv.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/rules-mkiv.pdf Rules – rules bounded to the typeset text (2018)]</div></li><br />
<li class="Graphics">[[File:graphics.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/graphics.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/graphics.pdf Graphics - integrating graphics in your document (2018)]</div></li><br />
<li class="Graphics">[[File:svg-lmtx.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/svg-lmtx.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/svg-lmtx.pdf SVG in ConTeXt and metafun xl (2019)]</div></li><br />
<li class="Graphics">[[File:luametafun.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/luametafun.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/luametafun.pdf LuaMetaFun (or Metafun xl) (2021)]</div></li><br />
<li class="Layout">[[File:style.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/style.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/style.pdf Typographic Programming - TeX thinking, line-breaking, protrusion,… (2004)]</div></li><br />
<li class="Layout">[[File:details.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/details.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/details.pdf In the details. Hints: grid typesetting, columns, backgrounds, graphics issues, formula tuning (2015)]</div></li><br />
<li class="Layout">[[File:columnsets.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/columnsets.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/columnsets.pdf Column sets (2016)]</div></li><br />
<li class="Layout">[[File:pagecolumns.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/pagecolumns.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/pagecolumns.pdf Pages Columns (2017)]</div></li><br />
<li class="Layout">[[File:spacing-mkiv.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/spacing-mkiv.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/spacing-mkiv.pdf Spacing in ConTeXt – Line spacing, line correction in grid typesetting (2018)]</div></li><br />
<li class="Tables">[[File:enattab.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/enattab.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/enattab.pdf Natural Tables in ConTEXt – Examples (2001)]</div></li><br />
<li class="Tables">[[File:spreadsheets-mkiv.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/spreadsheets-mkiv.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/spreadsheets-mkiv.pdf Simple Spreadsheets in ConTeXt MkIV (2016)]</div></li><br />
<li class="Tables">[[File:xtables-mkiv.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/xtables-mkiv.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/xtables-mkiv.pdf Extreme Tables in ConTeXt MkIV (2018)]</div></li><br />
<li class="Bibliography">[[File:mkiv-publications.jpg|100px|frameless|link=http://pragma-ade.nl/general/manuals/mkiv-publications.pdf]]<div style="padding-left:.5em; text-align:left;">[http://pragma-ade.nl/general/manuals/mkiv-publications.pdf Bibliographies the ConTeXt way (2017)]</div></li><br />
<li class="Sciences">[[File:mp-ch-en.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/mp-ch-en.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/mp-ch-en.pdf PPCHTeX - macros for typesetting chemical structures (2001)]</div></li><br />
<li class="Sciences">[[File:eppchtex.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/eppchtex.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/eppchtex.pdf PPCHTeX example - Chemical Formulas in ConTeXt (2001)]</div></li><br />
<li class="Sciences">[[File:mmoexamp.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/mmoexamp.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/mmoexamp.pdf OpenMath in ConTeXt – Examples (2006)]</div></li><br />
<li class="Sciences">[[File:mmlprime.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/mmlprime.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/mmlprime.pdf MathML (2015)]</div></li><br />
<li class="Sciences">[[File:units-mkiv.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/units-mkiv.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/units-mkiv.pdf Units - SI units support (2015)]</div></li><br />
<li class="Sciences">[[File:mmlexamp.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/mmlexamp.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/mmlexamp.pdf MathML in ConTeXt – Examples (2016)]</div></li><br />
<li class="Sciences">[[File:math-mkiv.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/math-mkiv.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/math-mkiv.pdf Math rendering (2018)]</div></li><br />
<li class="Interaction">[[File:mwidget-p.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/mwidget-p.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/mwidget-p.pdf Widgets uncovered - Form elements, cross references, JavaScript in PDF (2001)]</div></li><br />
<li class="Interaction">[[File:interaction.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/interaction.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/interaction.pdf Interactivity (2018)]</div></li><br />
<li class="Languages">[[File:languages-mkiv.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/languages-mkiv.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/languages-mkiv.pdf Languages in ConTEXt – explaining luatex and mkiv (2016)]</div></li><br />
<li class="Languages">[[File:bidi.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/bidi.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/bidi.pdf L2R R2L – a few tips (2019)]</div></li><br />
<li class="ConTeXtTools">[[File:mmodes.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/mmodes.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/mmodes.pdf Modes – Modes are used for conditionnal processing (screen, A4, letter…) (2008)]</div></li><br />
<li class="ConTeXtTools">[[File:texit.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/texit.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/texit.pdf TeX iT (2018)]</div></li><br />
<li class="ConTeXtTools">[[File:tiptrick.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/tiptrick.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/tiptrick.pdf Tip Trick (mtxrun command) (2018)]</div></li><br />
<li class="ConTeXtTools">[[File:workflows-mkiv.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/workflows-mkiv.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/workflows-mkiv.pdf Workflows support in ConTeXt - MkIV and LuaTeX features for efficiency (2019)]</div></li><br />
<li class="ConTeXtTools">[[File:lowlevel-boxes.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/lowlevel-boxes.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/lowlevel-boxes.pdf Low Level Tex – Boxes (2019)]</div></li><br />
<li class="ConTeXtTools">[[File:lowlevel-expansion.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/lowlevel-expansion.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/lowlevel-expansion.pdf Low Level Tex – Expansion (2019)]</div></li><br />
<li class="ConTeXtTools">[[File:lowlevel-registers.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/lowlevel-registers.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/lowlevel-registers.pdf Low Level Tex – Registers (2019)]</div></li><br />
<li class="ConTeXtTools">[[File:luatex.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/luatex.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/luatex.pdf LuaTeX Reference Manual (2020)]</div></li><br />
<li class="ConTeXtTools">[[File:tools-mkiv.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/tools-mkiv.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/tools-mkiv.pdf Luatools mtxrun for ContTeXt (2020)]</div></li><br />
<li class="ConTeXtTools">[[File:primitives.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/primitives.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/primitives.pdf New Primitives un LuaMetaTeX (2020)]</div></li><br />
<li class="ConTeXtTools">[[File:lowlevel-macros.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/lowlevel-macros.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/lowlevel-macros.pdf Low Level Tex – Macros (2020)]</div></li><br />
<li class="ConTeXtTools">[[File:lowlevel-grouping.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/lowlevel-grouping.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/lowlevel-grouping.pdf Low Level Tex – Grouping (2020)]</div></li><br />
<li class="ConTeXtTools">[[File:lowlevel-security.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/lowlevel-security.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/lowlevel-security.pdf Low Level Tex – Security (2020)]</div></li><br />
<li class="ConTeXtTools">[[File:lowlevel-conditionals.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/lowlevel-conditionals.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/lowlevel-conditionals.pdf Low Level Tex – Conditionals (2021)]</div></li><br />
<li class="ConTeXtTools">[[File:luametatex.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/luametatex.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/luametatex.pdf LuaMetaTeX Reference Manual (2021)]</div></li><br />
<li class="ConTeXtTools">[[File:lowlevel-characters.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/lowlevel-characters.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/lowlevel-characters.pdf Low Level Tex – Characters (2021)]</div></li><br />
<li class="ConTeXtTools">[[File:lowlevel-scope.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/lowlevel-scope.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/lowlevel-scope.pdf Low Level Tex – Scope (2021)]</div></li><br />
<li class="ConTeXtTools">[[File:lowlevel-paragraphs.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/lowlevel-paragraphs.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/lowlevel-paragraphs.pdf Low Level Tex – Paragraphs (2021)]</div></li><br />
<li class="XML">[[File:xfigures-s.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/xfigures-s.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/xfigures-s.pdf Figures – ConTeXt XML (2001)]</div></li><br />
<li class="XML">[[File:xmathml-s.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/xmathml-s.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/xmathml-s.pdf MathML – ConTeXt XML (how to invoke mathml, addendum of mathml) (2001)]</div></li><br />
<li class="XML">[[File:xphysml-s.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/xphysml-s.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/xphysml-s.pdf PhysML – ConTeXt XML (2001)]</div></li><br />
<li class="XML">[[File:xchemml-s.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/xchemml-s.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/xchemml-s.pdf ChemML – ConTeXt XML (2001)]</div></li><br />
<li class="XML">[[File:xxmldir.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/xxmldir.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/xxmldir.pdf Directory Trees (2004)]</div></li><br />
<li class="XML">[[File:epub-mkiv.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/epub-mkiv.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/epub-mkiv.pdf Exporting XML and ePub from Context (2015)]</div></li><br />
<li class="XML">[[File:xml-mkiv.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/xml-mkiv.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/xml-mkiv.pdf Dealing with XML in ConTeXt MkIV (2016)]</div></li><br />
<li class="XML">[[File:templates-mkiv.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/templates-mkiv.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/templates-mkiv.pdf XML/Lua templates (2016)]</div></li><br />
<li class="XML">[[File:steps-mkiv.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/steps-mkiv.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/steps-mkiv.pdf Steps – ConTeXt XML (2017)]</div></li><br />
<li class="Programming-DB">[[File:swiglib-mkiv.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/swiglib-mkiv.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/swiglib-mkiv.pdf SWIGlib – Basics : use external libraries (2016)]</div></li><br />
<li class="Programming-DB">[[File:lua-mkiv.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/lua-mkiv.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/lua-mkiv.pdf Lua - the ConTeXt libraries (2016)]</div></li><br />
<li class="Programming-DB">[[File:cld-mkiv.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/cld-mkiv.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/cld-mkiv.pdf ConTeXt Lua Documents (2018)]</div></li><br />
<li class="Programming-DB">[[File:sql-mkiv.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/sql-mkiv.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/sql-mkiv.pdf SQL in ConTeXt (2020)]</div></li><br />
<li class="Programming-DB">[[File:libraries-mkiv.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/libraries-mkiv.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/libraries-mkiv.pdf Libraries – Basics (2020)]</div></li><br />
<li class="Programming-DB">[[File:ecmascript-mkiv.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/ecmascript-mkiv.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/ecmascript-mkiv.pdf ECMA SCRIPT in context lmtx - using the optional mujs library (2020)]</div></li><br />
<li class="Development">[[File:hybrid.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/hybrid.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/hybrid.pdf 2- MkIV Hybrid Technology - How LuaTeX combines TeX, MetaPost, Lua and XML (2012)]</div></li><br />
<li class="Development">[[File:about.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/about.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/about.pdf 3- About LuaTeX and ConTeXt in 2015 (2015)]</div></li><br />
<li class="Development">[[File:mreadme.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/mreadme.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/mreadme.pdf Read Me first (2016)]</div></li><br />
<li class="Development">[[File:mk.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/mk.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/mk.pdf 1- Context MarkII MarkIV - The history of LuaTeX 2006–2009 (2016)]</div></li><br />
<li class="Development">[[File:still.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/still.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/still.pdf 4- Still going on (2016)]</div></li><br />
<li class="Development">[[File:onandon.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/onandon.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/onandon.pdf 4.5- On and on (2016)]</div></li><br />
<li class="Development">[[File:notnow.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/notnow.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/notnow.pdf 5.5- Not Now (2018)]</div></li><br />
<li class="Development">[[File:followingup.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/followingup.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/followingup.pdf 5- Following up (current working report) (2019)]</div></li><br />
<li class="Development">[[File:musings.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/musings.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/musings.pdf ConTeXt Musing (2019)]</div></li><br />
<li class="Development">[[File:evenmore.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/evenmore.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/evenmore.pdf 6- Even More – fun with luametatex and context (2020)]</div></li><br />
<li class="TextEditors">[[File:scite-context-readme.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/scite-context-readme.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/scite-context-readme.pdf Scite in Context MkIV : editor setup (2011)]</div></li><br />
</ul><br />
<br />
<br />
= Deprecated manuals =<br />
<ul class="filter-sections"><br />
<li class="Basics">[[File:mp-cb-en.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/mp-cb-en.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/mp-cb-en.pdf ConTeXt an excursion (1999)]</div></li><br />
<li class="Fonts">[[File:mtexfont.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/mtexfont.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/mtexfont.pdf TexFont explained (2001)]</div></li><br />
<li class="Fonts">[[File:co-fonts.jpg|100px|frameless|link=http://context.aanhet.net/svn/contextman/context-reference/en/co-fonts.pdf]]<div style="padding-left:.5em; text-align:left;">[http://context.aanhet.net/svn/contextman/context-reference/en/co-fonts.pdf Fonts chapter (2005)]</div></li><br />
<li class="Fonts">[[File:mfonts.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/mfonts.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/mfonts.pdf Fonts in Context (2005)]</div></li><br />
<li class="Fonts">[[File:showfont.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/showfont.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/showfont.pdf Font Sampler (MkII) (2005)]</div></li><br />
<li class="Graphics">[[File:mmakempy.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/mmakempy.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/mmakempy.pdf Creating MetaPost outlines (2001)]</div></li><br />
<li class="Graphics">[[File:mlabels.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/mlabels.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/mlabels.pdf Labels : Adding Text to Graphics (2002)]</div></li><br />
<li class="Layout">[[File:columns.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/columns.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/columns.pdf Columns (2003)]</div></li><br />
<li class="Layout">[[File:xcorresp.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/xcorresp.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/xcorresp.pdf Correspondence (2003)]</div></li><br />
<li class="Layout">[[File:correspondence.jpg|100px|frameless|link=http://bitbucket.org/wolfs/correspondence/downloads/correspondence.pdf]]<div style="padding-left:.5em; text-align:left;">[http://bitbucket.org/wolfs/correspondence/downloads/correspondence.pdf Correspondence with ConTEXt (2010)]</div></li><br />
<li class="Sciences">[[File:06.jpg|100px|frameless|link=https://www.ntg.nl/maps/34/06.pdf]]<div style="padding-left:.5em; text-align:left;">[https://www.ntg.nl/maps/34/06.pdf ConTeXt rehab for amsmath addicts (2006)]</div></li><br />
<li class="Languages">[[File:mchinese.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/mchinese.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/mchinese.pdf Chinese in Context (2001)]</div></li><br />
<li class="ConTeXtTools">[[File:mtexexec.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/mtexexec.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/mtexexec.pdf TeXEXEC explained (2001)]</div></li><br />
<li class="ConTeXtTools">[[File:minstall.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/minstall.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/minstall.pdf How to install Context (2001)]</div></li><br />
<li class="ConTeXtTools">[[File:mtexutil.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/mtexutil.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/mtexutil.pdf TeXUTIL (2001)]</div></li><br />
<li class="ConTeXtTools">[[File:mtexwork.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/mtexwork.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/mtexwork.pdf TeXwork (2001)]</div></li><br />
<li class="ConTeXtTools">[[File:ex-gui.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/ex-gui.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/ex-gui.pdf PRAGMA POD example gui (2002)]</div></li><br />
<li class="ConTeXtTools">[[File:mpstopdf.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/mpstopdf.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/mpstopdf.pdf Weaving PS into PDF (2003)]</div></li><br />
<li class="ConTeXtTools">[[File:mtexsync-p.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/mtexsync-p.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/mtexsync-p.pdf texsync (2003)]</div></li><br />
<li class="ConTeXtTools">[[File:mpattern.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/mpattern.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/mpattern.pdf Hyphenation patterns (2005)]</div></li><br />
<li class="ConTeXtTools">[[File:xmanipulate.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/xmanipulate.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/xmanipulate.pdf Preprocessing Source Files & Manipulating Graphic Resources (2005)]</div></li><br />
<li class="ConTeXtTools">[[File:mtexmfstart.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/mtexmfstart.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/mtexmfstart.pdf TEXMF Start (2006)]</div></li><br />
<li class="XML">[[File:example.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/example.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/example.pdf XML in ConTeXt (MkII) (2001)]</div></li><br />
<li class="XML">[[File:xmlfoe.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/xmlfoe.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/xmlfoe.pdf Just an XML FO engine (2004)]</div></li><br />
<li class="TextEditors">[[File:mscite-s.jpg|100px|frameless|link=http://www.pragma-ade.com/general/manuals/mscite-s.pdf]]<div style="padding-left:.5em; text-align:left;">[http://www.pragma-ade.com/general/manuals/mscite-s.pdf Scite in Context : short manual (2006)]</div></li><br />
</ul><br />
<br />
<br />
= Remarks =<br />
<br />
* To save time of developers, '''please, read the manuals before you start asking questions at the [https://mailman.ntg.nl/mailman/listinfo/ntg-context mailing list''']. <br />
* Most of the manuals are available in the [http://www.pragma-ade.com/install.htm ConTeXt distribution], and on the mirrors like [https://bitbucket.org/phg/context-mirror/src/beta/doc/context/documents/general/ bitbucket.org], with their [https://bitbucket.org/phg/context-mirror/src/beta/doc/context/sources/general/manuals sources],<br />
* An other overview is also available at [http://www.pragma-ade.com/overview.htm Pragma-Ade website], with an interactive PDF as the [http://www.pragma-ade.com/show-man.pdf Manuals Gallery],<br />
* Some printed versions can be purchased from [http://www.h2o-boeken.nl/product-category/context H2O-Books]:<br />
** [http://www.h2o-boeken.nl/product/metafun-manual/ MetaFun manual] - 2010<br />
** [http://www.h2o-boeken.nl/product/mkii-mkiv-the-history-of-luatex/ MKII – MKIV, the history of LuaTeX] - 2010<br />
** [http://www.h2o-boeken.nl/product/layouts-in-context/ Layouts in ConTeXt] - 2011<br />
** [http://www.h2o-boeken.nl/product/fonts-in-context/ Fonts in ConTeXt] - 2011<br />
* Henri Menke also gathers and comments this precious material at [https://github.com/hmenke/context-examples/blob/master/GUIDE.md The definitive guide to ConTeXt MkIV documentation].<br />
<br />
<br />
[[Category:Documentation]]<br />
[[Category:Basics]]</div>Wolfgang Schusterhttps://wiki.contextgarden.net/index.php?title=Symbols/mvs&diff=31984Symbols/mvs2020-10-26T15:22:36Z<p>Wolfgang Schuster: Changed name of the marvosym font for \showfont</p>
<hr />
<div>< [[Symbols]]<br />
<br />
= Martin Vogel Symbols =<br />
<br />
You can load the <b>Martin Vogel Symbols</b> with<br />
<texcode><br />
\usesymbols[mvs]<br />
</texcode><br />
There are several symbol sets defined. If you want the symbol for Neptune, you can either load the whole <i>astronomic</i> sybol set first:<br />
<texcode><br />
\setupsymbolset [astronomic]<br />
\symbol [Neptune]<br />
</texcode><br />
or use it as<br />
<texcode><br />
\symbol[astronomic][Neptune]<br />
</texcode><br />
<context><br />
\usesymbols[mvs]<br />
\symbol[astronomic][Neptune]<br />
</context><br />
<br />
<font color="red"><b>Warning</b>: some definitions in symb-mvs are outdated since the file [[source:symb-mvs.tex|symb-mvs.tex]] wasn't synchronized with font changes. Also, some symbol sets don't have really sensible names. The file needs to be updated.</font><br />
<br />
== Symbol Sets ==<br />
<br />
=== astronomic ===<br />
<context><br />
\usesymbols[mvs]<br />
\showsymbolset[astronomic]<br />
</context><br />
<br />
=== zodiac ===<br />
<br />
<context><br />
\usesymbols[mvs]<br />
\showsymbolset[zodiac]<br />
</context><br />
<br />
=== europe ===<br />
<br />
<context><br />
\usesymbols[mvs]<br />
\showsymbolset[europe]<br />
</context><br />
<br />
=== martinvogel 1 ===<br />
<br />
<context><br />
\usesymbols[mvs]<br />
\showsymbolset[martinvogel 1]<br />
</context><br />
<br />
=== martinvogel 2 ===<br />
<br />
<context><br />
\usesymbols[mvs]<br />
\showsymbolset[martinvogel 2]<br />
</context><br />
<br />
=== martinvogel 3 ===<br />
<br />
<context><br />
\usesymbols[mvs]<br />
\showsymbolset[martinvogel 3]<br />
</context><br />
<br />
== All glyphs ==<br />
<br />
<context><br />
\setuplayout[scale=0.8]<br />
\showfont[marvosym.ttf]<br />
</context><br />
<br />
== See also ==<br />
* [http://www.ctan.org/tex-archive/fonts/psfonts/marvosym/ marvosym on CTAN] and [http://tug.ctan.org/fonts/psfonts/marvosym/marvodoc.pdf marvodoc.pdf]<br />
* source: [[source:symb-mvs.tex|symb-mvs.tex]]<br />
<br />
[[Category:Symbols]]</div>Wolfgang Schusterhttps://wiki.contextgarden.net/index.php?title=Description&diff=23714Description2018-01-16T00:40:03Z<p>Wolfgang Schuster: Added empty line after paragraph delimited descriptions.</p>
<hr />
<div>< [[From LaTeX to ConTeXt]] | [[Structurals]] ><br />
<br />
= Basic Description Lists =<br />
<br />
== LaTeX ==<br />
<br />
LaTeX provides a <tt>description</tt> environment, which works just like an itemized or enumerated list except that the item labels are specified by an (optional) argument to the {{cmd|item}} command, rather than being automatically generated. This is useful for making lists of definitions and other sorts of descriptions that are headed by a keyword.<br />
<br />
<texcode><br />
\documentclass{article}<br />
\begin{document}<br />
\begin{description}<br />
\item[Short] This is a shorter item label, and some text that talks<br />
about it. The text is wrapped into a paragraph, with successive<br />
lines indented.<br />
\item[Rather longer label] This is a longer item label. As you can<br />
see, the text is not started a specified distance in -- unlike<br />
with other lists -- but is spaced a fixed distance from the end<br />
of the label.<br />
\end{description}<br />
\end{document}<br />
</texcode><br />
<br />
== ConTeXt ==<br />
<br />
ConTeXt provides a similar mechanism. Unlike the LaTeX version, ConTeXt's description mechanism does not enclose the items in an environment, but instead formats them independently according to formats given in {{cmd|setupdescriptions}} or {{cmd|definedescription}}. The {{cmd|definedescription}} latter command is used to define a named description class, which can later be called using its name. This example defines a <tt>latexdesc</tt> description, with parameters that roughly approximate the LaTeX defaults.<br />
<br />
<context source=yes><br />
\definedescription[latexdesc][<br />
headstyle=bold, style=normal, align=flushleft, alternative=hanging, <br />
width=broad, margin=1cm]<br />
<br />
\latexdesc{Short} This is a shorter item label, and some text that <br />
talks about it. The text is wrapped into a paragraph, with <br />
successive lines indented.<br />
<br />
\latexdesc{Rather longer label} This is a longer item label. As you <br />
can see, the text is not started a specified distance in -- unlike <br />
with other lists -- but is spaced a fixed distance from the end of <br />
the label.<br />
<br />
</context><br />
<br />
The empty lines (or {{cmd|par}}) after each description (here, <tt>\latexdesc</tt>) line are required.<br />
<br />
The <tt>margin=<i>dimension</i></tt> key specifies the hanging indentation for lines after the first line. In addition, the separation between the label and the text can be specified using a <tt>distance=<i>dimension</i></tt> key.<br />
<br />
<br />
= Multi-Paragraph Descriptions =<br />
<br />
== LaTeX ==<br />
<br />
Because the LaTeX description mechanism is an environment, it is simple to include multiple paragraphs in a description environment, or even to embed sub-lists. For instance, consider the following example:<br />
<br />
<texcode><br />
\documentclass{article}<br />
\begin{document}<br />
\begin{description}<br />
\item[Para] This is a shorter item label, and some text that talks about it.<br />
The text is wrapped into a paragraph, with successive lines indented.<br />
<br />
This is another paragraph under the "Para" item.<br />
<br />
\begin{description}<br />
\item[Sub-Item] This is a description of an item which is within the<br />
"Para" item.<br />
<br />
\item[Sub-Item] Another sub-item.<br />
\end{description}<br />
\item[Short] A short item that's not part of that really long "Para" item.<br />
\end{description}<br />
\end{document}<br />
</texcode><br />
<br />
In this example, the code indentation has been used to illustrate the alignment of the typeset output. Everything between <code>\item[Para]</code> and <code>\item[Short]</code> is part of the "Para" item, and is indented by the same amount. The embedded description then embeds any following lines on the "Sub-Item"s by an additional indentation, as one would expect.<br />
<br />
== ConTeXt ==<br />
<br />
Multiple paragraphs (without first line indenting) can be created as follows:<br />
<br />
<context source=yes><br />
\definedescription[descr][<br />
headstyle=bold, style=normal, align=flushleft, alternative=hanging, <br />
width=broad, margin=1cm]<br />
<br />
\startdescr{Para}<br />
This is a shorter item label, and some text that talks about it.<br />
The text is wrapped into a paragraph, with successive lines indented.<br />
<br />
This is another paragraph under the "Para" item.<br />
\startdescr{Sub Item} <br />
This is a description of an item which is within the "Para" item.<br />
\stopdescr<br />
\startdescr{Sub Item} <br />
Another Sub Item <br />
\stopdescr<br />
\stopdescr<br />
\startdescr{Short}<br />
A short item that's not part of that really long "Para" item.<br />
\stopdescr<br />
</context><br />
<br />
<br />
= Descriptions with Fixed Label Width =<br />
<br />
== LaTeX ==<br />
<br />
In LaTeX, the <tt>mdwlist</tt> package can be used to set a fixed label width.<br />
<br />
<texcode><br />
\documentclass{article}<br />
\usepackage{mdwlist}<br />
\begin{document}<br />
\begin{basedescript}{\desclabelstyle{\pushlabel}\desclabelwidth{6em}}<br />
\item[Short] This is a shorter item label, and some text that talks about it.<br />
The text is wrapped into a paragraph, with successive lines indented.<br />
\item[Rather longer label] This is a longer item label. As you can see, the<br />
paragraph simply starts 6em in.<br />
\end{basedescript}<br />
\end{document}<br />
</texcode><br />
<br />
== ConTeXt ==<br />
<br />
Using an explicit dimension as argument for the 'width' parameter<br />
sets the label to 5em:<br />
<br />
<context source=yes><br />
\definedescription[notation][<br />
headstyle=bold, style=normal, align=flushleft, alternative=hanging, <br />
width=5em]<br />
<br />
\notation{Short} This is a shorter item label, and some text that talks<br />
about it. The text is wrapped into a paragraph, with successive<br />
lines indented.<br />
<br />
\notation{Rather longer label} This is a longer item label. As you can<br />
see, the paragraph simply pretends the label is 5em wide.<br />
<br />
</context><br />
<br />
Another example:<br />
<br />
<context source=yes><br />
\setupcolors[state=start]<br />
\definedescription[Desc][alternative=top, hang=20,<br />
headstyle=bold, headcolor=blue<br />
command=\hskip-1cm, margin=1cm]<br />
<br />
\Desc{Short} This item's short label is set above the paragraph. The<br />
paragraph starts 1cm in.<br />
<br />
\Desc{Rather longer label} This item's rather longer label is also set<br />
above the paragraph. The paragraph starts 1cm in.<br />
<br />
</context><br />
<br />
== See also ==<br />
* {{cmd|definedescription}}<br />
* {{cmd|startdescription}}</div>Wolfgang Schusterhttps://wiki.contextgarden.net/index.php?title=URL&diff=23447URL2017-08-15T17:06:00Z<p>Wolfgang Schuster: moved Url to URL</p>
<hr />
<div>== Overview ==<br />
URLs can be typeset in various ways. You may specify a URL for later reuse via {{cmd|useURL}}:<br />
<texcode><br />
\useURL[aurl] [http://xkcd.com/149/] [] [I prefer hot dogs.] <br />
</texcode><br />
where #1 is the identifier, #2 is the URL you want to point to, and #4 the text to be displayed where the URL is used. #3 can be used for the 'file path' portion of the URL, if you want. This dates back to when hyperlink support in <br />
DVI viewers required that split.<br />
<br />
Alternatively, you can use only two arguments and the URL will be used as its own text. <br />
<texcode><br />
\useURL[anotherurl] [http://xkcd.com/224/]<br />
</texcode><br />
(That way any character may appear inside the URL string without breaking things under certain circumstances, which can happen when you specify the URL itself as the fourth argument.)<br />
<br />
Now that you have defined some URLs you are ready to dereference them by their identifier wherever you please. Don't forget to enable interaction for clickable WWW-look-and-feel.<br />
<texcode><br />
\setupinteraction[state=start]<br />
\starttext<br />
\from[aurl] % typesets the URL description in color<br />
\from[anotherurl] % typesets the URL in color<br />
\stoptext<br />
</texcode><br />
<br />
You can use<br />
<texcode><br />
\url[aurl]<br />
</texcode><br />
as well, which behaves like \from[#1].<br />
<br />
== How to Typeset URLs ==<br />
<br />
=== Example for Mailto #1 ===<br />
<context source=yes><br />
\setupinteraction[state=start] <br />
\useurl [mymail] [mailto:nobody@example.zzz] [][visible@mailaddress.zzz]<br />
<br />
\starttext <br />
<br />
Send your spam to \from[mymail]! <br />
<br />
\stoptext <br />
</context><br />
<br />
=== Example for Mailto #2 ===<br />
<br />
<context source=yes><br />
\setupinteraction[state=start] <br />
\starttext <br />
Send your spam to \goto{visible@mailaddress.zzz}[url(mailto:nobody@example.zzz)] <br />
\stoptext <br />
</context><br />
<br />
=== Example for WWW ({{cmd|goto}}) ===<br />
<br />
Another way of typesetting URLs is the {{cmd|goto}}: \goto{#1}[#2] command. This expects the description text as first argument and the actual URL as the second one; note that it has to be wrapped in url(#2) to create a clickable link:<br />
<texcode><br />
\goto{In Lua, array indices start from one.}[url(http://www.xkcd.com/163/)]<br />
</texcode><br />
<br />
=== Escaping of Special Characters ===<br />
<br />
Note that special characters, eg hash sign, percent sign, must be escaped.<br />
Escaping means that the special character will be processed one step later and it prevents<br />
annoying error messages during compilation.<br />
<br />
The <code>#</code> sign will be replaced by <code>\#</code>,<br/><br />
the <code>%</code> sign will be replaced by <code>\%</code>, etc.<br />
<br />
<context source=yes><br />
\setupinteraction[state=start] <br />
\useurl [myurl] [www.example.zzz/\#999] []<br />
[www.example.zzz/\#999] <br />
</context><br />
<br />
Another way of writing special characters is described below, with hyphenated URLs.<br />
<br />
== Hyphenated URLs ==<br />
<br />
URLs tend to become large monsters under many circumstances but you may have a good reason not to conceal them from the reader. <br />
This is where hyphenation comes in handy.<br />
ConTeXt provides a dedicated mechanism for chopping them into pieces:<br />
<context source=yes><br />
\hyphenatedurl{http://bits.blogs.nytimes.com/2010/03/05/a-former-book-designer-says-good-riddance-to-print/?hpw}<br />
</context><br />
<br />
=== Hyphenation Rules ===<br />
<br />
This has some characters predefined where Hans “likes” URLs to break (see the list at the beginning of [[source:lang-url.lua|lang-url.lua]], cf. [http://www.ntg.nl/pipermail/ntg-context/2008/032959.html a message on ntg-context]).<br />
If you prefer other characters you can add them via:<br />
<texcode><br />
\sethyphenatedurlnormal{:=?&}<br />
\sethyphenatedurlbefore{?&}<br />
\sethyphenatedurlafter {:=}<br />
</texcode><br />
<br />
URL hyphenation can, of course, be used wherever you need them.<br />
<texcode><br />
\useURL[yaurl] [http://xkcd.com/638/] [] [\hyphenatedurl{http://xkcd.com/638/}]<br />
\starttext<br />
\from[yaurl]<br />
\stoptext<br />
</texcode><br />
<br />
=== Escaping Special Characters ===<br />
<br />
The method for escaping of special characters described above does not work with command<br />
{{cmd|hyphenatedurl}}, unfortunately. Escaping backslash will undesirably appear on the output.<br />
<br />
In this case, all special characters must be rewritten to commands, see the following list:<br />
<table><br />
<tr><td><code>%</code></td><td> --> <code>{{cmd|letterpercent}}</code></td></tr><br />
<tr><td><code>#</code></td><td> --> <code>{{cmd|letterhash}}</code></td></tr><br />
</table><br />
<br />
A custom symbol can be inserted as well, eg in case of a linebreak:<br />
<texcode><br />
\def\hyphenatedurlseparator{↩}<br />
</texcode><br />
<br />
These special commands can be used in other cases, like {{cmd|useURL}}, too.<br />
<br />
<br />
== Setting Color and Style ==<br />
For {{cmd|url}}:<br />
<texcode><br />
\setupurl<br />
[color=blue,<br />
style=\tf]<br />
</texcode><br />
For \goto and \from:<br />
<texcode><br />
\setupinteraction<br />
[state=start,<br />
color=blue,<br />
style=\tf]<br />
</texcode><br />
<br />
== Tips and Tricks ==<br />
<br />
=== Many Different Hyperrefs ===<br />
If you need many hyperrefs in your document these definitions may be handy for you<br />
<context source=yes><br />
\def\href#1#2{\useURL[#2][{#2}][][{#1}]\goto{\url[#2]}[url(#1)]} <br />
\def\ahref#1{\color[linkcolor]{\ttx \href{#1}{<#1>}}} <br />
\def\fullahref#1{\color[linkcolor]{\ttx \href{#1}{http://#1}}} <br />
\def\mailto#1{\useURL[#1][mailto:#1][][#1]\from[{#1}]} <br />
\def\MailTo#1#2{\useURL[#1][mailto:#1][][#2]\from[{#1}]} <br />
<br />
Send mail to \MailTo{foo@bar.zzz}{Mr. Foo}<br />
</context><br />
<br />
=== External Links ===<br />
Create a macro for external links in a colour that is distinct from other document links.<br />
<br />
<pre><br />
% Enable document colours<br />
\setupcolors[state=start,]<br />
<br />
% Internal link colours<br />
\setupinteraction[state=start,color=blue,]<br />
<br />
% External link colours<br />
\definecolor[steelblue][h=4682B4]<br />
\define[2]\href{%<br />
\begingroup<br />
\setupinteraction[<br />
style=normal,<br />
color=steelblue,<br />
]%<br />
\goto{#1}[url(#2)]%<br />
\endgroup%<br />
}<br />
<br />
% Set index colours<br />
\setupcombinedlist[content][<br />
interaction=all,<br />
color=red,<br />
]<br />
<br />
% Set the table of contents colours<br />
\setuplist[chapter][<br />
% Text colour<br />
color=darkcyan,<br />
% Page number colour<br />
pagecolor=darkgreen,<br />
]<br />
<br />
% Set up the index heading colour<br />
\setupregister[index][<br />
color=darkgray,<br />
balance=no,<br />
]<br />
<br />
\def\Google{G\color[red]{o}\color[orange]{o}g\color[green]{l}\color[red]{e}}<br />
<br />
\starttext<br />
\completecontent<br />
<br />
\startchapter[title=chapter]<br />
Search \index{source code}{source code} using \href{\Google{} Website}{http://google.com}! Read about<br />
\index{syntax}{syntax}.<br />
\stopchapter<br />
<br />
\placeindex<br />
<br />
\stoptext<br />
</pre></div>Wolfgang Schusterhttps://wiki.contextgarden.net/index.php?title=Command/definefontfamily&diff=23126Command/definefontfamily2016-08-14T20:43:11Z<p>Wolfgang Schuster: Fixed wring arguments for the \definefontfamily command</p>
<hr />
<div>{{Reference<br />
|name=definefontfamily<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd">\definefontfamily<span class="first">[...]</span><span class="second">[...]</span><span class="third">[...]</span><span class="fourth">[...,...=...,...]</span></td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[...]</td><br />
<td>TEXT (typescript identifier)</td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[...]</td><br />
<td>rm ss tt mm hw cg serif sans mono math handwriting calligraphy</td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[...]</td><br />
<td>TEXT (existing font name)</td><br />
</tr><br />
<tr valign="top" class="fourth"><br />
<td class="cmd">[[Command/keyword:rscale|rscale]]</td><br />
<td>[[Command/value:NUMBER|NUMBER]]</td><br />
</tr><br />
<tr valign="top" class="fourth"><br />
<td class="cmd">[[Command/keyword:features|features]]</td><br />
<td>[[Command/value:IDENTIFIER|IDENTIFIER]]</td><br />
</tr><br />
<tr valign="top" class="fourth"><br />
<td class="cmd">[[Command/keyword:designsize|designsize]]</td><br />
<td>[[Command/value:default|default]] [[Command/value:auto|auto]]</td><br />
</tr><br />
<tr valign="top" class="fourth"><br />
<td class="cmd">[[Command/keyword:goodies|goodies]]</td><br />
<td>[[Command/value:IDENTIFIER|IDENTIFIER]]</td><br />
</tr><br />
</table><br />
<br />
== Description == <br />
<br />
== Example ==<br />
<br />
In the first example we create a new typeface with the name `mainface` which includes fonts from the TeX Gyre family. Even though there is no math used in this example it is better to set one because math symbols are sometimes used in text mode.<br />
<br />
<context mode="mkiv" source="yes" text="produces"><br />
\definefontfamily [mainface] [rm] [TeX Gyre Pagella]<br />
\definefontfamily [mainface] [ss] [TeX Gyre Heros]<br />
\definefontfamily [mainface] [mm] [TeX Gyre Pagella Math]<br />
<br />
\setupbodyfont[mainface]<br />
<br />
\starttext<br />
\rm Serif: TeX Gyre Pagella<br />
<br />
\ss Sans: TeX Gyre Heros<br />
\stoptext<br />
</context><br />
<br />
In this example we are switching the fonts which are used for the upright, italic etc. alternatives. With the help of the `style` keyword you access one of the predefined styles, by default `\definefontfamily` uses the following styles for each alternative:<br />
<br />
{|<br />
! Alternative !! Style<br />
|-<br />
| tf || regular<br />
|-<br />
| it || italic<br />
|-<br />
| sl || slanted<br />
|-<br />
| bf || bold<br />
|-<br />
|bi || bolditalic<br />
|-<br />
| sc || smallcaps<br />
|}<br />
<br />
<context mode="mkiv" source="yes" text="produces"><br />
\definefontfamily[changedstyles][rm][TeX Gyre Pagella][tf=style:italic,it=style:bold,bf=style:bolditalic,bi=style:regular]<br />
<br />
\setupbodyfont[pagella]<br />
<br />
\starttext<br />
\rm\tf Regular, \it Italic, \bf Bold and \bi BoldItalic.<br />
<br />
\switchtobodyfont[changedstyles]<br />
<br />
\rm\tf Regular, \it Italic, \bf Bold and \bi BoldItalic.<br />
</context><br />
<br />
<context mode="mkiv" source="yes" text="produces"><br />
\definefontfamily[changedfiles][rm][TeX Gyre Pagella][it=file:texgyreherositalic,bi=file:texgyrecursorbolditalic]<br />
<br />
\setupbodyfont[changedfiles]<br />
<br />
\starttext<br />
\tf Regular, \it Italic, \bf Bold and \bi BoldItalic.<br />
</context><br />
<br />
<context mode="mkiv" source="yes" text="produces"><br />
\definefontfamily[changedfeatures][rm][TeX Gyre Pagella][tf=features:smallcaps,bf=features:none]<br />
<br />
\setupbodyfont[pagella]<br />
<br />
\starttext<br />
\tf ffi, \it ffi, \bf ffi, \bi ffi.<br />
<br />
\switchtobodyfont[changedfeatures]<br />
<br />
\tf ffi, \it ffi, \bf ffi, \bi ffi.<br />
\stoptext<br />
</context><br />
<br />
If it is not possible to install fonts system-wide, one can explicitly specify the filename of a font. Custom fonts often don't come with math symbols or a fitting monospaced font. One can replace these using Latin Modern which comes with ConTeXt.<br />
<br />
<context mode="mkiv" source="yes" text="produces"><br />
\definefontfamily [mainface][serif] [Latin Modern Roman]<br />
[tf=file:filename_serif_regular.ttf,<br />
it=file:filename_serif_italic.ttf,<br />
bf=file:filename_serif_bold.ttf,<br />
bi=file:filename_serif_bold_italic.ttf,<br />
sc=file:filename_serif_smallcaps.ttf]<br />
\definefontfamily [mainface][sans] [Latin Modern Sans]<br />
[tf=file:filename_sans_regular.ttf,<br />
it=file:filename_sans_italic.ttf,<br />
bf=file:filename_sans_bold.ttf,<br />
bi=file:filename_sans_bold_italic.ttf,<br />
sc=file:filename_sans_smallcaps.ttf]<br />
\definefontfamily [mainface] [mono] [Latin Modern Mono] [features=none]<br />
\definefontfamily [mainface] [math] [Latin Modern Math]<br />
\setupbodyfont [mainface,11pt] <br />
\starttext<br />
\tf ffi, \it ffi, \bf ffi, \bi ffi.<br />
<br />
\tt Monospaced<br />
<br />
$\sqrt{3x^2}$<br />
<br />
\stoptext<br />
<br />
</context><br />
<br />
== See also ==<br />
<br />
* {{cmd|definetypeface}}<br />
* {{cmd|definefallbackfamily}}</div>Wolfgang Schusterhttps://wiki.contextgarden.net/index.php?title=Command/setupmargindata&diff=23106Command/setupmargindata2016-07-25T15:48:36Z<p>Wolfgang Schuster: Moved the content for \setupmargindata to the correct page</p>
<hr />
<div>{{Reference<br />
|name=setupmargindata<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd">\setupmargindata<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>left right number </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Command/keyword:location|location]]</td><br />
<td>[[Command/value:flushleft|flushleft]] [[Command/value:flushright|flushright]] [[Command/value:both|both]] </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: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:align|align]]</td><br />
<td>[[Command/value:inner|inner]] [[Command/value:outer|outer]] [[Command/value:left|left]] [[Command/value:right|right]] [[Command/value:middle|middle]] [[Command/value:normal|normal]] [[Command/value:no|no]] [[Command/value:yes|yes]] </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Command/keyword:line|line]]</td><br />
<td>[[Command/value:number|number]] </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Command/keyword:distance|distance]]</td><br />
<td>[[Command/value:dimension|dimension]] </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Command/keyword:separator|separator]]</td><br />
<td>[[Command/value:text|text]] </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Command/keyword:width|width]]</td><br />
<td>[[Command/value:dimension|dimension]] </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Command/keyword:distance|distance]]</td><br />
<td>[[Command/value:dimension|dimension]] </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Command/keyword:stack|stack]]</td><br />
<td>[[Command/value:yes|yes]] [[Command/value:no|no]] </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[...,...=...,...]</td><br />
<td>see [[Command/setupframed|\setupframed]] </td><br />
</tr><br />
</table><br />
<br />
== Description ==<br />
<br />
Stack option is used to emulate LaTeX's marginpars (they're considered floats, hence the resulting margin notes do not overlap).<br />
<br />
The first bracket can be used to provide different setups for different margin text types. It defines which type of text the following parameters apply to. So the following code defines that any text placed in the margin using <code>\inright{...}</code> will be slanted:<br />
<texcode><br />
\setupmargindata[right][style=slanted]<br />
</texcode><br />
<br />
The previous code does <i>not</i> alter the location of the <code>\inmargin</code> command. To do that you would use:<br />
<texcode><br />
\setupmargindata[location=right,style=slanted]<br />
</texcode><br />
<br />
== Example ==<br />
<br />
The following code inserts text in the right-hand page margin:<br />
<br />
<texcode><br />
\setupmargindata[inmargin][location=right]<br />
<br />
\starttext<br />
This is an example of a simple margin note set in the slanted font<br />
of the document. If used correctly, the note \inmargin{Here is a<br />
simple margin note.} should print on the side with the command<br />
\type {\inmargin} placed in the text. You will of course want to<br />
adjust your margins to accommodate the type.<br />
\stoptext<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/Margins|setupmargindata]]</div>Wolfgang Schusterhttps://wiki.contextgarden.net/index.php?title=Command/setupinmargin&diff=23105Command/setupinmargin2016-07-25T15:47:23Z<p>Wolfgang Schuster: </p>
<hr />
<div>The {{cmd|setupinmargin}} command has been renamed to {{cmd|setupmargindata}}.</div>Wolfgang Schusterhttps://wiki.contextgarden.net/index.php?title=Command/definefontfamily&diff=22630Command/definefontfamily2014-09-11T12:37:39Z<p>Wolfgang Schuster: How to use the \definefontfamily command</p>
<hr />
<div>{{Reference<br />
|name=definefontfamily<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd">\definefontfamily<span class="first">[...]</span><span class="second">[...]</span><span class="third">[...]</span><span class="fourth">[...,...=...,...]</span></td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[...]</td><br />
<td>TEXT (typescript identifier)</td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[...]</td><br />
<td>rm ss tt mm hw cg serif sans mono math handwriting calligraphy</td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[...]</td><br />
<td>TEXT (existing font name)</td><br />
</tr><br />
<tr valign="top" class="fourth"><br />
<td class="cmd">[[Command/keyword:scale|scale]]</td><br />
<td>[[Command/value:NUMBER|NUMBER]]</td><br />
</tr><br />
<tr valign="top" class="fourth"><br />
<td class="cmd">[[Command/keyword:alternative|alternative]]</td><br />
<td>[[Command/value:default|default]] [[Command/value:selectfont|selectfont]] [[Command/value:simplefonts|simplefonts]]</td><br />
</tr><br />
<tr valign="top" class="fourth"><br />
<td class="cmd">[[Command/keyword:features|features]]</td><br />
<td>[[Command/value:IDENTIFIER|IDENTIFIER]]</td><br />
</tr><br />
<tr valign="top" class="fourth"><br />
<td class="cmd">[[Command/keyword:opticalsize|opticalsize]]</td><br />
<td>[[Command/value:yes|yes]] [[Command/value:no|no]]</td><br />
</tr><br />
<tr valign="top" class="fourth"><br />
<td class="cmd">[[Command/keyword:goodies|goodies]]</td><br />
<td>[[Command/value:IDENTIFIER|IDENTIFIER]]</td><br />
</tr><br />
</table><br />
<br />
== Description == <br />
<br />
== Example ==<br />
<br />
In the first example we create a new typeface with the name `mainface` which includes fonts from the TeX Gyre family. Even though there is no math used in this example it is better to set one because math symbols are sometimes used in text mode.<br />
<br />
<context mode="mkiv" source="yes" text="produces"><br />
\definefontfamily [mainface] [rm] [TeX Gyre Pagella]<br />
\definefontfamily [mainface] [ss] [TeX Gyre Heros]<br />
\definefontfamily [mainface] [mm] [TeX Gyre Pagella Math]<br />
<br />
\setupbodyfont[mainface]<br />
<br />
\starttext<br />
\rm Serif: TeX Gyre Pagella<br />
<br />
\ss Sans: TeX Gyre Heros<br />
\stoptext<br />
</context><br />
<br />
In this example we are switching the fonts which are used for the upright, italic etc. alternatives. With the help of the `style` keyword you access one of the predefined styles, by default `\definefontfamily` uses the following styles for each alternative:<br />
<br />
{|<br />
! Alternative !! Style<br />
|-<br />
| tf || regular<br />
|-<br />
| it || italic<br />
|-<br />
| sl || slanted<br />
|-<br />
| bf || bold<br />
|-<br />
|bi || bolditalic<br />
|-<br />
| sc || smallcaps<br />
|}<br />
<br />
<context mode="mkiv" source="yes" text="produces"><br />
\definefontfamily[changedstyles][rm][TeX Gyre Pagella][tf=style:italic,it=style:bold,bf=style:bolditalic,bi=style:regular]<br />
<br />
\setupbodyfont[pagella]<br />
<br />
\starttext<br />
\rm\tf Regular, \it Italic, \bf Bold and \bi BoldItalic.<br />
<br />
\switchtobodyfont[changedstyles]<br />
<br />
\rm\tf Regular, \it Italic, \bf Bold and \bi BoldItalic.<br />
</context><br />
<br />
<context mode="mkiv" source="yes" text="produces"><br />
\definefontfamily[changedfiles][rm][TeX Gyre Pagella][it=file:texgyreherositalic,bi=file:texgyrecursorbolditalic]<br />
<br />
\setupbodyfont[changedfiles]<br />
<br />
\starttext<br />
\tf Regular, \it Italic, \bf Bold and \bi BoldItalic.<br />
</context><br />
<br />
<context mode="mkiv" source="yes" text="produces"><br />
\definefontfamily[changedfeatures][rm][TeX Gyre Pagella][tf=features:smallcaps,bf=features:none]<br />
<br />
\setupbodyfont[pagella]<br />
<br />
\starttext<br />
\tf ffi, \it ffi, \bf ffi, \bi ffi.<br />
<br />
\switchtobodyfont[changedfeatures]<br />
<br />
\tf ffi, \it ffi, \bf ffi, \bi ffi.<br />
\stoptext<br />
</context><br />
<br />
== See also ==<br />
<br />
* {{cmd|definetypeface}}<br />
* {{cmd|definefallbackfamily}}</div>Wolfgang Schusterhttps://wiki.contextgarden.net/index.php?title=Command/definefontfamily&diff=22629Command/definefontfamily2014-09-10T20:09:36Z<p>Wolfgang Schuster: Syntax definition for the \definefontfamily command</p>
<hr />
<div>{{Reference<br />
|name=definefontfamily<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd">\definefontfamily<span class="first">[...]</span><span class="second">[...]</span><span class="third">[...]</span><span class="fourth">[...,...=...,...]</span></td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[...]</td><br />
<td>TEXT (typescript identifier)</td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[...]</td><br />
<td>rm ss tt mm hw cg serif sans mono math handwriting calligraphy</td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[...]</td><br />
<td>TEXT (existing font name)</td><br />
</tr><br />
<tr valign="top" class="fourth"><br />
<td class="cmd">[[Command/keyword:scale|scale]]</td><br />
<td>[[Command/value:NUMBER|NUMBER]]</td><br />
</tr><br />
<tr valign="top" class="fourth"><br />
<td class="cmd">[[Command/keyword:alternative|alternative]]</td><br />
<td>[[Command/value:default|default]] [[Command/value:selectfont|selectfont]] [[Command/value:simplefonts|simplefonts]]</td><br />
</tr><br />
<tr valign="top" class="fourth"><br />
<td class="cmd">[[Command/keyword:features|features]]</td><br />
<td>[[Command/value:IDENTIFIER|IDENTIFIER]]</td><br />
</tr><br />
<tr valign="top" class="fourth"><br />
<td class="cmd">[[Command/keyword:opticalsize|opticalsize]]</td><br />
<td>[[Command/value:yes|yes]] [[Command/value:no|no]]</td><br />
</tr><br />
<tr valign="top" class="fourth"><br />
<td class="cmd">[[Command/keyword:goodies|goodies]]</td><br />
<td>[[Command/value:IDENTIFIER|IDENTIFIER]]</td><br />
</tr><br />
</table></div>Wolfgang Schusterhttps://wiki.contextgarden.net/index.php?title=Command/setuphyphenmark&diff=21395Command/setuphyphenmark2013-01-24T23:13:09Z<p>Wolfgang Schuster: Highlight default value</p>
<hr />
<div>{{Reference<br />
|name=setuphyphenmark<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd">\setuphyphenmark<span class="first" >[...=...]</span></td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:sign|sign]]</td><br />
<td>normal '''wide'''</td><br />
</tr><br />
</table><br />
<br />
<br />
== Description == <br />
<br />
<br />
<br />
== Example ==<br />
<!-- Please fill in an example if you can --><br />
<br />
== See also ==<br />
<!-- something like [[cmd:goto|\goto]] --><br />
<br />
[[Category:Commands|setuphyphenmark]]</div>Wolfgang Schusterhttps://wiki.contextgarden.net/index.php?title=Command/setuphyphenmark&diff=21394Command/setuphyphenmark2013-01-24T23:06:07Z<p>Wolfgang Schuster: Replace wrong with right values</p>
<hr />
<div>{{Reference<br />
|name=setuphyphenmark<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd">\setuphyphenmark<span class="first" >[...=...]</span></td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:sign|sign]]</td><br />
<td>normal wide</td><br />
</tr><br />
</table><br />
<br />
<br />
== Description == <br />
<br />
<br />
<br />
== Example ==<br />
<!-- Please fill in an example if you can --><br />
<br />
== See also ==<br />
<!-- something like [[cmd:goto|\goto]] --><br />
<br />
[[Category:Commands|setuphyphenmark]]</div>Wolfgang Schusterhttps://wiki.contextgarden.net/index.php?title=Command/setupformulae&diff=13477Command/setupformulae2011-11-14T11:15:26Z<p>Wolfgang Schuster: The key to change the space after a formula is “spaceafter”.</p>
<hr />
<div>{{Reference<br />
|name=setupformulae<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd">\setupformulae<span class="first" >[...,...=...,...]</span></td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Reference/en/keyword:location|location]]</td><br />
<td>[[Reference/en/value:left|left]] [[Reference/en/value:right|right]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Reference/en/keyword:left|left]]</td><br />
<td>[[Reference/en/value:text|text]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Reference/en/keyword:right|right]]</td><br />
<td>[[Reference/en/value:text|text]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Reference/en/keyword:align|align]]</td><br />
<td>[[Reference/en/value:flushleft|flushleft]] [[Reference/en/value:middle|middle]] [[Reference/en/value:flushright|flushright]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Reference/en/keyword:option|option]]</td><br />
<td>[[Reference/en/value:middle|middle]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Reference/en/keyword:strut|strut]]</td><br />
<td>[[Reference/en/value:yes|yes]] [[Reference/en/value:no|no]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Reference/en/keyword:distance|distance]]</td><br />
<td>[[Reference/en/value:dimension|dimension]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Reference/en/keyword:margin|margin]]</td><br />
<td>[[Reference/en/value:dimension|dimension]] [[Reference/en/value:standard|standard]] [[Reference/en/value:yes|yes]] [[Reference/en/value:no|no]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Reference/en/keyword:leftmargin|leftmargin]]</td><br />
<td>[[Reference/en/value:dimension|dimension]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Reference/en/keyword:rightmargin|rightmargin]]</td><br />
<td>[[Reference/en/value:dimension|dimension]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Reference/en/keyword:indentnext|indentnext]]</td><br />
<td>[[Reference/en/value:yes|yes]] [[Reference/en/value:no|no]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Reference/en/keyword:alternative|alternative]]</td><br />
<td>[[Reference/en/value:name|name]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Reference/en/keyword:spacebefore|spacebefore]]</td><br />
<td>[[Reference/en/value:dimension|dimension]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Reference/en/keyword:after|spaceafter]]</td><br />
<td>[[Reference/en/value:dimension|dimension]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Reference/en/keyword:separator|separator]]</td><br />
<td>[[Reference/en/value:text|text]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Reference/en/keyword:conversion|conversion]]</td><br />
<td>[[Reference/en/value:numbers|numbers]] [[Reference/en/value:characters|characters]] [[Reference/en/value:Characters|Characters]] [[Reference/en/value:romannumerals|romannumerals]] [[Reference/en/value:Romannumerals|Romannumerals]] [[Reference/en/value:text|text]] </td><br />
</tr><br />
</table><br />
<br />
== Description ==<br />
Using option <code>[way=bysection]</code> resets the numbering to 1 at each new section, but does not prefix the numbers with the section number, to do that, use the following options:<br />
<code><br />
\setupformulae[way=bysection,prefixsegments=section]<br />
</code><br />
<br />
== Example ==<br />
<!-- Please fill in an example if you can --><br />
<br />
== See also ==<br />
<!-- something like [[cmd:goto|\goto]] --><br />
<br />
[[Category:Reference/en|setupformulae]]</div>Wolfgang Schusterhttps://wiki.contextgarden.net/index.php?title=Table_of_Contents&diff=13417Table of Contents2011-10-12T07:23:13Z<p>Wolfgang Schuster: Replaced structureblock with sectonblock.</p>
<hr />
<div>== Using Table of Contents ==<br />
<br />
To get the default table of contents use:<br />
<texcode><br />
\completecontent % with title<br />
\placecontent % without title<br />
</texcode><br />
<br />
<br />
One important quirk. If you do not start the document with \completecontent, but use it later –for example after the introduction–, you should use:<br />
<texcode><br />
\completecontent[criterium=all]<br />
</texcode><br />
<br />
<br />
When \completecontent is at the end of the document you can use:<br />
<texcode><br />
\completecontent[criterium=previous]<br />
</texcode><br />
<br />
== Modifing the default Table of Contents ==<br />
<br />
You can customize the appearance, number of shown levels and other attributes of predefined TOC. Please note that <code>level</code> parameter has recently(02/2010) no effect in [[Mark IV]], you may use <cmd>placelist[chapter,section]</cmd> instad of <cmd>setupcombinedlist[content][level=2]</cmd>.<br />
<br />
<context source="yes"><br />
\setupcolors[state=start]<br />
% turn off numbering of some levels<br />
\setuphead[subsection][number=no]<br />
\setuphead[subsubsection][number=no]<br />
% TOC<br />
% level=4, \subsubsubsections are not listed in TOC<br />
% alternative=c, space to the page number is filled with dots<br />
\setupcombinedlist[content][level=4,alternative=c]<br />
%\setuplist[chapter][width=5mm,style=bold]<br />
\setuplist[section][width=10mm,style=bold]<br />
\setuplist[subsection][width=20mm]<br />
% pagestyle=normal for changing the appearance of pagenumber<br />
\setuplist[subsubsection][width=20mm,style=slanted,pagestyle=normal]<br />
\starttext<br />
<br />
\startcolor[darkgreen]<br />
\completecontent<br />
\stopcolor<br />
<br />
\section{First section}<br />
\subsection{First subsection}<br />
\subsubsection{First subsubsection}<br />
\subsubsubsection{First subsubsubsection}<br />
\section{Second section}<br />
\subsection{Second subsection}<br />
\subsubsection{Second subsubsection}<br />
\subsubsubsection{Second subsubsubsection}<br />
\stoptext<br />
</context><br />
<br />
== Page Numbering in Table of Contents ==<br />
<br />
If you have a special page numbering style it won't automatically be reflected in the table of contents. You need to set the parameters of the table of contents separately. For example, <br />
<br />
<texcode><br />
\starttext<br />
\startfrontmatter<br />
\placecombinedlist[MyContentsList]<br />
\stopfrontmatter<br />
\startbodymatter<br />
\setuppagenumbering[way=bychapter, left=A, chapternumber=yes, numberseparator=/]<br />
...<br />
\stopbodymatter<br />
</texcode><br />
<br />
will give you pagenumbering such as A1/1, A1/2 etc. on the pages in the bodymatter. In the table of contents, however, these will show up as 1-1, 1-2 etc. The ToC needs to be formatted separately. <br />
<br />
To get a prefix to the page numbering (like "A"), use<br />
<br />
<texcode><br />
\def\ChapterPrefix#1{A#1}<br />
\setuplist[chapter][pagecommand=\ChapterPrefix]<br />
</texcode><br />
<br />
To get the numberseparator working, you need to know that the ToC will use the separator that is active ''at the time the ToC is output''. So you need to set it immediately before you call the ToC command, e.g.<br />
<br />
<texcode><br />
\setuppagenumbering[numberseparator=/]<br />
\placecombinedlist[MyContentsList]<br />
</texcode><br />
<br />
The above method '''does not work in MkIV'''(not anymore atleast). Hence the code below illustrates how to get it working under MkIV. It should be noted that MkIV and MkII are incompatible with respect to this feature.<br />
<br />
As an example, consider that the frontmatter uses roman numerals and bodymatter remains unchanged. To reflect the romannumerals of the front matter in the TOC,<br />
<br />
<texcode><br />
\definestructureconversionset[frontpart:pagenumber][][romannumerals]<br />
\definestructureconversionset[bodypart:pagenumber] [][numbers]<br />
<br />
\setuplist[chapter][pageconversionset=pagenumber]<br />
<br />
\startsectionblockenvironment[frontpart]<br />
\setupuserpagenumber[numberconversion=romannumerals]<br />
\setuppagenumber[number=1]<br />
\stopsectionblockenvironment<br />
<br />
\startsectionblockenvironment[bodypart]<br />
\setuppagenumber[number=1]<br />
\stopsectionblockenvironment<br />
</texcode><br />
<br />
== Dots in section numbers ==<br />
<br />
Last Number Dot in Table of Contents (e.g. 2.1.3.): see [[Dotted_number_in_caption]].<br />
<br />
If you want to avoid a dot if there's no number, try this solution (by Wolfgang Schuster as of 2008-04-29):<br />
<texcode><br />
\setuplist<br />
[chapter,section,...]<br />
[numbercommand=\DotAfterNumber]<br />
<br />
\def\DotAfterNumber#1{\doiftext{#1}{#1.}}<br />
</texcode><br />
<br />
== Author in ToC ==<br />
see setup for author/title/subtitle titling and author in ToC in [[Proceedings_style]].<br />
<br />
You can write "everything" to the ToC or an other list (see below) using <cmd>writetolist</cmd>.<br />
<br />
== Several ToC's in different languages ==<br />
If you want to have two tables of contents in your document, one in a native<br />
language and the other, for example, in english. This is how to do it:<br />
<br />
<texcode><br />
\mainlanguage[de]<br />
<br />
\starttext<br />
<br />
\completecontent<br />
<br />
%\start\language[en]<br />
\start\mainlanguage[en]<br />
\completecontent<br />
\stop<br />
<br />
\chapter{\translate[en=Chapter One,de=Kapitel Eins]}<br />
<br />
\chapter{\translate[en=Chapter Two,de=Kapitel Zwei]}<br />
<br />
\stoptext<br />
</texcode><br />
<br />
<br />
== Creating other "Table of ..." ==<br />
<br />
Generally all "Table (List) of ..." are defined with <cmd>definelist</cmd> and <cmd>setuplist</cmd>.<br />
You can "collect" several section levels in one list using <cmd>definecombinedlist</cmd>, that's even explained in "ConTeXt, an excursion" (see [[Official_ConTeXt_Documentation]]).<br />
<br />
To have some parts of your title texts ''not'' appear in the table of contents, use <cmd>nolist</cmd> and have a look at [http://www.pragma-ade.com/general/magazines/mag-0001.pdf mag-0001.pdf].<br />
<br />
<br />
== How the table of contents is generated by ConTeXt ==<br />
(from Tobias Burnus [http://archive.contextgarden.net/message/20060809.162652.8f517267.en.html on the mailinglist])<br />
<br />
The mechanism is a follows:<br />
<br />
# TeX is run and chapter names with pagenumbers etc. are saved into <jobname>.tui.<br />
# TeXutil is run and sorts some entries in *.tui and writes *.tuo<br />
# TeX is run again, reads .tuo and uses that data to produce the table of contents etc. (and produces a new .tui) As this changes the page numbers (for longer table of contents), TeXutil and TeX are re-run again.<br />
<br />
In principle TeXExec should do this automatically.</div>Wolfgang Schusterhttps://wiki.contextgarden.net/index.php?title=Talk:Main_Page&diff=13412Talk:Main Page2011-10-06T14:06:30Z<p>Wolfgang Schuster: Spam</p>
<hr />
<div>= General Wiki Comments =<br />
== front page ==<br />
i think one should tidy up the wiki front page. There are to many links and too many with unclear naming. May be less, more precise words in frames and some piktograms help.--[[User:Jstein|Jstein]] 00:23, 27 November 2010 (UTC)<br />
Revision of ConTeXt User Manual appears twice. Thats a bit confusing.<br />
<br />
== GIFs ==<br />
Is it forbidden to upload GIFs? I wanted to upload one for the Animation page (I'm not sure if that's a good idea anyway; it would be used to get a feeling of what approximately Adobe Reader is capable to do/limited to). I get a warning <i>".gif" is not a recommended image file format.</i>, but then nothing happened any further. --Thanks, [[User:Mojca Miklavec|Mojca]]<br />
<br />
== function show_command ==<br />
it does '''still''' not work.<br />
<br />
the fuction is defined as such:<br />
<code><pre>function show_command(URL) {<br />
open_window().location.href='http://texshow.contextgarden.net/cmd/' + URL;<br />
}</pre></code><br />
and thus redirects to some url under http://texshow.contextgarden.net/<br />
<br />
no matter what that url is, the subdomain redirects to the page [[:Category:Reference/en]] (no, not [[:Category:Reference/en/URL]]!)<br />
<br />
please fix it.<br />
<br />
:Edit: Mojca did it, thanks!<br />
<br />
– [[User:Flying sheep|flying sheep]] 23:24, 22 August 2011 (CEST)<br />
<br />
= Comments on [[Main Page]] =<br />
Please add a link to the 'third party page'<br />
: Already there, but Hans got confused about its name. Left-side menu, in the middle of 'garden', you see 'third party modules'. That is the correct page, but a nice upload interface is currently still missing. [[User:Taco|Taco]]<br />
<br />
----<br />
Mojca recently asked (in the changelog) for comments on the reorganization of the [[Main Page]]. It looks quite good to me, overall. The "how to edit a Wiki page" should probably link to the existing [[Help:Editing]] page, or perhaps directly to MediaWiki's Help:Editing page.<br />
<br />
I do think a couple of the section headings should be changed. "Tips, Tricks, and Hacks" is becoming a storehouse of actual documentation as well as just small "tricks", and the name should reflect that: something like "ConTeXt Documentation and How-To", maybe. "Help & Guidelines" should be "Wiki Help & Guidelines", so as to distinguish it from "ConTeXt help".<br />
<br />
It may also be useful to put "short explanations" next to the links, much as I've been doing in the [[From LaTeX to ConTeXt]] page.<br />
<br />
--[[User:Brooks|Brooks]] 02:49, 4 Sep 2005 (UTC)<br />
<br />
: Brooks, you wrote too much today ;) ! You cannot expect people to read all your comments!!! (I didn't even notice your posting here until I wanted to add something).<br>Yes, "How to edit a Wiki page" should certainly be merged with [[Help:Editing]]. I forgot that this page ever existed as it somehow disappeared from my view. [[Help:Contents]] should ugently be changed as well. (Feel free to do it.)<br />
<br />
: I thought that "Help & Guidelines" could be used for guidelines about writing to the mailing list as well, but it's true that it should be distinguished from ConTeXt help. I agree to add comments next to links (but what comments?).<br> Also, quite some stuff is still missing on the main page, the "Main ConTeXt Documentation and HowTo-s" needs to be reorganized and <b>Categories</b> should be defined, so that we can start categorizing the majority of pages (I had no idea what Categories to define for pages under "Visuals", "Structurals", "Inside ConTeXt" (which should probably better be defined as "Programming" or something similar), ...). Quite some "secondary pages" are missing (connecting the first page and actual articles, just like your [[From LaTeX to ConTeXt]], one page with [[Links]] is certainly missing).<br />
<br />
: Despite the generally accepted decision to lock the first page, I hope that I'm not violating the rules too much if I unlock it for two days (sorry, Patrick), so that you can improve it by yourself if you want. If anyone spams the first page in the meantime, I take the responsibility to remove the spam from it (as soon as I come online).<br />
:--[[User:Mojca Miklavec|Mojca]] 19:37, 4 Sep 2005 (UTC)<br />
:: No problem at all, go ahead and feel free to unlock it. BTW: I really like the look of the new page, but I still need some time to make real comments --[[User:Patrick Gundlach|pg]] 10:55, 5 Sep 2005 (UTC)<br />
<br />
:: Thanks! I think I'll make a copy of the [[Main Page]], and put it in [[Main Page Sandbox]], so I can muck about with some organizational ideas without affecting the "live" version until they're finished. I was going to say that we could delete [[Main Page Sandbox]] after we're done, but it might be useful to leave it up for future things like this. --[[User:Brooks|Brooks]] 23:09, 4 Sep 2005 (UTC)<br />
<br />
:: Another idea for handling the main page, as far as editing goes -- see [http://sandbox.contextgarden.net/Brooks's_Sandbox_Two|This Page on the Sandbox]. There's no actual content on the page; it's all in a pair of templates. That page could then be locked, but people could still edit the templates and change the content, so long as they knew which templates to edit. I don't know how smart the spammers are, but it ought to at least block the lazy and/or automatic ones. --[[User:Brooks|Brooks]] 00:08, 5 Sep 2005 (UTC)<br />
<br />
::: This seems hidden enough for me (until I knew what Templates are about and where they are stored, I had to search really long until I was able to see the content) --[[User:Mojca Miklavec|Mojca]] 00:21, 5 Sep 2005 (UTC)<br />
<br />
:::: Let's try it. Good Idea. If it turns out wrong, we can still decide later. --[[User:Patrick Gundlach|pg]] 10:55, 5 Sep 2005 (UTC)<br />
<br />
----<br />
I '''really''' like the new look of the wiki! --[[User:Braslau|Alan]]<br />
<br />
= General ConTeXt Questions =<br />
<br />
This is not the place to ask general questions about ConTeXt. If you have a longer question, the best thing to do with it is create a new page (see [[Help:Editing]] for how to do that) with a description of the problem, and put the special text <code><nowiki>{{Howto}}</nowiki></code> in it, which will cause it to be listed on the [[Category:How to]] page. If you have a short question that is appropriate for the [[FAQ]], you can add it there, and leave the answer blank. If you have a question that you wish to discuss, the best place for that is the [http://www.ntg.nl/mailman/listinfo/ntg-context ConTeXt mailing list] or the "Discussion" page associated with a particularly relevant Wiki page, though you can also use the [[Talk:FAQ|FAQ's "Talk" page]] if there's not an obvious choice.<br />
<br />
<br />
{{Howto}}[http://wiki.contextgarden.net/How_to_configure_Scite_and_Context Configuring Scite and ConTeXt(I have some Compiling problem)]</div>Wolfgang Schusterhttps://wiki.contextgarden.net/index.php?title=Gnuplot&diff=13409Gnuplot2011-10-03T20:16:05Z<p>Wolfgang Schuster: Modules are now installed with the “modules” parameter</p>
<hr />
<div>< [[Modules]] | [[Graphics]] | [[Math]] ><br />
<br />
http://www.gnuplot.info/figs/title2.png<br />
<br />
[http://www.gnuplot.info Gnuplot] is a portable command-line driven utility for function plotting for many platforms.<br />
<br />
To make the examples on this page work, you need a modified binary of Gnuplot (see below).<br />
<br />
== Minimal Example ==<br />
<br />
<texcode><br />
\usemodule[gnuplot]<br />
<br />
% write a script for gnuplot<br />
\startGNUPLOTscript[sin]<br />
plot sin(x)<br />
\stopGNUPLOTscript<br />
<br />
% include the resulting graphic into the document<br />
\useGNUPLOTgraphic[sin]<br />
</texcode><br />
<br />
Calling gnuplot to create the graphic and postprocessing should happen automatically.<br />
<br />
== Requirements ==<br />
<br />
* '''[http://modules.contextgarden.net/gnuplot Gnuplot module]'''<br />
** in TeX Live you need to have <code>context-gnuplot</code> installed, in [[ConTeXt Standalone]] you can install it with <code>--modules=t-gnuplot</code> switch<br />
* '''Gnuplot has to be installed''' (and in your PATH)<br />
:On most Linux installations this is probably already the case. On Windows you have to create a file <code>gnuplot.bat</code> with something like:<br />
"C:\Program Files\gnuplot\bin\wgnupl32.exe" %*<br />
:and put that file to a <i>"visible place"</i> (has to be found in PATH).<br />
* '''[[write18]]''' has to be enabled<br />
=== To use the ConTeXt terminal (recommended) ===<br />
==== Windows ====<br />
You can take [http://dl.contextgarden.net/modules/gnuplot-win.zip these] binaries from [[modules:gnuplot-win|Modules in the garden]] ''(Note: the binary is old, but I don't have windows any more to compile the latest binary; I can only hope that it still works.)''<br />
==== Unix or Mac ====<br />
The easiest way to fetch and compile the binary is:<br />
git clone git://github.com/mojca/gnuplot.git<br />
./prepare<br />
./configure<br />
make<br />
:''(Alternatively you could download gnuplot source from http://www.gnuplot.info, copy [http://github.com/mojca/gnuplot/raw/master/term/context.trm context.trm] to <code>term/</code>, add <code>#include "context.trm"</code> to <code>src/term.h</code> and follow the same steps for compilation.)''<br />
<br />
Then replace the old gnuplot executable (once backup-ed) with the one in <code>src/gnuplot</code> or type:<br />
make install<br />
Feel free to contact [[User:Mojca Miklavec|Mojca]] in case of problems.<br />
<br />
== Creating stand-alone, whole-page plots ==<br />
<br />
Here's an example of how to make a stand-alone ConTeXt document with one plot per page:<br />
<br />
set term context standalone size 15cm,10cm header '\usetypescript[iwona][ec]' font 'iwona,ss' 10dd<br />
set output 'example.tex'<br />
plot ...<br />
<br />
== More complex example ==<br />
<br />
(I need to change this example to highlight other aspects. Metapost is kind-of-obsolete since ConTeXt terminal was derived from it and produces superior results. But the example below should still be valid.)<br />
<br />
<texcode><br />
\usemodule[gnuplot]<br />
<br />
\setupGNUPLOT[terminal=mp,option=color]<br />
<br />
% general settings for the whole document<br />
\startGNUPLOTinclusions<br />
<br />
# you may use TeX commands to format the titles and axes<br />
set title '\bf Trigonometry'<br />
set xlabel '$x$'<br />
set ylabel '$y$'<br />
<br />
# to prevent uneven numbering: will result in<br />
# (0.0, 0.5, 1.0, 1.5, ...) instead of<br />
# (0, 0.5, 1, 1.5, ...)<br />
set format y '\%.1f'<br />
\stopGNUPLOTinclusions<br />
<br />
\startGNUPLOTscript[tan]<br />
plot tan(x) t '$\tan(x)$'<br />
\stopGNUPLOTscript<br />
<br />
\startGNUPLOTscript[sin]<br />
plot 4*sin(x)+x t '$4\sin(x)+x$', x t '$x$' lt 3<br />
\stopGNUPLOTscript<br />
<br />
\useGNUPLOTgraphic[tan]<br />
\useGNUPLOTgraphic[sin][width=10cm]<br />
</texcode><br />
<br />
== Using other terminals ==<br />
<br />
<i>(Needs a revision.)</i><br />
<br />
Gnuplot support output in different formats with, for example<br />
set terminal mp color solid<br />
will output a metapost document with colors and without dashed lines. After some appropriate preprocessing (with [[MPtoPDF]] for this particular case) this file can be included in PDF documents.<br />
<br />
You can specify the terminal with<br />
<texcode><br />
\setupGNUPLOT[terminal=mp,options=color solid]<br />
</texcode><br />
<br />
* <code>terminal=</code> is mandatory since that't the only way to tell ConTeXt how to preprocess the file.<br />
* <code>options=</code> is optional and is appended to the end of <code>set terminal [terminal name]</code>. You can also override it by saying<br />
<texcode><br />
\startGNUPLOTinclusions<br />
set terminal mp color solid<br />
\stopGNUPLOTinclusions<br />
</texcode><br />
But you have to be careful that you don't set any other terminal with <code>output=</code> then.<br />
<br />
<!-- Another way to specify it is to override the terminal setting --><br />
<br />
Currently supported terminals are (attention: links not from the latest documentation):<br />
* [http://www.gnuplot.info/docs/gnuplot.html#mp mp/metapost]: uses [[MPtoPDF]] to convert images to pdf, but the context terminal should replace it<br />
* [http://www.gnuplot.info/docs/gnuplot.html#postscript_ ps/postscript]: most advanced in the number of supported features<br />
* [http://www.gnuplot.info/docs_4.0/gnuplot.html#png_%28NEW%29 png (1)],[http://www.gnuplot.info/docs_4.2/gnuplot.html#x1-41500051.53 png (2)]: outputs bitmap images (no preprocessing needed)<br />
* [http://www.gnuplot.info/docs_4.0/gnuplot.html#pdf pdf (old)],[http://www.gnuplot.info/docs_4.2/gnuplot.html#x1-41300051.51 pdf (new)]: outputs PDF directly for (no preprocessing needed), but is usually not available in most binaries of gnuplot<br />
* '''context''':<br />
<br />
The current gnuplot-documentation can be downloaded [http://www.gnuplot.info/docs_4.4/gnuplot.pdf here].<br />
<br />
== Development ==<br />
<br />
* [http://groups.google.com/group/gnuplot-context mailing list]<br />
<br />
== History ==<br />
<br />
I ([[User:Mojca Miklavec|Mojca Miklavec]]) probably mentioned long time ago that I would like to have (or write?) support for Gnuplot inside ConTeXt, but I had no knowledge to do that. Peter Münster posted the very first module for gnuplut support on the mailing list [http://article.gmane.org/gmane.comp.tex.context/24884], but that version only worked with bash. In the days to follow Hans Hagen has written a new module (based on my numerous "possible and impossible" requests) and Taco additionally provided some bugfixes and minor changes.<br />
<br />
The module provides an option to select the most appropriate/suitable driver according to the user's choice (metapost, png, pdf, postscript were the firs ones to be supported). Hans was wondering why there was no '''context terminal'''. I took over it's development, the code is almost finished by now, but I guess that Hans now regrets that question already.<br />
<br />
He had to invest quite some time into fixing buggy inclusion of text into graphics using <code>textext</code> (if nothing else, he had to read and reply to all the mails [complaints] that me and Taco sent him), just to lead to the conclusion that <code>textext</code> was useless for graphics produced by Gnuplot: too slow and TeX ran out of memory after 10 minutes while processing approximately the 13<sup>th</sup> plot. After that the new marvellous <code>\sometxt</code> command was born.<br />
<br />
I'm currently sticking tiny pieces together in the way I want the module to work. Hans could probably finish the same work that costs me a few days in a few minutes, but after dropping me a bone, he decided to leave me the joy of diving into ConTeXt internals and to let me figure out how to program in ConTeXt by myself. So I still keep spamming the mailing list with numerous questions and both Taco and Hans - without whom implementing the module would be impossible - keep answering.<br />
<br />
== Alternatives for Function Plotting ==<br />
<br />
* in [[MetaPost]]<br />
** [[source:m-graph.tex|m-graph]] Module (see [http://cm.bell-labs.com/who/hobby/cstr_164.pdf Drawing Graphs with MetaPost] by John D. Hobby)<br />
** functions in [[MetaFun]], see [[manual:metafun-s.pdf|metafun-s.pdf]], section 9.3<br />
* others<br />
** [http://pyx.sourceforge.net/ PyX] - graph drawing through python interface with TeX typesetting & PostScript capabilities<br />
** [http://theory.kitp.ucsb.edu/~paxton/tioga.html Tioga] - creating figures and plots using Ruby, PDF, and TeX<br />
** [http://comp.uark.edu/~luecking/tex/mfpic.html mfpic] - a scheme for producing pictures from LaTeX commands. The LaTeX commands generate a input file to be processed by Metapost.<br />
** [http://matplotlib.sourceforge.net matplotlib] - a Matlab-inspired Python based plotting tool which incorporates many features, including the use of TeX in labels, titles etc.<br />
** [http://tug.ctan.org/tex-archive/graphics/pgf/contrib/pgfplots/ pgfplots] - a TikZ-based LaTeX package for drawing graphs<br />
<br />
=== Other links ===<br />
* [http://tug.ctan.org/tex-archive/macros/latex/contrib/exceltex/ exceltex] - an interesting LaTeX package to get data from Excel into LaTeX<br />
* [http://peter.affenbande.org/gnuplot/ Lua-based TikZ terminal] - might be interesting to adapt it for ConTeXt (an [http://www.guit.sssup.it/phpbb/viewtopic.php?p=19929 interesting example])<br />
<br />
<br />
[[Image:Slo Ministry of Higher Education Science and Technology.jpg]]<br />
<br />
[[Category:Modules]]<br />
[[Category:Graphics]]<br />
[[Category:Math]]</div>Wolfgang Schusterhttps://wiki.contextgarden.net/index.php?title=Fonts_in_LuaTeX&diff=13408Fonts in LuaTeX2011-10-03T20:10:14Z<p>Wolfgang Schuster: Modules are now installed with the “modules” parameter</p>
<hr />
<div>{{note|This page is not finished yet}}<br />
<br />
'''Please, someone, fill this page !'''<br />
<br />
'''This page is beeing regorganized'''<br />
<br />
Using [[LuaTeX]] as the processing engine in ConTeXt allows one to directly use fonts installed on the user's system. Instead of converting all fonts into the standard <code>.tfm</code> and <code>.vf</code> formats (as outlined in some [[My Way]] documents<ref>[http://dl.contextgarden.net/websitesarchive/atl/tex/OpenType.pdf OpenType in ConTeXt] by Adam Lindsay</ref><ref>[http://dl.contextgarden.net/myway/expertfonts.pdf Installing Expert Fonts: Minion Pro] by Idris Samawi Hamid</ref>), LuaTeX creates these metric files automatically at run-time. This greatly simplifies font installation in ConTeXt.<br />
<br />
= How LuaTeX handles system fonts =<br />
<br />
LuaTeX can use fonts in non-TeX format (e.g. OpenType, TrueType or Type1 format) directly. When ConTeXt processes a file that uses such non-traditional fonts, the actual fonts themselves are loaded in LuaTeX's embedded section of fontforge to extract their metric information. This removes the need for tfm and vf files on your disk, but it is also a somewhat lengthy and often memory-hungry process. Fortunately, the result of that internal preprocessing are also saved inside the texmf cache. Future runs using the same font (not just this file, but all files using that particular font) can then use the cached version of the metrics instead.<br />
<br />
Mac OS users should note that the current version of LuaTeX (0.60) has severe problems dealing with the new TrueType collection fonts in Snow Leopard (Mac OS 10.6). The older Mac OS .dfont format works fine nowadays.<br />
<br />
== Building the font database ==<br />
<br />
You need to specify where the fonts should be looked for, by setting the <code>OSFONTDIR</code> environment variable. On Windows, this might be achieved by running<br />
set OSFONTDIR=c:/windows/fonts/<br />
if the fonts should be found in <code>c:/windows/fonts/</code>. For Unix machines,<br />
export OSFONTDIR="/usr/local/share/fonts;$HOME/.fonts"<br />
indicate that the fonts should be found in both <code>/usr/local/share/fonts</code> and <code>$HOME/.fonts</code>.<br />
<br />
The font database will then be automatically generated in the next run of <code>context</code>. You can also generate it manually by typing <br />
mtxrun --script fonts --reload<br />
<br />
The output should look like<br />
MTXrun | fontnames: identifying tree font files with suffix otf<br />
MTXrun | fontnames: identifying tree font files with suffix OTF<br />
MTXrun | fontnames: 331 tree files identified, 332 hash entries added, runtime 7.653 seconds<br />
MTXrun | fontnames: identifying tree font files with suffix ttf<br />
MTXrun | fontnames: identifying tree font files with suffix TTF<br />
MTXrun | fontnames: 17 tree files identified, 14 hash entries added, runtime 4.645 seconds<br />
...<br />
MTXrun | fontnames: 94 system files identified, 94 hash entries added, runtime 0.554 seconds<br />
MTXrun | fontnames: 3837 files read, 3342 normal and 49 extra entries added, 5 rejected, 3386 valid<br />
<br />
If mtxrun has problem finding the mtx-fonts.lua file, it may be necessary to regenerate ConTeXt's file database:<br />
context --generate<br />
<br />
== Querying the font database ==<br />
<br />
The command<br />
mtxrun --script fonts --list --all --pattern=*<br />
will return the whole entries of the font database as a list, such as<br />
<br />
...<br />
warnockprobold WarnockPro-Bold E:/Fonts/Warnock Pro/WarnockPro-Bold.otf<br />
warnockproboldcapt WarnockPro-BoldCapt E:/Fonts/Warnock Pro/WarnockPro-BoldCapt.otf<br />
warnockprobolddisp WarnockPro-BoldDisp E:/Fonts/Warnock Pro/WarnockPro-BoldDisp.otf<br />
warnockproboldit WarnockPro-BoldIt E:/Fonts/Warnock Pro/WarnockPro-BoldIt.otf<br />
warnockprobolditcapt WarnockPro-BoldItCapt E:/Fonts/Warnock Pro/WarnockPro-BoldItCapt.otf<br />
warnockprobolditdisp WarnockPro-BoldItDisp E:/Fonts/Warnock Pro/WarnockPro-BoldItDisp.otf<br />
warnockprobolditsubh WarnockPro-BoldItSubh E:/Fonts/Warnock Pro/WarnockPro-BoldItSubh.otf<br />
warnockproboldsubh WarnockPro-BoldSubh E:/Fonts/Warnock Pro/WarnockPro-BoldSubh.otf<br />
...<br />
<br />
You can query the database against a particular pattern. For instance,<br />
mtxrun --script fonts --list --all --pattern=Delicious*<br />
will return<br />
deliciousbold Delicious-Bold /usr/local/share/fonts/d/delicious_bold.otf<br />
deliciousbolditalic Delicious-BoldItalic /usr/local/share/fonts/d/delicious_bolditalic.otf<br />
deliciousheavy Delicious-Heavy /usr/local/share/fonts/d/delicious_heavy.otf<br />
deliciousitalic Delicious-Italic /usr/local/share/fonts/d/delicious_italic.otf<br />
deliciousroman Delicious-Roman /usr/local/share/fonts/d/delicious_roman.otf<br />
delicioussmallcaps Delicious-SmallCaps /usr/local/share/fonts/d/delicious_smallcaps.otf<br />
<br />
You can get useful informations about your fonts by using the <code>--info</code> option. For instance,<br />
mtxrun --script fonts --list --info --pattern=Delicious*Roman<br />
will return<br />
MTXrun | fontname: deliciousroman<br />
MTXrun | fullname: Delicious-Roman<br />
MTXrun | filename: /usr/local/share/fonts/d/delicious_roman.otf<br />
MTXrun |<br />
MTXrun | gpos features:<br />
MTXrun |<br />
MTXrun | feature script languages<br />
MTXrun |<br />
MTXrun | kern latn dflt<br />
MTXrun |<br />
MTXrun | gsub features:<br />
MTXrun |<br />
MTXrun | feature script languages<br />
MTXrun |<br />
MTXrun | tlig all all<br />
MTXrun | trep all all<br />
<br />
== Installing new fonts ==<br />
<br />
After installing new fonts, the font database must be rebuilt for LuaTeX to access them.<br />
<br />
In current versions of Mark IV (earlier than July 2008) this is automatically done whenever a named font cannot be found.<br />
<br />
You only have to do the reload manually when you have installed updates to already installed fonts that cause the font and/or file names to change. <br />
This normally only happens for fonts that are still in development like [[TeX Gyre]] and [[Latin Modern]].<br />
<br />
You can rebuild the database manually, using the already-mentioned command<br />
mtxrun --script fonts --reload<br />
<br />
Alternatively, you can turn off the automatic rebuild of the database, by setting either of<br />
MTX.FONTS.AUTOLOAD<br />
MTX_FONTS_AUTOLOAD<br />
to "no".<br />
<br />
== References ==<br />
<br />
[http://context.aanhet.net/svn/contextman/context-reference/en/co-fonts.pdf The new manual chapter on fonts]<br />
<br />
= Using fonts =<br />
<br />
Handling fonts in LuaTeX can be done<br />
* in a simple but limited way, using the <code>simplefonts</code> module;<br />
* in the standard way, using [[TypeScripts]]<br />
<br />
== With the <code>simplefonts</code> module ==<br />
<br />
[http://www.ctan.org/tex-archive/macros/context/contrib/context-simplefonts simplefonts] is a third-party module written by Wolfgang Schuster.<br />
<br />
It simplifies the use of fonts in LuaTeX by<br />
* freeing the user from writing or using [[TypeScripts]];<br />
* offering an interface similar to the [http://www.ctan.org/tex-archive/macros/xetex/latex/fontspec/ fontspec package for XeTeX]<br />
<br />
For instance, assuming the [http://www.josbuivenga.demon.nl/delicious.html Delicious fonts] are properly installed and recognized by ConTeXt, you can simply write:<br />
<br />
<texcode><br />
\usemodule[simplefonts] % load the module<br />
\setmainfont[Delicious] % set Delicious as main (serif) font<br />
<br />
\starttext<br />
\rm\tf roman \it italic \bf bold \bi bolditalic \sc smallcaps<br />
\stoptext<br />
</texcode><br />
<br />
=== Installing <code>simplefonts</code> ===<br />
<br />
* If you're using LuaTeX along with TeXlive 2009, <code>simplefonts</code> is already installed<br />
* If you're running [[ConTeXt Standalone]], <code>simplefonts</code> can be installed like [http://wiki.contextgarden.net/ConTeXt_Standalone#Installing_third_party_modules any third-party module]:<br />
first-setup.sh --modules="t-simplefonts"<br />
<br />
== The standard way: Typescripts ==<br />
<br />
=== Installing typescripts ===<br />
<br />
Installing typescripts consists in the following:<br />
<br />
1. Copy the typescript files into either <br />
<texcode>$TEXMF/tex/texmf-fonts/tex/context/user<br />
$TEXMF/tex/texmf-project/tex/context/user</texcode><br />
2. Run <code>context --generate</code><br />
<br />
By convention, typescript files are named like <code>type-(fontname|foundry).tex</code>. <br />
<br />
It may happen that some <code>type-xx.tex</code> typescript file depends on mkiv-specific code located in a matching <code>type-xx.mkiv</code> file. In this case, both files need to be installed.<br />
<br />
=== Loading typescripts ===<br />
<br />
A typescript file named <code>type-xx.tex</code> should be loaded using<br />
\usetypescriptfile[type-xx]<br />
<br />
An alternative way is<br />
\usetypefile[xx]<br />
where ConTeXt prepends <code>type-</code> when it loads the file; but <br />
<cmd>usetypescriptfile</cmd> is the preferred command because it takes care of the<br />
<cmd>starttypescriptcollection</cmd>/<cmd>stoptypescriptcollection</cmd> environments.<br />
<br />
=== Very simple example of typescript ===<br />
<br />
If you are new to typescript you might have a look at this [[Simple Typescript Example]] to get a first idea how to use it.<br />
<br />
=== Where to find existing typescripts ===<br />
<br />
Each of the typescripts below defines a keyword to use with <cmd>setupbodyfont</cmd>. Usually this is the same as the name of the typescript, but there is one exception (<code>antykwa-torunska</code>)<br />
<br />
* Latin Modern (typescript name: <code>modern</code>; this is the default font set)<br />
* Latin Modern variant (ts name: <code>modernvariable</code>; LM variable typewriter for serif)<br />
* Postscript (ts name: <code>postscript</code>; Termes for serif, Heros for sans, Cursor for mono)<br />
* Antykwa Toruńska (ts name: <code>antykwa-torunska</code>; only serif; defines <tt>antykwa</tt> as keyword for <cmd>setupbodyfont</cmd>)<br />
* Iwona (ts name: <code>iwona</code>; only sans serif)<br />
* Iwona Light, Medium and Heavy (ts names: <code>iwona-light</code>, <code>iwona-medium</code>, <code>iwona-heavy</code>; only sans; the medium variant is a small bit heavier than a "regular" one)<br />
* Pagella (ts name: <code>palatino</code>; only serif)<br />
* Termes (ts name: <code>times</code>; only serif, Heros for sans)<br />
<br />
=== Usage example ===<br />
<br />
<texcode><br />
\usetypescript[palatino]<br />
\setupbodyfont[palatino,18pt]<br />
<br />
\starttext<br />
Hello world, I'm Pagella!<br />
\stoptext<br />
</texcode><br />
<br />
The first line seems to order ConTeXt to "install" (for the current file) the given typescript (it accepts what I have earlier called a "typescript name"). The last one starts using it (you may omit the size if you are satisfied with the default).<br />
<br />
=== Combining predefined fonts in your own typescripts ===<br />
<br />
It is also possible to combine fonts from the TeX Gyre collection in your own typescripts. The example below combines Bonum (Bookman) roman, Adventor (AvantGarde) for sans serif, Cursor (Courier) for teletype, and Euler for math. The <code>rscale=...</code> option ensures that all fonts have the same x-height. (You can lookup the relative x-heigt of a font using fontforge.)<br />
<br />
<texcode><br />
\starttypescript [Bonum]<br />
\definetypeface [Bonum] [rm] [serif] [bonum] [default]<br />
\definetypeface [Bonum] [ss] [sans] [adventor] [default] [rscale=0.887]<br />
\definetypeface [Bonum] [tt] [mono] [cursor] [default] [rscale=1.163]<br />
\definetypeface [Bonum] [mm] [math] [euler] [default] [rscale=1.050]<br />
\stoptypescript<br />
<br />
\usetypescript[Bonum]<br />
\setupbodyfont[Bonum,12pt]<br />
<br />
\starttext<br />
Hello world, I'm Bonum!<br />
\stoptext<br />
</texcode><br />
<br />
= Old contents =<br />
<br />
* [[TrueType fonts in luaTeX]]<br />
<br />
==== Good ol' typescripts ====<br />
<br />
Of course, Mark IV allows you to use typescripts as you've always done; for example:<br />
<br />
<texcode><br />
\usetypescript[palatino]<br />
\setupbodyfont[palatino,12pt]<br />
effe fietsen 2: \input tufte $\sqrt{2}$ \eogonek<br />
<br />
\sc effe fietsen 2: \input tufte $\sqrt{2}$ \eogonek<br />
</texcode><br />
<br />
That's as simple as using a traditional ConTeXt typescript!<br />
<br />
But ... how is it any different, then? Well, the difference is that in Mark IV, we can use an Opentype font directly, so that what is done here: when we want to use Palatino, the [[TeX Gyre]] equivalent (“Pagella”) is called and we can use its Opentype “features”; read on.<br />
<br />
==== Opentype features ====<br />
<br />
A “feature”, in the Opentype jargon, is a set of rules describing changes in the appearance of the text. Hmm, that's not very precise. Let's show some examples. First of all, you have to know that features are referred to by 4-letter tags, and you will see this a lot. One of them is ‘smcp‘, for “small caps“. Let's consider the following Mark IV-only code:<br />
<br />
<texcode><br />
\definefontfeature[smallcaps][language=DFLT,script=latn,smcp=yes]<br />
\font\palasmallcaps=texgyrepagella-regular*smallcaps<br />
\palasmallcaps This is a text in small capitals.<br />
</texcode><br />
<br />
Here you basically define a (Mark IV) feature with the name ”smallcaps”, and associate it with the (Opentype) feature “smcp”. You have to specify which script you want to use it with; scripts in Opentype are also tagged with four letters, and “latn” is of course Latin.<br />
<br />
Then you define a TeX font with that feature.<br />
<br />
You can see what features are defined in a particular font with the following bit of code<br />
<br />
<texcode><br />
\ctxlua<br />
{<br />
fontname = 'texgyrepagella-regular.otf'<br />
<br />
--[[ First read the font data.<br />
This makes heavy use of some of the Mark IV code]]<br />
tfmdata = fonts.tfm.read_and_define("file:" .. fontname, 655360)<br />
font = tfmdata.shared.otfdata<br />
if font<br />
then<br />
gsubfeatures = fonts.otf.analyze_features(font.gsub)<br />
gposfeatures = fonts.otf.analyze_features(font.gpos)<br />
end<br />
<br />
if gsubfeatures then<br />
table.sort(gsubfeatures) % We want our list sorted alphabetically!<br />
tex.sprint("\\rm GSUB features: \\tt ") % Beware: you don't want \rm to be interpreted by lua (\rm would yield carriage return + letter m)!<br />
for _, feat in ipairs(gsubfeatures)<br />
do tex.sprint(feat) tex.sprint(' ')<br />
end<br />
else tex.sprint("\\rm No GSUB features")<br />
end<br />
tex.sprint("\\par")<br />
<br />
if gposfeatures then<br />
tex.sprint("\\rm GPOS features: \\tt ")<br />
table.sort(gposfeatures)<br />
for _, feat in ipairs(gposfeatures)<br />
do tex.sprint(feat) tex.sprint(' ')<br />
end<br />
else tex.sprint("\\rm No GPOS features")<br />
end<br />
}<br />
</texcode><br />
<br />
It prints the list on the page. You'll notice there are two sets of features, each one of them defined in a different table of the Opentype font: the <code>GSUB</code> table (for Glyph SUBstitution) gives rules for replacing glyphs in certains circumstances (think of ligatures: f + i -> fi); the <code>GPOS</code> table (Glyph POSititioning) gives rules for moving glyphs (think of kerning: A + V -> A <kerning> V).<br />
<br />
Incidentally, the above code gives some basic examples of LuaTeX programming, a mixture of both Lua and TeX programming with some special features (features in the general sense, not the Opentype one :-).<br />
<br />
==== A (Complete) Typescript Example ====<br />
<br />
<texcode><br />
\starttypescript [sans] [franklin]<br />
<br />
\definefontsynonym [FranklinBookRegular] [name:FranklinGothicBookITC-Regular] [features=default]<br />
\definefontsynonym [FranklinMediumRegular] [name:FranklinGothicMediumITC-Regular] [features=default]<br />
\definefontsynonym [FranklinDemiRegular] [name:FranklinGothicDemiITC-Regular] [features=default]<br />
\definefontsynonym [FranklinHeavyRegular] [name:FranklinGothicHeavyITC-Regular] [features=default]<br />
<br />
\definefontsynonym [FranklinBookItalic] [name:FranklinGothicBookITC-Italic] [features=default]<br />
\definefontsynonym [FranklinDemiItalic] [name:FranklinGothicMediumITC-Italic] [features=default]<br />
\definefontsynonym [FranklinHeavyItalic] [name:FranklinGothicDemiITC-Italic] [features=default]<br />
\definefontsynonym [FranklinMediumItalic] [name:FranklinGothicHeavyITC-Italic] [features=default]<br />
<br />
\stoptypescript<br />
<br />
\starttypescript [sans] [franklin]<br />
<br />
\definefontsynonym [Sans] [FranklinBookRegular] [features=default]<br />
\definefontsynonym [SansItalic] [FranklinBookItalic] [features=default]<br />
\definefontsynonym [SansBold] [FranklinDemiRegular] [features=default]<br />
\definefontsynonym [SansBoldItalic] [FranklinDemiItalic] [features=default]<br />
\definefontsynonym [SansSlanted] [SansItalic] [features=default]<br />
\definefontsynonym [SansBoldSlanted] [SansBoldItalic] [features=default]<br />
\definefontsynonym [SansCaps] [Sans] [features=smallcaps]<br />
<br />
\stoptypescript<br />
<br />
\definetypeface[franklin][rm][sans][franklin][default]<br />
\definetypeface[franklin][ss][sans][franklin][default]<br />
\definetypeface[franklin][tt][mono][modern] [default][rscale=1.12]<br />
\definetypeface[franklin][mm][math][iwona] [default][rscale=1.02]<br />
<br />
\setupbodyfont[franklin,ss,10pt]<br />
</texcode><br />
<br />
<br />
<br />
Just the simplest way to use an otf font — or any font that does appear in <tt>mtxrun --script font --list</tt> — in all the document.<br />
<br />
I’m stick here :<br />
<br />
\definefontfeature [myfontfeature] [method=node, kern=yes, OTHER_FEATURE_COMMA_SEPERATED]<br />
\definefontsynonym [MyFontRegular] [name:TheFontName-Regular][features=myfontfeature]<br />
\definedfont [MyFontRegular at 16pt]<br />
<br />
This doesn’t run for my title which use « \tfc », only for the body of the text.<br />
<br />
*\definefontfeature<br />
**[myfontfeature] : you can use the name you want. It will be use at the next line ;<br />
**the fonts feature can be found with <tt>otfinfo -f TheFontFile.otf</tt>.<br />
*\definefontsynonym :<br />
**[MyFontRegular] : you can use the name you want. It will be use at the next line ;<br />
**The name after <tt>name:</tt> is the name given by <tt>mtxrun --script font --list</tt><br />
**The « name: » part can be replaced by <tt>file:TheFontFile.otf</tt><br />
<br />
<br />
== Example ==<br />
<br />
<br />
Now to access, say the regular warnock font, the following are valid. And I ought to mention that Hans recommends the first http://article.gmane.org/gmane.comp.tex.context/43685.<br />
<br />
<texcode><br />
% Hans recommends this format;<br />
\definefontsynonym [WarnockPro-Regular] [name:warnockproregular] <br />
</texcode><br />
<br />
and<br />
<br />
<texcode><br />
\definefontsynonym [WarnockPro-Regular] [name:WarnockPro-Regular]<br />
</texcode><br />
<br />
An entire typescript would be defined as;<br />
<br />
<texcode><br />
\definefontfeature[latin-smallcaps][smallcaps][script=latn]<br />
<br />
\starttypescript [serif] [warnockpro]<br />
\setups[font:fallback:sans]<br />
\definefontsynonym [WarnockPro-Regular] [name:WarnockPro-Regular] <br />
\definefontsynonym [WarnockPro-Bold] [name:WarnockPro-Bold] <br />
\definefontsynonym [WarnockPro-Italic] [name:WarnockPro-It] <br />
\definefontsynonym [WarnockPro-BoldItalic] [name:WarnockPro-BoldIt] <br />
\stoptypescript<br />
<br />
\starttypescript [serif] [warnockpro]<br />
\definefontsynonym [Serif] [WarnockPro-Regular] [features=default]<br />
\definefontsynonym [SerifBold] [WarnockPro-Bold] [features=default]<br />
\definefontsynonym [SerifItalic] [WarnockPro-Italic] [features=default]<br />
\definefontsynonym [SerifBoldItalic] [WarnockPro-BoldItalic] [features=default]<br />
\definefontsynonym [SerifCaps] [Serif] [features=latin-smallcaps]<br />
\stoptypescript<br />
<br />
\definetypeface[adobe][rm][serif][warnockpro][default]<br />
\setupbodyfont[adobe,11pt]<br />
<br />
</texcode><br />
<br />
= References =<br />
<references/><br />
<br />
[[Category:Fonts]]<br />
[[Category:International]]<br />
[[Category:LuaTeX]]</div>Wolfgang Schusterhttps://wiki.contextgarden.net/index.php?title=Floating_Objects&diff=13403Floating Objects2011-10-02T20:17:26Z<p>Wolfgang Schuster: Fixed</p>
<hr />
<div>< [[Visuals]] | [[Graphics]] | [[Using Graphics]] ><br />
<br />
Floats are elements like tables or figures that are placed (and numbered) automatically by TeX. They are so called as they can ''float'' around the output pages to a place where TeX thinks they are appropriate (You can influence what TeX thinks as appropriate).<br />
<br />
Floats are ConTeXt's "base class" for everything that uses a <tt>\place...</tt> command (table, figure, own floats).<br />
<br />
If you search options of e.g. <cmd>placeexternalfigure</cmd> you must look after <cmd>placefloat</cmd> in the manual! (same for <tt>\setup...</tt> etc.)<br />
<br />
The float types "graphic", "figure", "table" and "intermezzo" are readily defined. If you need more (i.e. if you need another numbering or table of something), you can easily define your own floats with <cmd>definefloat</cmd>.<br />
<br />
<texcode><br />
\placefloat[place][reference]{caption}{some float}<br />
</texcode><br />
<br />
'''place''' is one or several (comma separated) of:<br />
<table><br />
<tr bgcolor="#AAAAAA"><th>preference</th><th align="left">result</th></tr><br />
<tr bgcolor="#DDDDDD"><td>left</td><td>left of text</td></tr><br />
<tr><td>right</td><td>right of text</td></tr><br />
<tr bgcolor="#DDDDDD"><td>here</td><td>preferably here</td></tr><br />
<tr><td>top</td><td>at top of page</td></tr><br />
<tr bgcolor="#DDDDDD"><td>bottom</td><td>at bottom of page</td></tr><br />
<tr><td>inleft</td><td>in left margin</td></tr><br />
<tr bgcolor="#DDDDDD"><td>inright</td><td>in right margin</td></tr><br />
<tr><td>inmargin</td><td>in the margin (left or right)</td></tr><br />
<tr bgcolor="#DDDDDD"><td>margin</td><td>in the margin (margin float)</td></tr><br />
<tr><td>page</td><td>on a new (empty) page</td></tr><br />
<tr bgcolor="#DDDDDD"><td>opposite</td><td>on the left page</td></tr><br />
<tr><td>always</td><td>precedence over stored floats</td></tr><br />
<tr bgcolor="#DDDDDD"><td>force</td><td>per se here</td></tr><br />
<tr><td>split</td><td>(For TABLES only) split tables</td></tr><br />
</table><br />
(table copied from the manual)<br />
<br />
<cmd>placefigure</cmd> and <cmd>placetable</cmd> also accept the same set of options, and allow to create floating figures and captions respectively.<br />
<br />
'''reference'''<br />
<br />
If you don't need to refer to your float, you can leave this parameter out.<br />
<br />
== Examples ==<br />
I will explain the examples in terms of <cmd>placefigure</cmd> but the same set of options are also valid for other floats.<br />
<br />
* If you do not want a caption<br />
<texcode><br />
\placefigure {none} {\externalfigure[figurename]}<br />
</texcode><br />
<br />
or<br />
<br />
<texcode><br />
\placefigure[none] {} {\externalfigure[figurename]}<br />
</texcode><br />
<br />
<br />
* If you do not want the figure to be numbered (but still want the caption)<br />
<br />
<texcode><br />
\placefigure [nonumber] {caption} {\externalfigure[figurename]}<br />
</texcode><br />
<br />
* Suppose you want the figure to be placed on the right side of the page, a few lines into the paragraph, and want the rest of the paragraph to warp around the figure<br />
<br />
<texcode><br />
\placefigure [right,2*line] {caption} {\externalfigure[figurename]}<br />
</texcode><br />
<br />
or <br />
<br />
<texcode><br />
\placefigure [right,2*hang] {caption} {\externalfigure[figurename]}<br />
</texcode><br />
<br />
This does not want correctly at a page boundary. The <tt>line</tt> options leaves the space above the figures empty, while the <tt>hang</tt> option also wraps texts above the figure.<br />
<br />
==Floats and columns==<br />
<br />
This special case is discussed [[Columns#Floats_and_other_limitations_of_columns|here]].<br />
<br />
==Protruding Floats in Double-Sided Documents==<br />
<br />
If you have a double-sided document with wide outer margins then you might want your figures to protrude into the margin. In a double-sided document you need to tell ConTeXt to decide whether to make the figure protrude to the left or the right. This can be done as follows:<br />
<br />
<texcode><br />
\definefloat[textmarginfigure][textmarginfigures]<br />
\setupfloat[textmarginfigure][location=inner]<br />
\placetextmarginfigure{\externalfigure[figurename]}<br />
</texcode><br />
<br />
The following code gives a full example that can be pasted into live ConTeXt:<br />
<br />
<texcode><br />
\setuppagenumbering [alternative=doublesided]<br />
\setuplayout[location=middle,backspace=2pc, width=20pc]<br />
\definefloat[textmarginfigure][textmarginfigures]<br />
\setupfloat[textmarginfigure][location=inner]<br />
\starttext<br />
\input knuth<br />
\placetextmarginfigure[here]{}{\externalfigure[figurename][width=30pc]}<br />
\input knuth<br />
\placetextmarginfigure[here]{}{\externalfigure[figurename][width=30pc]}<br />
\input knuth<br />
\stoptext<br />
</texcode><br />
<br />
== Floats and section headings ==<br />
By default, section headings don't wrap "around" floating objects. Instead, they will be moved down as far as needed to appear below the float. This behaviour can be controlled using the <tt>aligntitle</tt> option of the <cmd>setupheads</cmd> or <cmd>setuphead</cmd> commands.<br />
<br />
== Captions ==<br />
To change the style of figure(table) captions, use <cmd>setupcaptions</cmd>.<br />
<br />
== Flushing floats ==<br />
<br />
The command <cmd>placefloats</cmd> outputs all pending floats.</div>Wolfgang Schusterhttps://wiki.contextgarden.net/index.php?title=Module_Namespaces&diff=13027Module Namespaces2011-05-15T11:17:40Z<p>Wolfgang Schuster: Added “animation” namespace.</p>
<hr />
<div>=List of Module Namespaces=<br />
{{todo|This list is under construction and will eventually contain all namespaces used in context modules.}}<br />
<br />
To avoid clashes with existing and future commands, any module<br />
should adhere to the following rules:<br />
<br />
* Namespace identifiers (their <tt>name</tt> parameter) should have more than two characters (at least yours [http://article.gmane.org/gmane.comp.tex.context/61939]),<br />
<br />
* the namespace should be registered here for others to know.<br />
<br />
{|cellpadding="10" style="border:2px solid #addeff"<br />
! style="background:#addeff;" | Namespace !! Name<br />
! style="background:#addeff;" | Main file !! Description<br />
|-<br />
| <tt>algorithmic</tt><br />
| algorithmic<br />
| [https://bitbucket.org/wolfs/algorithmic t-algorithmic]<br />
| Write algorithms.<br />
|-<br />
| <tt>animation</tt><br />
| animation<br />
| [https://bitbucket.org/wolfs/animation t-animation]<br />
| Interface for fieldstack based animation.<br />
|-<br />
| <tt>annotation</tt><br />
| annotation<br />
| [https://bitbucket.org/wolfs/annotation t-annotation]<br />
| Annotate text blocks.<br />
|-<br />
| <tt>fancybreak</tt><br />
| fancybreak<br />
| [https://bitbucket.org/wolfs/fancybreak t-fancybreak]<br />
| Inserting thought breaks (transitions).<br />
|-<br />
| <tt>fx</tt><br />
| fixme<br />
| [https://bitbucket.org/wolfs/fixme t-fixme]<br />
| Todo notes.<br />
|-<br />
| <tt>fullpage</tt><br />
| fullpage<br />
| [https://bitbucket.org/wolfs/fullpage t-fullpage]<br />
| Set equal margin without \setuplayout.<br />
|-<br />
| <tt>letterspace</tt><br />
| letterspace<br />
| [https://bitbucket.org/phg/t-letterspace t-letterspace]<br />
| Define letterspacing macros.<br />
|-<br />
| <tt>rb</tt><br />
| ruby<br />
| [https://bitbucket.org/wolfs/ruby t-ruby]<br />
| Highlight text with ruby markup.<br />
|-<br />
|<tt>RST</tt><br />
| RST<br />
| [https://bitbucket.org/phg/context-rst t-rst]<br />
| Convert/typeset reStructuredText.<br />
|-<br />
|<tt>TRL</tt><br />
| transliterate<br />
| [https://bitbucket.org/phg/transliterator t-transliterator]<br />
| Transliteration from non-Latin scripts.<br />
|- <br />
| <tt>visualcounter</tt><br />
| visualcounter || [http://github.com/adityam/visualcounter t-visualcounter] || Display counters using a graphic<br />
|+ style="font-style:italic; font-size:83.3333%;" | Reserved module namespaces.<br />
|}<br />
<br />
=Generating a Namespace for Your Module=<br />
<br />
Context provides the user command [[cmd:definenamespace|\definenamespace]] <br />
that generates a valid namespace for variables and takes care<br />
of defining a setup command as well.<br />
Suppose you have a module called ''My Module'' (preferably in <br />
a file <tt>t-mymodule.mkiv</tt>) and want to reserve the<br />
namespace ''mymod''.<br />
The following snippet will get you a setup command<br />
<tt>\setupMyMod</tt>.<br />
<br />
<texcode><br />
\definenamespace[mymod] [<br />
type=module,<br />
name=MyMod,<br />
setup=list,<br />
]<br />
</texcode><br />
<br />
Through <tt>\setupMyMod</tt> you can now set the variables <br />
that you are planning to use in your module &ndash;<br />
it is already a mature command that conforms to the overall<br />
context style and can take a parameter list, a list of<br />
key-value pairs or both as arguments.<br />
Any parameter defined that way can now be retrieved via<br />
another command that got auto-generated, <tt>\MyModparameter</tt>.<br />
<br />
<texcode><br />
% setting a parameter within the namespace<br />
\setupMyMod[<br />
yamp=Yet another module parameter,<br />
]<br />
<br />
% command sequence that does something with the parameter<br />
\def\blueparameter{\setupcolors[state=start]\colored[blue]\MyModparameter{yamp}}<br />
<br />
% deploying the new user command<br />
\starttext<br />
\blueparameter<br />
\stoptext<br />
</texcode><br />
<br />
Wondering why your namespace, albeit defined as <tt>mymod</tt><br />
initially, is always referred to as ''MyMod'', i.e. the value<br />
of the parameter <tt>name</tt> as given in the definition?<br />
Internally the namespaces are represented as ordinary command<br />
sequences with a prefix.<br />
This prefix is composed from first the usual four<br />
[[System_Macros/Fundamentals#Protecting_internal_macros|''@''-signs]],<br />
second the namespace identifier, and third the key id from the<br />
argument list.<br />
In the example this results in a macro <tt>\@@@@</tt> + <br />
<tt>mymod</tt> + <tt>yamp</tt>.<br />
Thus, <tt>\MyModparameter{yamp}</tt> would be equivalent to<br />
calling:<br />
<br />
<texcode><br />
\unprotect<br />
\@@@@mymodyamp<br />
\protect<br />
</texcode><br />
<br />
=Namespace Configuration=<br />
<tt>\definenamespace</tt> accepts a number of options that<br />
determine what commands will be available.<br />
At the time of this writing (2010-09-27), this is rather<br />
new stuff and so far not guaranteed to stay in context<br />
unmodified.<br />
<br />
{|cellpadding="10" style="border:2px solid #addeff" rules="rows"<br />
! style="background:#addeff;" | Option !! Parameters and their description (''NS'' is a namespace dummy)<br />
|-<br />
|<tt>name</tt> || ''string'': The identifier that will be used to reference setups and parameters; e.&nbsp;g. a value of ''NS'' causes the macros <tt>\defineNS</tt> and <tt>\setupNS</tt> to be created.<br />
|-<br />
|<tt>parent</tt> || ''string'': a namespace identifier. Should be the same as the identifier of the module’s namespace.<br />
|-<br />
|<tt>type</tt> || <tt>module</tt>: creates the namespace prefixed with quadruple ''@''; other values are planned to be added in the future for internal purposes.<br />
|-<br />
|<tt>setup</tt> || <tt>list</tt> or ''boolean'': initiates the creation of a setup according to the <tt>name</tt> argument, e.&nbsp;g. <tt>\setupNS</tt>. The specified value influences the behaviour of the setup:<br />
{|<br />
|<tt>yes</tt> || first argument of the setup accepts one parameter (<tt>\setupNS[one][..,..=..,..]</tt>);<br />
|-<br />
|<tt>list</tt> || first argument of the setup accepts a comma separated list (<tt>\setupNS[one,two,three][..,..=..,..]</tt>).<br />
|}<br />
|-<br />
|align="right" | <tt>command</tt><br />
|<tt>list</tt> or ''boolean'': creates auxiliary macros and the proper command to define further commands within the new namespace (<tt>\defineNS</tt>).<br />
For a <tt>name</tt> parameter ''NS'', the values of the <tt>\setupNS</tt> command will be retrievable via <tt>\NSparameter{parametername}</tt>. Additionally, access is provided by <tt>\namedNSparameter</tt> and <tt>\detokenizedNSparameter</tt>.<br />
The <tt>\defineNS[command][..,..=..,..]</tt> can be used to create instances of a generic macro with local setups. Works like ordinary Context <tt>\definesomething</tt> commands and allows for inheritance (<tt>\defineNS[command][othercommand]</tt>). Of course, if <tt>command</tt> is set to ''list'', the first argument of <tt>\defineNS</tt> will take comma separated values.<br />
|-<br />
|<tt>comment</tt> || ''string'': meta-information, see [[#Related Commands|related commands]] below.<br />
|-<br />
|<tt>version</tt> || ''number'': meta-information, see [[#Related Commands|related commands]].<br />
|-<br />
|<tt>style</tt> || ''boolean'': enables special handling for text color and style attributes.<br />
If set to ''yes'', a macro <tt>\dosetNSattributes</tt> will be created. It receives the values for the <tt>style</tt> and <tt>color</tt> arguments as supplied to the <tt>\setupNS</tt> macro which itself gets created via the <tt>setup</tt> key (see above).<br />
|+ Optional settings for module namespaces.<br />
|}<br />
<br />
=Related Commands=<br />
==<tt>\listnamespaces</tt>==<br />
Prints all namespaces defined in tabular form along <br />
with additional information. Example:<br />
<br />
<texcode><br />
\definenamespace[Newns][<br />
name=Newns,<br />
type=module,<br />
setup=list,<br />
parent=NS,<br />
style=yes,<br />
version=3.141,<br />
comment=this space has been named,<br />
]<br />
<br />
\starttext<br />
\listnamespaces<br />
\stoptext<br />
</texcode><br />
<br />
=Further Information=<br />
* [[source:mult-aux.mkiv|Definition of <tt>\definenamespace</tt>]].<br />
* [[System Macros]].<br />
* Some of the functionality was explained by Wolfgang Schuster on the [http://archive.contextgarden.net/message/20101117.215320.314eb367.en.html Context list]</div>Wolfgang Schusterhttps://wiki.contextgarden.net/index.php?title=Tabulate&diff=12984Tabulate2011-04-06T08:14:30Z<p>Wolfgang Schuster: Tabulate doesn’t support columnspan</p>
<hr />
<div>< [[Tables Overview]] | [[Table]] ><br />
<br />
<br />
=Summary=<br />
<br />
[[cmd:starttabulate|Tabulate]] is a versatile table environment.<br />
It supports ''paragraphs'' in cells, ''vertical rules'' (for<br />
those typographically less demanding jobs&nbsp;…), and<br />
''colorization'' of those rules, the background of fields as well<br />
as the text itself.<br />
<br />
=Basic commands=<br />
<br />
The control sequence <tt>\starttabulate[#1]</tt> takes a layout<br />
string as optional argument.<br />
As is common with tables in TeX-based typesetting, this string<br />
(in its basic variant) consists primarily of the ''bar''<br />
character (“<tt>|</tt>”) as delimiter for columns,<br />
and of the letters <tt>c</tt>, <tt>l</tt>, as well as <tt>r</tt>,<br />
denoting the ''alignment'' within cells of this row.<br />
<br />
For instance consider a two-column table: if any text in the<br />
first column should be right aligned (''real''<br />
[[right and left|<tt>flushright</tt>]]) and the second column<br />
left aligned, the corresponding format string would be<br />
<tt>|l|r|</tt>.<br />
''NB'': those bars, as stated above, denote cell limits only<br />
&ndash; ''not'' vertical lines.<br />
<br />
<!--<br />
- wtf this listing was full of <tab> chars‽ Was this supposed<br />
- to be a bad pun on *tabulate*?<br />
--><br />
{|<br />
! width="55%"|<br />
! width="10%"|<br />
! width="35%"|<br />
|-<br />
| <texcode><br />
\starttabulate[|r|l|]<br />
\HL<br />
\NC {\bf format} \NC {\bf meaning} \NC\NR<br />
\HL<br />
\NC c \NC centered \NC\NR<br />
\NC l \NC left aligned \NC\NR<br />
\NC r \NC right aligned \NC\NR<br />
\NC w(1cm) \NC one line, fixed width \NC\NR<br />
\NC p(2cm) \NC paragraph, lines broken to fixed width \NC\NR<br />
\NC cg(.) \NC align on a character \NC\NR<br />
\HL<br />
\stoptabulate<br />
</texcode><br />
|<br />
|<context><br />
\starttabulate[|r|l|]<br />
\HL<br />
\NC {\bf format} \NC {\bf meaning} \NC\NR<br />
\HL<br />
\NC c \NC centered \NC\NR<br />
\NC l \NC left aligned \NC\NR<br />
\NC r \NC right aligned \NC\NR<br />
\NC w(1cm) \NC one line, fixed width \NC\NR<br />
\NC p(2cm) \NC paragraph, lines broken to fixed width \NC\NR<br />
\NC cg(.) \NC align on a character \NC\NR<br />
\HL<br />
\stoptabulate<br />
</context><br />
|}<br />
<br />
* <tt>HL</tt> draws a horizontal rule,<br />
* <tt>NC</tt> marks a new column (or new cell),<br />
* <tt>NR</tt> starts new row.<br />
<br />
It is generally not necessary to conclude lines with<br />
<tt>\NC\NR</tt> as <tt>\AR</tt> (for <em>a</em>uto<em>r</em>ow)<br />
will do the job as well.<br />
<br />
=Spanning Multiple Pages=<br />
<br />
Tabulate may extend to adjacient pages if needed.<br />
To achieve this the argument <tt>split</tt> must be set to<br />
''true''.<br />
''NB'': the difference between setting and unsetting this<br />
argument may not be visible on the first few pages. Rather, it<br />
seems to affect the ''end'' of the environment.<br />
<br />
<context source="yes"><br />
\setuppapersize [XY][A4]<br />
\setuppaper [nx=2,ny=2]<br />
\setuparranging [XY]<br />
\setupbodyfont[10pt]<br />
<br />
\starttext<br />
<br />
\setuptabulate[split=yes]<br />
<br />
\starttabulate<br />
\dorecurse{2}{<br />
\NC test \NC \input tufte \relax \NC \NR <br />
\NC test \NC \input dawkins \relax \NC \NR <br />
}<br />
\stoptabulate<br />
<br />
\stoptext \endinput<br />
</context><br />
<br />
==Titles==<br />
<br />
A tabulating environment can have an optional name which will be<br />
repeated above at every page break that occurs inside the table.<br />
This name needs to be specified as the argument of the<br />
<tt>title</tt> key of <tt>\setuptabulate</tt>.<br />
The <tt>header</tt> key has to be set to <em>text</em> for this<br />
to work.<br />
<br />
<texcode><br />
\setuptabulate[split=yes,header=text,title={\sc Table Titles Undisclosed!}]<br />
<br />
\starttabulate<br />
\dorecurse{2}{<br />
\NC Ed Tufte \NC \input tufte \relax \NC \NR<br />
\NC Dick Dawkins \NC \input dawkins \relax \NC \NR<br />
}<br />
</texcode><br />
<br />
<context><br />
\setuppapersize [XY][A4]<br />
\setuppaper [nx=2,ny=2]<br />
\setuparranging [XY]<br />
<br />
\starttext<br />
<br />
\setuptabulate[split=yes,header=text,title={\sc Table Titles Undisclosed!}]<br />
<br />
\starttabulate<br />
\dorecurse{2}{<br />
\NC Ed Tufte \NC \input tufte \relax \NC \NR <br />
\NC Dick Dawkins \NC \input dawkins \relax \NC \NR<br />
}<br />
\stoptabulate<br />
<br />
\stoptext \endinput<br />
</context><br />
<br />
<!--<br />
- ==Headers and Footers==<br />
- As I couldn’t get footers running I just comment this and<br />
- leave it to whoever discovers the trick to activate them.<br />
- (The <tt>footer=</tt> key seems to be implemented for<br />
- “\setuptabulate” but I couldn’t notice any effect.<br />
--><br />
==Headers==<br />
Tabulate supports header rows that can be repeated over new table<br />
pages instead of the title.<br />
There is a separate environment <tt>\starttablehead</tt> where<br />
this header row has to be specified in advance of its use in a<br />
tabulation.<br />
<br />
{|<br />
! width="55%"|<br />
! width="10%"|<br />
! width="35%"|<br />
|-<br />
| <texcode><br />
\setuptabulate[split=yes,header=repeat]<br />
<br />
\starttabulatehead<br />
\HL<br />
\NC {\bf format char} \NC {\bf meaning} \AR<br />
\HL<br />
\stoptabulatehead<br />
<br />
\starttabulate[|r|l|]<br />
\NC c \NC centered \AR<br />
\NC l \NC left aligned \AR<br />
\NC r \NC right aligned \AR<br />
\stoptabulate<br />
</texcode><br />
|<br />
| <context><br />
\setuptabulate[split=yes,header=repeat]<br />
<br />
\starttabulatehead<br />
\HL<br />
\NC {\bf format char} \NC {\bf meaning} \AR<br />
\HL<br />
\stoptabulatehead<br />
<br />
\starttabulate[|r|l|]<br />
\NC c \NC centered \AR<br />
\NC l \NC left aligned \AR<br />
\NC r \NC right aligned \AR<br />
\stoptabulate<br />
</context><br />
|}<br />
<br />
=Individualizing the Tabulate Look=<br />
<br />
Hans initially announced support for vertical lines and colors on<br />
the mailing list.[http://archive.contextgarden.net/message/20101117.123950.739657a7.en.html]<br />
<br />
==Rules==<br />
<br />
===Horizontal Rules===<br />
<br />
As already demonstrated above, the <tt>\HL</tt> statement inserts<br />
a hairline after the current line.<br />
This particularly useful when demarking header and footer rows or<br />
separated parts of a table that should not be as closely<br />
associated as the rows between the rules.<br />
<br />
{|<br />
! width="55%"|<br />
! width="10%"|<br />
! width="35%"|<br />
|-<br />
| <texcode><br />
\starttabulate[|r|c|l|] <br />
\NC test \NC test \NC test \NC\NR <br />
\HL<br />
\NC test \NC test \NC test \NC\NR <br />
\NC test \NC test \NC test \NC\NR <br />
\HL<br />
\NC test \NC test \NC test \NC\NR <br />
\HL<br />
\stoptabulate<br />
</texcode><br />
| <context><br />
\starttabulate[|r|c|l|] <br />
\NC test \NC test \NC test \NC\NR <br />
\HL<br />
\NC test \NC test \NC test \NC\NR <br />
\NC test \NC test \NC test \NC\NR <br />
\HL<br />
\NC test \NC test \NC test \NC\NR <br />
\HL<br />
\stoptabulate<br />
</context><br />
|}<br />
<br />
Context supports different categories of rules that can be<br />
configured individually in order to discern various applications.<br />
Their behaviour accounts for the designated use, e.&nbsp;g.<br />
<tt>\ML</tt> (mid rules) are intended to be deployed between<br />
ordinary rows of the table body and will prevent page breaks<br />
&ndash; no way you’d end up with a rogue hairline desecrating<br />
the bottom of your page’s text area.<br />
{|cellpadding="10" style="border:2px solid #addeff"<br />
! style="background:#addeff;" | Type !! Description<br />
|-<br />
|<tt>\HL</tt> || standard horizontal rule;<br />
|-<br />
|<tt>\FL</tt> || first rule;<br />
|-<br />
|<tt>\ML</tt> || mid rule;<br />
|-<br />
|<tt>\LL</tt> || bottom rule;<br />
|-<br />
|<tt>\LL</tt> and <tt>\TL</tt> || bottom rule;<br />
|-<br />
|<tt>\BL</tt> || last rule.<br />
|}<br />
<br />
Additionally, there is an options <tt>rulecolor</tt> for<br />
<tt>\setuptabulate</tt> that allows for those rules to be tinted.<br />
<br />
<texcode><br />
\setuptabulate[rulecolor=red]<br />
<br />
\starttabulate[|r|c|l|] <br />
\FL<br />
\NC first row \NC test \NC test \NC\NR <br />
\ML<br />
\NC rows in \NC test \NC test \NC\NR <br />
\NC between \NC test \NC test \NC\NR <br />
\LL <br />
\NC last row \NC test \NC test \NC\NR <br />
\BL<br />
\stoptabulate<br />
</texcode><br />
<br />
Other types can be discovered in the source<br />
([[source:tabl-tbl.mkiv|tabl-tbl.mkiv]]).<br />
<br />
===Vertical Rules===<br />
<br />
The <tt>\VL</tt> command serves as a replacement for <tt>\NC</tt><br />
to mark a cell border wherever a vertical rule may be desired (if<br />
they are to be desired at all from a typographical point of<br />
view).<br />
<br />
<texcode><br />
\starttabulate[||||] <br />
\NC test \VL test \VL test \VL\NR <br />
\VL test \NC test \VL test \VL\NR <br />
\VL test \VL test \NC test \VL\NR <br />
\VL test \VL test \VL test \NC\NR <br />
\stoptabulate<br />
</texcode><br />
<br />
==Coloring==<br />
<br />
The following elements can be colorized: rules, cell backgrounds,<br />
and, obviously, common text.<br />
<br />
===Colorizing Rules===<br />
<br />
For ''horizontal rules'' see above.<br />
<br />
For ''vertical rules'', <tt>\VL</tt> takes a defined color as an<br />
optional argument.<br />
<br />
<texcode><br />
\starttabulate[|r|c|l|] <br />
\VL test \VL[red] red rule \VL test \VL \NR <br />
\VL test \VL[green] green rule \VL test \VL \NR <br />
\VL test \VL[blue] blue rule \VL test \VL \NR <br />
\stoptabulate<br />
</texcode><br />
<br />
===Colorizing Backgrounds===<br />
''Backgrounds'' can be colorized either on column basis or<br />
individually by cell.<br />
<br />
There are four color-specific control sequences:<br />
{|<br />
|<tt>CR</tt> || color is applied to the background of the text and the remaining space on the right;<br />
|-<br />
|<tt>CC</tt> || color is applied to the background of the text only; <br />
|-<br />
|<tt>CM</tt> || color is applied to the background of the text and the remaining space on both sides;<br />
|-<br />
|<tt>CL</tt> || color is applied to the background of the text and the remaining space on the left.<br />
|}<br />
These are to complement the normal table layout expression (the<br />
first argument to <tt>\starttabulate</tt>.<br />
Thus, in order to colorize a four column table with the initial<br />
layout <tt>|c|c|c|c|</tt> it will have to be modified as follows:<br />
<texcode><br />
\starttabulate[|CR{red}c|CC{yellow}c|CM{green}c|CL{blue}c|] <br />
\NC test \NC test \NC test \NC test \NC \NR <br />
\NC test \NC test \NC test \NC test \NC \NR <br />
\NC test \NC test \NC test \NC test \NC \NR <br />
\NC test \NC test \NC test \NC test \NC \NR <br />
\stoptabulate<br />
</texcode><br />
<br />
Those control sequences, if applied within the table body, can<br />
replace the ordinary <tt>\NC</tt>, allowing individual cells to<br />
be colorized.<br />
<texcode><br />
\starttabulate[|c|c|c|c|c|c|]<br />
\NC g \NC l \NC i \NC d \NC e \NC r \NC \NR <br />
\NC g \NC l \NC i \CM[blue] d \NC e \NC r \NC \NR <br />
\NC g \NC l \NC i \NC d \CM[blue] e \NC r \NC \NR <br />
\NC g \NC l \CM[blue] i \CM[blue] d \CM[blue] e \NC r \NC \NR <br />
\NC g \NC l \NC i \NC d \NC e \NC r \NC \NR <br />
\stoptabulate<br />
</texcode><br />
<br />
<br />
===Colorizing Cell Text===<br />
''Normal text'' inside cells gets its color via the<br />
[[Colors|standard coloring commands]].<br />
<br />
<texcode><br />
\starttabulate[|r|c|l|] <br />
\NC test \NC {\colored[red] test} \NC test \NC\NR <br />
\NC test \NC {\colored[green] test} \NC test \NC\NR <br />
\NC test \NC {\colored[blue] test} \NC test \NC\NR <br />
\NC test \NC {\colored[cyan] test} \NC test \NC\NR <br />
\stoptabulate<br />
</texcode><br />
<br />
=See also=<br />
<br />
* More features are constantly added and documented only in the [[source:tabl-tbl.mkiv|source]].<br />
<br />
* [[cmd:starttabulate|Command description]]<br />
<br />
* [[TABLE|Natural Tables]]<br />
<br />
* [[cmd:starttable|Table environment]]<br />
<br />
[[Category:Tables]]</div>Wolfgang Schusterhttps://wiki.contextgarden.net/index.php?title=Command/fillinfield&diff=12982Command/fillinfield2011-04-05T17:54:05Z<p>Wolfgang Schuster: Format code with <texcode></p>
<hr />
<div>{{Reference<br />
|name=fillinfield<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd">\fillinfield<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>text </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">{...}</td><br />
<td><i>text</i> </td><br />
</tr><br />
</table><br />
<br />
== Example == <br />
<br />
<br />
<texcode><br />
\usemodule[fields,abr-pseudocaps]<br />
<br />
\setupinteraction[state=start]<br />
<br />
\starttext<br />
A few years back, \TEX\ could only produce \fillinfield [dvi]{\DVI}<br />
output, but nowadays, thanks to \fillinfield {Han The Thanh},<br />
we can also directly produce \fillinfield [pdf] {\PDF}! Nice eh?<br />
Actually, while the first field module was prototyped in \ACROBAT,<br />
the current implementation was debugged in \fillinfield [pdfTeX] {\PDFTEX}.<br />
Field support in \fillinfield [ConTeXt] {\CONTEXT} is rather advanced<br />
and complete and all kind of fields are supported. One can hook<br />
in appearances, and validation \fillinfield [JavaScripts] {\JAVASCRIPT}'s.<br />
Fields can be cloned and copied, where the latter saves some space.<br />
By using \fillinfield {objects} when suited, this module saves space anyway.<br />
\stoptext<br />
</texcode><br />
<br />
== See also ==<br />
<!-- something like [[cmd:goto|\goto]] --><br />
<br />
[[Category:Reference/en|fillinfield]]</div>Wolfgang Schusterhttps://wiki.contextgarden.net/index.php?title=Module_Namespaces&diff=12693Module Namespaces2011-01-04T12:07:28Z<p>Wolfgang Schuster: Module_Namespaces#List_of_Module_Namespaces: fixme</p>
<hr />
<div>=List of Module Namespaces=<br />
{{todo|This list is under construction and will eventually contain all namespaces used in context modules.}}<br />
<br />
To avoid clashes with existing and future commands, any module<br />
should adhere to the following rules:<br />
<br />
* Namespace identifiers (their <tt>name</tt> parameter) should have more than two characters (at least yours [http://article.gmane.org/gmane.comp.tex.context/61939]),<br />
<br />
* the namespace should be registered here for others to know.<br />
<br />
{|cellpadding="10" style="border:2px solid #addeff"<br />
! style="background:#addeff;" | Namespace !! Name<br />
! style="background:#addeff;" | Main file !! Description<br />
|-<br />
| <tt>algorithmic</tt><br />
| algorithmic<br />
| [https://bitbucket.org/wolfs/algorithmic t-algorithmic]<br />
| Write algorithms.<br />
|-<br />
| <tt>annotation</tt><br />
| annotation<br />
| [https://bitbucket.org/wolfs/annotation t-annotation]<br />
| Annotate text blocks.<br />
|-<br />
| <tt>fancybreak</tt><br />
| fancybreak<br />
| [https://bitbucket.org/wolfs/fancybreak t-fancybreak]<br />
| Inserting thought breaks (transitions).<br />
|-<br />
| <tt>fx</tt><br />
| fixme<br />
| [https://bitbucket.org/wolfs/fixme t-fixme]<br />
| Todo notes.<br />
|-<br />
| <tt>fullpage</tt><br />
| fullpage<br />
| [https://bitbucket.org/wolfs/fullpage t-fullpage]<br />
| Set equal margin without \setuplayout.<br />
|-<br />
| <tt>rb</tt><br />
| ruby<br />
| [https://bitbucket.org/wolfs/ruby t-ruby]<br />
| Highlight text with ruby markup.<br />
|-<br />
|<tt>RST</tt><br />
| reST<br />
| [https://bitbucket.org/phg/context-rst t-rst]<br />
| Convert/typeset reStructuredText.<br />
|-<br />
|<tt>TRL</tt><br />
| transliterate<br />
| [https://bitbucket.org/phg/transliterator t-transliterator]<br />
| Transliteration from non-Latin scripts.<br />
|- <br />
| <tt>visualcounter</tt><br />
| visualcounter || [http://github.com/adityam/visualcounter t-visualcounter] || Display counters using a graphic<br />
|+ style="font-style:italic; font-size:83.3333%;" | Reserved module namespaces.<br />
|}<br />
<br />
=Generating a Namespace for Your Module=<br />
<br />
Context provides the user command [[cmd:definenamespace|\definenamespace]] <br />
that generates a valid namespace for variables and takes care<br />
of defining a setup command as well.<br />
Suppose you have a module called ''My Module'' (preferably in <br />
a file <tt>t-mymodule.mkiv</tt>) and want to reserve the<br />
namespace ''mymod''.<br />
The following snippet will get you a setup command<br />
<tt>\setupMyMod</tt>.<br />
<br />
<texcode><br />
\definenamespace[mymod] [<br />
type=module,<br />
name=MyMod,<br />
setup=list,<br />
]<br />
</texcode><br />
<br />
Through <tt>\setupMyMod</tt> you can now set the variables <br />
that you are planning to use in your module &ndash;<br />
it is already a mature command that conforms to the overall<br />
context style and can take a parameter list, a list of<br />
key-value pairs or both as arguments.<br />
Any parameter defined that way can now be retrieved via<br />
another command that got auto-generated, <tt>\MyModparameter</tt>.<br />
<br />
<texcode><br />
% setting a parameter within the namespace<br />
\setupMyMod[<br />
yamp=Yet another module parameter,<br />
]<br />
<br />
% command sequence that does something with the parameter<br />
\def\blueparameter{\setupcolors[state=start]\colored[blue]\MyModparameter{yamp}}<br />
<br />
% deploying the new user command<br />
\starttext<br />
\blueparameter<br />
\stoptext<br />
</texcode><br />
<br />
Wondering why your namespace, albeit defined as <tt>mymod</tt><br />
initially, is always referred to as ''MyMod'', i.e. the value<br />
of the parameter <tt>name</tt> as given in the definition?<br />
Internally the namespaces are represented as ordinary command<br />
sequences with a prefix.<br />
This prefix is composed from first the usual four<br />
[[System_Macros/Fundamentals#Protecting_internal_macros|''@''-signs]],<br />
second the namespace identifier, and third the key id from the<br />
argument list.<br />
In the example this results in a macro <tt>\@@@@</tt> + <br />
<tt>mymod</tt> + <tt>yamp</tt>.<br />
Thus, <tt>\MyModparameter{yamp}</tt> would be equivalent to<br />
calling:<br />
<br />
<texcode><br />
\unprotect<br />
\@@@@mymodyamp<br />
\protect<br />
</texcode><br />
<br />
=Namespace Configuration=<br />
<tt>\definenamespace</tt> accepts a number of options that<br />
determine what commands will be available.<br />
At the time of this writing (2010-09-27), this is rather<br />
new stuff and so far not guaranteed to stay in context<br />
unmodified.<br />
<br />
{|cellpadding="10" style="border:2px solid #addeff" rules="rows"<br />
! style="background:#addeff;" | Option !! Parameters and their description (''NS'' is a namespace dummy)<br />
|-<br />
|<tt>name</tt> || ''string'': The identifier that will be used to reference setups and parameters; e.&nbsp;g. a value of ''NS'' causes the macros <tt>\defineNS</tt> and <tt>\setupNS</tt> to be created.<br />
|-<br />
|<tt>parent</tt> || ''string'': a namespace identifier. Should be the same as the identifier of the module’s namespace.<br />
|-<br />
|<tt>type</tt> || <tt>module</tt>: creates the namespace prefixed with quadruple ''@''; other values are planned to be added in the future for internal purposes.<br />
|-<br />
|<tt>setup</tt> || <tt>list</tt> or ''boolean'': initiates the creation of a setup according to the <tt>name</tt> argument, e.&nbsp;g. <tt>\setupNS</tt>. The specified value influences the behaviour of the setup:<br />
{|<br />
|<tt>yes</tt> || first argument of the setup accepts one parameter (<tt>\setupNS[one][..,..=..,..]</tt>);<br />
|-<br />
|<tt>list</tt> || first argument of the setup accepts a comma separated list (<tt>\setupNS[one,two,three][..,..=..,..]</tt>).<br />
|}<br />
|-<br />
|align="right" | <tt>command</tt><br />
|<tt>list</tt> or ''boolean'': creates auxiliary macros and the proper command to define further commands within the new namespace (<tt>\defineNS</tt>).<br />
For a <tt>name</tt> parameter ''NS'', the values of the <tt>\setupNS</tt> command will be retrievable via <tt>\NSparameter{parametername}</tt>. Additionally, access is provided by <tt>\namedNSparameter</tt> and <tt>\detokenizedNSparameter</tt>.<br />
The <tt>\defineNS[command][..,..=..,..]</tt> can be used to create instances of a generic macro with local setups. Works like ordinary Context <tt>\definesomething</tt> commands and allows for inheritance (<tt>\defineNS[command][othercommand]</tt>). Of course, if <tt>command</tt> is set to ''list'', the first argument of <tt>\defineNS</tt> will take comma separated values.<br />
|-<br />
|<tt>comment</tt> || ''string'': meta-information, see [[#Related Commands|related commands]] below.<br />
|-<br />
|<tt>version</tt> || ''number'': meta-information, see [[#Related Commands|related commands]].<br />
|-<br />
|<tt>style</tt> || ''boolean'': enables special handling for text color and style attributes.<br />
If set to ''yes'', a macro <tt>\dosetNSattributes</tt> will be created. It receives the values for the <tt>style</tt> and <tt>color</tt> arguments as supplied to the <tt>\setupNS</tt> macro which itself gets created via the <tt>setup</tt> key (see above).<br />
|+ Optional settings for module namespaces.<br />
|}<br />
<br />
=Related Commands=<br />
==<tt>\listnamespaces</tt>==<br />
Prints all namespaces defined in tabular form along <br />
with additional information. Example:<br />
<br />
<texcode><br />
\definenamespace[Newns][<br />
name=Newns,<br />
type=module,<br />
setup=list,<br />
parent=NS,<br />
style=yes,<br />
version=3.141,<br />
comment=this space has been named,<br />
]<br />
<br />
\starttext<br />
\listnamespaces<br />
\stoptext<br />
</texcode><br />
<br />
=Further Information=<br />
* [[source:mult-aux.mkiv|Definition of <tt>\definenamespace</tt>]].<br />
* [[System Macros]].<br />
* Some of the functionality was explained by Wolfgang Schuster on the [http://archive.contextgarden.net/message/20101117.215320.314eb367.en.html Context list]</div>Wolfgang Schusterhttps://wiki.contextgarden.net/index.php?title=Module_Namespaces&diff=12684Module Namespaces2010-12-30T19:19:04Z<p>Wolfgang Schuster: List of Module Namespaces: Added algorithmic, annotation, fullpage and ruby modules.</p>
<hr />
<div>=List of Module Namespaces=<br />
{{todo|This list is under construction and will eventually contain all namespaces used in context modules.}}<br />
<br />
To avoid clashes with existing and future commands, any module<br />
should adhere to the following rules:<br />
<br />
* Namespace identifiers (their <tt>name</tt> parameter) should have more than two characters (at least yours [http://article.gmane.org/gmane.comp.tex.context/61939]),<br />
<br />
* the namespace should be registered here for others to know.<br />
<br />
{|cellpadding="10" style="border:2px solid #addeff"<br />
! style="background:#addeff;" | Namespace !! Name<br />
! style="background:#addeff;" | Main file !! Description<br />
|-<br />
| <tt>algorithmic</tt><br />
| algorithmic<br />
| [https://bitbucket.org/wolfs/algorithmic t-algorithmic]<br />
| Write algorithms.<br />
|-<br />
| <tt>annotation</tt><br />
| annotation<br />
| [https://bitbucket.org/wolfs/annotation t-annotation]<br />
| Annotate text blocks.<br />
|-<br />
| <tt>fancybreak</tt><br />
| fancybreak<br />
| [https://bitbucket.org/wolfs/fancybreak t-fancybreak]<br />
| Inserting thought breaks (transitions).<br />
|-<br />
| <tt>fullpage</tt><br />
| fullpage<br />
| [https://bitbucket.org/wolfs/fullpage t-fullpage]<br />
| Set equal margin without \setuplayout.<br />
|-<br />
| <tt>rb</tt><br />
| ruby<br />
| [https://bitbucket.org/wolfs/ruby t-ruby]<br />
| Highlight text with ruby markup.<br />
|-<br />
|<tt>TRL</tt><br />
| transliterate<br />
| [https://bitbucket.org/phg/transliterator t-transliterator]<br />
| Transliteration from non-Latin scripts.<br />
|- <br />
| <tt>visualcounter</tt><br />
| visualcounter || [http://github.com/adityam/visualcounter t-visualcounter] || Display counters using a graphic<br />
|+ style="font-style:italic; font-size:83.3333%;" | Reserved module namespaces.<br />
|}<br />
<br />
=Generating a Namespace for Your Module=<br />
<br />
Context provides the user command [[cmd:definenamespace|\definenamespace]] <br />
that generates a valid namespace for variables and takes care<br />
of defining a setup command as well.<br />
Suppose you have a module called ''My Module'' (preferably in <br />
a file <tt>t-mymodule.mkiv</tt>) and want to reserve the<br />
namespace ''mymod''.<br />
The following snippet will get you a setup command<br />
<tt>\setupMyMod</tt>.<br />
<br />
<texcode><br />
\definenamespace[mymod] [<br />
type=module,<br />
name=MyMod,<br />
setup=list,<br />
]<br />
</texcode><br />
<br />
Through <tt>\setupMyMod</tt> you can now set the variables <br />
that you are planning to use in your module &ndash;<br />
it is already a mature command that conforms to the overall<br />
context style and can take a parameter list, a list of<br />
key-value pairs or both as arguments.<br />
Any parameter defined that way can now be retrieved via<br />
another command that got auto-generated, <tt>\MyModparameter</tt>.<br />
<br />
<texcode><br />
% setting a parameter within the namespace<br />
\setupMyMod[<br />
yamp=Yet another module parameter,<br />
]<br />
<br />
% command sequence that does something with the parameter<br />
\def\blueparameter{\setupcolors[state=start]\colored[blue]\MyModparameter{yamp}}<br />
<br />
% deploying the new user command<br />
\starttext<br />
\blueparameter<br />
\stoptext<br />
</texcode><br />
<br />
Wondering why your namespace, albeit defined as <tt>mymod</tt><br />
initially, is always referred to as ''MyMod'', i.e. the value<br />
of the parameter <tt>name</tt> as given in the definition?<br />
Internally the namespaces are represented as ordinary command<br />
sequences with a prefix.<br />
This prefix is composed from first the usual four<br />
[[System_Macros/Fundamentals#Protecting_internal_macros|''@''-signs]],<br />
second the namespace identifier, and third the key id from the<br />
argument list.<br />
In the example this results in a macro <tt>\@@@@</tt> + <br />
<tt>mymod</tt> + <tt>yamp</tt>.<br />
Thus, <tt>\MyModparameter{yamp}</tt> would be equivalent to<br />
calling:<br />
<br />
<texcode><br />
\unprotect<br />
\@@@@mymodyamp<br />
\protect<br />
</texcode><br />
<br />
=Namespace Configuration=<br />
<tt>\definenamespace</tt> accepts a number of options that<br />
determine what commands will be available.<br />
At the time of this writing (2010-09-27), this is rather<br />
new stuff and so far not guaranteed to stay in context<br />
unmodified.<br />
<br />
{|cellpadding="10" style="border:2px solid #addeff" rules="rows"<br />
! style="background:#addeff;" | Option !! Parameters and their description (''NS'' is a namespace dummy)<br />
|-<br />
|<tt>name</tt> || ''string'': The identifier that will be used to reference setups and parameters; e.&nbsp;g. a value of ''NS'' causes the macros <tt>\defineNS</tt> and <tt>\setupNS</tt> to be created.<br />
|-<br />
|<tt>parent</tt> || ''string'': a namespace identifier. Should be the same as the identifier of the module’s namespace.<br />
|-<br />
|<tt>type</tt> || <tt>module</tt>: creates the namespace prefixed with quadruple ''@''; other values are planned to be added in the future for internal purposes.<br />
|-<br />
|<tt>setup</tt> || <tt>list</tt> or ''boolean'': initiates the creation of a setup according to the <tt>name</tt> argument, e.&nbsp;g. <tt>\setupNS</tt>. The specified value influences the behaviour of the setup:<br />
{|<br />
|<tt>yes</tt> || first argument of the setup accepts one parameter (<tt>\setupNS[one][..,..=..,..]</tt>);<br />
|-<br />
|<tt>list</tt> || first argument of the setup accepts a comma separated list (<tt>\setupNS[one,two,three][..,..=..,..]</tt>).<br />
|}<br />
|-<br />
|align="right" | <tt>command</tt><br />
|<tt>list</tt> or ''boolean'': creates auxiliary macros and the proper command to define further commands within the new namespace (<tt>\defineNS</tt>).<br />
For a <tt>name</tt> parameter ''NS'', the values of the <tt>\setupNS</tt> command will be retrievable via <tt>\NSparameter{parametername}</tt>. Additionally, access is provided by <tt>\namedNSparameter</tt> and <tt>\detokenizedNSparameter</tt>.<br />
The <tt>\defineNS[command][..,..=..,..]</tt> can be used to create instances of a generic macro with local setups. Works like ordinary Context <tt>\definesomething</tt> commands and allows for inheritance (<tt>\defineNS[command][othercommand]</tt>). Of course, if <tt>command</tt> is set to ''list'', the first argument of <tt>\defineNS</tt> will take comma separated values.<br />
|-<br />
|<tt>comment</tt> || ''string'': meta-information, see [[#Related Commands|related commands]] below.<br />
|-<br />
|<tt>version</tt> || ''number'': meta-information, see [[#Related Commands|related commands]].<br />
|-<br />
|<tt>style</tt> || ''boolean'': enables special handling for text color and style attributes.<br />
If set to ''yes'', a macro <tt>\dosetNSattributes</tt> will be created. It receives the values for the <tt>style</tt> and <tt>color</tt> arguments as supplied to the <tt>\setupNS</tt> macro which itself gets created via the <tt>setup</tt> key (see above).<br />
|+ Optional settings for module namespaces.<br />
|}<br />
<br />
=Related Commands=<br />
==<tt>\listnamespaces</tt>==<br />
Prints all namespaces defined in tabular form along <br />
with additional information. Example:<br />
<br />
<texcode><br />
\definenamespace[Newns][<br />
name=Newns,<br />
type=module,<br />
setup=list,<br />
parent=NS,<br />
style=yes,<br />
version=3.141,<br />
comment=this space has been named,<br />
]<br />
<br />
\starttext<br />
\listnamespaces<br />
\stoptext<br />
</texcode><br />
<br />
=Further Information=<br />
* [[source:mult-aux.mkiv|Definition of <tt>\definenamespace</tt>]].<br />
* [[System Macros]].<br />
* Some of the functionality was explained by Wolfgang Schuster on the [http://archive.contextgarden.net/message/20101117.215320.314eb367.en.html Context list]</div>Wolfgang Schusterhttps://wiki.contextgarden.net/index.php?title=Protrusion&diff=11620Protrusion2010-05-02T09:01:18Z<p>Wolfgang Schuster: MkIV example now, explanation later</p>
<hr />
<div>< [[Fonts]]<br />
<br />
Character protrusion is a somewhat subtle advanced typographic effect in which some characters (often punctuation) are moved partially or fully into the margin in order to give it an optically smoother appearance. In ConTeXt, this is achieved via the font mechanisms within pdfTeX. Much of the difficult work is done in some presets by Hans, but there are a few tricks needed in order to activate the feature.<br />
<br />
This feature is also commonly called "Handling" after the font handling feature that enables it, and "Hanging" after what hyphens do into the margin. The microtype LaTeX package also includes a protrusion feature, and may be known by that name to a certain audience.<br />
<br />
Font handling is documented in the [[article:89|Fonts in ConTeXt]] manual.<br />
<br />
== Demo ==<br />
The simplest way to illustrate it is with a quick demo:<br />
<br />
<texcode><br />
\usetypescript[postscript][ec]<br />
\usetypescript[adobekb][ec]<br />
\usetypescript[serif][hanging][normal] % this creates the 'handling' synonyms<br />
\setupalign[hanging] % this actually triggers the feature<br />
</texcode><br />
<br />
The first two lines switch the font (see below for Latin Modern), and the second two lines actually activate the feature. <br />
<br />
<texcode><br />
\setupbodyfont[postscript]<br />
\starttext<br />
\input tufte <br />
\stoptext<br />
</texcode><br />
<br />
Switch the font that we setup, and show an example with lots of punctuation. The illustration has '''normal''' hanging enabled:<br />
<br />
<context><br />
\usetypescript[postscript][ec]<br />
\usetypescript[adobekb][ec]<br />
\usetypescript[serif][hanging][normal] % this creates the 'handling' synonyms<br />
\setupalign[hanging] % this actually triggers the feature<br />
\setuptolerance[tolerant]<br />
\setupbodyfont[postscript]<br />
\setupcolors[state=start]<br />
\starttext<br />
\startframedtext[width=270pt,rightframe=on,frame=off,align=hanging,offset=none,framecolor=middlegray]<br />
\input tufte <br />
\stopframedtext<br />
\stoptext<br />
</context><br />
<br />
== Details ==<br />
<br />
The [[cmd:usetypescript|\usetypescript]] command has three arguments. The definitions that we use are in [[source:type-exa.tex| type-exa.tex]], and reference the low-level definitions in [[source:hand-def.tex| hand-def.tex]]. There are different possible values for each argument, which, by convention, are:<br />
\usetypescript [''family''] [''trigger''] [''type'']<br />
{| border="1" cellspacing="0"<br />
| ''family''<br />
| colspan="2" | '''serif''', '''sans''', and/or '''mono'''<br />
|-<br />
| ''trigger''<br />
| colspan="2" | '''handling''' or '''hanging''' for protrusion; '''handling''' or '''hz''' for font expansion<br />
|-<br />
| rowspan="5" | ''type''<br />
| '''pure''' <br />
| full protrusion of only selected punctuation<br />
|-<br />
| '''normal'''<br />
| partial protrusion of punctuation and some asymmetrical letters<br />
|-<br />
| '''hz'''<br />
| variable correction of character widths<br />
|-<br />
| '''quality'''<br />
| combination of '''hz''' and '''pure'''<br />
|-<br />
| '''highquality'''<br />
| combination of '''hz''' and '''normal'''<br />
|}<br />
<br />
== Use with Latin Modern ==<br />
Because ConTeXt pre-loads its default Latin Modern font, it is a little tricky to get it to work right. Here is one solution, where you setup the hanging, load an alternative latin-modern typescript, and then reset the defaults:<br />
<br />
<texcode><br />
\usetypescript[serif,sans,mono][hanging][pure]<br />
\setupalign[hanging] <br />
\usetypescript[modern-base][texnansi] % a simplified latin-modern typescript<br />
\setupbodyfont[reset]<br />
\setupbodyfont[modern]<br />
</texcode><br />
<br />
The illustration has '''pure''' hanging enabled:<br />
<br />
<context><br />
\usetypescript[serif][hanging][pure] % this creates the 'handling' synonyms<br />
\setupalign[hanging] % this actually triggers the feature<br />
\usetypescript[modern-base][texnansi]<br />
\setupbodyfont[reset]<br />
\setupbodyfont[modern]<br />
\setupcolors[state=start]<br />
\starttext<br />
\startframedtext[width=270pt,rightframe=on,frame=off,align=hanging,offset=none,framecolor=middlegray]<br />
\input tufte <br />
\stopframedtext<br />
\stoptext<br />
</context><br />
<br />
==Hz adjustments==<br />
For more radical effects, where you need to fit to a fixed, narrow measure, you can enable Hz-style font adjustments, wherein individual characters are adjusted by miniscule amounts as necessary. These are enabled by the '''hz''', '''quality''', and '''highquality''' options listed above. Usage is with such lines as:<br />
<br />
<texcode><br />
\usetypescript[serif][hz][quality] % this creates the 'handling' synonyms<br />
\setupalign[hanging,hz] % this turns on the hanging and hz features<br />
</texcode><br />
<br />
The example shows how slight font expansion improves the fitting to the margin without changing the tolerance on the inter-word spacing. The left passage is with ''hanging'' alone enabled, and the right is with ''hanging'' and ''hz'' both enabled. It's not for everyone, as the process can distort letter shapes.<br />
<br />
<br />
<context><br />
\usetypescript[postscript][ec]<br />
\usetypescript[adobekb][ec]<br />
\setupfonthandling[hz][min=30,max=30,step=10]<br />
\usetypescript[serif][hz][quality] % this creates the 'handling' synonyms<br />
\setupalign[hanging] % this actually triggers the feature<br />
\setupbodyfont[postscript]<br />
\setupcolors[state=start]<br />
\setupframedtexts[width=4.6cm,rightframe=on,frame=off,offset=none,framecolor=middlegray,tolerance=verystrict]<br />
\starttext<br />
\startcombination[2*1]<br />
{\startframedtext[none][align=hanging]<br />
\input ward <br />
\stopframedtext}{\it hanging alone}<br />
{\startframedtext[none][align={hanging,hz}]<br />
\input ward <br />
\stopframedtext}{\it hanging + hz}<br />
\stopcombination<br />
\stoptext<br />
</context><br />
<br />
== MkIV ==<br />
<br />
<texcode><br />
\definefontfeature[default][default][expansion=quality,protrusion=quality]<br />
<br />
\usetypescript[modern-base]<br />
\setupbodyfont[reset,modern]<br />
<br />
\setupalign[hz,hanging]<br />
<br />
\showframe<br />
<br />
\starttext<br />
\input tufte<br />
\stoptext<br />
</texcode></div>Wolfgang Schusterhttps://wiki.contextgarden.net/index.php?title=Shaped_paragraphs&diff=10395Shaped paragraphs2010-04-05T18:17:33Z<p>Wolfgang Schuster: Indentnext</p>
<hr />
<div>< [[Visuals]] |<br />
<br />
=== Paragraphs with hanging indention ===<br />
If you want to indent paragraphs from the second line on, you can use this bit from Hans Hagen:<br />
<br />
<texcode><br />
\starttext<br />
<br />
\definestartstop<br />
[exdent]<br />
[before={\startnarrower[left]\setupindenting[-\leftskip,yes]},<br />
after=\stopnarrower]<br />
<br />
\setuphead[section][indentnext=yes]<br />
\section{Test}<br />
\startexdent<br />
\input knuth \endgraf<br />
\stopexdent<br />
<br />
\stoptext<br />
</texcode><br />
<br />
<context><br />
\starttext<br />
\setuplayout[scale=0.8,width=13cm]<br />
\definestartstop<br />
[exdent]<br />
[before={\startnarrower[left]\setupindenting[-\leftskip,yes]},<br />
after=\stopnarrower]<br />
<br />
\setuphead[section][indentnext=first]<br />
\section{Test}<br />
\startexdent<br />
\input knuth \endgraf<br />
\stopexdent<br />
<br />
\stoptext<br />
</context></div>Wolfgang Schusterhttps://wiki.contextgarden.net/index.php?title=Titles&diff=10081Titles2009-10-17T16:44:50Z<p>Wolfgang Schuster: Pixar header needs deeptextcommand</p>
<hr />
<div>< [[Structurals]] | [[Visuals]] ><br />
<br />
==Default==<br />
<br />
Titles define the structure of your document. Decide yourself, how deep you want to nest them:<br />
<br />
<table><br />
<tr bgcolor="#CCCCCC"><br />
<th>numbered</th><br />
<th>unnumbered</th><br />
</tr><br />
<tr><br />
<td><cmd>part</cmd><br />
</td><td>&#151;</td><br />
</tr><br />
<tr><br />
<td><cmd>chapter</cmd></td><br />
<td><cmd>title</cmd></td><br />
</tr><br />
<tr><br />
<td><cmd>section</cmd></td><br />
<td><cmd>subject</cmd></td><br />
</tr><br />
<tr><br />
<td><cmd>subsection</cmd></td><br />
<td><cmd>subsubject</cmd></td><br />
</tr><br />
<tr><br />
<td><cmd>subsubsection</cmd></td><br />
<td><cmd>subsubsubject</cmd></td><br />
</tr><br />
<tr><br />
<td>...</td><br />
<td>...</td><br />
</tr><br />
</table><br />
<br />
The ''unnumbered'' versions don't appear in a table of contents! But you can<br />
switch off the numbering of the ''numbered'' versions with <cmd>setuphead</cmd><br />
to get unnumbered titles ''and'' a toc (confusing?).<br />
<br />
Also note that in the front matter of the document, all titles are unnumbered<br />
by default. In this case, the only difference between the "numbered" and<br />
"unnumbered" titles is that the latter don't show up in the table of contents.<br />
<br />
===Referencing Titles===<br />
<br />
Every heading command can take an optional parameter as reference:<br />
<br />
<texcode><br />
\title[hasselt-by-night]{Hasselt by night}<br />
</texcode><br />
<br />
The bracket pair is optional and used for internal [[References]]. If you want<br />
to refer to this header you type for example<br />
<br />
<texcode><br />
\at{page}[hasselt-by-night].<br />
<br />
(see <cmd>at</cmd>)<br />
</texcode><br />
<br />
==Titling Style==<br />
<br />
see <cmd>setuphead</cmd> and some enhanced samples below.<br />
<br />
A FAQ is how to get a line under the title:<br />
<br />
<texcode><br />
\setupbackgrounds[header][text][bottomframe=on]<br />
</texcode><br />
<br />
To make the section numbers appear as characters, do<br />
<br />
<texcode><br />
\setupsection[section-3][bodypartconversion=Character]<br />
</texcode><br />
<br />
The <code>section-3</code> corresponds to <code>section</code>. Similarly,<br />
<code>section-1</code> corresponds to <code>part</code>, <code>section-2</code><br />
corresponds to <code>chapter</code> and so on.<br />
<br />
==Titling Alignment==<br />
<br />
Titles should often be left aligned without hyphenation. Try this:<br />
<br />
<texcode><br />
\setuphead[chapter][align={flushleft, nothyphenated, verytolerant}] % "flushleft" is the same as "right"<br />
</texcode><br />
<br />
==Using colors in chapters and sections==<br />
<br />
If you want you may have colors on your document's chapters or sections.<br />
To do that you should use <cmd>setuphead</cmd>. Take a look at the following<br />
example:<br />
<br />
<texcode><br />
\setupcolors[state=start] % Important. You won't have colors without it.<br />
<br />
\setuphead[chapter][header=empty] % Chapter pages won't have headers<br />
<br />
\setupheadertexts[][chapter] % The header will be the chapter's name<br />
<br />
\starttext<br />
<br />
\completecontent<br />
<br />
\chapter{Black chapter 1}<br />
<br />
\setuphead[section][color=darkcyan] % This is how you change your chapter's color.<br />
<br />
\section{Dark cyan section 1.1}<br />
<br />
\page<br />
Test.<br />
<br />
\setuphead[chapter][color=darkgreen]<br />
<br />
\chapter{Dark green chapter}<br />
<br />
\page<br />
Test.<br />
<br />
\setuphead[chapter][color=red]<br />
<br />
\chapter{Red chapter}<br />
<br />
\page<br />
Test.<br />
<br />
\stoptext <br />
</texcode><br />
<br />
==Your Own Titling Levels==<br />
<br />
Of course you can define your own titling commands and probably must adapt the default settings.<br />
<br />
<texcode><br />
\definehead[myheader][section]<br />
<br />
\setuphead<br />
[myheader]<br />
[numberstyle=bold,<br />
textstyle=cap,<br />
before=\hairline\blank,<br />
after=\nowhitespace\hairline]<br />
<br />
\myheader[hasselt-ref]{Hasselt makes headlines}<br />
</texcode><br />
<br />
A new header <cmd>myheader</cmd> is defined and it inherits the properties<br />
of <cmd>section</cmd> (title, subject, whatever). You can ''define'' several<br />
headers at once!<br />
<br />
==Formatting Titles with <cmd>setuphead</cmd>==<br />
<br />
<cmd>setuphead</cmd> accepts a number of parameters which change the style of<br />
the heading. At least the following commands are available:<br />
<br />
<table><br />
<tr bgcolor="#CCCCCC"><br />
<th>text</th><br />
<th>number</th><br />
</tr><br />
<tr><br />
<td><tt>textstyle</tt></td><br />
<td><tt>numberstyle</tt></td><br />
</tr><br />
<tr><br />
<td><tt>textcommand</tt></td><br />
<td><tt>numbercommand</tt></td><br />
</tr><br />
<tr><br />
<td><tt>deeptextcommand</tt></td><br />
<td><tt>deepnumbercommand</tt></td><br />
</tr><br />
</table><br />
<br />
Quite obviously, the number-commands work on the chapter/section/etc. number,<br />
their text counterparts change the text itself. However, there are differences<br />
between <tt>style</tt>, <tt>command</tt> and <tt>deepcommand</tt>.<br />
<br />
The <tt>style</tt> variants accept a style (<tt>bold</tt>, <tt>cap</tt>, etc.)<br />
or a font switch (<cmd>em</cmd>, <cmd>tfx</cmd>, etc). <tt>texstyle</tt> prepends<br />
the text with the associated style. <tt>textcommand</tt> is a command name which<br />
is given the text (with all markup) as a parameter. <tt>deeptextcommand</tt> is<br />
similar to <tt>textcommand</tt> but it acts only on the text (not on the markup).<br />
<br />
So, if we have <cmd>title{A story}</cmd>, the different parameters have the following results:<br />
<br />
<table><br />
<tr><br />
<td><tt>textstyle=\em</tt></td><br />
<td><tt>=></tt></td><br />
<td><tt>\em A story</tt></td><br />
</tr><br />
<tr><br />
<td><tt>textstyle=\em, textcommand=\uppercase</tt></td><br />
<td><tt>=></tt></td><br />
<td><tt>\uppercase{\em A story}</tt></td><br />
<td><tt>=></tt></td><br />
<td><tt>\em A STORY</tt></td><br />
</tr><br />
<tr><br />
<td><tt>textstyle=\em, deeptextcommand=\uppercase</tt></td><br />
<td><tt>=></tt></td><br />
<td><tt>\em\uppercase{A story}</tt></td><br />
<td><tt>=></tt><br />
</td><td><tt>\em A STORY</tt></td><br />
</tr><br />
</table><br />
<br />
What is the difference between <tt>textcommand</tt> and <tt>deeptextcommand</tt>,<br />
then? With this example there is very little difference, as <tt>uppercase</tt><br />
knows how to handle markup. Sometimes this is not the case. For example, an almost<br />
similar command <tt>WORD</tt> is not compatible with <tt>textcommand</tt>, because<br />
it wreaks havoc with markup:<br />
<br />
<table><br />
<tr><br />
<td><tt>textstyle=\em, textcommand=\WORD</tt></td><br />
<td><tt>=></tt></td><br />
<td><tt>\WORD{\em A story}</tt></td><br />
<td><tt>=></tt></td><br />
<td><tt>\EM A STORY</tt></td><br />
</tr><br />
<tr><br />
<td><tt>textstyle=\em, deeptextcommand=\WORD</tt></td><br />
<td><tt>=></tt></td><br />
<td><tt>\em\WORD{A story}</tt></td><br />
<td><tt>=></tt></td><br />
<td><tt>\em A STORY</tt></td><br />
</tr><br />
</table><br />
<br />
In this case using <tt>deeptextcommand</tt> is the correct solution for capitalizing<br />
headers. (Using <cmd>uppercase</cmd> works in this specific case, but only if you stick<br />
to Latin 1 or Anglo-Saxon characters. Other languages will suffer from lowercase accented<br />
characters, like CAFé.)<br />
<br />
=== Truly empty pagebreak before chapters ===<br />
<br />
Using <cmd>setuppagenumbering[alternative=doublesided]</cmd> makes the chapters start<br />
on the right page. However, the blank page is not truely empty, it contains headers and<br />
footers. To get truely empty pages, use the following<br />
<br />
<texcode><br />
\definepagebreak<br />
[mychapterpagebreak]<br />
[yes,header,right]<br />
%[yes,header,left]<br />
%[yes,header,footer,right]<br />
<br />
\setuphead<br />
[chapter]<br />
[page=mychapterpagebreak]<br />
%[page=Mychapterpagebreak,header=empty,footer=empty]<br />
<br />
%\setupsectionblock[frontpart][page=chapter]<br />
%\setupsectionblock[bodypart][page=chapter]<br />
%\setupsectionblock[backpart][page=chapter]<br />
%\setupsectionblock[appendix][page=chapter]<br />
<br />
\setuppagenumbering[alternative=doublesided,location={header,margin}]<br />
\setupheadertexts[{My special headertext}]<br />
\setupfootertexts[This is a text in the footer]<br />
%\setupbackgrounds[header][text][bottomframe=on]<br />
<br />
\starttext<br />
\chapter{testA} \dorecurse{10}{\input tufte }<br />
\chapter{testB} \dorecurse{10}{\input tufte }<br />
\chapter{testC} \dorecurse{10}{\input tufte }<br />
\stoptext<br />
</texcode><br />
<br />
Explaination (provided by Willi Egger on the mailing list)<br />
<br />
* You define a new pagebreak rule. It has the name <code>mychapterpagebreak</code>. The options set read as: <code>pagebreak=yes</code>, placeheader, use a right page.<br />
* You set options for the header of type chapter and use for the option page the before defined new pagebreak.<br />
* You might want to experiment with the commented lines and see what happens. For example, the <code>\setupsectionblock</code> commands will give a truly blank page (if needed) after the specified \stop*part command.<br />
<br />
== Independent Section Numbering ==<br />
<br />
If you want section numbering to be independent of chapter numbering, use<br />
<br />
<texcode><br />
\setuphead [chapter][resetnumber=no]<br />
\setupsection[section][previousnumber=no]<br />
</texcode><br />
<br />
==Unnumbered titles in table of contents==<br />
<br />
Some times one wants an unnumbered chapter, say introduction, the following might do that trick:<br />
<br />
<texcode><br />
\definehead [intro] [chapter]<br />
\setuphead [intro] [number=no]<br />
\definecombinedlist [content][intro,chapter,section]<br />
\setuplist [intro] [headnumber=no]<br />
<br />
\starttext<br />
\completecontent<br />
\startfrontmatter<br />
\intro{No number}<br />
\stopfrontmatter<br />
<br />
\startbodymatter<br />
\chapter{Has number}<br />
\stopbodymatter<br />
\stoptext<br />
</texcode><br />
<br />
<context><br />
\definehead [intro] [chapter]<br />
\setuphead [intro] [number=no]<br />
<br />
\definecombinedlist [content][intro,chapter,section]<br />
\setuplist [intro] [headnumber=no]<br />
<br />
\starttext<br />
\completecontent<br />
\startfrontmatter<br />
\intro{No number}<br />
\stopfrontmatter<br />
<br />
\startbodymatter<br />
\chapter{Has number}<br />
\stopbodymatter<br />
\stoptext<br />
</context><br />
<br />
<br />
<br />
==Your Own Title Styles==<br />
<br />
Sometimes the possibilities of <cmd>setuphead</cmd> aren't enough. You can define<br />
your own styling commands, as shown in the following examples.<br />
<br />
===Expanded chapter titles===<br />
<br />
This example illustrates expanded chapter titles.<br />
<br />
<texcode><br />
\def\MyChapterCommand#1#2% #1 is number, #2 is text<br />
{\framed[frame=off,bottomframe=on,topframe=on]<br />
{\vbox{\headtext{chapter} #1\blank#2}}} % \vbox is needed for \blank to work<br />
<br />
\setuphead[chapter][command=\MyChapterCommand, style={\ss\bfa}]<br />
<br />
\setupheadtext[chapter=Chapter] % used by \headtext<br />
</texcode><br />
<br />
so <tt>\chapter{My First Chapter}</tt> looks like:<br />
<br />
<context><br />
\def\MyChapterCommand#1#2%<br />
{\framed[frame=off,bottomframe=on,topframe=on]<br />
{\vbox{\headtext{chapter} #1\blank#2}}}<br />
<br />
\setuphead[chapter][command=\MyChapterCommand, style={\ss\bfa}]<br />
\setupheadtext[chapter=Chapter]<br />
<br />
\chapter{My First Chapter}<br />
</context><br />
<br />
===Exercise numbers===<br />
<br />
For a textbook, suppose that you collect the exercises in a section at the end<br />
of each chapter, with each exercise a subsection having a short title, and the<br />
exercises should be numbered only by the subsection (not 1.6.7 for example,<br />
just 7). The usage:<br />
<br />
<texcode><br />
\section{Exercises}<br />
<br />
\exercise{Batteries}<br />
What is the cost of energy from a 9V battery? From a wall socket (the mains)?<br />
</texcode><br />
<br />
The setup code:<br />
<texcode><br />
\definehead[exercise][subsection]<br />
<br />
\setuphead<br />
[exercise]<br />
[style=italic, <br />
numbercommand={\determineheadnumber[subsection]\currentheadnumber\gobbleoneargument}]<br />
</texcode><br />
<br />
===A complex graphical element under the chapter title===<br />
<br />
<texcode><br />
\setupcolors[state=start]<br />
\startuseMPgraphic{HeaderDeco}<br />
numeric w, h, repeats;<br />
path p[];<br />
w := OverlayWidth ; h := OverlayHeight ;<br />
repeats := abs(TextWidth/BodyFontSize);<br />
p[1] := unitsquare xscaled w yscaled h ;<br />
draw p[1] withcolor white;<br />
p[2] := fullcircle scaled BodyFontSize;<br />
p[3] := fullcircle scaled .25BodyFontSize;<br />
draw p[2] shifted (.5BodyFontSize,0);<br />
for i = 1 upto repeats:<br />
if odd i :<br />
filldraw p[3] shifted (i*BodyFontSize+.5BodyFontSize,0);<br />
else :<br />
draw p[2] shifted (i*BodyFontSize+.5BodyFontSize,0);<br />
fi;<br />
endfor;<br />
\stopuseMPgraphic<br />
<br />
\setuphead[chapter][command=\Myheader]<br />
\setupheadtext[chapter=Chapitre]<br />
\defineoverlay[HeaderDeco][\uniqueMPgraphic{HeaderDeco}]<br />
<br />
\def\Myheader#1#2{%<br />
\framedtext<br />
[width= \overlaywidth,<br />
height=6\bodyfontsize,<br />
background={foreground,HeaderDeco},<br />
offset=0pt,<br />
strut=no,<br />
frame=off,<br />
align=middle]{%<br />
\headtext{chapter} #1<br />
\blank[small]<br />
#2}}<br />
<br />
\starttext<br />
\chapter{Here we go!}<br />
\stoptext<br />
</texcode><br />
<br />
It looks like:<br />
<br />
<context><br />
\setupcolors[state=start]<br />
\startuseMPgraphic{HeaderDeco}<br />
numeric w, h, repeats;<br />
path p[];<br />
w := OverlayWidth ; h := OverlayHeight ;<br />
repeats := abs(TextWidth/BodyFontSize);<br />
p[1] := unitsquare xscaled w yscaled h ;<br />
draw p[1] withcolor white;<br />
p[2] := fullcircle scaled BodyFontSize;<br />
p[3] := fullcircle scaled .25BodyFontSize;<br />
draw p[2] shifted (.5BodyFontSize,0);<br />
for i = 1 upto repeats:<br />
if odd i :<br />
filldraw p[3] shifted (i*BodyFontSize+.5BodyFontSize,0);<br />
else :<br />
draw p[2] shifted (i*BodyFontSize+.5BodyFontSize,0);<br />
fi;<br />
endfor;<br />
\stopuseMPgraphic<br />
<br />
\setuphead[chapter][command=\Myheader]<br />
\setupheadtext<br />
[chapter=Chapitre]<br />
\defineoverlay[HeaderDeco][\uniqueMPgraphic{HeaderDeco}]<br />
<br />
\def\Myheader#1#2{%<br />
\framedtext<br />
[width= \overlaywidth,<br />
height=6\bodyfontsize,<br />
background={foreground,HeaderDeco},<br />
offset=0pt,<br />
strut=no,<br />
frame=off,<br />
align=middle]{%<br />
\headtext{chapter} #1<br />
\blank[small]<br />
#2}}<br />
<br />
\starttext<br />
\chapter{Here we go!}<br />
\stoptext<br />
</context><br />
<br />
===Titles in margin===<br />
<br />
It is sometimes wanted to place the title of a section/subject etc in the margin next to the section text (instead of above it).<br />
This is achieved by the following setup:<br />
<br />
<texcode><br />
\setuphead<br />
[subject]<br />
[alternative=text,distance=0pt,command=\MyHead]<br />
<br />
\def\MyHead#1#2{\inmargin{#1 #2}}<br />
</texcode><br />
<br />
This (with 'style=\sc' added in setuphead) gives:<br />
<br />
<context><br />
\setuphead<br />
[subject]<br />
[alternative=text,distance=0pt,command=\MyHead,style=\sc]<br />
<br />
\def\MyHead#1#2{\inmargin{#1 #2}}<br />
<br />
\starttext<br />
<br />
\subject{First Subject}<br />
This is the text in the first subject. This is the text in the first subject.<br />
This is the text in the first subject. This is the text in the first subject.<br />
This is the text in the first subject. This is the text in the first subject.<br />
This is the text in the first subject. This is the text in the first subject.<br />
<br />
\subject{Second Subject}<br />
This is the text in the second subject. This is the text in the second subject.<br />
This is the text in the second subject. This is the text in the second subject. <br />
This is the text in the second subject. This is the text in the second subject. <br />
This is the text in the second subject. This is the text in the second subject. <br />
<br />
\stoptext<br />
</context><br />
<br />
See the mailing list thread [[http://www.ntg.nl/pipermail/ntg-context/2003/002053.html]] for more on this.<br />
<br />
===Headings numbered independent of chapters or other headings===<br />
<br />
If you want a heading that gets numbered without resetting at new sections or chapters (for example, for problems whose numbers increment throughout a book), here is a solution due to Hans [http://archive.contextgarden.net/message/20030415.153451.374310d8.en.html on the mailing list]:<br />
<br />
<texcode><br />
% use a lower level head<br />
<br />
\definehead<br />
[Problem]<br />
[subsubsubsection]<br />
<br />
% cleaned up<br />
<br />
\setuphead<br />
[Problem]<br />
[style=\ss\bf,<br />
color=red,<br />
before=\blank]<br />
<br />
% use a label text<br />
<br />
\setuplabeltext<br />
[Problem=Problem ]<br />
<br />
% use your own numbers<br />
<br />
\setuphead<br />
[Problem]<br />
[ownnumber=yes]<br />
<br />
% increment and feed<br />
<br />
\newcounter\ProblemNumber<br />
<br />
\def\problem#1%<br />
{\doglobal\increment\ProblemNumber<br />
\Problem{\ProblemNumber}{#1}}<br />
<br />
% nicer here<br />
<br />
\setuplist<br />
[Problem]<br />
[alternative=c,<br />
criterium=all,<br />
width=2em,<br />
interaction=all]<br />
<br />
% the test<br />
<br />
\starttext<br />
<br />
List of Problems<br />
<br />
\blank[big] \placelist[Problem] \blank[big]<br />
<br />
\section{Tufte}<br />
<br />
\input tufte<br />
<br />
\problem{First problem}<br />
<br />
The first problem description.<br />
<br />
\section{Another Tufte}<br />
<br />
\input tufte<br />
<br />
\problem{Second problem}<br />
<br />
Second problem description.<br />
<br />
\stoptext<br />
</texcode><br />
<br />
===Chapter headers===<br />
<br />
Setup of headers like chapters.<br />
<br />
While reading Pixar docs about Renderman, I've found their headers nice and wanted to copy this style.<br />
I found a premise in Metafun manual, p.187 (Hello text), and Hans email me ([http://archive.contextgarden.net/message/20041020.100630.d531bb1d.en.html 20/10/2004 ]) on the context list a more simple solution than using metapost. The minimum is to put it here, for others who are like me, wandering for source code.<br />
Feel free to adapt code below to your langage specific settings, mine is french.<br />
<br />
<texcode><br />
\useencoding[ffr]<br />
\mainlanguage[fr]<br />
\enableregime[utf] %for UTF8<br />
<br />
% \enableregime[il1] %for ISO 8859-1 8859-15<br />
<br />
\usetypescript[palatino][texnansi]<br />
\setupbodyfont[palatino,rm,12pt]<br />
<br />
\setupcolors[state=start]<br />
<br />
\definefont[BigFontOne][Regular sa 3] %RegularSlanted sa 3(ori)%Sans sa 3:don't work (pb accents)<br />
\definefont[BigFontTwo][RegularBold sa 2] %%RegularSlanted<br />
<br />
\definecolor[BigColorOne][r=.86,g=.850,b=.54]<br />
\definecolor[BigColorTwo][r=.43,g=.425,b=.27]<br />
<br />
\setuphead<br />
[chapter]<br />
[deeptextcommand=\MyChapterText,<br />
color=BigColorTwo,<br />
style=\BigFontTwo]<br />
<br />
\def\MyChapterText#1{\rlap{\BigFontOne\BigColorOne#1}\kern15pt#1}<br />
<br />
\starttext<br />
<br />
\chapter[chap:ques]{Question}<br />
\chapter[chap:answ]{Answer}<br />
\chapter[chap:answ]{Remarque}<br />
\chapter[chap:answ]{Cours}<br />
\chapter[chap:answ]{Exercice}<br />
\chapter[chap:answ]{Travail dirigé}<br />
\chapter[chap:answ]{Exposé}<br />
\stoptext<br />
</texcode><br />
<br />
I've tryed to change a bit Hans code, by putting \kern15pt, for moving backgroundtext to the left of \rlap alignment, and an unsuccess one to switch same backgroundtext in Sans font (no french accents).<br />
<br />
olivier<br />
<br />
<context><br />
\useencoding[ffr]<br />
\mainlanguage[fr]<br />
<br />
% fonts currently don't work this way,<br />
% I'll fix that soon. Patrick<br />
<br />
% \usetypescript[palatino][texnansi]<br />
% \setupbodyfont[palatino,rm,12pt]<br />
<br />
\setupcolors[state=start]<br />
<br />
\definefont[BigFontOne][Regular sa 3] %RegularSlanted sa 3(ori)%Sans sa 3:don't work (pb accents)<br />
\definefont[BigFontTwo][RegularBold sa 2] %%RegularSlanted<br />
<br />
\definecolor[BigColorOne][r=.86,g=.850,b=.54]<br />
\definecolor[BigColorTwo][r=.43,g=.425,b=.27]<br />
<br />
\setuphead<br />
[chapter]<br />
[textcommand=\MyChapterText,<br />
color=BigColorTwo,<br />
style=\BigFontTwo]<br />
<br />
\def\MyChapterText#1{\rlap{\BigFontOne\BigColorOne#1}\kern15pt#1}<br />
<br />
\starttext<br />
<br />
\chapter[chap:ques]{Question}<br />
<br />
% only one page please, since this is displayed inline. Patrick<br />
% \chapter[chap:answ]{Answer}<br />
% \chapter[chap:answ]{Remarque}<br />
% \chapter[chap:answ]{Cours}<br />
% \chapter[chap:answ]{Exercice}<br />
% \chapter[chap:answ]{Travail dirigé}<br />
% \chapter[chap:answ]{Exposé}<br />
\stoptext<br />
</context><br />
<br />
===Figures in Headings===<br />
<br />
This example shows how to completely replace the chapter text and number by an image:<br />
<br />
<context source="yes"><br />
\setupexternalfigures[location=default] % needed only for the wiki to the find the figure<br />
<br />
\useexternalfigure[chapter-1][cow.pdf]<br />
\useexternalfigure[chapter-2][hacker.jpg]<br />
<br />
\setuphead<br />
[chapter]<br />
[command=\MyChapterCommand]<br />
<br />
\def\MyChapterCommand#1#2%<br />
{\externalfigure[chapter-\currentheadnumber][height=5cm]}<br />
<br />
\starttext<br />
<br />
\chapter{One}<br />
\section{First section of Chapter One}<br />
<br />
\stoptext<br />
</context><br />
<br />
However, this "forgets" to put the chapter in the TOC. So you have to set<br />
the <tt>textcommand</tt> and <tt>numbercommand</tt> separately instead<br />
(thus retaining the command that puts the chapter in the TOC), rather than<br />
setting the overall <tt>command</tt>, if you need a complete TOC.<br />
<br />
<texcode><br />
\setuphead<br />
[chapter]<br />
[textcommand=\MyChapterTextCommand,<br />
numbercommand=\MyChapterNumberCommand]<br />
<br />
\def\MyChapterNumberCommand#1{} % hide chapter number<br />
<br />
\def\MyChapterTextCommand#1%<br />
{\externalfigure[chapter-\currentheadnumber][height=5cm]}<br />
</texcode><br />
<br />
[http://archive.contextgarden.net/message/20050519.215526.df7c5cd1.html]<br />
<br />
===Chapter head with absolute positioning of following text===<br />
<br />
<texcode><br />
\setuphead[chapter][before=\vbox to 4cm\bgroup,after=\vss\egroup]<br />
\starttext<br />
\chapter{test} \input tufte<br />
\stoptext<br />
</texcode><br />
<br />
No matter how many lines the chapter head runs to, the text will always start, e.g. 4cm below the top of the heading:<br />
<br />
<context><br />
\setuppapersize[A6][A6]<br />
\setuphead[chapter][before=\vbox to 4cm\bgroup,after=\vss\egroup]<br />
\setupbodyfont[8pt]<br />
\starttext<br />
\chapter{test} \input tufte<br />
\stoptext<br />
</context><br />
<br />
====Bug and proposed workaround====<br />
<br />
I tried this sample and <cmd>getmarking[chapter]</cmd>, used in my headers,<br />
stopped to work properly. Proposed workaround below.<br />
--[[User:Sebastian.rooks|SeR]] 00:52, 27 January 2006 (CET)<br />
<br />
<texcode><br />
\def\MyChapterCommand#1#2%<br />
{\vbox to 4cm\bgroup<br />
{#1\hskip.75em #2}<br />
\vss<br />
\egroup}<br />
<br />
\setuphead[chapter][header=nomarking,command=\MyChapterCommand]<br />
\starttext<br />
\chapter{test} \input tufte<br />
\stoptext<br />
</texcode><br />
<br />
<context><br />
\setuppapersize[A6][A6]<br />
\setupbodyfont[8pt]<br />
\def\MyChapterCommand#1#2%<br />
{\vbox to 4cm\bgroup<br />
{#1\hskip.75em #2}<br />
\vss<br />
\egroup}<br />
\setuphead[chapter][header=nomarking,command=\MyChapterCommand]<br />
\starttext<br />
\chapter{test} \input tufte<br />
\stoptext<br />
</context><br />
<br />
===Section head with underlining to width of last line===<br />
<br />
A style called for section headings to be followed by a rule which extends only the width of the text. More tricky was the need to make sure that if the text ran onto another line, it was the length of the ''last'' line that was to be followed. <br />
<br />
Hans came up with this cleverness, showing two alternate ways of doing it:<br />
<br />
<context source="yes" text="produces"><br />
\def\FirstSolution#1#2%<br />
{\vbox\bgroup<br />
\setbox0\hbox{#1}<br />
\hsize.4\textwidth<br />
\beginshapebox#2\endshapebox<br />
\gdef\SetLastLineWidth{\xdef\LastLineWidth{\the\wd\scratchbox}}%<br />
\reshapebox<br />
{\setbox\scratchbox\hbox{\unhbox\shapebox}%<br />
\SetLastLineWidth<br />
\globallet\SetLastLineWidth\relax<br />
\box\scratchbox}%<br />
\scratchdimen\dimexpr\wd0+.25em+\LastLineWidth\relax<br />
% \setbox2\ruledvbox {\innerflushshapebox} <br />
% why is correction needed<br />
\setbox2\vbox {\vskip-\lineskip\innerflushshapebox}<br />
\setbox0\vbox to \ht2{\box0}<br />
\hbox{\box0\hskip.25em\box2}<br />
\offinterlineskip<br />
\vskip.25ex<br />
\blackrule[width=\scratchdimen,height=1pt]<br />
\egroup}<br />
<br />
\doglobal\newcounter\NextLinePos<br />
<br />
\def\SecondSolution#1#2%<br />
{\vbox\bgroup<br />
\hsize.4\textwidth<br />
\doglobal\increment\NextLinePos<br />
\setbox\scratchbox\hbox{#1}<br />
\hbox{\vtop{\copy\scratchbox}\hskip.25em\vtop{#2}}%<br />
\offinterlineskip<br />
\scratchdimen\dimexpr\wd\scratchbox+.25em+<br />
\MPx{e:npl:\NextLinePos}-\MPx{b:npl:\NextLinePos}\relax<br />
\vskip.25ex<br />
\blackrule[width=\scratchdimen,height=1pt]<br />
\egroup}<br />
<br />
\def\DoSecondSolution#1%<br />
{\bpos{npl:\NextLinePos}#1\epos{npl:\NextLinePos}}<br />
<br />
% \showstruts<br />
<br />
\setuphead[section][command=\FirstSolution]<br />
<br />
\starttext<br />
<br />
\section{is this nice or not}<br />
<br />
\section{is this nice or not nice, that's the question}<br />
<br />
\setuphead[section][command=\SecondSolution,deeptextcommand=\DoSecondSolution]<br />
<br />
\section{is this nice or not}<br />
<br />
\section{is this nice or not nice, that's the question}<br />
<br />
\stoptext<br />
</context><br />
<br />
As if that wasn't enough, Taco pointed out that <cmd>lastlinewidth</cmd><br />
is the easy route to finding the width of the last line. Use something like:<br />
<br />
<code><br />
\optimizedisplayspacingtrue\setlastlinewidth % core-mat macro<br />
\global\advance\lastlinewidth-\hangindent\par % adjust<br />
\blackrule[width=\lastlinewidth,height=1pt]<br />
</code><br />
<br />
<br />
[[Category:Fonts]]<br />
[[Category:Graphics]]<br />
[[Category:Text elements]]</div>Wolfgang Schusterhttps://wiki.contextgarden.net/index.php?title=MkIV_Differences&diff=10058MkIV Differences2009-10-06T11:07:32Z<p>Wolfgang Schuster: code correction</p>
<hr />
<div>In [[Mark IV]], much has changed. Most of the changes are not noticeable at the source document level, but there are in fact a few important differences. This page attempts to list the intentional as well as the unavoidable incompatibilities between Mark IV and Mark II (but not bugs). <br />
<br />
= Command line =<br />
<br />
You start Mark IV with the '''context''' command, and Mark II with '''texexec'''. The two programs are not the same, and even though they have mostly the same command line, there are some differences. Mostly, this is because '''context''' is still lacking a number of options of texexec like for example --passon (those will probably be implemented at some point in the future), but it also parses the command line different. You must remember to always give the full name of the options, and then the effects should be almost unnoticeable.<br />
<br />
= Paragraph formatting =<br />
<br />
It should come as no surprise that '''mode=node''' generates different effects, but even with a traditional font setup there are incompatibilies unless you use tfm-only fonts. <br />
<br />
== Actual font usage ==<br />
<br />
If you have a font in both OpenType and traditional Type 1, then Mark IV will typically use one version and Mark II the other. There is no guarantee that both sets have the same metrics.<br />
<br />
== Interword spacing ==<br />
<br />
TFM-based (Type 1) fonts, especially those generated by afmtotfm, tend to use heuristics to decide on the width of the interword space instead of looking at the actual value inside the font. In Mark IV, it is much more likely that the actual value from the font is used, because Mark IV prefers the actual AFM files over any existing TFM files. As this affects interword spacing, linebreaks in Mark IV can be quite different from the ones in Mark II.<br />
<br />
== Line spacing ==<br />
<br />
TFM-based fonts often have to round heights and depths to allow for restrictions in the TFM format. This affects individual glyphs but more importantly, it can change the value of '1ex'. This can affect line spacing, because ConTeXt by default uses the value '2.8ex' for the setting of \baselineskip.<br />
<br />
= Languages and Regimes =<br />
<br />
Mark IV needs your input to be in UTF-8. Legacy documents using 8bit encodings have to be converted to utf-8 before they are usable.<br />
<br />
Linebreaks can be different because full-blown UTF-8 hyphenation patterns are used.<br />
<br />
= Fonts and Typescripts =<br />
<br />
Typescripts in Mark IV never specify any encoding at all (Unicode is mandatory)<br />
<br />
= Metapost =<br />
<br />
All inline metapost code in your document is executed in a large continuous run (and it seems that all metapost code is sometimes even interpreted twice). This means you should stay away from metapost equations unless you explicitly reset the used variables yourself.<br />
<br />
= Indices and sorting =<br />
<br />
Sort orders can be different because of changes to the sort order lists.<br />
<br />
<br />
== Images ==<br />
<br />
When using mkii, following code will give you document with two identical images (2nd will be the copy of 1st) even if they are different.<br />
<br />
Mkiv will give you what you expect, I mean two different images (of course only if they are different).<br />
<br />
<texcode><br />
\starttext<br />
\placefigure[here,force,none]{}{\externalfigure[image1/image.png][width=5cm]}<br />
\placefigure[here,force,none]{}{\externalfigure[image2/image.png][width=5cm]}<br />
\stoptext<br />
</texcode></div>Wolfgang Schusterhttps://wiki.contextgarden.net/index.php?title=Modules&diff=9973Modules2009-09-07T16:46:27Z<p>Wolfgang Schuster: Installation</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 hard<br />
for people how are new in TeX or aren't interested in TeX programming themselve.<br />
<br />
According to the TDS (TeX directory structure) and the ConTeXt developers user<br />
written files reside under the path<br />
<br />
$TEXMF/tex/context/third/<modulename>/<files><br />
<br />
in the private TeX directory ($TEXMF), private directories can have the names<br />
<br />
* texmf-local<br />
* texmf-extra<br />
* texmf-project<br />
<br />
but there existence depend on the TeX distribution and texmf-local is the most<br />
common one.<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 minimals===<br />
<br />
Users of the ConTeXt minimals dont't have to download the module files and unzip<br />
them in the local directory because they can use the 'first-setup' for this.<br />
<br />
To install for example the simpleslides modules you write<br />
<br />
first-setup.sh --extras="t-simpleslides"<br />
<br />
To install more modules at the same time write<br />
<br />
first-setup.sh --extras="t-simpleslides,t-french"<br />
<br />
The complete list of availables modules in minimals is:<br />
<br />
* f-urwgaramond<br />
* f-urwgothic<br />
* t-account<br />
* t-algorithmic<br />
* t-bib<br />
* t-bnf<br />
* t-chromato<br />
* t-cmscbf<br />
* t-cmttbf<br />
* t-construction-plan<br />
* t-degrade<br />
* t-fixme<br />
* t-french<br />
* t-games<br />
* t-gnuplot<br />
* t-layout<br />
* t-letter<br />
* t-lettrine<br />
* t-lilypond<br />
* t-mathsets<br />
* t-simplefonts<br />
* t-simpleslides<br />
* t-taspresent<br />
* t-tikz<br />
* t-typearea<br />
* t-typescripts<br />
* t-vim<br />
<br />
===TeX Live===<br />
<br />
{{Note | description required}}<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-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 />
==Included modules:==<br />
* [[source:t-bib.tex|t-bib]]: [[Bibliography]] (maintained by Taco)<br />
* [[source:m-arabtex.tex|m-arabtex]]: loading of Lagally's [[Arabian and Hebrew|ArabTeX]]<br />
* [[source:m-chart.tex|m-chart]]: [[Flow Charts]]<br />
* [[source:m-chemic.tex|m-chemic]]: [[Chemistry|PPCHTeX]] (chemical structure formulae)<br />
* [[source:m-cweb.tex|m-cweb]]: [[CWEB]] pretty printing<br />
* [[source:m-database.tex|m-database]]: creating simple tables (or forwarding data to user-defined commands) using [[m-database|comma/space/tab-separated values]]<br />
* [[source:m-dratex|m-dratex]]: loading of DraTeX<br />
* [[source:m-edtsnc.tex|m-edtsnc]]: support for editor synchronization, will replace m-pdfsync<br />
* [[source:m-educat.tex|m-educat]]: educational additions (for settings school tests or questionaires)<br />
* [[source:m-gamma.tex|m-gamma]]: [[Aleph|Omega]] support<br />
* [[source:m-graph.tex|m-graph]]: support for [[MetaPost]] graph module<br />
* [[source:m-layout.tex|m-layout]]: defines some [[Layout]] presets<br />
* [[source:m-level.tex|m-level]]: module for catching nesting errors<br />
* [[source:m-narrowtt.tex|m-narrowtt]]: using a narrower [[Latin Modern]] font for verbatim<br />
* [[source:m-newmat.tex|m-newmat]]: support for some AMSmath features, is loaded by [[Math with amsl|amsl]], see [[Math with newmat]]<br />
* [[source:m-pdfsnc.tex|m-pdfsnc]]: editor/PDF synchronization support (used by iTeXMac and TeXShop)<br />
* [[source:m-pictex.tex|m-pictex]]: needed for [[PicTeX]] without eTeX<br />
* [[source:m-plus.tex|m-plus]]: loads some extra features (currently empty)<br />
* [[source:m-pstric.tex|m-pstric]]: connection macros for [[PSTricks]] (PostScript tricks)<br />
* [[source:m-r.tex|m-r]]: typing and executing [http://www.r-project.org/ R] scripts<br />
* [[source:m-quest.tex|m-quest]]: module for fill-in forms (dutch only)<br />
* [[source:m-steps.tex|m-steps]]: Step Charts, see [[XML]] step charts<br />
* [[source:m-streams.tex|m-streams]]: Synchronised typesetting from different sources<br />
* [[source:m-subsub.tex|m-subsub]]: Defines 5 extra sectioning levels<br />
* [[source:m-tex4ht.tex|m-tex4ht]]: convert a ConTeXt document to html, more about it on [[tex4ht]]<br />
* [[source:m-tryout.tex|m-tryout]]: Contains temporary functions for testing<br />
* [[source:m-units.tex|m-units]]: Structured input of values with [[units]]<br />
* [[source:m-visual.tex|m-visual]]: [[Visual Debugging]] (described in [[This Way]] no.7 [[manual:mag-0007.pdf|Faking Text and More]])<br />
<br />
==Contributed modules:==<br />
For a list of contributed modules see [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 />
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.<br />
<br />
<br />
<b>TODO</b><br />
<br />
Each module should have an associated specification file (as in [http://source.contextgarden.net/tex/context/interface/cont-en.xml /tex/context/interface/cont-en.xml]). Probably one day this will become a part of [http://texshow.contextgarden.net/ texshow] and will also be easy-to-edit.<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 />
\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 backgroud, as in context documentation, add the following<br />
<br />
<texcode><br />
\setupframedtexts<br />
[setuptext]<br />
[background=screen,<br />
frame=off]<br />
</texcode></div>Wolfgang Schusterhttps://wiki.contextgarden.net/index.php?title=TypeScripts_-_Old_Content&diff=9947TypeScripts - Old Content2009-08-21T16:12:02Z<p>Wolfgang Schuster: reformat typescripts</p>
<hr />
<div>< [[Fonts]] ><br />
<br />
Typescripts are the ConTeXt way of using fonts and defining font families.<br />
<br />
Beware, the examples on this page work only with MkII / pdfTeX (i.e. neither XeTeX nor LuaTeX).<br />
<br />
==Basics==<br />
<br />
Sample typescript for the free text font [http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&item_id=Gentium Gentium]. Installation instructions are at [[Installing a TrueType font, step by step]].<br />
A typescript must live in your project folder or in another folder in your ConTeXt path (e.g., <tt>(texmf)/tex/context/user</tt>)<br />
<br />
<texcode><br />
% type-sil-gentium.tex<br />
% Typescript for serif family SIL Gentium<br />
<br />
% load mapfile<br />
<br />
\starttypescript [map] [gentium] [\defaultencoding]<br />
\loadmapfile [\defaultencoding-sil-gentium.map]<br />
\stoptypescript<br />
<br />
% mapping from PostScript name (or visible font name, if it's a TrueType font) to TFM file name<br />
% The second argument means that these names are loaded with either the 'gentium'<br />
% or 'gentium-alt' names.<br />
<br />
\starttypescript [serif] [gentium,gentium-alt] [\defaultencoding] % mapping is used by two "name" typescripts<br />
\definefontsynonym [Gentium] [\defaultencoding-genr101] [encoding=\defaultencoding]<br />
\definefontsynonym [Gentium-Italic] [\defaultencoding-geni101] [encoding=\defaultencoding]<br />
\definefontsynonym [GentiumAlt] [\defaultencoding-genar101] [encoding=\defaultencoding]<br />
\definefontsynonym [GentiumAlt-Italic] [\defaultencoding-genai101] [encoding=\defaultencoding]<br />
\stoptypescript<br />
<br />
% mapping from generic family name to PostScript name<br />
<br />
\starttypescript [serif] [gentium] [name]<br />
\definefontsynonym [Serif] [Gentium]<br />
\definefontsynonym [SerifItalic] [Gentium-Italic]<br />
\stoptypescript<br />
<br />
% additional mapping to alternate glyphs, not further used<br />
<br />
\starttypescript [serif] [gentium-alt] [name]<br />
\definefontsynonym [Serif] [GentiumAlt]<br />
\definefontsynonym [SerifItalic] [GentiumAlt-Italic]<br />
\stoptypescript<br />
<br />
% sample family definition<br />
% here we define only the serif (rm) version.<br />
<br />
\starttypescript [sil-gentium]<br />
\definetypeface [sil-gentium] [rm] [serif] [gentium] [default] [encoding=\defaultencoding]<br />
% \definetypeface [sil-gentium] [ss] [sans] [default] [default] [encoding=\defaultencoding]<br />
% \definetypeface [sil-gentium] [tt] [mono] [default] [default] [encoding=\defaultencoding]<br />
% \definetypeface [sil-gentium] [mm] [math] [default] [default] [encoding=\defaultencoding]<br />
\stoptypescript<br />
</texcode><br />
<br />
The multiple mapping is not strictly needed, but increases flexibility.<br />
<br />
To use your new typescript, write the following in your environment file (or single TeX file):<br />
<br />
<texcode><br />
\setupencoding[default=ec] % defines \defaultencoding<br />
<br />
\usetypescriptfile[type-sil-gentium]<br />
<br />
\usetypescript[sil-gentium]<br />
\setupbodyfont[sil-gentium,rm,12pt]<br />
<br />
\setupbodyfontenvironment [default] [em=italic] % slanted is default emphasize in ConTeXt<br />
</texcode><br />
<br />
The map file was written by [[texfont]] and lives in <tt>(texmf)/fonts/map/pdftex/context</tt>.<br />
It combines raw TFM (metrics), PostScript name, font file and encoding<br />
<texcode><br />
% ec-sil-gentium.map<br />
ec-raw-genai101 GentiumAlt-Italic 4 < genai101.pfb ec.enc<br />
ec-raw-genar101 GentiumAlt 4 < genar101.pfb ec.enc<br />
ec-raw-geni101 Gentium-Italic 4 < geni101.pfb ec.enc<br />
ec-raw-genr101 Gentium 4 < genr101.pfb ec.enc<br />
</texcode><br />
<br />
==The next step: making it more generic==<br />
<br />
If you'd like to write a typescript that handles many more encodings, somewhat more generically, here is one model to build upon:<br />
<texcode><br />
% type-sil-gentium.tex<br />
% Typescript for serif family SIL Gentium<br />
<br />
% This is the first change we need to make: we list all the encodings it can match,<br />
% and then use that data within the typescript:<br />
<br />
\starttypescript [map] [gentium] [ec,texnansi,8r,t5,t2a,t2b,qx]<br />
\loadmapfile [\typescriptthree-sil-gentium.map]<br />
\stoptypescript<br />
<br />
% We use the same technique. As the encoding variable shows up in the third<br />
% argument, we use \typescriptthree.<br />
<br />
\starttypescript [serif] [gentium] [ec,texnansi,8r,t5,t2a,t2b,qx]<br />
\definefontsynonym [Gentium] [\typescriptthree-genr101] [encoding=\typescriptthree]<br />
\definefontsynonym [Gentium-Italic] [\typescriptthree-geni101] [encoding=\typescriptthree]<br />
\definefontsynonym [GentiumAlt] [\typescriptthree-genar101][encoding=\typescriptthree]<br />
\definefontsynonym [GentiumAlt-Italic] [\typescriptthree-genai101][encoding=\typescriptthree]<br />
\stoptypescript<br />
<br />
% Getting fancy: occasionally you want to access alternates from the main font:<br />
<br />
\starttypescript [serif] [gentium] [name]<br />
\setups [font:fallback:serif] % We use the new (and fast loading) font fallbacks to cover bold markup.<br />
\definefontsynonym [Serif] [Gentium]<br />
\definefontsynonym [SerifItalic] [Gentium-Italic]<br />
% Gentium contains only two faces, so we map everything else on Italic<br />
\definefontsynonym [SerifSlanted] [SerifItalic]<br />
\definefontsynonym [SerifBoldItalic] [SerifItalic]<br />
\definefontsynonym [SerifCaps] [SerifItalic]<br />
\definefontsynonym [SerifBoldCaps] [SerifItalic]<br />
% markup of \Var[alt] results in a (subtle) font switch (Gentium's alternate glyphs change only some diacritics):<br />
\definefontvariant [Serif] [alt] [Alt]<br />
% unfortunately you need to define eight synonyms to handle the fallback cases:<br />
\definefontsynonym [SerifRegular] [Serif]<br />
\definefontsynonym [SerifRegularAlt] [GentiumAlt] % you must define "Regular" for every additional variant<br />
\definefontsynonym [SerifBoldAlt] [GentiumAlt]<br />
\definefontsynonym [SerifCapsAlt] [GentiumAlt]<br />
\definefontsynonym [SerifItalicAlt] [GentiumAlt-Italic]<br />
\definefontsynonym [SerifSlantedAlt] [GentiumAlt-Italic]<br />
\definefontsynonym [SerifBoldItalicAlt] [GentiumAlt-Italic]<br />
\definefontsynonym [SerifBoldSlantedAlt] [GentiumAlt-Italic]<br />
\stoptypescript<br />
<br />
% sample family definition<br />
% here we define only the serif (rm) version.<br />
<br />
\starttypescript [sil-gentium] [ec,texnansi,8r,t5,t2a,t2b,qx]<br />
\definetypeface [sil-gentium] [rm] [serif] [gentium] [default] [encoding=\typescripttwo]<br />
% \definetypeface [sil-gentium] [ss] [sans] [default] [default] [encoding=\typescripttwo]<br />
% \definetypeface [sil-gentium] [tt] [mono] [default] [default] [encoding=\typescripttwo]<br />
% \definetypeface [sil-gentium] [mm] [math] [default] [default] [encoding=\typescripttwo]<br />
\stoptypescript<br />
<br />
</texcode><br />
<br />
==Links==<br />
* [http://www.pragma-ade.com/general/manuals/showfont.pdf examples of using typescripts] by Pragma<br />
* [http://www.ramm.ch/fiee/texnique/?menu=0-1-4&amp;lang=en example typescripts] for free and commercial fonts, by Hraban (partly outdated)<br />
* Sample of [http://wiki.contextgarden.net/exljbris_typescript MkIV typescripts for exljbris fonts]<br />
* typescripts for some fonts from the FontSite500 CD on the [[Font Site]] page, by Holger Schöner<br />
* typescripts for lazy font combinations on the [[Flexi Face]] page<br />
* some pointers on extending typescripts to accommodate access to &ldquo;variants,&rdquo; like old-style figures, are on the [[Font Variants]] page<br />
* [[Fonts in XeTeX]] gives some details about the [[XeTeX]]-specific typescripts in <tt>type-xtx</tt><br />
<br />
[[Category:Fonts]]</div>Wolfgang Schusterhttps://wiki.contextgarden.net/index.php?title=Filecontents&diff=9931Filecontents2009-08-08T20:00:48Z<p>Wolfgang Schuster: New interface for messages</p>
<hr />
<div>LaTeX provides a <code>filecontent</code> environment to embed text in your document<br />
which is written to a external document when your process it. The filename is given with<br />
the argument for the environment.<br />
<br />
You could define a environment for the same effect with the buffer mechanism, the code<br />
for such a environment is:<br />
<br />
<texcode><br />
\unprotect<br />
<br />
\definemessageconstant {filecontents}<br />
<br />
\startinterface all<br />
\setinterfacemessage{filecontents}{title}{filecontents}<br />
\setinterfacemessage{filecontents}{1} {Overwriting file --}<br />
\setinterfacemessage{filecontents}{2} {Writing file --}<br />
\stopinterface<br />
<br />
\def\startfilecontents<br />
{\begingroup<br />
\protectbuffersfalse<br />
\dostartfilecontents}<br />
<br />
\def\dostartfilecontents[#1]%<br />
{\doiffileexistselse{#1}<br />
{\showmessage\m!filecontents{1}{#1}}<br />
{\showmessage\m!filecontents{2}{#1}}%<br />
\beforesplitstring#1\at.\to\filename<br />
\aftersplitstring #1\at.\to\extension<br />
\let\f!temporaryextension\extension<br />
\dostartbuffer[\filename][startfilecontents][stopfilecontents]}<br />
<br />
\def\stopfilecontents<br />
{\doifmode{mkiv}{\savebuffer[\filename]\ctxlua{file.copy("\jobname-\filename.tmp","\filename.\f!temporaryextension")}}%<br />
\endgroup}<br />
<br />
\protect<br />
</texcode><br />
<br />
You could use this environment in your document in the following way.<br />
<br />
<texcode><br />
\startfilecontents[song.txt]<br />
If I could choose my paradise,<br />
And please myself with choice of bliss,<br />
Then I would have your soft blue eyes<br />
And rosy little mouth to kiss!<br />
Your lips, as smooth and tender, child,<br />
As rose-leaves in a coppice wild.<br />
<br />
If fate bade choose some sweet unrest,<br />
To weave my troubled life a snare,<br />
Then I would say "her maiden breast<br />
And golden ripple of her hair;"<br />
And weep amid those tresses, child,<br />
Contented to be thus beguiled.<br />
<br />
(Thomas Asche - No and Yes)<br />
\stopfilecontents<br />
</texcode></div>Wolfgang Schusterhttps://wiki.contextgarden.net/index.php?title=Fonts_in_LuaTeX&diff=9929Fonts in LuaTeX2009-08-08T09:15:28Z<p>Wolfgang Schuster: Fonts in LuaTex moved to Fonts in LuaTeX: Wrong name</p>
<hr />
<div>{{note|This page is not finished yet}}<br />
<br />
'''Please, someone, fill this page !'''<br />
<br />
'''This page is beeing regorganized'''<br />
<br />
= Getting access to the system fonts =<br />
<br />
LuaTeX can use non-TeX fonts (in OpenType, TrueType or Type1 format) directly.<br />
<br />
The first time that you run<br />
<br />
context myfile.tex<br />
<br />
on a file that uses such non-traditional fonts (which is probably always), the actual fonts themselves have to be loaded in luatex's embedded section of fontforge to extract their metric information. This removes the need for tfm and vf files on your disk, but it is also a somewhat lengthy and often memory-hungry process.<br />
<br />
That is why the results of that internal preprocessing are also saved inside the texmf cache. Future runs using the same font (not just this file, but all files using that particular font) can then use the cached version of the metrics instead. <br />
<br />
== Building the font database ==<br />
<br />
You need to specify where the fonts should be looked for, by setting the <code>OSFONTDIR</code> environment variable. For instance,<br />
set OSFONTDIR=c:/windows/fonts/<br />
if the fonts should be found in <code>c:/windows/fonts/</code>; or<br />
export OSFONTDIR="/usr/local/share/fonts;$HOME/.fonts"<br />
if the fonts should be found in both <code>/usr/local/share/fonts</code> and <code>$HOME/.fonts</code>.<br />
<br />
The font database will then be automatically generated in the next run of <code>context</code><br />
<br />
You can also generate it manually by typing <br />
mtxrun --script font --reload<br />
or equally<br />
mtxrun --script fonts --reload<br />
<br />
The output should look like<br />
MTXrun | fontnames: identifying tree font files with suffix otf<br />
MTXrun | fontnames: identifying tree font files with suffix OTF<br />
MTXrun | fontnames: 331 tree files identified, 332 hash entries added, runtime 7.653 seconds<br />
MTXrun | fontnames: identifying tree font files with suffix ttf<br />
MTXrun | fontnames: identifying tree font files with suffix TTF<br />
MTXrun | fontnames: 17 tree files identified, 14 hash entries added, runtime 4.645 seconds<br />
...<br />
MTXrun | fontnames: 94 system files identified, 94 hash entries added, runtime 0.554 seconds<br />
MTXrun | fontnames: 3837 files read, 3342 normal and 49 extra entries added, 5 rejected, 3386 valid<br />
<br />
<br />
<br />
== Querying the font database ==<br />
<br />
The command<br />
mtxrun --script fonts --list<br />
will return the whole entries of the font database as a list, such as<br />
<br />
...<br />
warnockprobold WarnockPro-Bold E:/Fonts/Warnock Pro/WarnockPro-Bold.otf<br />
warnockproboldcapt WarnockPro-BoldCapt E:/Fonts/Warnock Pro/WarnockPro-BoldCapt.otf<br />
warnockprobolddisp WarnockPro-BoldDisp E:/Fonts/Warnock Pro/WarnockPro-BoldDisp.otf<br />
warnockproboldit WarnockPro-BoldIt E:/Fonts/Warnock Pro/WarnockPro-BoldIt.otf<br />
warnockprobolditcapt WarnockPro-BoldItCapt E:/Fonts/Warnock Pro/WarnockPro-BoldItCapt.otf<br />
warnockprobolditdisp WarnockPro-BoldItDisp E:/Fonts/Warnock Pro/WarnockPro-BoldItDisp.otf<br />
warnockprobolditsubh WarnockPro-BoldItSubh E:/Fonts/Warnock Pro/WarnockPro-BoldItSubh.otf<br />
warnockproboldsubh WarnockPro-BoldSubh E:/Fonts/Warnock Pro/WarnockPro-BoldSubh.otf<br />
...<br />
<br />
You can query the database against a particular pattern. For instance,<br />
mtxrun --script fonts --list --pattern=Delicious*<br />
will return<br />
deliciousbold Delicious-Bold /usr/local/share/fonts/d/delicious_bold.otf<br />
deliciousbolditalic Delicious-BoldItalic /usr/local/share/fonts/d/delicious_bolditalic.otf<br />
deliciousheavy Delicious-Heavy /usr/local/share/fonts/d/delicious_heavy.otf<br />
deliciousitalic Delicious-Italic /usr/local/share/fonts/d/delicious_italic.otf<br />
deliciousroman Delicious-Roman /usr/local/share/fonts/d/delicious_roman.otf<br />
delicioussmallcaps Delicious-SmallCaps /usr/local/share/fonts/d/delicious_smallcaps.otf<br />
<br />
You can get useful informations about your fonts by using the <code>--info</code> option. For instance,<br />
mtxrun --script fonts --list --info --pattern=Delicious*Roman<br />
will return<br />
MTXrun | fontname: deliciousroman<br />
MTXrun | fullname: Delicious-Roman<br />
MTXrun | filename: /usr/local/share/fonts/d/delicious_roman.otf<br />
MTXrun |<br />
MTXrun | gpos features:<br />
MTXrun |<br />
MTXrun | feature script languages<br />
MTXrun |<br />
MTXrun | kern latn dflt<br />
MTXrun |<br />
MTXrun | gsub features:<br />
MTXrun |<br />
MTXrun | feature script languages<br />
MTXrun |<br />
MTXrun | tlig all all<br />
MTXrun | trep all all<br />
<br />
== Installing new fonts ==<br />
<br />
After installing new fonts, the font database must be rebuilt for LuaTeX to access them.<br />
<br />
In current versions of Mark IV (earlier than July 2008) this is automatically done whenever a named font cannot be found.<br />
<br />
You only have to do the reload manually when you have installed updates to already installed fonts that cause the font and/or file names to change. <br />
This normally only happens for fonts that are still in development like [[TeX Gyre]] and [[Latin Modern]].<br />
<br />
You can rebuild the database manually, using the already-mentioned command<br />
mtxrun --script fonts --reload<br />
<br />
Alternatively, you can turn off the automatic rebuild of the database, by setting either of<br />
MTX.FONTS.AUTOLOAD<br />
MTX_FONTS_AUTOLOAD<br />
to "no".<br />
<br />
== References ==<br />
<br />
[http://context.aanhet.net/svn/contextman/context-reference/en/co-fonts.pdf The new manual chapter on fonts]<br />
<br />
= Using fonts =<br />
<br />
Handling fonts in LuaTeX can be done<br />
* in a simple but limited way, using the <code>simplefonts</code> module;<br />
* in the standard way, using [[TypeScripts]]<br />
<br />
== With the <code>simplefonts</code> module ==<br />
<br />
<code>simplefonts</code> is a third-party module written by Wolfgang Schuster.<br />
<br />
It simplifies the use of fonts in LuaTeX by<br />
* freeing the user from writing or using [[TypeScripts]];<br />
* offering an interface similar to the [http://www.ctan.org/tex-archive/macros/xetex/latex/fontspec/ fontspec package for XeTeX]<br />
<br />
For instance, assuming the [http://www.josbuivenga.demon.nl/delicious.html Delicious fonts] are properly installed and recognized by ConTeXt, you can simply write:<br />
<br />
<texcode><br />
\usemodule[simplefonts] % load the module<br />
\setmainfont[Delicious] % set Delicious as main (serif) font<br />
<br />
\starttext<br />
\rm\tf roman \it italic \bf bold \bi bolditalic \sc smallcaps<br />
\stoptext<br />
</texcode><br />
<br />
== The standard way: Typescripts ==<br />
<br />
=== Installing typescripts ===<br />
<br />
Installing typescripts consists in the following:<br />
<br />
1. Copy the typescript files into either <br />
<texcode>$TEXMF/tex/texmf-fonts/tex/context/user<br />
$TEXMF/tex/texmf-project/tex/context/user</texcode><br />
2. Run <code>context --generate</code><br />
<br />
By convention, typescript files are named like <code>type-(fontname|foundry).tex</code>. <br />
<br />
It may happen that some <code>type-xx.tex</code> typescript file depends on mkiv-specific code located in a matching <code>type-xx.mkiv</code> file. In this case, both files need to be installed.<br />
<br />
=== Loading typescripts ===<br />
<br />
A typescript file named <code>type-xx.tex</code> should be loaded using<br />
\usetypescriptfile[type-xx]<br />
<br />
An alternative way is<br />
\usetypefile[xx]<br />
where ConTeXt prepends <code>type-</code> when it loads the file; but <br />
<cmd>usetypescriptfile</cmd> is the preferred command because it takes care of the<br />
<cmd>starttypescriptcollection</cmd>/<cmd>stoptypescriptcollection</cmd> environments.<br />
<br />
=== Where to find existing typescripts ===<br />
<br />
Each of the typescripts below defines a keyword to use with <cmd>setupbodyfont</cmd>. Usually this is the same as the name of the typescript, but there is one exception (<code>antykwa-torunska</code>)<br />
<br />
* Latin Modern (typescript name: <code>modern</code>; this is the default font set)<br />
* Latin Modern variant (ts name: <code>modernvariable</code>; LM variable typewriter for serif)<br />
* Postscript (ts name: <code>postscript</code>; Termes for serif, Heros for sans, Cursor for mono)<br />
* Antykwa Toruńska (ts name: <code>antykwa-torunska</code>; only serif; defines <tt>antykwa</tt> as keyword for <cmd>setupbodyfont</cmd>)<br />
* Iwona (ts name: <code>iwona</code>; only sans serif)<br />
* Iwona Light, Medium and Heavy (ts names: <code>iwona-light</code>, <code>iwona-medium</code>, <code>iwona-heavy</code>; only sans; the medium variant is a small bit heavier than a "regular" one)<br />
* Pagella (ts name: <code>palatino</code>; only serif)<br />
* Termes (ts name: <code>times</code>; only serif, Heros for sans)<br />
<br />
== Usage example ==<br />
<br />
<texcode><br />
\usetypescript[palatino]<br />
\setupbodyfont[palatino,18pt]<br />
<br />
\starttext<br />
Hello world, I'm Pagella!<br />
\stoptext<br />
</texcode><br />
<br />
The first line seems to order ConTeXt to "install" (for the current file) the given typescript (it accepts what I have earlier called a "typescript name"). The last one starts using it (you may omit the size if you are satisfied with the default).<br />
<br />
== Combining predefined fonts in your own typescripts ==<br />
<br />
It is also possible to combine fonts from the TeX Gyre collection in your own typescripts. The example below combines Bonum (Bookman) roman, Adventor (AvantGarde) for sans serif, Cursor (Courier) for teletype, and Euler for math. The <code>rscale=...</code> option ensures that all fonts have the same x-height. (You can lookup the relative x-heigt of a font using fontforge.)<br />
<br />
<texcode><br />
\starttypescript [Bonum]<br />
\definetypeface [Bonum] [rm] [serif] [bonum] [default]<br />
\definetypeface [Bonum] [ss] [sans] [adventor] [default] [rscale=0.887]<br />
\definetypeface [Bonum] [tt] [mono] [cursor] [default] [rscale=1.163]<br />
\definetypeface [Bonum] [mm] [math] [euler] [default] [rscale=1.050]<br />
\stoptypescript<br />
<br />
\usetypescript[Bonum]<br />
\setupbodyfont[Bonum,12pt]<br />
<br />
\starttext<br />
Hello world, I'm Bonum!<br />
\stoptext<br />
</texcode><br />
<br />
= Old contents =<br />
<br />
* [[TrueType fonts in luaTeX]]<br />
<br />
==== Good ol' typescripts ====<br />
<br />
Of course, Mark IV allows you to use typescripts as you've always done; for example:<br />
<br />
<texcode><br />
\usetypescript[palatino]<br />
\setupbodyfont[palatino,12pt]<br />
effe fietsen 2: \input tufte $\sqrt{2}$ \eogonek<br />
<br />
\sc effe fietsen 2: \input tufte $\sqrt{2}$ \eogonek<br />
</texcode><br />
<br />
That's as simple as using a traditional ConTeXt typescript!<br />
<br />
But ... how is it any different, then? Well, the difference is that in Mark IV, we can use an Opentype font directly, so that what is done here: when we want to use Palatino, the [[TeX Gyre]] equivalent (“Pagella”) is called and we can use its Opentype “features”; read on.<br />
<br />
==== Opentype features ====<br />
<br />
A “feature”, in the Opentype jargon, is a set of rules describing changes in the appearance of the text. Hmm, that's not very precise. Let's show some examples. First of all, you have to know that features are referred to by 4-letter tags, and you will see this a lot. One of them is ‘smcp‘, for “small caps“. Let's consider the following Mark IV-only code:<br />
<br />
<texcode><br />
\definefontfeature[smallcaps][language=DFLT,script=latn,smcp=yes]<br />
\font\palasmallcaps=texgyrepagella-regular*smallcaps<br />
\palasmallcaps This is a text in small capitals.<br />
</texcode><br />
<br />
Here you basically define a (Mark IV) feature with the name ”smallcaps”, and associate it with the (Opentype) feature “smcp”. You have to specify which script you want to use it with; scripts in Opentype are also tagged with four letters, and “latn” is of course Latin.<br />
<br />
Then you define a TeX font with that feature.<br />
<br />
You can see what features are defined in a particular font with the following bit of code<br />
<br />
<texcode><br />
\ctxlua<br />
{<br />
fontname = 'texgyrepagella-regular.otf'<br />
<br />
--[[ First read the font data.<br />
This makes heavy use of some of the Mark IV code]]<br />
tfmdata = fonts.tfm.read_and_define("file:" .. fontname, 655360)<br />
font = tfmdata.shared.otfdata<br />
if font<br />
then<br />
gsubfeatures = fonts.otf.analyze_features(font.gsub)<br />
gposfeatures = fonts.otf.analyze_features(font.gpos)<br />
end<br />
<br />
if gsubfeatures then<br />
table.sort(gsubfeatures) % We want our list sorted alphabetically!<br />
tex.sprint("\\rm GSUB features: \\tt ") % Beware: you don't want \rm to be interpreted by lua (\rm would yield carriage return + letter m)!<br />
for _, feat in ipairs(gsubfeatures)<br />
do tex.sprint(feat) tex.sprint(' ')<br />
end<br />
else tex.sprint("\\rm No GSUB features")<br />
end<br />
tex.sprint("\\par")<br />
<br />
if gposfeatures then<br />
tex.sprint("\\rm GPOS features: \\tt ")<br />
table.sort(gposfeatures)<br />
for _, feat in ipairs(gposfeatures)<br />
do tex.sprint(feat) tex.sprint(' ')<br />
end<br />
else tex.sprint("\\rm No GPOS features")<br />
end<br />
}<br />
</texcode><br />
<br />
It prints the list on the page. You'll notice there are two sets of features, each one of them defined in a different table of the Opentype font: the <code>GSUB</code> table (for Glyph SUBstitution) gives rules for replacing glyphs in certains circumstances (think of ligatures: f + i -> fi); the <code>GPOS</code> table (Glyph POSititioning) gives rules for moving glyphs (think of kerning: A + V -> A <kerning> V).<br />
<br />
Incidentally, the above code gives some basic examples of LuaTeX programming, a mixture of both Lua and TeX programming with some special features (features in the general sense, not the Opentype one :-).<br />
<br />
==== A (Complete) Typescript Example ====<br />
<br />
<texcode><br />
\starttypescript [sans] [franklin]<br />
<br />
\definefontsynonym [FranklinBookRegular] [name:FranklinGothicBookITC-Regular] [features=default]<br />
\definefontsynonym [FranklinMediumRegular] [name:FranklinGothicMediumITC-Regular] [features=default]<br />
\definefontsynonym [FranklinDemiRegular] [name:FranklinGothicDemiITC-Regular] [features=default]<br />
\definefontsynonym [FranklinHeavyRegular] [name:FranklinGothicHeavyITC-Regular] [features=default]<br />
<br />
\definefontsynonym [FranklinBookItalic] [name:FranklinGothicBookITC-Italic] [features=default]<br />
\definefontsynonym [FranklinDemiItalic] [name:FranklinGothicMediumITC-Italic] [features=default]<br />
\definefontsynonym [FranklinHeavyItalic] [name:FranklinGothicDemiITC-Italic] [features=default]<br />
\definefontsynonym [FranklinMediumItalic] [name:FranklinGothicHeavyITC-Italic] [features=default]<br />
<br />
\stoptypescript<br />
<br />
\starttypescript [sans] [franklin]<br />
<br />
\definefontsynonym [Sans] [FranklinBookRegular] [features=default]<br />
\definefontsynonym [SansItalic] [FranklinBookItalic] [features=default]<br />
\definefontsynonym [SansBold] [FranklinDemiRegular] [features=default]<br />
\definefontsynonym [SansBoldItalic] [FranklinDemiItalic] [features=default]<br />
\definefontsynonym [SansSlanted] [SansItalic] [features=default]<br />
\definefontsynonym [SansBoldSlanted] [SansBoldItalic] [features=default]<br />
\definefontsynonym [SansCaps] [Sans] [features=smallcaps]<br />
<br />
\stoptypescript<br />
<br />
\definetypeface[franklin][rm][sans][franklin][default]<br />
\definetypeface[franklin][ss][sans][franklin][default]<br />
\definetypeface[franklin][tt][mono][modern] [default][rscale=1.12]<br />
\definetypeface[franklin][mm][math][iwona] [default][rscale=1.02]<br />
<br />
\setupbodyfont[franklin,ss,10pt]<br />
</texcode><br />
<br />
<br />
<br />
Just the simplest way to use an otf font — or any font that does appear in <tt>mtxrun --script font --list</tt> — in all the document.<br />
<br />
I’m stick here :<br />
<br />
\definefontfeature [myfontfeature] [method=node, kern=yes, OTHER_FEATURE_COMMA_SEPERATED]<br />
\definefontsynonym [MyFontRegular] [name:TheFontName-Regular][features=myfontfeature]<br />
\definedfont [MyFontRegular at 16pt]<br />
<br />
This doesn’t run for my title which use « \tfc », only for the body of the text.<br />
<br />
*\definefontfeature<br />
**[myfontfeature] : you can use the name you want. It will be use at the next line ;<br />
**the fonts feature can be found with <tt>otfinfo -f TheFontFile.otf</tt>.<br />
*\definefontsynonym :<br />
**[MyFontRegular] : you can use the name you want. It will be use at the next line ;<br />
**The name after <tt>name:</tt> is the name given by <tt>mtxrun --script font --list</tt><br />
**The « name: » part can be replaced by <tt>file:TheFontFile.otf</tt><br />
<br />
<br />
== Example ==<br />
<br />
<br />
Now to access, say the regular warnock font, the following are valid. And I ought to mention that Hans recommends the first http://article.gmane.org/gmane.comp.tex.context/43685.<br />
<br />
<texcode><br />
% Hans recommends this format;<br />
\definefontsynonym [WarnockPro-Regular] [name:warnockproregular] <br />
</texcode><br />
<br />
and<br />
<br />
<texcode><br />
\definefontsynonym [WarnockPro-Regular] [name:WarnockPro-Regular]<br />
</texcode><br />
<br />
An entire typescript would be defined as;<br />
<br />
<texcode><br />
\definefontfeature[latin-smallcaps][smallcaps][script=latn]<br />
<br />
\starttypescript [serif] [warnockpro]<br />
\setups[font:fallback:sans]<br />
\definefontsynonym [WarnockPro-Regular] [name:WarnockPro-Regular] <br />
\definefontsynonym [WarnockPro-Bold] [name:WarnockPro-Bold] <br />
\definefontsynonym [WarnockPro-Italic] [name:WarnockPro-It] <br />
\definefontsynonym [WarnockPro-BoldItalic] [name:WarnockPro-BoldIt] <br />
\stoptypescript<br />
<br />
\starttypescript [serif] [warnockpro]<br />
\definefontsynonym [Serif] [WarnockPro-Regular] [features=default]<br />
\definefontsynonym [SerifBold] [WarnockPro-Bold] [features=default]<br />
\definefontsynonym [SerifItalic] [WarnockPro-Italic] [features=default]<br />
\definefontsynonym [SerifBoldItalic] [WarnockPro-BoldItalic] [features=default]<br />
\definefontsynonym [SerifCaps] [Serif] [features=latin-smallcaps]<br />
\stoptypescript<br />
<br />
\definetypeface[adobe][rm][serif][warnockpro][default]<br />
\setupbodyfont[adobe,11pt]<br />
<br />
</texcode><br />
<br />
[[Category:Fonts]]<br />
[[Category:International]]</div>Wolfgang Schusterhttps://wiki.contextgarden.net/index.php?title=Fonts_in_LuaTeX&diff=9826Fonts in LuaTeX2009-06-15T18:42:34Z<p>Wolfgang Schuster: missing </code></p>
<hr />
<div>{{note|This page is not finished yet}}<br />
<br />
'''Please, someone, fill this page !'''<br />
<br />
'''This page is beeing regorganized'''<br />
<br />
= Getting access to the system fonts =<br />
<br />
LuaTeX can use non-TeX fonts (in OpenType, TrueType or Type1 format) directly.<br />
<br />
The first time that you run<br />
<br />
context myfile.tex<br />
<br />
on a file that uses such non-traditional fonts (which is probably always), the actual fonts themselves have to be loaded in luatex's embedded section of fontforge to extract their metric information. This removes the need for tfm and vf files on your disk, but it is also a somewhat lengthy and often memory-hungry process.<br />
<br />
That is why the results of that internal preprocessing are also saved inside the texmf cache. Future runs using the same font (not just this file, but all files using that particular font) can then use the cached version of the metrics instead. <br />
<br />
== Building the font database ==<br />
<br />
You need to specify where the fonts should be looked for, by setting the <code>OSFONTDIR</code> environment variable. For instance,<br />
set OSFONTDIR=c:/windows/fonts/<br />
if the fonts should be found in <code>c:/windows/fonts/</code>; or<br />
export OSFONTDIR="/usr/local/share/fonts;$HOME/.fonts"<br />
if the fonts should be found in both <code>/usr/local/share/fonts</code> and <code>$HOME/.fonts</code>.<br />
<br />
The font database will then be automatically generated in the next run of <code>context</code><br />
<br />
You can also generate it manually by typing <br />
mtxrun --script font --reload<br />
or equally<br />
mtxrun --script fonts --reload<br />
<br />
The output should look like<br />
MTXrun | fontnames: identifying tree font files with suffix otf<br />
MTXrun | fontnames: identifying tree font files with suffix OTF<br />
MTXrun | fontnames: 331 tree files identified, 332 hash entries added, runtime 7.653 seconds<br />
MTXrun | fontnames: identifying tree font files with suffix ttf<br />
MTXrun | fontnames: identifying tree font files with suffix TTF<br />
MTXrun | fontnames: 17 tree files identified, 14 hash entries added, runtime 4.645 seconds<br />
...<br />
MTXrun | fontnames: 94 system files identified, 94 hash entries added, runtime 0.554 seconds<br />
MTXrun | fontnames: 3837 files read, 3342 normal and 49 extra entries added, 5 rejected, 3386 valid<br />
<br />
<br />
<br />
== Querying the font database ==<br />
<br />
The command<br />
mtxrun --script fonts --list<br />
will return the whole entries of the font database as a list, such as<br />
<br />
...<br />
warnockprobold WarnockPro-Bold E:/Fonts/Warnock Pro/WarnockPro-Bold.otf<br />
warnockproboldcapt WarnockPro-BoldCapt E:/Fonts/Warnock Pro/WarnockPro-BoldCapt.otf<br />
warnockprobolddisp WarnockPro-BoldDisp E:/Fonts/Warnock Pro/WarnockPro-BoldDisp.otf<br />
warnockproboldit WarnockPro-BoldIt E:/Fonts/Warnock Pro/WarnockPro-BoldIt.otf<br />
warnockprobolditcapt WarnockPro-BoldItCapt E:/Fonts/Warnock Pro/WarnockPro-BoldItCapt.otf<br />
warnockprobolditdisp WarnockPro-BoldItDisp E:/Fonts/Warnock Pro/WarnockPro-BoldItDisp.otf<br />
warnockprobolditsubh WarnockPro-BoldItSubh E:/Fonts/Warnock Pro/WarnockPro-BoldItSubh.otf<br />
warnockproboldsubh WarnockPro-BoldSubh E:/Fonts/Warnock Pro/WarnockPro-BoldSubh.otf<br />
...<br />
<br />
You can query the database against a particular pattern. For instance,<br />
mtxrun --script fonts --list --pattern=Delicious*<br />
will return<br />
deliciousbold Delicious-Bold /usr/local/share/fonts/d/delicious_bold.otf<br />
deliciousbolditalic Delicious-BoldItalic /usr/local/share/fonts/d/delicious_bolditalic.otf<br />
deliciousheavy Delicious-Heavy /usr/local/share/fonts/d/delicious_heavy.otf<br />
deliciousitalic Delicious-Italic /usr/local/share/fonts/d/delicious_italic.otf<br />
deliciousroman Delicious-Roman /usr/local/share/fonts/d/delicious_roman.otf<br />
delicioussmallcaps Delicious-SmallCaps /usr/local/share/fonts/d/delicious_smallcaps.otf<br />
<br />
You can get useful informations about your fonts by using the <code>--info</code> option. For instance,<br />
mtxrun --script fonts --list --info --pattern=Delicious*Roman<br />
will return<br />
MTXrun | fontname: deliciousroman<br />
MTXrun | fullname: Delicious-Roman<br />
MTXrun | filename: /usr/local/share/fonts/d/delicious_roman.otf<br />
MTXrun |<br />
MTXrun | gpos features:<br />
MTXrun |<br />
MTXrun | feature script languages<br />
MTXrun |<br />
MTXrun | kern latn dflt<br />
MTXrun |<br />
MTXrun | gsub features:<br />
MTXrun |<br />
MTXrun | feature script languages<br />
MTXrun |<br />
MTXrun | tlig all all<br />
MTXrun | trep all all<br />
<br />
== Installing new fonts ==<br />
<br />
After installing new fonts, the font database must be rebuilt for LuaTeX to access them.<br />
<br />
In current versions of Mark IV (earlier than July 2008) this is automatically done whenever a named font cannot be found.<br />
<br />
You only have to do the reload manually when you have installed updates to already installed fonts that cause the font and/or file names to change. <br />
This normally only happens for fonts that are still in development like [[TeX Gyre]] and [[Latin Modern]].<br />
<br />
You can rebuild the database manually, using the already-mentioned command<br />
mtxrun --script fonts --reload<br />
<br />
Alternatively, you can turn off the automatic rebuild of the database, by setting either of<br />
MTX.FONTS.AUTOLOAD<br />
MTX_FONTS_AUTOLOAD<br />
to "no".<br />
<br />
== References ==<br />
<br />
[http://context.aanhet.net/svn/contextman/context-reference/en/co-fonts.pdf The new manual chapter on fonts]<br />
<br />
= Using fonts =<br />
<br />
Handling fonts in LuaTeX can be done<br />
* in a simple but limited way, using the <code>simplefonts</code> module;<br />
* in the standard way, using [[TypeScripts]]<br />
<br />
== With the <code>simplefonts</code> module ==<br />
<br />
<code>simplefonts</code> is a third-party module written by Wolfgang Schuster.<br />
<br />
It simplifies the use of fonts in LuaTeX by<br />
* freeing the user from writing or using [[TypeScripts]];<br />
* offering an interface similar to the [http://www.ctan.org/tex-archive/macros/xetex/latex/fontspec/ fontspec package for XeTeX]<br />
<br />
For instance, assuming the [http://www.josbuivenga.demon.nl/delicious.html Delicious fonts] are properly installed and recognized by ConTeXt, you can simply write:<br />
<br />
<texcode><br />
\usemodule[simplefonts] % load the module<br />
\setmainfont[Delicious] % set Delicious as main (serif) font<br />
<br />
\starttext<br />
\rm\tf roman \it italic \bf bold \bi bolditalic \sc smallcaps<br />
\stoptext<br />
</texcode><br />
<br />
== The standard way: Typescripts ==<br />
<br />
=== Installing typescripts ===<br />
<br />
Installing typescripts consists in the following:<br />
<br />
1. Copy the typescript files into either <br />
<texcode>$TEXMF/tex/texmf-fonts/tex/context/user<br />
$TEXMF/tex/texmf-project/tex/context/user</texcode><br />
2. Run <code>context --generate</code><br />
<br />
By convention, typescript files are named like <code>type-(fontname|foundry).tex</code>. <br />
<br />
It may happen that some <code>type-xx.tex</code> typescript file depends on mkiv-specific code located in a matching <code>type-xx.mkiv</code> file. In this case, both files need to be installed.<br />
<br />
=== Loading typescripts ===<br />
<br />
A typescript file named <code>type-xx.tex</code> should be loaded using<br />
\usetypescriptfile[type-xx]<br />
<br />
An alternative way is<br />
\usetypefile[xx]<br />
where ConTeXt prepends <code>type-</code> when it loads the file; but <br />
<cmd>usetypescriptfile</cmd> is the preferred command because it takes care of the<br />
<cmd>starttypescriptcollection</cmd>/<cmd>stoptypescriptcollection</cmd> environments.<br />
<br />
=== Where to find existing typescripts ===<br />
<br />
Each of the typescripts below defines a keyword to use with <cmd>setupbodyfont</cmd>. Usually this is the same as the name of the typescript, but there is one exception (<code>antykwa-torunska</code>)<br />
<br />
* Latin Modern (typescript name: <code>modern</code>; this is the default font set)<br />
* Latin Modern variant (ts name: <code>modernvariable</code>; LM variable typewriter for serif)<br />
* Postscript (ts name: <code>postscript</code>; Termes for serif, Heros for sans, Cursor for mono)<br />
* Antykwa Toruńska (ts name: <code>antykwa-torunska</code>; only serif; defines <tt>antykwa</tt> as keyword for <cmd>setupbodyfont</cmd>)<br />
* Iwona (ts name: <code>iwona</code>; only sans serif)<br />
* Iwona Light, Medium and Heavy (ts names: <code>iwona-light</code>, <code>iwona-medium</code>, <code>iwona-heavy</code>; only sans; the medium variant is a small bit heavier than a "regular" one)<br />
* Pagella (ts name: <code>palatino</code>; only serif)<br />
* Termes (ts name: <code>times</code>; only serif, Heros for sans)<br />
<br />
== Usage example ==<br />
<br />
<texcode><br />
\usetypescript[palatino]<br />
\setupbodyfont[palatino,18pt]<br />
<br />
\starttext<br />
Hello world, I'm Pagella!<br />
\stoptext<br />
</texcode><br />
<br />
The first line seems to order ConTeXt to "install" (for the current file) the given typescript (it accepts what I have earlier called a "typescript name"). The last one starts using it (you may omit the size if you are satisfied with the default).<br />
<br />
== Combining predefined fonts in your own typescripts ==<br />
<br />
It is also possible to combine fonts from the TeX Gyre collection in your own typescripts. The example below combines Bonum (Bookman) roman, Adventor (AvantGarde) for sans serif, Cursor (Courier) for teletype, and Euler for math. The <code>rscale=...</code> option ensures that all fonts have the same x-height. (You can lookup the relative x-heigt of a font using fontforge.)<br />
<br />
<texcode><br />
\starttypescript [Bonum]<br />
\definetypeface [Bonum] [rm] [serif] [bonum] [default]<br />
\definetypeface [Bonum] [ss] [sans] [adventor] [default] [rscale=0.887]<br />
\definetypeface [Bonum] [tt] [mono] [cursor] [default] [rscale=1.163]<br />
\definetypeface [Bonum] [mm] [math] [euler] [default] [rscale=1.050]<br />
\stoptypescript<br />
<br />
\usetypescript[Bonum]<br />
\setupbodyfont[Bonum,12pt]<br />
<br />
\starttext<br />
Hello world, I'm Bonum!<br />
\stoptext<br />
</texcode><br />
<br />
= Old contents =<br />
<br />
* [[TrueType fonts in luaTeX]]<br />
<br />
==== Good ol' typescripts ====<br />
<br />
Of course, Mark IV allows you to use typescripts as you've always done; for example:<br />
<br />
<texcode><br />
\usetypescript[palatino]<br />
\setupbodyfont[palatino,12pt]<br />
effe fietsen 2: \input tufte $\sqrt{2}$ \eogonek<br />
<br />
\sc effe fietsen 2: \input tufte $\sqrt{2}$ \eogonek<br />
</texcode><br />
<br />
That's as simple as using a traditional ConTeXt typescript!<br />
<br />
But ... how is it any different, then? Well, the difference is that in Mark IV, we can use an Opentype font directly, so that what is done here: when we want to use Palatino, the [[TeX Gyre]] equivalent (“Pagella”) is called and we can use its Opentype “features”; read on.<br />
<br />
==== Opentype features ====<br />
<br />
A “feature”, in the Opentype jargon, is a set of rules describing changes in the appearance of the text. Hmm, that's not very precise. Let's show some examples. First of all, you have to know that features are referred to by 4-letter tags, and you will see this a lot. One of them is ‘smcp‘, for “small caps“. Let's consider the following Mark IV-only code:<br />
<br />
<texcode><br />
\definefontfeature[smallcaps][language=DFLT,script=latn,smcp=yes]<br />
\font\palasmallcaps=texgyrepagella-regular*smallcaps<br />
\palasmallcaps This is a text in small capitals.<br />
</texcode><br />
<br />
Here you basically define a (Mark IV) feature with the name ”smallcaps”, and associate it with the (Opentype) feature “smcp”. You have to specify which script you want to use it with; scripts in Opentype are also tagged with four letters, and “latn” is of course Latin.<br />
<br />
Then you define a TeX font with that feature.<br />
<br />
You can see what features are defined in a particular font with the following bit of code<br />
<br />
<texcode><br />
\ctxlua<br />
{<br />
fontname = 'texgyrepagella-regular.otf'<br />
<br />
--[[ First read the font data.<br />
This makes heavy use of some of the Mark IV code]]<br />
tfmdata = fonts.tfm.read_and_define("file:" .. fontname, 655360)<br />
font = tfmdata.shared.otfdata<br />
if font<br />
then<br />
gsubfeatures = fonts.otf.analyze_features(font.gsub)<br />
gposfeatures = fonts.otf.analyze_features(font.gpos)<br />
end<br />
<br />
if gsubfeatures then<br />
table.sort(gsubfeatures) % We want our list sorted alphabetically!<br />
tex.sprint("\\rm GSUB features: \\tt ") % Beware: you don't want \rm to be interpreted by lua (\rm would yield carriage return + letter m)!<br />
for _, feat in ipairs(gsubfeatures)<br />
do tex.sprint(feat) tex.sprint(' ')<br />
end<br />
else tex.sprint("\\rm No GSUB features")<br />
end<br />
tex.sprint("\\par")<br />
<br />
if gposfeatures then<br />
tex.sprint("\\rm GPOS features: \\tt ")<br />
table.sort(gposfeatures)<br />
for _, feat in ipairs(gposfeatures)<br />
do tex.sprint(feat) tex.sprint(' ')<br />
end<br />
else tex.sprint("\\rm No GPOS features")<br />
end<br />
}<br />
</texcode><br />
<br />
It prints the list on the page. You'll notice there are two sets of features, each one of them defined in a different table of the Opentype font: the <code>GSUB</code> table (for Glyph SUBstitution) gives rules for replacing glyphs in certains circumstances (think of ligatures: f + i -> fi); the <code>GPOS</code> table (Glyph POSititioning) gives rules for moving glyphs (think of kerning: A + V -> A <kerning> V).<br />
<br />
Incidentally, the above code gives some basic examples of LuaTeX programming, a mixture of both Lua and TeX programming with some special features (features in the general sense, not the Opentype one :-).<br />
<br />
==== A (Complete) Typescript Example ====<br />
<br />
<texcode><br />
\starttypescript [sans] [franklin]<br />
<br />
\definefontsynonym [FranklinBookRegular] [name:FranklinGothicBookITC-Regular] [features=default]<br />
\definefontsynonym [FranklinMediumRegular] [name:FranklinGothicMediumITC-Regular] [features=default]<br />
\definefontsynonym [FranklinDemiRegular] [name:FranklinGothicDemiITC-Regular] [features=default]<br />
\definefontsynonym [FranklinHeavyRegular] [name:FranklinGothicHeavyITC-Regular] [features=default]<br />
<br />
\definefontsynonym [FranklinBookItalic] [name:FranklinGothicBookITC-Italic] [features=default]<br />
\definefontsynonym [FranklinDemiItalic] [name:FranklinGothicMediumITC-Italic] [features=default]<br />
\definefontsynonym [FranklinHeavyItalic] [name:FranklinGothicDemiITC-Italic] [features=default]<br />
\definefontsynonym [FranklinMediumItalic] [name:FranklinGothicHeavyITC-Italic] [features=default]<br />
<br />
\stoptypescript<br />
<br />
\starttypescript [sans] [franklin]<br />
<br />
\definefontsynonym [Sans] [FranklinBookRegular] [features=default]<br />
\definefontsynonym [SansItalic] [FranklinBookItalic] [features=default]<br />
\definefontsynonym [SansBold] [FranklinDemiRegular] [features=default]<br />
\definefontsynonym [SansBoldItalic] [FranklinDemiItalic] [features=default]<br />
\definefontsynonym [SansSlanted] [SansItalic] [features=default]<br />
\definefontsynonym [SansBoldSlanted] [SansBoldItalic] [features=default]<br />
\definefontsynonym [SansCaps] [Sans] [features=smallcaps]<br />
<br />
\stoptypescript<br />
<br />
\definetypeface[franklin][rm][sans][franklin][default]<br />
\definetypeface[franklin][ss][sans][franklin][default]<br />
\definetypeface[franklin][tt][mono][modern] [default][rscale=1.12]<br />
\definetypeface[franklin][mm][math][iwona] [default][rscale=1.02]<br />
<br />
\setupbodyfont[franklin,ss,10pt]<br />
</texcode><br />
<br />
<br />
<br />
Just the simplest way to use an otf font — or any font that does appear in <tt>mtxrun --script font --list</tt> — in all the document.<br />
<br />
I’m stick here :<br />
<br />
\definefontfeature [myfontfeature] [method=node, kern=yes, OTHER_FEATURE_COMMA_SEPERATED]<br />
\definefontsynonym [MyFontRegular] [name:TheFontName-Regular][features=myfontfeature]<br />
\definedfont [MyFontRegular at 16pt]<br />
<br />
This doesn’t run for my title which use « \tfc », only for the body of the text.<br />
<br />
*\definefontfeature<br />
**[myfontfeature] : you can use the name you want. It will be use at the next line ;<br />
**the fonts feature can be found with <tt>otfinfo -f TheFontFile.otf</tt>.<br />
*\definefontsynonym :<br />
**[MyFontRegular] : you can use the name you want. It will be use at the next line ;<br />
**The name after <tt>name:</tt> is the name given by <tt>mtxrun --script font --list</tt><br />
**The « name: » part can be replaced by <tt>file:TheFontFile.otf</tt><br />
<br />
<br />
== Example ==<br />
<br />
<br />
Now to access, say the regular warnock font, the following are valid. And I ought to mention that Hans recommends the first http://article.gmane.org/gmane.comp.tex.context/43685.<br />
<br />
<texcode><br />
% Hans recommends this format;<br />
\definefontsynonym [WarnockPro-Regular] [name:warnockproregular] <br />
</texcode><br />
<br />
and<br />
<br />
<texcode><br />
\definefontsynonym [WarnockPro-Regular] [name:WarnockPro-Regular]<br />
</texcode><br />
<br />
An entire typescript would be defined as;<br />
<br />
<texcode><br />
\definefontfeature[latin-smallcaps][smallcaps][script=latn]<br />
<br />
\starttypescript [serif] [warnockpro]<br />
\setups[font:fallback:sans]<br />
\definefontsynonym [WarnockPro-Regular] [name:WarnockPro-Regular] <br />
\definefontsynonym [WarnockPro-Bold] [name:WarnockPro-Bold] <br />
\definefontsynonym [WarnockPro-Italic] [name:WarnockPro-It] <br />
\definefontsynonym [WarnockPro-BoldItalic] [name:WarnockPro-BoldIt] <br />
\stoptypescript<br />
<br />
\starttypescript [serif] [warnockpro]<br />
\definefontsynonym [Serif] [WarnockPro-Regular] [features=default]<br />
\definefontsynonym [SerifBold] [WarnockPro-Bold] [features=default]<br />
\definefontsynonym [SerifItalic] [WarnockPro-Italic] [features=default]<br />
\definefontsynonym [SerifBoldItalic] [WarnockPro-BoldItalic] [features=default]<br />
\definefontsynonym [SerifCaps] [Serif] [features=latin-smallcaps]<br />
\stoptypescript<br />
<br />
\definetypeface[adobe][rm][serif][warnockpro][default]<br />
\setupbodyfont[adobe,11pt]<br />
<br />
</texcode><br />
<br />
[[Category:Fonts]]<br />
[[Category:International]]</div>Wolfgang Schusterhttps://wiki.contextgarden.net/index.php?title=User:Wolfgang_Schuster&diff=9823User:Wolfgang Schuster2009-06-10T21:18:20Z<p>Wolfgang Schuster: brochure: missing \unprotect</p>
<hr />
<div>== Sample Code ==<br />
<br />
=== Full page figures ===<br />
<br />
The following macro allows me to include figures in my document and adjust them to have the size of a normal page.<br />
<br />
<texcode><br />
\unprotect<br />
<br />
\definesystemvariable{xx}<br />
<br />
\def\fullpagebox<br />
{\dosingleempty\dofullpagebox}<br />
<br />
\def\dofullpagebox[#1]%<br />
{\bgroup<br />
\getparameters[\??xx][\c!nx=1,\c!ny=1,#1]%<br />
\dowithnextbox<br />
{\!!widtha\dimexpr\paperwidth/\nextboxwd\relax<br />
\!!widthb\dimexpr\paperheight/\nextboxht\relax<br />
\ifdim\!!widtha>\!!widthb<br />
\setbox\nextbox\vbox\!!to\@@xxny\paperheight<br />
{\vss\expanded{\scale[\c!width=\@@xxnx\paperwidth]{\flushnextbox}}\vss}%<br />
\else<br />
\setbox\nextbox\hbox\!!to\@@xxnx\paperwidth<br />
{\hss\expanded{\scale[\c!height=\@@xxny\paperheight]{\flushnextbox}}\hss}%<br />
\fi<br />
\setbox\nextbox\hbox{\clip[\c!width=\@@xxnx\paperwidth,\c!height=\@@xxny\paperheight]{\flushnextbox}}%<br />
\startTEXpage<br />
\flushnextbox<br />
\stopTEXpage<br />
\egroup}%<br />
\hbox}<br />
<br />
\def\fullpagefigure<br />
{\dodoubleempty\dofullpagefigure}<br />
<br />
\def\dofullpagefigure[#1][#2]%<br />
{\ifsecondargument<br />
\fullpagebox[#1]{\externalfigure[#2]}%<br />
\else<br />
\fullpagebox[]{\externalfigure[#1]}%<br />
\fi}<br />
<br />
\protect<br />
<br />
\starttext<br />
<br />
\fullpagefigure[image]<br />
<br />
\fullpagefigure[nx=2][image]<br />
<br />
\fullpagefigure[ny=2][image]<br />
<br />
\stoptext<br />
</texcode><br />
<br />
=== Flashcards ===<br />
<br />
For tests and vocabulary it is usefull to use flashcards for learning.<br />
<br />
<texcode><br />
\unprotect<br />
<br />
\installpagearrangement FLASHCARD<br />
{\dosetuparrangement\@@ppnx\@@ppny{\numexpr\@@ppxy*2\relax}%<br />
{\numexpr\@@ppnx+\plusone\relax}{\numexpr\@@ppny+\plusone\relax}%<br />
\pusharrangedpageFLASHCARD\poparrangedpagesAB\relax}<br />
<br />
\newcounter\arrangedpageshiftX<br />
\newcounter\arrangedpageshiftY<br />
<br />
\def\dopusharrangedpageFLASHCARD#1%<br />
{\ifnum\arrangedpageshiftX<\arrangedpageX<br />
\ifodd\arrangedpageN<br />
\handlearrangedpageXandY{#1}0\arrangedpageshiftX\arrangedpageshiftY\arrangedpageA<br />
\else<br />
\handlearrangedpageXandY{#1}0{\numexpr\@@ppnx-\arrangedpageshiftX-1\relax}\arrangedpageshiftY\arrangedpageB<br />
\doglobal\increment\arrangedpageshiftX<br />
\fi<br />
\fi<br />
\ifnum\arrangedpageshiftX=\@@ppnx<br />
\doglobal\newcounter\arrangedpageshiftX<br />
\doglobal\increment\arrangedpageshiftY<br />
\fi}<br />
<br />
\def\pusharrangedpageFLASHCARD#1%<br />
{\doglobal\increment\arrangedpageN<br />
\reportarrangedpage\arrangedpageN<br />
\ifnum\arrangedpageN=\numexpr\@@ppxy*2\relax<br />
\dopusharrangedpageFLASHCARD{#1}%<br />
\doglobal\newcounter\arrangedpageshiftX<br />
\doglobal\newcounter\arrangedpageshiftY<br />
\poparrangedpages<br />
\else<br />
\dopusharrangedpageFLASHCARD{#1}%<br />
\fi}<br />
<br />
\protect<br />
</texcode><br />
<br />
To create cards you have to select a number of rows and columns and set the papersize to a value small enough to fit all cards on one sheet of paper.<br />
<br />
<texcode><br />
\setuppapersize[A7][A3,landscape]<br />
\setuppaper [nx=4,ny=2]<br />
\setuparranging[FLASHCARD]<br />
\setuplayout [location=middle,marking=on]<br />
<br />
\setupbackgrounds[page][frame=on]<br />
<br />
\starttext<br />
<br />
\dorecurse{20}<br />
{\startstandardmakeup[align=middle]<br />
Front side \recurselevel<br />
\stopstandardmakeup<br />
\startstandardmakeup[align=middle]<br />
Back side \recurselevel<br />
\stopstandardmakeup}<br />
<br />
\stoptext<br />
</texcode><br />
<br />
=== Brochures ===<br />
<br />
<texcode><br />
\unprotect<br />
<br />
\installpagearrangement LEAFLET<br />
{\dosetuparrangement\@@ppnx1{\numexpr\@@ppnx*2\relax}{\numexpr\@@ppnx+\plusone\relax}2%<br />
\pusharrangedpageLEAFLET\poparrangedpagesAB\relax}<br />
<br />
\def\pusharrangedpageLEAFLET#1%<br />
{\doglobal\increment\arrangedpageN<br />
\reportarrangedpage\arrangedpageN<br />
\ifnum\arrangedpageN=\plusone<br />
\handlearrangedpageXandY{#1}0{\numexpr\@@ppnx-1\relax}0\arrangedpageA<br />
\else\ifnum\arrangedpageN>\numexpr\@@ppnx+1\relax<br />
\handlearrangedpageXandY{#1}0{\numexpr\arrangedpageN-\@@ppnx-2\relax}0\arrangedpageA<br />
\else<br />
\handlearrangedpageXandY{#1}0{\numexpr\arrangedpageN-2\relax}0\arrangedpageB<br />
\fi\fi<br />
\ifnum\arrangedpageN=\arrangedpageT<br />
\poparrangedpages<br />
\fi}<br />
<br />
\protect<br />
</texcode><br />
<br />
<texcode><br />
\setuppapersize[DL][A3,landscape]<br />
\setuppaper [nx=3]<br />
\setuparranging[LEAFLET]<br />
\setuplayout [location=middle,marking=on]<br />
<br />
\setupbackgrounds[page][frame=on]<br />
<br />
\starttext<br />
<br />
\dorecurse{6}<br />
{\startstandardmakeup[align=middle]<br />
\ssd Page \recurselevel<br />
\stopstandardmakeup}<br />
<br />
\stoptext<br />
</texcode><br />
<br />
=== Dictionary entries in XML-format ===<br />
<br />
Just a example how to use XML to store and access information.<br />
<br />
In my example the content for the dictionary is stored in a buffer,<br />
to use a external file for the data the commented lines for MkII<br />
and MkIV are required.<br />
<br />
<texcode><br />
% engine=pdftex<br />
<br />
\startbuffer[lexicon]<br />
</texcode><br />
<xmlcode><br />
<lexicon><br />
<entry name='LaTeX'><br />
<name>&latex;</name><br />
<description>Macro package from Leslie Lamport.</description><br />
</entry><br />
<entry name='ConTeXt'><br />
<name>&context;</name><br />
<description>Macro package from Hans Hagen.</description><br />
</entry><br />
<entry name='TeX'><br />
<name>&tex;</name><br />
<description>the program from von Donald E. Knuth.</description><br />
</entry><br />
<entry name='Pragma Ade'><br />
<name>PRAGMA Advanced Document Engineering</name><br />
<description>Hans Hagens company.</description><br />
</entry><br />
</lexicon><br />
</xmlcode><br />
<texcode><br />
\stopbuffer<br />
</texcode><br />
<br />
This is the MkII code to process the data above.<br />
<br />
<texcode><br />
\definesorting[lexiconentry][lexicon]<br />
<br />
\setupsorting<br />
[lexiconentry]<br />
[criterium=all,<br />
command=\placelexiconentry]<br />
<br />
\definedescription<br />
[lexicon]<br />
[width=broad,<br />
hang=1]<br />
<br />
\def\placelexiconentry#1%<br />
{\bgroup<br />
\enableXML<br />
\expanded{\flushXMLelement{name:#1}}%<br />
\egroup}<br />
<br />
\defineXMLentities [tex] {tex} {\TeX}<br />
\defineXMLentities [latex] {latex} {\LaTeX}<br />
\defineXMLentities [context] {context} {\ConTeXt}<br />
<br />
\defineXMLenvironment [entry]<br />
{\defineXMLsave[name]<br />
\defineXMLsave[description]}<br />
{\startlexicon{\XMLflush{name}}<br />
\XMLflush{description}<br />
\stoplexicon}<br />
<br />
\startXMLmapping[lexicon:load]<br />
<br />
\defineXMLenvironmentsave [entry] [name=]<br />
{}<br />
{\edef\currentLEXICONENTRY{\XMLop{name}}%<br />
\gsaveXMLdatainelement{name:\currentLEXICONENTRY}{entry}{entry}%<br />
\expanded{\lexiconentry[lexicon:\XMLop{name}]{\XMLop{name}}}%<br />
\setbox\scratchbox\hbox{\getvalue{lexicon:\XMLop{name}}}}<br />
<br />
\stopXMLmapping<br />
<br />
\def\loaddata<br />
{\dosingleargument\doloaddata}<br />
<br />
\def\doloaddata[#1]%<br />
{\bgroup<br />
\endlinechar\minusone<br />
\startXMLmapping[lexicon:load]%<br />
%\expanded{\processXMLfilegrouped{#1}}%<br />
\expanded{\processXMLbuffer[#1]}%<br />
\stopXMLmapping<br />
\egroup}<br />
<br />
\starttext<br />
\loaddata[lexicon]<br />
\placelistoflexicon<br />
\stoptext<br />
</texcode><br />
<br />
In MkIV we have direct access to the data can process the content<br />
without the previous step to save everything in macros.<br />
<br />
<texcode><br />
\definesorting[lexiconentry][lexicon]<br />
<br />
\setupsorting<br />
[lexiconentry]<br />
[criterium=all,<br />
command=\placelexiconentry]<br />
<br />
\startxmlsetups xml:lexicon<br />
\xmlsetsetup{\xmldocument}{entry}{*}<br />
\stopxmlsetups<br />
<br />
\xmlregistersetup{xml:lexicon}<br />
<br />
\startxmlsetups entry<br />
\expanded{\lexiconentry[lexicon:\xmlatt{#1}{name}]{\xmlatt{#1}{name}}}<br />
\setbox\scratchbox\hbox{\getvalue{lexicon:\xmlatt{#1}{name}}}<br />
\stopxmlsetups<br />
<br />
\definedescription<br />
[lexicon]<br />
[width=broad,<br />
hang=1]<br />
<br />
\def\placelexiconentry#1%<br />
{\bgroup<br />
\enableXML<br />
\xmlfilter{lexicon:process}{/lexicon/entry[@name='#1']}<br />
\egroup}<br />
<br />
\defineXMLentities [tex] {tex} {\TeX}<br />
\defineXMLentities [latex] {latex} {\LaTeX}<br />
\defineXMLentities [context] {context} {\ConTeXt}<br />
<br />
\defineXMLenvironment [entry]<br />
{\defineXMLsave[name]<br />
\defineXMLsave[description]}<br />
{\startlexicon{\XMLflush{name}}<br />
\XMLflush{description}<br />
\stoplexicon}<br />
<br />
\xmlprocessbuffer{lexicon:load}{lexicon}{}<br />
<br />
\starttext<br />
\xmlloadbuffer{lexicon:process}{lexicon}<br />
\placelistoflexicon<br />
\stoptext<br />
</texcode><br />
<br />
<br />
== Feature Requests ==<br />
<br />
* <code>grid=yes</code> option for <code>\definelayout</code>,<br />
* temporary user variable for privat macros (see above),<br />
* macro <code>\defineuvervariable{...}</code> to define namespaces for third party modules.<br />
* New version of the <cmd>startfigure</cmd> environment<br />
<br />
<br />
==Links==<br />
<br />
* http://www.ruhr-uni-bochum.de/www-rz/schwanbs/TeX/<br />
* http://wolfgang.schuster.googlepages.com/<br />
* http://tug.ctan.org/tex-archive/macros/latex/contrib/leaflet/</div>Wolfgang Schusterhttps://wiki.contextgarden.net/index.php?title=Filecontents&diff=9652Filecontents2009-04-17T08:44:34Z<p>Wolfgang Schuster: messages</p>
<hr />
<div>LaTeX provides a <code>filecontent</code> environment to embed text in your document<br />
which is written to a external document when your process it. The filename is given with<br />
the argument for the environment.<br />
<br />
You could define a environment for the same effect with the buffer mechanism, the code<br />
for such a environment is:<br />
<br />
<texcode><br />
\unprotect<br />
<br />
\definemessageconstant {filecontents}<br />
<br />
\startmessages all library: filecontents<br />
title: filecontents<br />
1: Overwriting file --<br />
2: Writing file --<br />
\stopmessages<br />
<br />
\def\startfilecontents<br />
{\begingroup<br />
\protectbuffersfalse<br />
\dostartfilecontents}<br />
<br />
\def\dostartfilecontents[#1]%<br />
{\doiffileexistselse{#1}<br />
{\showmessage\m!filecontents{1}{#1}}<br />
{\showmessage\m!filecontents{2}{#1}}%<br />
\beforesplitstring#1\at.\to\filename<br />
\aftersplitstring #1\at.\to\extension<br />
\let\f!temporaryextension\extension<br />
\dostartbuffer[\filename][startfilecontents][stopfilecontents]}<br />
<br />
\def\stopfilecontents<br />
{\doifmode{mkiv}{\savebuffer[\filename]\ctxlua{file.copy("\jobname-\filename.tmp","\filename.\f!temporaryextension")}}%<br />
\endgroup}<br />
<br />
\protect<br />
</texcode><br />
<br />
You could use this environment in your document in the following way.<br />
<br />
<texcode><br />
\startfilecontents[song.txt]<br />
If I could choose my paradise,<br />
And please myself with choice of bliss,<br />
Then I would have your soft blue eyes<br />
And rosy little mouth to kiss!<br />
Your lips, as smooth and tender, child,<br />
As rose-leaves in a coppice wild.<br />
<br />
If fate bade choose some sweet unrest,<br />
To weave my troubled life a snare,<br />
Then I would say "her maiden breast<br />
And golden ripple of her hair;"<br />
And weep amid those tresses, child,<br />
Contented to be thus beguiled.<br />
<br />
(Thomas Asche - No and Yes)<br />
\stopfilecontents<br />
</texcode></div>Wolfgang Schusterhttps://wiki.contextgarden.net/index.php?title=Filecontents&diff=9595Filecontents2009-03-29T21:56:50Z<p>Wolfgang Schuster: Implementation in ConTeXt</p>
<hr />
<div>LaTeX provides a <code>filecontent</code> environment to embed text in your document<br />
which is written to a external document when your process it. The filename is given with<br />
the argument for the environment.<br />
<br />
You could define a environment for the same effect with the buffer mechanism, the code<br />
for such a environment is:<br />
<br />
<texcode><br />
\unprotect<br />
<br />
\def\startfilecontents<br />
{\begingroup<br />
\protectbuffersfalse<br />
\dostartfilecontents}<br />
<br />
\def\dostartfilecontents[#1]%<br />
{\beforesplitstring#1\at.\to\filename<br />
\aftersplitstring #1\at.\to\extension<br />
\let\f!temporaryextension\extension<br />
\dostartbuffer[\filename][startfilecontents][stopfilecontents]}<br />
<br />
\def\stopfilecontents<br />
{\doifmode{mkiv}{\savebuffer[\filename]\ctxlua{file.copy("\jobname-\filename.tmp","\filename.\f!temporaryextension")}}%<br />
\endgroup}<br />
<br />
\protect<br />
</texcode><br />
<br />
You could use this environment in your document in the following way.<br />
<br />
<texcode><br />
\startfilecontents[song.txt]<br />
If I could choose my paradise,<br />
And please myself with choice of bliss,<br />
Then I would have your soft blue eyes<br />
And rosy little mouth to kiss!<br />
Your lips, as smooth and tender, child,<br />
As rose-leaves in a coppice wild.<br />
<br />
If fate bade choose some sweet unrest,<br />
To weave my troubled life a snare,<br />
Then I would say "her maiden breast<br />
And golden ripple of her hair;"<br />
And weep amid those tresses, child,<br />
Contented to be thus beguiled.<br />
<br />
(Thomas Asche - No and Yes)<br />
\stopfilecontents<br />
</texcode></div>Wolfgang Schusterhttps://wiki.contextgarden.net/index.php?title=Letter&diff=9584Letter2009-03-26T00:41:48Z<p>Wolfgang Schuster: new link to manual</p>
<hr />
<div>< [[Modules]] | [[User:Wolfgang_Schuster]] ><br />
<br />
{{note|This module is still in development}}<br />
<br />
== Introduction ==<br />
<br />
The letter module provides a interface to write different kinds of correspondence<br />
with the support for different styles and extensions.<br />
<br />
== Example ==<br />
<br />
<texcode><br />
\usemodule[letter]<br />
<br />
\starttext<br />
<br />
\startletter<br />
[opening={Dear Reader,},<br />
closing={Best regards,},<br />
signature={The TeXnician}]<br />
<br />
\input knuth<br />
<br />
\stopletter<br />
<br />
\stoptext<br />
</texcode><br />
<br />
produces<br />
<br />
<div style="padding:10px; border:thin dashed green;"><br />
<context><br />
\usemodule[letter]<br />
<br />
\starttext<br />
<br />
\startletter<br />
[opening={Dear Reader,},<br />
closing={Best regards,},<br />
signature={The TeXnician}]<br />
<br />
\input knuth<br />
<br />
\stopletter<br />
<br />
\stoptext<br />
</context><br />
</div><br />
<br />
== Styles ==<br />
<br />
The layout of the letter can be changed with styles, the module comes<br />
with styles for:<br />
<br />
* Germany<br />
* Netherlands<br />
* France<br />
* America<br />
<br />
== Features ==<br />
<br />
It is possible to change the default input method to the one used by Hans<br />
Hagen in the m-letter module or Donald Knuths letter style in the TeXbook.<br />
<br />
== Further Information ==<br />
<br />
You can find more informations here: <br />
<br />
* http://modules.contextgarden.net/letter<br />
* http://wolfgang.schuster.googlepages.com/letter<br />
* http://www.ctan.org/tex-archive/macros/context/contrib/context-letter/<br />
<br />
The manual for module is included in newer versions of the package or available from:<br />
<br />
* http://dl.contextgarden.net/modules/t-letter/doc/context/third/letter/correspondence.pdf<br />
* http://wolfgang.schuster.googlepages.com/lm.pdf</div>Wolfgang Schusterhttps://wiki.contextgarden.net/index.php?title=Expressions&diff=9571Expressions2009-03-24T00:20:13Z<p>Wolfgang Schuster: Typo</p>
<hr />
<div>< [[Main Page]] | [[Inside ConTeXt]] ><br />
<br />
ConTeXt implements extensions from eTeX including the evaluation of expressions<br />
(quoted from the [[http://www.ntg.nl/maps/20/38.pdf| eTeX manual]]):<br />
<br />
== Expressions ==<br />
<br />
eTeX introduces the notion of expressions of type number, dimen, glue, or<br />
muglue, that can be used whenever a quantity of that type is needed. Such<br />
expressions are evaluated by eTeX's scanning mechanism; they are initiated<br />
by one of the commands <code>\numexpr</code>, <code>\dimexpr</code>,<br />
<code>\glueexpr</code>, or <code>\muexpr</code><br />
(determining the type <i>t</i>) and terminated by <code>\relax</code> (which<br />
will be absorbed by the scanning mechanism). An expression consists of one<br />
or more terms of the same type to be added or subtracted; a term of type <i>t</i><br />
consists of a factor of that type, optionally multiplied and/or<br />
divided by numeric factors; finally a factor of type <i>t</i> is either a<br />
parenthesized subexpression or a quantity (number, etc.) of that type.<br />
<br />
== Examples ==<br />
<br />
It has been pointed out that<br />
the only important thing for <code>\dimexpr</code> is to write the dimen value<br />
as first value after the <code>\dimexpr</code> command and then the numeric values.<br />
Notice that the following expression is also valid:<br />
<texcode><br />
\placesidebyside {\externalfigure[cow][width=.4\textwidth]}<br />
{\framed[width=.4\textwidth,height=\dimexpr.4\textwidth*200/275\relax]<br />
{\vbox{this is a box}}}<br />
</texcode><br />
<br />
<context><br />
\setupexternalfigures[location={local,default}]<br />
\placesidebyside{\externalfigure[cow][width=.4\textwidth]}<br />
{\framed[width=.4\textwidth,height=\dimexpr.4\textwidth*200/275\relax]<br />
{\vbox{this is a cow-sized box}}}<br />
</context><br />
<br />
{{todo|Add some more illustrative examples.}}<br />
<br />
== More on evaluating expressions in ConTeXt ==<br />
<br />
Whereas the eTeX <code>\dimexpr</code> is quite useful,<br />
one must be aware of its limitations arising from how integer arithmetic is performed within TeX.<br />
Following a discussion on the ConTeXt mailing list,<br />
http://archive.contextgarden.net/thread/20090323.122228.af43852e.en.html<br />
this will be illustrated through a pedagogical example (including, as a bonus, a few handy tricks):<br />
<br />
----<br />
''Our question today is how to divide two dimension and compare their result with the result of another division. To do this, we first assign values to four dimensions. Then, we will try using eTeX functions with ConTeXt; the following example should work:''<br />
<br />
<context source="yes"><br />
\dimen0=15pt<br />
\dimen2=20pt<br />
\dimen4=15pt<br />
\dimen6=30pt<br />
<br />
\ifdim\dimexpr\dimen0/\dimen2\relax<\dimexpr\dimen4/\dimen6\relax<br />
The second fraction is greater.<br />
\else<br />
The first fraction is greater.<br />
\fi<br />
</context><br />
<br />
''This appears to work, but does it really? What will be the result if the second fraction were to be greater:''<br />
<br />
<context source="yes"><br />
\dimen0=15pt<br />
\dimen2=20pt<br />
\dimen4=15pt<br />
%\dimen6=30pt<br />
\dimen6=15pt<br />
<br />
\ifdim\dimexpr\dimen0/\dimen2\relax<\dimexpr\dimen4/\dimen6\relax<br />
The second fraction is now greater.<br />
\else<br />
The first fraction is still greater.<br />
\fi<br />
</context><br />
<br />
''What is going on here? The result is weird and unexpected. Why did this happen? Is TeX broken? Let's take a closer look at the real values of the dimensions and their results after division:''<br />
<context source="yes"><br />
\dimen0=15pt<br />
\the\dimen0{}<br />
</context><br />
''which has a real internal value of''<br />
<context source="yes"><br />
\dimen0=15pt<br />
\number\dimen0{}<br />
</context><br />
''in scaled points. Only the second integer value (in scaled points) is important for our calculation.''<br />
''We also need to know the internal value of the second dimension:''<br />
<context source="yes"><br />
\dimen2=20pt<br />
\number\dimen2<br />
</context><br />
''Finally, we would like to know the result of the division of these two numbers:''<br />
<context source="yes"><br />
\dimen0=15pt<br />
\dimen2=20pt<br />
\number\dimexpr\dimen0/\dimen2\relax<br />
</context><br />
<br />
''The result of the integer division is 1 (rather than the decimal 0.75); This illustrates that the result of dividing two numbers that are nearly equal within TeX is not very useful. We can get around this by multiplying the numerators by some large factor, assuring that the evaluated fractions remain integer:''<br />
<context source="yes"><br />
\dimen0=15pt<br />
\dimen2=20pt<br />
\dimen4=15pt<br />
%\dimen6=30pt<br />
\dimen6=15pt<br />
<br />
\ifdim\dimexpr100\dimen0/\dimen2\relax<\dimexpr100\dimen4/\dimen6\relax<br />
The second fraction is now greater.<br />
\else<br />
The first fraction is still greater.<br />
\fi<br />
</context><br />
<br />
== LuaTeX ==<br />
<br />
''Alternatively, we can use luaTeX to reliably get the correct result. The <code>tex.dimen</code> command allows us to access the <code>\dimen</code> register from TeX in Lua.''<br />
<br />
<texcode><br />
\dimen0=15pt<br />
\dimen2=20pt<br />
\dimen4=15pt<br />
\dimen6=30pt<br />
<br />
\startluacode<br />
if tex.dimen[0] / tex.dimen[2] < tex.dimen[4] / tex.dimen[6] then<br />
tex.sprint("The second fraction is greater.")<br />
else<br />
tex.sprint("The first fraction is greater.")<br />
end<br />
\stopluacode<br />
</texcode><br />
<br />
<context><br />
\dimen0=15pt<br />
\dimen2=20pt<br />
\dimen4=15pt<br />
\dimen6=30pt<br />
<br />
\ifdim\dimexpr100\dimen0/\dimen2\relax<\dimexpr100\dimen4/\dimen6\relax<br />
The second fraction is greater.<br />
\else<br />
The first fraction is greater.<br />
\fi<br />
</context><br />
<br />
''and''<br />
<br />
<texcode><br />
\dimen0=15pt<br />
\dimen2=20pt<br />
\dimen4=15pt<br />
%\dimen6=30pt<br />
\dimen6=15pt<br />
<br />
\startluacode<br />
if tex.dimen[0] / tex.dimen[2] < tex.dimen[4] / tex.dimen[6] then<br />
tex.sprint("The second fraction is now greater.")<br />
else<br />
tex.sprint("The first fraction is still greater.")<br />
end<br />
\stopluacode<br />
</texcode><br />
<br />
<context><br />
\dimen0=15pt<br />
\dimen2=20pt<br />
\dimen4=15pt<br />
\dimen6=15pt<br />
<br />
\ifdim\dimexpr100\dimen0/\dimen2\relax<\dimexpr100\dimen4/\dimen6\relax<br />
The second fraction is now greater.<br />
\else<br />
The first fraction is still greater.<br />
\fi<br />
</context><br />
<br />
''The output is now correct in both cases without making use of any tricks.''</div>Wolfgang Schusterhttps://wiki.contextgarden.net/index.php?title=Expressions&diff=9570Expressions2009-03-24T00:18:18Z<p>Wolfgang Schuster: Output for lua code</p>
<hr />
<div>< [[Main Page]] | [[Inside ConTeXt]] ><br />
<br />
ConTeXt implements extensions from eTeX including the evaluation of expressions<br />
(quoted from the [[http://www.ntg.nl/maps/20/38.pdf| eTeX manual]]):<br />
<br />
== Expressions ==<br />
<br />
eTeX introduces the notion of expressions of type number, dimen, glue, or<br />
muglue, that can be used whenever a quantity of that type is needed. Such<br />
expressions are evaluated by eTeX's scanning mechanism; they are initiated<br />
by one of the commands <code>\numexpr</code>, <code>\dimexpr</code>,<br />
<code>\glueexpr</code>, or <code>\muexpr</code><br />
(determining the type <i>t</i>) and terminated by <code>\relax</code> (which<br />
will be absorbed by the scanning mechanism). An expression consists of one<br />
or more terms of the same type to be added or subtracted; a term of type <i>t</i><br />
consists of a factor of that type, optionally multiplied and/or<br />
divided by numeric factors; finally a factor of type <i>t</i> is either a<br />
parenthesized subexpression or a quantity (number, etc.) of that type.<br />
<br />
== Examples ==<br />
<br />
It has been pointed out that<br />
the only important thing for <code>\dimexpr</code> is to write the dimen value<br />
as first value after the <code>\dimexpr</code> command and then the numeric values.<br />
Notice that the following expression is also valid:<br />
<texcode><br />
\placesidebyside {\externalfigure[cow][width=.4\textwidth]}<br />
{\framed[width=.4\textwidth,height=\dimexpr.4\textwidth*200/275\relax]<br />
{\vbox{this is a box}}}<br />
</texcode><br />
<br />
<context><br />
\setupexternalfigures[location={local,default}]<br />
\placesidebyside{\externalfigure[cow][width=.4\textwidth]}<br />
{\framed[width=.4\textwidth,height=\dimexpr.4\textwidth*200/275\relax]<br />
{\vbox{this is a cow-sized box}}}<br />
</context><br />
<br />
{{todo|Add some more illustrative examples.}}<br />
<br />
== More on evaluating expressions in ConTeXt ==<br />
<br />
Whereas the eTeX <code>\dimexpr</code> is quite useful,<br />
one must be aware of its limitations arising from how integer arithmetic is performed within TeX.<br />
Following a discussion on the ConTeXt mailing list,<br />
http://archive.contextgarden.net/thread/20090323.122228.af43852e.en.html<br />
this will be illustrated through a pedagogical example (including, as a bonus, a few handy tricks):<br />
<br />
----<br />
''Our question today is how to divide two dimension and compare their result with the result of another division. To do this, we first assign values to four dimensions. Then, we will try using eTeX functions with ConTeXt; the following example should work:''<br />
<br />
<context source="yes"><br />
\dimen0=15pt<br />
\dimen2=20pt<br />
\dimen4=15pt<br />
\dimen6=30pt<br />
<br />
\ifdim\dimexpr\dimen0/\dimen2\relax<\dimexpr\dimen4/\dimen6\relax<br />
The second fraction is greater.<br />
\else<br />
The first fraction is greater.<br />
\fi<br />
</context><br />
<br />
''This appears to work, but does it really? What will be the result if the second fraction were to be greater:''<br />
<br />
<context source="yes"><br />
\dimen0=15pt<br />
\dimen2=20pt<br />
\dimen4=15pt<br />
%\dimen6=30pt<br />
\dimen6=15pt<br />
<br />
\ifdim\dimexpr\dimen0/\dimen2\relax<\dimexpr\dimen4/\dimen6\relax<br />
The second fraction is now greater.<br />
\else<br />
The first fraction is still greater.<br />
\fi<br />
</context><br />
<br />
''What is going on here? The result is weird and unexpected. Why did this happen? Is TeX broken? Let's take a closer look at the real values of the dimensions and their results after division:''<br />
<context source="yes"><br />
\dimen0=15pt<br />
\the\dimen0{}<br />
</context><br />
''which has a real internal value of''<br />
<context source="yes"><br />
\dimen0=15pt<br />
\number\dimen0{}<br />
</context><br />
''in scaled points. Only the second integer value (in scaled points) is important for our calculation.''<br />
''We also need to know the internal value of the second dimension:''<br />
<context source="yes"><br />
\dimen2=20pt<br />
\number\dimen2<br />
</context><br />
''Finally, we would like to know the result of the division of these two numbers:''<br />
<context source="yes"><br />
\dimen0=15pt<br />
\dimen2=20pt<br />
\number\dimexpr\dimen0/\dimen2\relax<br />
</context><br />
<br />
''The result of the integer division is 1 (rather than the decimal 0.75); This illustrates that the result of dividing two numbers that are nearly equal within TeX is not very useful. We can get around this by multiplying the numerators by some large factor, assuring that the evaluated fractions remain integer:''<br />
<context source="yes"><br />
\dimen0=15pt<br />
\dimen2=20pt<br />
\dimen4=15pt<br />
%\dimen6=30pt<br />
\dimen6=15pt<br />
<br />
\ifdim\dimexpr100\dimen0/\dimen2\relax<\dimexpr100\dimen4/\dimen6\relax<br />
The second fraction is now greater.<br />
\else<br />
The first fraction is still greater.<br />
\fi<br />
</context><br />
<br />
== LuaTeX ==<br />
<br />
''Alternatively, we can use luaTeX to reliably get the correct result. The <code>tex.dimen</code> command allows us to access the <code>\dimen</code> register from TeX in Lua.''<br />
<br />
<texcode><br />
\dimen0=15pt<br />
\dimen2=20pt<br />
\dimen4=15pt<br />
\dimen6=30pt<br />
<br />
\startluacode<br />
if tex.dimen[0] / tex.dimen[2] < tex.dimen[4] / tex.dimen[6] then<br />
tex.sprint("The second fraction is greater.")<br />
else<br />
tex.sprint("The first fraction is greater.")<br />
end<br />
\stopluacode<br />
</texcode><br />
<br />
<context><br />
\dimen0=15pt<br />
\dimen2=20pt<br />
\dimen4=15pt<br />
\dimen6=30pt<br />
<br />
\ifdim\dimexpr100\dimen0/\dimen2\relax<\dimexpr100\dimen4/\dimen6\relax<br />
The second fraction is now greater.<br />
\else<br />
The first fraction is still greater.<br />
\fi<br />
</context><br />
<br />
''and''<br />
<br />
<texcode><br />
\dimen0=15pt<br />
\dimen2=20pt<br />
\dimen4=15pt<br />
%\dimen6=30pt<br />
\dimen6=15pt<br />
<br />
\startluacode<br />
if tex.dimen[0] / tex.dimen[2] < tex.dimen[4] / tex.dimen[6] then<br />
tex.sprint("The second fraction is now greater.")<br />
else<br />
tex.sprint("The first fraction is still greater.")<br />
end<br />
\stopluacode<br />
</texcode><br />
<br />
<context><br />
\dimen0=15pt<br />
\dimen2=20pt<br />
\dimen4=15pt<br />
\dimen6=15pt<br />
<br />
\ifdim\dimexpr100\dimen0/\dimen2\relax<\dimexpr100\dimen4/\dimen6\relax<br />
The second fraction is now greater.<br />
\else<br />
The first fraction is still greater.<br />
\fi<br />
</context><br />
<br />
''The output is now correct in both cases without making use of any tricks.''</div>Wolfgang Schusterhttps://wiki.contextgarden.net/index.php?title=MetaPost&diff=9273MetaPost2009-03-01T22:38:48Z<p>Wolfgang Schuster: Undo revision 9272 by 221.130.193.14 (Talk)</p>
<hr />
<div>< [[Math]], [[MetaFun]], [[Graphics]]<br />
<br />
* John Hobby's page: http://cm.bell-labs.com/who/hobby/MetaPost.html<br />
* Current development: http://foundry.supelec.fr/projects/metapost/<br />
<br />
MetaPost is a graphical programming language, based on Donald Knuth's MetaFont. Normally MP graphics are converted to PostScript and used with dvips, but ConTeXt can use it directly with PDF (see <br />
[http://www.pragma-ade.com/general/sources/mptopdf.pdf MPtoPDF]).<br />
<br />
MetaPost is ConTeXt's "native" graphics mode, see [[MetaFun]].<br />
<br />
<br />
== Documentation & Tutorials ==<br />
* [http://www.ctan.org/tex-archive/graphics/metapost/mpman.pdf A User's Manual for MetaPost] <!-- http://cm.bell-labs.com/who/hobby/cstr_162.pdf has its pages reversed --><br />
* [http://remote.science.uva.nl/~heck/Courses/mptut.pdf Learning METAPOST by doing] ([http://maps.aanhet.net/maps/pdf/32_14.pdf this] and [http://maps.aanhet.net/maps/pdf/32_15.pdf this link] are not working)<br />
* [http://www.tug.org/pracjourn/2006-4/henderson/henderson.pdf A Beginner's Guide to METAPOST for Creating High-Quality Graphics] by Troy Henderson<br />
* [[manual:metafun-s.pdf|MetaFun]]<br />
* [http://tex.loria.fr/prod-graph/zoonekynd/metapost/metapost.html Lots of examples]<br />
<br />
== Different Packages, Extensions & Applications of Metapost ==<br />
* [http://www.ctan.org/tex-archive/graphics/metaplot/ MetaPlot] - graph drawing<br />
* [http://www.ctan.org/tex-archive/graphics/metapost/contrib/macros/metaobj/ MetaObj]<br />
<br />
* [http://stud4.tuwien.ac.at/~e0225855/finomaton/finomaton.html finomaton] - drawing finite state automata<br />
* [http://www-math.univ-poitiers.fr/~phan/statsmac.html statsmac] - metapost macros for statistics graphs<br />
* [http://metauml.sourceforge.net/ MetaUML] - MetaPost library for typesetting UML diagrams<br />
<br />
=== 3D support ===<br />
* [http://matagalatlante.org/nobre/featpost/doc/featexamples.html FeatPost]<br />
* [http://www.gnu.org/software/3dldf/LDF.html 3DLDF]<br />
* [http://www-math.univ-poitiers.fr/~phan/m3Dplain.html m3D]<br />
<br />
{{todo|needs major review}}<br />
<br />
== MetaPost relatives ==<br />
=== Font Creation ===<br />
* [[MetaType1]], see [http://www.ctan.org/tex-archive/fonts/utilities/metatype1/ CTAN]<br />
<br />
=== 3D drawing ===<br />
* [http://asymptote.sourceforge.net/ Asymptote] - inspired by MetaPost & fully generalizes MetaPost path construction algorithms to three-dimensions<br />
<br />
== Other Links ==<br />
<br />
* http://melusine.eu.org/syracuse/metapost/<br />
<br />
<br />
[[Category:Graphics]]<br />
[[Category:Metapost]]</div>Wolfgang Schusterhttps://wiki.contextgarden.net/index.php?title=LPeg&diff=9264LPeg2009-02-24T10:00:36Z<p>Wolfgang Schuster: Reformated code</p>
<hr />
<div>== Writing a parser with LPeg ==<br />
<br />
To parser input files for the use with TeX you could either write Lua macros to convert pass the input to TeX or use LPeg to parse the files in a more simple manner.<br />
<br />
=== First version for a sgf parser ===<br />
<br />
The code below reads input in sgf syntax and pass the content to TeX macros.<br />
<br />
<texcode><br />
\startluacode<br />
<br />
do<br />
<br />
thirddata = thirddata or { }<br />
thirddata.sgf = thirddata.sgf or { }<br />
<br />
local function command(name,x)<br />
tex.sprint(tex.texcatcodes,string.format("\\csname sgf!%s\\endcsname{%s}",name,x))<br />
end<br />
<br />
local nodes = { }<br />
<br />
function nodes.B(x) command("black",x) end<br />
function nodes.W(x) command("white",x) end<br />
<br />
local function action(what,data)<br />
local a = nodes[what]<br />
if a then<br />
a(data)<br />
else<br />
print("unknown action: " .. what)<br />
end<br />
end<br />
<br />
local function start()<br />
nesting = nesting + 1<br />
command("start",nesting)<br />
end<br />
<br />
local function stop()<br />
command("stop",nesting)<br />
nesting = nesting - 1<br />
end<br />
<br />
local space = lpeg.S(' \r\n')^1<br />
local lower = lpeg.R("az")<br />
local upper = lpeg.R("AZ")<br />
local letter = lower + upper<br />
local position = letter^2<br />
local left = lpeg.P("(")<br />
local right = lpeg.P(")")<br />
local none = 1- (left + right)<br />
<br />
local node = (lpeg.P(";") * lpeg.C(lpeg.S("BW")) * lpeg.P("[") * lpeg.C(position) * lpeg.P("]")) / action<br />
local branch = lpeg.P { left/start * (lpeg.V(1) + node + space)^0 * right/stop }<br />
<br />
local parser = (branch + node + space)^0<br />
<br />
function thirddata.sgf.parsea(str)<br />
nesting = 0<br />
parser:match(str)<br />
end<br />
<br />
local function nest(str)<br />
tex.sprint(tex.ctxcatcodes,string.format("\\parsesgfb{%s}",str))<br />
end<br />
<br />
local node = (lpeg.P(";") * lpeg.C(lpeg.S("BW")) * lpeg.P("[") * lpeg.C(position) * lpeg.P("]")) / action<br />
local branch = lpeg.P { left * (lpeg.V(1) + (none^1/nest) + space)^0 * right }<br />
<br />
local parser = (branch + node + space)^0<br />
<br />
function thirddata.sgf.parseb(str)<br />
nesting = 0<br />
parser:match(str)<br />
end<br />
<br />
end<br />
<br />
\stopluacode<br />
</texcode><br />
<br />
To work with the output from the parser we need the following TeX macros.<br />
<br />
<texcode><br />
\long\def\parsesgfa#1{\ctxlua{thirddata.sgf.parsea("#1")}}<br />
\long\def\parsesgfb#1{\ctxlua{thirddata.sgf.parseb("#1")}}<br />
<br />
\starttexdefinition sgf!start #1<br />
\par \advance\leftskip by +2em<br />
\stoptexdefinition<br />
<br />
\starttexdefinition sgf!stop #1<br />
\par \advance\leftskip by -2em<br />
\stoptexdefinition<br />
<br />
\starttexdefinition sgf!node #1<br />
Node: #1\par<br />
\stoptexdefinition<br />
<br />
\starttexdefinition sgf!white #1<br />
White: #1\par<br />
\stoptexdefinition<br />
<br />
\starttexdefinition sgf!black #1<br />
Black: #1\par<br />
\stoptexdefinition<br />
<br />
\protect<br />
<br />
\starttext<br />
<br />
\parsesgfa{(;B[aa];W[bb](;B[cc](;B[dd];W[ee](;B[ff]);W[gg]));W[hh])}<br />
\blank<br />
\parsesgfb{(;B[aa];W[bb](;B[cc](;B[dd];W[ee](;B[ff]);W[gg]));W[hh])}<br />
<br />
\stoptext<br />
</texcode><br />
<br />
=== A extended version ===<br />
<br />
The second version of the sgf parser is less restricted to the arguments for the commands in the input and delimits the arguments in a slightly different way than the first version.<br />
<br />
<texcode><br />
\startluacode<br />
<br />
do<br />
<br />
thirddata = thirddata or { }<br />
thirddata.sgf = thirddata.sgf or { }<br />
<br />
local function command(name,x)<br />
tex.sprint(tex.texcatcodes,string.format("\\csname sgf!%s\\endcsname{%s}",name,x))<br />
end<br />
<br />
local nodes = { }<br />
<br />
function nodes.B (x) command("black" ,x) end<br />
function nodes.W (x) command("white" ,x) end<br />
function nodes.AW(x) command("addwhite",x) end<br />
function nodes.C (x) command("comment" ,x) end<br />
<br />
local function action(what,data)<br />
local a = nodes[what]<br />
if a then<br />
for w in string.gmatch(data,"%b[]") do<br />
a(string.sub(w,2,-2))<br />
end<br />
else<br />
print("unknown action: " .. what)<br />
end<br />
end<br />
<br />
local function nodecontent(str)<br />
tex.sprint(tex.ctxcatcodes,string.format("\\csname sgf!node\\endcsname{%s}",string.sub(str,2)))<br />
end<br />
<br />
local space = lpeg.S(' \r\n')^1<br />
local lcletter = lpeg.R("az")<br />
local ucletter = lpeg.R("AZ")<br />
local letter = lcletter + ucletter<br />
<br />
local propindent = ucletter^1<br />
<br />
local property = lpeg.C(propindent) * lpeg.C{ (lpeg.P("[") * (1 - lpeg.S"[]")^0 * lpeg.P("]"))^1} / action<br />
<br />
local function nest(str)<br />
tex.sprint(tex.ctxcatcodes,string.format("\\parsesgf{%s}",string.sub(str,2,-2)))<br />
end<br />
<br />
local node = lpeg.P{ ";" * (propindent * (lpeg.P("[") * (1 - lpeg.S"[]")^0 * lpeg.P("]"))^1)^1} / nodecontent<br />
local branch = lpeg.P{ "(" * ((1 - lpeg.S"()") + lpeg.V(1))^0 * ")" } / nest<br />
<br />
local parser = (branch + node + property + space)^0<br />
<br />
function thirddata.sgf.parse(str)<br />
parser:match(str)<br />
end<br />
<br />
end<br />
<br />
\stopluacode<br />
</texcode><br />
<br />
The TeX code for the second version is nearly the same as in the first draft, this was the goal for both version because it is more important to keep the interface in TeX and make the modifications in low level TeX or Lua code.<br />
<br />
<texcode><br />
\def\sgfflush#1{\ctxlua{thirddata.sgf.parse("#1")}}<br />
<br />
\starttexdefinition parsesgf #1<br />
\par \advance\leftskip by +2em<br />
\sgfflush{#1}<br />
\par \advance\leftskip by -2em<br />
\stoptexdefinition<br />
<br />
\starttexdefinition sgf!node #1<br />
\par \sgfflush{#1}<br />
\stoptexdefinition<br />
<br />
\starttexdefinition sgf!white #1<br />
White: #1\quad<br />
\stoptexdefinition<br />
<br />
\starttexdefinition sgf!black #1<br />
Black: #1\quad<br />
\stoptexdefinition<br />
<br />
\starttexdefinition sgf!addwhite #1<br />
Add White: #1\quad<br />
\stoptexdefinition<br />
<br />
\starttexdefinition sgf!comment #1<br />
Comment: #1\quad<br />
\stoptexdefinition<br />
<br />
\protect<br />
<br />
\starttext<br />
<br />
\parsesgf{(;C[First move in game 123]B[aa]AW[aa];W[bb](;B[cc](;B[dd];W[ee][ff](;B[ff]);W[gg]));W[hh])}<br />
<br />
\stoptext<br />
</texcode><br />
<br />
== External Links ==<br />
<br />
* http://www.inf.puc-rio.br/~roberto/lpeg.html<br />
* http://www.red-bean.com/sgf/</div>Wolfgang Schusterhttps://wiki.contextgarden.net/index.php?title=Spellchecker&diff=9261Spellchecker2009-02-19T21:14:29Z<p>Wolfgang Schuster: Spellchecking</p>
<hr />
<div>{{note|This feature works only in MkIV}}<br />
<br />
== Introduction ==<br />
<br />
One of the various new features in MkIV is a simple spellchecker. It allows you to highlight right and wrong words with different colors.<br />
<br />
== Wordlist ==<br />
<br />
ConTeXt needs a list with the correct spelling of the words to be able to check them.<br />
<br />
For the example below a list with the following content was used, to test the sample on your own save the list in a textfile with the name words-de.txt with UTF-8 encoding.<br />
<br />
<pre><br />
Adler<br />
Alten<br />
Baum<br />
Doch<br />
Eltern<br />
Frucht<br />
Gewann<br />
Herkommen<br />
Junge<br />
Kalb<br />
Kind<br />
Mutter<br />
Namen<br />
Spruch<br />
Ursprung<br />
Vater<br />
Wohl<br />
Zucht<br />
auch<br />
begabt<br />
deßgleichen<br />
geartet<br />
gehabt<br />
gelten<br />
gern<br />
haben<br />
hoch<br />
hundert<br />
kein<br />
merk<br />
mich<br />
nach<br />
nicht<br />
noch<br />
recht<br />
schlägt<br />
selten<br />
sind<br />
wahr<br />
wird<br />
wäscht<br />
</pre><br />
<br />
== Example ==<br />
<br />
We will test now the function with the following example. The word list is loaded with the <cmd>loadspellchecklist</cmd> command.<br />
With the first argument to set the language of the text file and with the second the name of the file.<br />
The command <cmd>setupspellchecking</cmd> enables the spell checking function for your document.<br />
<br />
<texcode><br />
\setupcolors[state=start]<br />
<br />
\loadspellchecklist[de][words-de.txt]<br />
\setupspellchecking[state=start]<br />
<br />
\mainlanguage[de]<br />
<br />
\starttext<br />
<br />
Von dem Ursprung, Herkommen und Namen der Schildbürger in Misnopotamien.<br />
<br />
Es haben die Alten vor vielen hundert Jahren diesen herrlichen Spruch gehabt,<br />
welcher auch noch zu diesen unsern Zeiten wahr ist und deßhalb gelten soll:<br />
<br />
\startlines<br />
Eltern, wie die geartet sind, <br />
So ist gemeinlich auch ihr Kind: <br />
Sind sie mit Tugenden begabt, <br />
An Kindern ihr deßgleichen habt. <br />
Kein guter Baum giebt böse Frucht, <br />
Gern schlägt der Mutter nach die Zucht. <br />
Ein gutes Kalb, eine gute Kuh, <br />
Das Junge wächst dem Vater zu. <br />
Gewann der Adler hoch von Muth <br />
Wohl je furchtsame Taubenbrut? <br />
Doch merk mich recht, merk mich mit Fleiß, <br />
Was man nicht wäscht, wird selten weiß.<br />
\stoplines<br />
<br />
\stoptext<br />
</texcode><br />
<br />
The output of the example above is:<br />
<br />
<br />
<context><br />
\enableregime[utf]<br />
<br />
\setupcolors[state=start]<br />
<br />
\mainlanguage[de]<br />
<br />
\starttext<br />
<br />
Von dem {\green Ursprung}, {\green Herkommen} und {\green Namen}<br />
der {\red Schildbürger} in {\red Misnopotamien}.<br />
<br />
Es {\green haben} die {\green Alten} vor {\red vielen} {\green hundert}<br />
{\red Jahren diesen herrlichen} {\green Spruch gehabt}, {\red welcher}<br />
{\green auch noch} zu {\red diesen unsern Zeiten} {\green wahr} ist und<br />
deß{\red halb} gelten {\red soll}:<br />
<br />
\startlines<br />
{\green Eltern}, wie die {\green geartet sind}, <br />
So ist {\red gemeinlich} {\green auch} ihr {\green Kind}: <br />
{\green Sind} sie mit {\red Tugenden} {\green begabt}, <br />
An {\red Kindern} ihr deß{\red gleichen habt}. <br />
{\green Kein} {\red guter} {\green Baum} {\red giebt böse} {\green Frucht}, <br />
{\green Gern schlägt} der {\green Mutter nach} die {\green Zucht}. <br />
Ein {\red gutes} {\green Kalb}, {\red eine gute} Kuh, <br />
Das {\green Junge} {\red wächst} dem {\green Vater} zu. <br />
{\green Gewann} der {\green Adler hoch} von {\red Muth} <br />
{\green Wohl} je {\red furchtsame Taubenbrut}? <br />
{\green Doch merk mich recht, merk mich} mit {\red Flei}ß, <br />
Was man {\green nicht wäscht}, {\green wird selten} weiß.<br />
\stoplines<br />
<br />
\stoptext<br />
</context></div>Wolfgang Schusterhttps://wiki.contextgarden.net/index.php?title=Letter&diff=9245Letter2009-02-05T23:48:50Z<p>Wolfgang Schuster: Framed output</p>
<hr />
<div>< [[Modules]] | [[User:Wolfgang_Schuster]] ><br />
<br />
{{note|This module is still in development}}<br />
<br />
== Introduction ==<br />
<br />
The letter module provides a interface to write different kinds of correspondence<br />
with the support for different styles and extensions.<br />
<br />
== Example ==<br />
<br />
<texcode><br />
\usemodule[letter]<br />
<br />
\starttext<br />
<br />
\startletter<br />
[opening={Dear Reader,},<br />
closing={Best regards,},<br />
signature={The TeXnician}]<br />
<br />
\input knuth<br />
<br />
\stopletter<br />
<br />
\stoptext<br />
</texcode><br />
<br />
produces<br />
<br />
<div style="padding:10px; border:thin dashed green;"><br />
<context><br />
\usemodule[letter]<br />
<br />
\starttext<br />
<br />
\startletter<br />
[opening={Dear Reader,},<br />
closing={Best regards,},<br />
signature={The TeXnician}]<br />
<br />
\input knuth<br />
<br />
\stopletter<br />
<br />
\stoptext<br />
</context><br />
</div><br />
<br />
== Styles ==<br />
<br />
The layout of the letter can be changed with styles, the module comes<br />
with styles for:<br />
<br />
* Germany<br />
* Netherlands<br />
* France<br />
* America<br />
<br />
== Features ==<br />
<br />
It is possible to change the default input method to the one use by Hans<br />
Hagen in the m-letter module or Donald Knuths letter style in the TeXbook.<br />
<br />
== Further Information ==<br />
<br />
You can find more informations here: <br />
<br />
* http://modules.contextgarden.net/letter<br />
* http://wolfgang.schuster.googlepages.com/letter<br />
* http://www.ctan.org/tex-archive/macros/context/contrib/context-letter/<br />
<br />
The manual for module is included in newer versions of the package or available from:<br />
<br />
* http://dl.contextgarden.net/modules/t-letter/doc/context/third/letter/lm.pdf<br />
* http://wolfgang.schuster.googlepages.com/lm.pdf</div>Wolfgang Schusterhttps://wiki.contextgarden.net/index.php?title=Titles&diff=9244Titles2009-02-05T18:35:16Z<p>Wolfgang Schuster: Loaded figure</p>
<hr />
<div>< [[Structurals]] | [[Visuals]] ><br />
<br />
==Default==<br />
<br />
Titles define the structure of your document. Decide yourself, how deep you want to nest them:<br />
<br />
<table><br />
<tr bgcolor="#CCCCCC"><br />
<th>numbered</th><br />
<th>unnumbered</th><br />
</tr><br />
<tr><br />
<td><cmd>part</cmd><br />
</td><td>&#151;</td><br />
</tr><br />
<tr><br />
<td><cmd>chapter</cmd></td><br />
<td><cmd>title</cmd></td><br />
</tr><br />
<tr><br />
<td><cmd>section</cmd></td><br />
<td><cmd>subject</cmd></td><br />
</tr><br />
<tr><br />
<td><cmd>subsection</cmd></td><br />
<td><cmd>subsubject</cmd></td><br />
</tr><br />
<tr><br />
<td><cmd>subsubsection</cmd></td><br />
<td><cmd>subsubsubject</cmd></td><br />
</tr><br />
<tr><br />
<td>...</td><br />
<td>...</td><br />
</tr><br />
</table><br />
<br />
The ''unnumbered'' versions don't appear in a table of contents! But you can<br />
switch off the numbering of the ''numbered'' versions with <cmd>setuphead</cmd><br />
to get unnumbered titles ''and'' a toc (confusing?).<br />
<br />
===Referencing Titles===<br />
<br />
Every heading command can take an optional parameter as reference:<br />
<br />
<texcode><br />
\title[hasselt-by-night]{Hasselt by night}<br />
</texcode><br />
<br />
The bracket pair is optional and used for internal [[References]]. If you want<br />
to refer to this header you type for example<br />
<br />
<texcode><br />
\at{page}[hasselt-by-night].<br />
<br />
(see <cmd>at</cmd>)<br />
</texcode><br />
<br />
==Titling Style==<br />
<br />
see <cmd>setuphead</cmd> and some enhanced samples below.<br />
<br />
A FAQ is how to get a line under the title:<br />
<br />
<texcode><br />
\setupbackgrounds[header][text][bottomframe=on]<br />
</texcode><br />
<br />
To make the section numbers appear as characters, do<br />
<br />
<texcode><br />
\setupsection[section-3][bodypartconversion=Character]<br />
</texcode><br />
<br />
The <code>section-3</code> corresponds to <code>section</code>. Similarly,<br />
<code>section-1</code> corresponds to <code>part</code>, <code>section-2</code><br />
corresponds to <code>chapter</code> and so on.<br />
<br />
==Titling Alignment==<br />
<br />
Titles should often be left aligned without hyphenation. Try this:<br />
<br />
<texcode><br />
\setuphead[chapter][align={flushleft, nothyphenated, verytolerant}] % "flushleft" is the same as "right"<br />
</texcode><br />
<br />
===Using colors in chapters and sections===<br />
<br />
If you want you may have colors on your document's chapters or sections.<br />
To do that you should use <cmd>setuphead</cmd>. Take a look at the following<br />
example:<br />
<br />
<texcode><br />
\setupcolors[state=start] % Important. You won't have colors without it.<br />
<br />
\setuphead[chapter][header=empty] % Chapter pages won't have headers<br />
<br />
\setupheadertexts[][chapter] % The header will be the chapter's name<br />
<br />
\starttext<br />
<br />
\completecontent<br />
<br />
\chapter{Black chapter 1}<br />
<br />
\setuphead[section][color=darkcyan] % This is how you change your chapter's color.<br />
<br />
\section{Dark cyan section 1.1}<br />
<br />
\page<br />
Test.<br />
<br />
\setuphead[chapter][color=darkgreen]<br />
<br />
\chapter{Dark green chapter}<br />
<br />
\page<br />
Test.<br />
<br />
\setuphead[chapter][color=red]<br />
<br />
\chapter{Red chapter}<br />
<br />
\page<br />
Test.<br />
<br />
\stoptext <br />
</texcode><br />
<br />
==Your Own Titling Levels==<br />
<br />
Of course you can define your own titling commands and probably must adapt the default settings.<br />
<br />
<texcode><br />
\definehead[myheader][section]<br />
<br />
\setuphead<br />
[myheader]<br />
[numberstyle=bold,<br />
textstyle=cap,<br />
before=\hairline\blank,<br />
after=\nowhitespace\hairline]<br />
<br />
\myheader[hasselt-ref]{Hasselt makes headlines}<br />
</texcode><br />
<br />
A new header <cmd>myheader</cmd> is defined and it inherits the properties<br />
of <cmd>section</cmd> (title, subject, whatever). You can ''define'' several<br />
headers at once!<br />
<br />
==Formatting Titles with <cmd>setuphead</cmd>==<br />
<br />
<cmd>setuphead</cmd> accepts a number of parameters which change the style of<br />
the heading. At least the following commands are available:<br />
<br />
<table><br />
<tr bgcolor="#CCCCCC"><br />
<th>text</th><br />
<th>number</th><br />
</tr><br />
<tr><br />
<td><tt>textstyle</tt></td><br />
<td><tt>numberstyle</tt></td><br />
</tr><br />
<tr><br />
<td><tt>textcommand</tt></td><br />
<td><tt>numbercommand</tt></td><br />
</tr><br />
<tr><br />
<td><tt>deeptextcommand</tt></td><br />
<td><tt>deepnumbercommand</tt></td><br />
</tr><br />
</table><br />
<br />
Quite obviously, the number-commands work on the chapter/section/etc. number,<br />
their text counterparts change the text itself. However, there are differences<br />
between <tt>style</tt>, <tt>command</tt> and <tt>deepcommand</tt>.<br />
<br />
The <tt>style</tt> variants accept a style (<tt>bold</tt>, <tt>cap</tt>, etc.)<br />
or a font switch (<cmd>em</cmd>, <cmd>tfx</cmd>, etc). <tt>texstyle</tt> prepends<br />
the text with the associated style. <tt>textcommand</tt> is a command name which<br />
is given the text (with all markup) as a parameter. <tt>deeptextcommand</tt> is<br />
similar to <tt>textcommand</tt> but it acts only on the text (not on the markup).<br />
<br />
So, if we have <cmd>title{A story}</cmd>, the different parameters have the following results:<br />
<br />
<table><br />
<tr><br />
<td><tt>textstyle=\em</tt></td><br />
<td><tt>=></tt></td><br />
<td><tt>\em A story</tt></td><br />
</tr><br />
<tr><br />
<td><tt>textstyle=\em, textcommand=\uppercase</tt></td><br />
<td><tt>=></tt></td><br />
<td><tt>\uppercase{\em A story}</tt></td><br />
<td><tt>=></tt></td><br />
<td><tt>\em A STORY</tt></td><br />
</tr><br />
<tr><br />
<td><tt>textstyle=\em, deeptextcommand=\uppercase</tt></td><br />
<td><tt>=></tt></td><br />
<td><tt>\em\uppercase{A story}</tt></td><br />
<td><tt>=></tt><br />
</td><td><tt>\em A STORY</tt></td><br />
</tr><br />
</table><br />
<br />
What is the difference between <tt>textcommand</tt> and <tt>deeptextcommand</tt>,<br />
then? With this example there is very little difference, as <tt>uppercase</tt><br />
knows how to handle markup. Sometimes this is not the case. For example, an almost<br />
similar command <tt>WORD</tt> is not compatible with <tt>textcommand</tt>, because<br />
it wreaks havoc with markup:<br />
<br />
<table><br />
<tr><br />
<td><tt>textstyle=\em, textcommand=\WORD</tt></td><br />
<td><tt>=></tt></td><br />
<td><tt>\WORD{\em A story}</tt></td><br />
<td><tt>=></tt></td><br />
<td><tt>\EM A STORY</tt></td><br />
</tr><br />
<tr><br />
<td><tt>textstyle=\em, deeptextcommand=\WORD</tt></td><br />
<td><tt>=></tt></td><br />
<td><tt>\em\WORD{A story}</tt></td><br />
<td><tt>=></tt></td><br />
<td><tt>\em A STORY</tt></td><br />
</tr><br />
</table><br />
<br />
In this case using <tt>deeptextcommand</tt> is the correct solution for capitalizing<br />
headers. (Using <cmd>uppercase</cmd> works in this specific case, but only if you stick<br />
to Latin 1 or Anglo-Saxon characters. Other languages will suffer from lowercase accented<br />
characters, like CAFé.)<br />
<br />
=== Truly empty pagebreak before chapters ===<br />
<br />
Using <cmd>setuppagenumbering[alternative=doublesided]</cmd> makes the chapters start<br />
on the right page. However, the blank page is not truely empty, it contains headers and<br />
footers. To get truely empty pages, use the following<br />
<br />
<texcode><br />
\definepagebreak<br />
[mychapterpagebreak]<br />
[yes,header,right]<br />
%[yes,header,left]<br />
%[yes,header,footer,right]<br />
<br />
\setuphead<br />
[chapter]<br />
[page=mychapterpagebreak]<br />
%[page=Mychapterpagebreak,header=empty,footer=empty]<br />
<br />
%\setupsectionblock[frontpart][page=chapter]<br />
%\setupsectionblock[bodypart][page=chapter]<br />
%\setupsectionblock[backpart][page=chapter]<br />
%\setupsectionblock[appendix][page=chapter]<br />
<br />
\setuppagenumbering[alternative=doublesided,location={header,margin}]<br />
\setupheadertexts[{My special headertext}]<br />
\setupfootertexts[This is a text in the footer]<br />
%\setupbackgrounds[header][text][bottomframe=on]<br />
<br />
\starttext<br />
\chapter{testA} \dorecurse{10}{\input tufte }<br />
\chapter{testB} \dorecurse{10}{\input tufte }<br />
\chapter{testC} \dorecurse{10}{\input tufte }<br />
\stoptext<br />
</texcode><br />
<br />
Explaination (provided by Willi Egger on the mailing list)<br />
<br />
* You define a new pagebreak rule. It has the name <code>mychapterpagebreak</code>. The options set read as: <code>pagebreak=yes</code>, placeheader, use a right page.<br />
* You set options for the header of type chapter and use for the option page the before defined new pagebreak.<br />
* You might want to experiment with the commented lines and see what happens. For example, the <code>\setupsectionblock</code> commands will give a truly blank page (if needed) after the specified \stop*part command.<br />
<br />
== Independent Section Numbering ==<br />
<br />
If you want section numbering to be independent of chapter numbering, use<br />
<br />
<texcode><br />
\setuphead [chapter][resetnumber=no]<br />
\setupsection[section][previousnumber=no]<br />
</texcode><br />
<br />
==Your Own Title Styles==<br />
<br />
Sometimes the possibilities of <cmd>setuphead</cmd> aren't enough. You can define<br />
your own styling commands, as shown in the following examples.<br />
<br />
===Expanded chapter titles===<br />
<br />
This example illustrates expanded chapter titles.<br />
<br />
<texcode><br />
\def\MyChapterCommand#1#2% #1 is number, #2 is text<br />
{\framed[frame=off,bottomframe=on,topframe=on]<br />
{\vbox{\headtext{chapter} #1\blank#2}}} % \vbox is needed for \blank to work<br />
<br />
\setuphead[chapter][command=\MyChapterCommand, style={\ss\bfa}]<br />
<br />
\setupheadtext[chapter=Chapter] % used by \headtext<br />
</texcode><br />
<br />
so <tt>\chapter{My First Chapter}</tt> looks like:<br />
<br />
<context><br />
\def\MyChapterCommand#1#2%<br />
{\framed[frame=off,bottomframe=on,topframe=on]<br />
{\vbox{\headtext{chapter} #1\blank#2}}}<br />
<br />
\setuphead[chapter][command=\MyChapterCommand, style={\ss\bfa}]<br />
\setupheadtext[chapter=Chapter]<br />
<br />
\chapter{My First Chapter}<br />
</context><br />
<br />
===Exercise numbers===<br />
<br />
For a textbook, suppose that you collect the exercises in a section at the end<br />
of each chapter, with each exercise a subsection having a short title, and the<br />
exercises should be numbered only by the subsection (not 1.6.7 for example,<br />
just 7). The usage:<br />
<br />
<texcode><br />
\section{Exercises}<br />
<br />
\exercise{Batteries}<br />
What is the cost of energy from a 9V battery? From a wall socket (the mains)?<br />
</texcode><br />
<br />
The setup code:<br />
<texcode><br />
\definehead[exercise][subsection]<br />
<br />
\setuphead<br />
[exercise]<br />
[style=italic, <br />
numbercommand={\determineheadnumber[subsection]\currentheadnumber\gobbleoneargument}]<br />
</texcode><br />
<br />
===A complex graphical element under the chapter title===<br />
<br />
<texcode><br />
\setupcolors[state=start]<br />
\startuseMPgraphic{HeaderDeco}<br />
numeric w, h, repeats;<br />
path p[];<br />
w := OverlayWidth ; h := OverlayHeight ;<br />
repeats := abs(TextWidth/BodyFontSize);<br />
p[1] := unitsquare xscaled w yscaled h ;<br />
draw p[1] withcolor white;<br />
p[2] := fullcircle scaled BodyFontSize;<br />
p[3] := fullcircle scaled .25BodyFontSize;<br />
draw p[2] shifted (.5BodyFontSize,0);<br />
for i = 1 upto repeats:<br />
if odd i :<br />
filldraw p[3] shifted (i*BodyFontSize+.5BodyFontSize,0);<br />
else :<br />
draw p[2] shifted (i*BodyFontSize+.5BodyFontSize,0);<br />
fi;<br />
endfor;<br />
\stopuseMPgraphic<br />
<br />
\setuphead[chapter][command=\Myheader]<br />
\setupheadtext[chapter=Chapitre]<br />
\defineoverlay[HeaderDeco][\uniqueMPgraphic{HeaderDeco}]<br />
<br />
\def\Myheader#1#2{%<br />
\framedtext<br />
[width= \overlaywidth,<br />
height=6\bodyfontsize,<br />
background={foreground,HeaderDeco},<br />
offset=0pt,<br />
strut=no,<br />
frame=off,<br />
align=middle]{%<br />
\headtext{chapter} #1<br />
\blank[small]<br />
#2}}<br />
<br />
\starttext<br />
\chapter{Here we go!}<br />
\stoptext<br />
</texcode><br />
<br />
It looks like:<br />
<br />
<context><br />
\setupcolors[state=start]<br />
\startuseMPgraphic{HeaderDeco}<br />
numeric w, h, repeats;<br />
path p[];<br />
w := OverlayWidth ; h := OverlayHeight ;<br />
repeats := abs(TextWidth/BodyFontSize);<br />
p[1] := unitsquare xscaled w yscaled h ;<br />
draw p[1] withcolor white;<br />
p[2] := fullcircle scaled BodyFontSize;<br />
p[3] := fullcircle scaled .25BodyFontSize;<br />
draw p[2] shifted (.5BodyFontSize,0);<br />
for i = 1 upto repeats:<br />
if odd i :<br />
filldraw p[3] shifted (i*BodyFontSize+.5BodyFontSize,0);<br />
else :<br />
draw p[2] shifted (i*BodyFontSize+.5BodyFontSize,0);<br />
fi;<br />
endfor;<br />
\stopuseMPgraphic<br />
<br />
\setuphead[chapter][command=\Myheader]<br />
\setupheadtext<br />
[chapter=Chapitre]<br />
\defineoverlay[HeaderDeco][\uniqueMPgraphic{HeaderDeco}]<br />
<br />
\def\Myheader#1#2{%<br />
\framedtext<br />
[width= \overlaywidth,<br />
height=6\bodyfontsize,<br />
background={foreground,HeaderDeco},<br />
offset=0pt,<br />
strut=no,<br />
frame=off,<br />
align=middle]{%<br />
\headtext{chapter} #1<br />
\blank[small]<br />
#2}}<br />
<br />
\starttext<br />
\chapter{Here we go!}<br />
\stoptext<br />
</context><br />
<br />
===Titles in margin===<br />
<br />
It is sometimes wanted to place the title of a section/subject etc in the margin next to the section text (instead of above it).<br />
This is achieved by the following setup:<br />
<br />
<texcode><br />
\setuphead<br />
[subject]<br />
[alternative=text,distance=0pt,command=\MyHead]<br />
<br />
\def\MyHead#1#2{\inmargin{#1 #2}}<br />
</texcode><br />
<br />
This (with 'style=\sc' added in setuphead) gives:<br />
<br />
<context><br />
\setuphead<br />
[subject]<br />
[alternative=text,distance=0pt,command=\MyHead,style=\sc]<br />
<br />
\def\MyHead#1#2{\inmargin{#1 #2}}<br />
<br />
\starttext<br />
<br />
\subject{First Subject}<br />
This is the text in the first subject. This is the text in the first subject.<br />
This is the text in the first subject. This is the text in the first subject.<br />
This is the text in the first subject. This is the text in the first subject.<br />
This is the text in the first subject. This is the text in the first subject.<br />
<br />
\subject{Second Subject}<br />
This is the text in the second subject. This is the text in the second subject.<br />
This is the text in the second subject. This is the text in the second subject. <br />
This is the text in the second subject. This is the text in the second subject. <br />
This is the text in the second subject. This is the text in the second subject. <br />
<br />
\stoptext<br />
</context><br />
<br />
See the mailing list thread [[http://www.ntg.nl/pipermail/ntg-context/2003/002053.html]] for more on this.<br />
<br />
===Headings numbered independent of chapters or other headings===<br />
<br />
If you want a heading that gets numbered without resetting at new sections or chapters (for example, for problems whose numbers increment throughout a book), here is a solution due to Hans [http://archive.contextgarden.net/message/20030415.153451.374310d8.en.html on the mailing list]:<br />
<br />
<texcode><br />
% use a lower level head<br />
<br />
\definehead<br />
[Problem]<br />
[subsubsubsection]<br />
<br />
% cleaned up<br />
<br />
\setuphead<br />
[Problem]<br />
[style=\ss\bf,<br />
color=red,<br />
before=\blank]<br />
<br />
% use a label text<br />
<br />
\setuplabeltext<br />
[Problem=Problem ]<br />
<br />
% use your own numbers<br />
<br />
\setuphead<br />
[Problem]<br />
[ownnumber=yes]<br />
<br />
% increment and feed<br />
<br />
\newcounter\ProblemNumber<br />
<br />
\def\problem#1%<br />
{\doglobal\increment\ProblemNumber<br />
\Problem{\ProblemNumber}{#1}}<br />
<br />
% nicer here<br />
<br />
\setuplist<br />
[Problem]<br />
[alternative=c,<br />
criterium=all,<br />
width=2em,<br />
interaction=all]<br />
<br />
% the test<br />
<br />
\starttext<br />
<br />
List of Problems<br />
<br />
\blank[big] \placelist[Problem] \blank[big]<br />
<br />
\section{Tufte}<br />
<br />
\input tufte<br />
<br />
\problem{First problem}<br />
<br />
The first problem description.<br />
<br />
\section{Another Tufte}<br />
<br />
\input tufte<br />
<br />
\problem{Second problem}<br />
<br />
Second problem description.<br />
<br />
\stoptext<br />
</texcode><br />
<br />
===Chapter headers===<br />
<br />
Setup of headers like chapters.<br />
<br />
While reading Pixar docs about Renderman, I've found their headers nice and wanted to copy this style.<br />
I found a premise in Metafun manual, p.187 (Hello text), and Hans email me ([http://archive.contextgarden.net/message/20041020.100630.d531bb1d.en.html 20/10/2004 ]) on the context list a more simple solution than using metapost. The minimum is to put it here, for others who are like me, wandering for source code.<br />
Feel free to adapt code below to your langage specific settings, mine is french.<br />
<br />
<texcode><br />
\useencoding[ffr]<br />
\mainlanguage[fr]<br />
\enableregime[utf] %for UTF8<br />
<br />
% \enableregime[il1] %for ISO 8859-1 8859-15<br />
<br />
\usetypescript[palatino][texnansi]<br />
\setupbodyfont[palatino,rm,12pt]<br />
<br />
\setupcolors[state=start]<br />
<br />
\definefont[BigFontOne][Regular sa 3] %RegularSlanted sa 3(ori)%Sans sa 3:don't work (pb accents)<br />
\definefont[BigFontTwo][RegularBold sa 2] %%RegularSlanted<br />
<br />
\definecolor[BigColorOne][r=.86,g=.850,b=.54]<br />
\definecolor[BigColorTwo][r=.43,g=.425,b=.27]<br />
<br />
\setuphead<br />
[chapter]<br />
[textcommand=\MyChapterText,<br />
color=BigColorTwo,<br />
style=\BigFontTwo]<br />
<br />
\def\MyChapterText#1{\rlap{\BigFontOne\BigColorOne#1}\kern15pt#1}<br />
<br />
\starttext<br />
<br />
\chapter[chap:ques]{Question}<br />
\chapter[chap:answ]{Answer}<br />
\chapter[chap:answ]{Remarque}<br />
\chapter[chap:answ]{Cours}<br />
\chapter[chap:answ]{Exercice}<br />
\chapter[chap:answ]{Travail dirigé}<br />
\chapter[chap:answ]{Exposé}<br />
\stoptext<br />
</texcode><br />
<br />
I've tryed to change a bit Hans code, by putting \kern15pt, for moving backgroundtext to the left of \rlap alignment, and an unsuccess one to switch same backgroundtext in Sans font (no french accents).<br />
<br />
olivier<br />
<br />
<context><br />
\useencoding[ffr]<br />
\mainlanguage[fr]<br />
<br />
% fonts currently don't work this way,<br />
% I'll fix that soon. Patrick<br />
<br />
% \usetypescript[palatino][texnansi]<br />
% \setupbodyfont[palatino,rm,12pt]<br />
<br />
\setupcolors[state=start]<br />
<br />
\definefont[BigFontOne][Regular sa 3] %RegularSlanted sa 3(ori)%Sans sa 3:don't work (pb accents)<br />
\definefont[BigFontTwo][RegularBold sa 2] %%RegularSlanted<br />
<br />
\definecolor[BigColorOne][r=.86,g=.850,b=.54]<br />
\definecolor[BigColorTwo][r=.43,g=.425,b=.27]<br />
<br />
\setuphead<br />
[chapter]<br />
[textcommand=\MyChapterText,<br />
color=BigColorTwo,<br />
style=\BigFontTwo]<br />
<br />
\def\MyChapterText#1{\rlap{\BigFontOne\BigColorOne#1}\kern15pt#1}<br />
<br />
\starttext<br />
<br />
\chapter[chap:ques]{Question}<br />
<br />
% only one page please, since this is displayed inline. Patrick<br />
% \chapter[chap:answ]{Answer}<br />
% \chapter[chap:answ]{Remarque}<br />
% \chapter[chap:answ]{Cours}<br />
% \chapter[chap:answ]{Exercice}<br />
% \chapter[chap:answ]{Travail dirigé}<br />
% \chapter[chap:answ]{Exposé}<br />
\stoptext<br />
</context><br />
<br />
===Figures in Headings===<br />
<br />
This example shows how to completely replace the chapter text and number by an image:<br />
<br />
<context source="yes"><br />
\setupexternalfigures[location=default] % needed only for the wiki to the find the figure<br />
<br />
\useexternalfigure[chapter-1][cow.pdf]<br />
\useexternalfigure[chapter-2][hacker.jpg]<br />
<br />
\setuphead<br />
[chapter]<br />
[command=\MyChapterCommand]<br />
<br />
\def\MyChapterCommand#1#2%<br />
{\externalfigure[chapter-\currentheadnumber][height=5cm]}<br />
<br />
\starttext<br />
<br />
\chapter{One}<br />
\section{First section of Chapter One}<br />
<br />
\stoptext<br />
</context><br />
<br />
However, this "forgets" to put the chapter in the TOC. So you have to set<br />
the <tt>textcommand</tt> and <tt>numbercommand</tt> separately instead<br />
(thus retaining the command that puts the chapter in the TOC), rather than<br />
setting the overall <tt>command</tt>, if you need a complete TOC.<br />
<br />
<texcode><br />
\setuphead<br />
[chapter]<br />
[textcommand=\MyChapterTextCommand,<br />
numbercommand=\MyChapterNumberCommand]<br />
<br />
\def\MyChapterNumberCommand#1{} % hide chapter number<br />
<br />
\def\MyChapterTextCommand#1%<br />
{\externalfigure[chapter-\currentheadnumber][height=5cm]}<br />
</texcode><br />
<br />
[http://archive.contextgarden.net/message/20050519.215526.df7c5cd1.html]<br />
<br />
===Chapter head with absolute positioning of following text===<br />
<br />
<texcode><br />
\setuphead[chapter][before=\vbox to 4cm\bgroup,after=\vss\egroup]<br />
\starttext<br />
\chapter{test} \input tufte<br />
\stoptext<br />
</texcode><br />
<br />
No matter how many lines the chapter head runs to, the text will always start, e.g. 4cm below the top of the heading:<br />
<br />
<context><br />
\setuppapersize[A6][A6]<br />
\setuphead[chapter][before=\vbox to 4cm\bgroup,after=\vss\egroup]<br />
\setupbodyfont[8pt]<br />
\starttext<br />
\chapter{test} \input tufte<br />
\stoptext<br />
</context><br />
<br />
====Bug and proposed workaround====<br />
<br />
I tried this sample and <cmd>getmarking[chapter]</cmd>, used in my headers,<br />
stopped to work properly. Proposed workaround below.<br />
--[[User:Sebastian.rooks|SeR]] 00:52, 27 January 2006 (CET)<br />
<br />
<texcode><br />
\def\MyChapterCommand#1#2%<br />
{\vbox to 4cm\bgroup<br />
{#1\hskip.75em #2}<br />
\vss<br />
\egroup}<br />
<br />
\setuphead[chapter][header=nomarking,command=\MyChapterCommand]<br />
\starttext<br />
\chapter{test} \input tufte<br />
\stoptext<br />
</texcode><br />
<br />
<context><br />
\setuppapersize[A6][A6]<br />
\setupbodyfont[8pt]<br />
\def\MyChapterCommand#1#2%<br />
{\vbox to 4cm\bgroup<br />
{#1\hskip.75em #2}<br />
\vss<br />
\egroup}<br />
\setuphead[chapter][header=nomarking,command=\MyChapterCommand]<br />
\starttext<br />
\chapter{test} \input tufte<br />
\stoptext<br />
</context><br />
<br />
===Section head with underlining to width of last line===<br />
<br />
A style called for section headings to be followed by a rule which extends only the width of the text. More tricky was the need to make sure that if the text ran onto another line, it was the length of the ''last'' line that was to be followed. <br />
<br />
Hans came up with this cleverness, showing two alternate ways of doing it:<br />
<br />
<context source="yes" text="produces"><br />
\def\FirstSolution#1#2%<br />
{\vbox\bgroup<br />
\setbox0\hbox{#1}<br />
\hsize.4\textwidth<br />
\beginshapebox#2\endshapebox<br />
\gdef\SetLastLineWidth{\xdef\LastLineWidth{\the\wd\scratchbox}}%<br />
\reshapebox<br />
{\setbox\scratchbox\hbox{\unhbox\shapebox}%<br />
\SetLastLineWidth<br />
\globallet\SetLastLineWidth\relax<br />
\box\scratchbox}%<br />
\scratchdimen\dimexpr\wd0+.25em+\LastLineWidth\relax<br />
% \setbox2\ruledvbox {\innerflushshapebox} <br />
% why is correction needed<br />
\setbox2\vbox {\vskip-\lineskip\innerflushshapebox}<br />
\setbox0\vbox to \ht2{\box0}<br />
\hbox{\box0\hskip.25em\box2}<br />
\offinterlineskip<br />
\vskip.25ex<br />
\blackrule[width=\scratchdimen,height=1pt]<br />
\egroup}<br />
<br />
\doglobal\newcounter\NextLinePos<br />
<br />
\def\SecondSolution#1#2%<br />
{\vbox\bgroup<br />
\hsize.4\textwidth<br />
\doglobal\increment\NextLinePos<br />
\setbox\scratchbox\hbox{#1}<br />
\hbox{\vtop{\copy\scratchbox}\hskip.25em\vtop{#2}}%<br />
\offinterlineskip<br />
\scratchdimen\dimexpr\wd\scratchbox+.25em+<br />
\MPx{e:npl:\NextLinePos}-\MPx{b:npl:\NextLinePos}\relax<br />
\vskip.25ex<br />
\blackrule[width=\scratchdimen,height=1pt]<br />
\egroup}<br />
<br />
\def\DoSecondSolution#1%<br />
{\bpos{npl:\NextLinePos}#1\epos{npl:\NextLinePos}}<br />
<br />
% \showstruts<br />
<br />
\setuphead[section][command=\FirstSolution]<br />
<br />
\starttext<br />
<br />
\section{is this nice or not}<br />
<br />
\section{is this nice or not nice, that's the question}<br />
<br />
\setuphead[section][command=\SecondSolution,deeptextcommand=\DoSecondSolution]<br />
<br />
\section{is this nice or not}<br />
<br />
\section{is this nice or not nice, that's the question}<br />
<br />
\stoptext<br />
</context><br />
<br />
As if that wasn't enough, Taco pointed out that <cmd>lastlinewidth</cmd><br />
is the easy route to finding the width of the last line. Use something like:<br />
<br />
<code><br />
\optimizedisplayspacingtrue\setlastlinewidth % core-mat macro<br />
\global\advance\lastlinewidth-\hangindent\par % adjust<br />
\blackrule[width=\lastlinewidth,height=1pt]<br />
</code><br />
<br />
<br />
[[Category:Fonts]]<br />
[[Category:Graphics]]<br />
[[Category:Text elements]]</div>Wolfgang Schusterhttps://wiki.contextgarden.net/index.php?title=Layers&diff=9235Layers2009-02-03T11:10:30Z<p>Wolfgang Schuster: Added example for dynamic layer content.</p>
<hr />
<div>< [[Layout]] | [[Columns]] | [[Overlays]] | [[Logos]] | [[Collectors]] ><br />
<br />
'''Layers''' are ConTeXt's mechanism for absolute positioning of elements and other advanced techniques like switching elements on and off.<br />
<br />
There's still no manual about them.<br />
<br />
==My first Layer==<br />
<br />
Define a layer that takes the whole page<br />
<texcode><br />
\definelayer [mybg] % name of the layer<br />
[x=0mm, y=0mm, % from upper left corner of paper<br />
width=\paperwidth, height=\paperheight] % let the layer cover the full paper<br />
</texcode><br />
<br />
Now you can put something in that layer:<br />
<texcode><br />
\setlayer [mybg] % name of the layer<br />
[hoffset=1cm, voffset=1cm] % placement (from upper left corner of the layer)<br />
{\framed[frame=on, width=3cm, height=2cm]{LAYER}} % the actual contents of the layer<br />
</texcode><br />
<br />
Activate the layer as a background:<br />
<texcode><br />
\setupbackgrounds[page][background=mybg]<br />
</texcode><br />
This command makes the layer appear only once after the background is activated. If you want to repeat the layer on each page, use the option <code>repeat=yes</code> in the <cmd>definelayer</cmd> command.<br />
<br />
==Placement==<br />
<br />
There are several possibilities for defining the placement of layer content:<br />
* x, y : offset from upper left corner of paper<br />
* hoffset, voffset : offset from upper left corner of layer<br />
* corner : reference point, something like <code>{left, top}</code><br />
* location : alignment of the element relative to the corner, something like <code>{right, bottom}</code><br />
* preset : a named location, see below<br />
<br />
There are some "presets" for paper egde placement:<br />
<texcode><br />
% These four are defined by ConTeXt!<br />
\definelayerpreset [lefttop] [corner={left,top}, location={right,bottom}]<br />
\definelayerpreset [righttop] [corner={right,top}, location={left,bottom}]<br />
\definelayerpreset [leftbottom] [corner={left,bottom}, location={right,top}]<br />
\definelayerpreset [rightbottom] [corner={right,bottom}, location={left,top}]<br />
</texcode><br />
Similarly you can define your own presets.<br />
<br />
==State==<br />
<br />
The available options for the "state" of a layer are:<br />
<br />
* start: layer appears only on the current page<br />
* stop: layer doesn't show up<br />
* repeat: layer prints on all pages<br />
* next: layer appears on the following page<br />
* continue: layer appears on all pages except the first<br />
<br />
<br />
==Place labels on pictures==<br />
<br />
Layers can be used to put labels on pictures, alternative ways can be found in the [[manual:details.pdf| Details]] manual<br />
(see also [[Collectors]]).<br />
<br />
<texcode><br />
\definelayer [figure][width=\overlaywidth,height=\overlayheight]<br />
\defineoverlay[figure][{\directsetup{figure}\tightlayer[figure]}]<br />
<br />
\setupcolors[state=start]<br />
<br />
\starttext<br />
<br />
\startsetups figure<br />
<br />
\setlayerframed<br />
[figure]<br />
[preset=rightbottom,<br />
x=.25\layerwidth,<br />
y=.25\layerheight]<br />
{HERE}<br />
<br />
\setlayerframed<br />
[figure]<br />
[preset=leftbottom,<br />
x=.15\layerwidth,<br />
y=.35\layerheight]<br />
{THERE}<br />
<br />
\stopsetups<br />
<br />
\externalfigure[cow][background={foreground,figure},width=4cm,height=8cm]<br />
<br />
\startsetups figure<br />
<br />
\setlayerframed<br />
[figure]<br />
[preset=righttop,<br />
x=.25\layerwidth,<br />
y=.25\layerheight]<br />
{MORE}<br />
<br />
\setlayerframed<br />
[figure]<br />
[preset=middle,<br />
foregroundcolor=green]<br />
{EVEN MORE}<br />
<br />
\stopsetups<br />
<br />
\externalfigure[cow][background={foreground,figure},width=14cm,height=2cm]<br />
<br />
\defineexternalfigure[whatever][background={foreground,figure}]<br />
<br />
\startsetups figure<br />
<br />
\setlayerframed<br />
[figure]<br />
[preset=righttop,<br />
x=.25\layerwidth,<br />
y=.25\layerheight]<br />
{\red MORE}<br />
<br />
\setlayerframed<br />
[figure]<br />
[preset=middle,<br />
foregroundcolor=green]<br />
{EVEN MORE}<br />
<br />
\stopsetups<br />
<br />
\externalfigure[cow][whatever][width=14cm,height=4cm]<br />
<br />
\stoptext<br />
</texcode><br />
<br />
<br />
==Use dynamic content==<br />
<br />
The content of layer is fixed after your set it and will appear in the same way on each page.<br />
<br />
<texcode><br />
\definelayer<br />
[pagenumber]<br />
[width=\paperwidth,<br />
height=\paperheight,<br />
preset=middle,<br />
state=repeat]<br />
<br />
\setlayer[pagenumber]{Page \pagenumber}<br />
<br />
\setupbackgrounds[page][background=pagenumber]<br />
<br />
\starttext<br />
\dorecurse{4}{\page[empty]}<br />
\stoptext<br />
</texcode><br />
<br />
This is not always what you desire like in the example above, where on each page the current page number should be shown and not the number from the first page.<br />
<br />
To recalculate the content on each new page you have to enclose the <cmd>setlayer</cmd> settings within <cmd>startsetups</cmd> ... <cmd>stopsetups</cmd> and<br />
write <code>\setupbackgrounds[page][setups=setupname,background=layername]</code> in your document.<br />
<br />
<texcode><br />
\definelayer<br />
[pagenumber]<br />
[width=\paperwidth,<br />
height=\paperheight,<br />
preset=middle]<br />
<br />
\startsetups layer<br />
<br />
\setlayer[pagenumber]{Page \pagenumber}<br />
<br />
\stopsetups<br />
<br />
\setupbackgrounds[page][setups=layer,background=pagenumber]<br />
<br />
\starttext<br />
\dorecurse{4}{\page[empty]}<br />
\stoptext<br />
</texcode><br />
<br />
<br />
==Links==<br />
<br />
* Some applications in the [[manual:details.pdf|Details]] manual<br />
* [[Sample documents]]: [[BusinessCard]] and [[Letter style]]<br />
* Source: [[source:page-lyr.tex|page-lyr]]<br />
* Example of [[Alternating backgrounds and repeating layers]] and [[Draft Watermark]]<br />
<br />
{{todo|We need a lot of documentation and samples for this complicated subject.}}<br />
<br />
[[Category:Graphics]] [[Category:Layers]]</div>Wolfgang Schusterhttps://wiki.contextgarden.net/index.php?title=Letter_style&diff=9220Letter style2009-01-26T20:58:32Z<p>Wolfgang Schuster: New letter style.</p>
<hr />
<div>< [[Sample documents]]<br />
<br />
<br />
== Wolfgang's Letter Module ==<br />
<br />
[[Letter]]<br />
<br />
== German Letter style ==<br />
<br />
The following is thought to be a(n early version of a) template for DIN (Deutsches Institut für Normung, German Standardization Institute) conforming letters. Using some provided commands, it should be easy to set sender and receiver addresses for window envelopes, include text or a logo at the top, and contact information to the right of the window space.<br />
<br />
If you want to use it, save the following as <tt>letterstyle.tex</tt> and follow the usage instructions. A downloadable version is available [[media:letterstyle.tex|here]].<br />
<br />
'''Beware:''' This style redefines <cmd>subject</cmd> as letter subject line and thus disables header setup!<br />
<br />
<texcode><br />
%<br />
% Style (environment) for writing letters<br />
%<br />
% (c) 2004 Holger Schöner hfsch@cs.tu-berlin.de<br />
% with contributions from Stefan Bunzel<br />
%<br />
% Feel free to use as you like. If modified, please remove the above<br />
% copyright notice.<br />
%<br />
<br />
%=============================================================================<br />
% Usage:<br />
%<br />
% \environment letterstyle<br />
% \starttext<br />
% \letter{<string>}<br />
% \setdate{(string)}<br />
% \place{(string)}<br />
% \shortsender{(one-line address of sender)}<br />
% \disposal{(orders)}<br />
% \addressee{(address of receiver; use \\ and \| for new lines)}<br />
% % Block with information about sender on the right hand side (name, phone,<br />
% % fax, email, etc.). (key) is set flush right in a very small font (by<br />
% % default, see \keystyle) and specifies the type of information, and (value)<br />
% % is the actual information.<br />
% \senderone{(key)}{(value)}<br />
% \sendertwo{(key)}{(value)}<br />
% ...<br />
% \sendernine{(key)}{(value)}<br />
% \addfirstheaderlayer[corner={top,left},location={bottom,right}]{\framed[width=\overlaywidth,height=\logoboxheight,frame=off]{}}<br />
% \headercontent{(text)} % Text placed in the header of every page except the first<br />
% \addheaderlayer[corner={top,left},location={bottom,right}]{}<br />
% \footercontent{(text)} % Text placed in the footer of every page<br />
% \addfooterlayer[corner={bottom,right},location={top,left}]{}<br />
% \subject{(subject)}<br />
% \greeting{(greetings formulation)}<br />
% \signature{(name)}<br />
% \attachments{(text)}<br />
%<br />
% ----------------------------------------------------------------------------<br />
% Modes:<br />
% demo: Set an example letter specified at the end of this file for<br />
% test/demo purposes.<br />
% nofold: Determines whether folding marks are set or not. By default,<br />
% they are printed; using this mode they are left out.<br />
%<br />
% Set modes by using<br />
% texexec -pdf --mode=(mode1,mode2,...) (file)<br />
% or specify \enablemode[(mode)] in your input (before including the style)<br />
%<br />
% ----------------------------------------------------------------------------<br />
% There are some nasty tricks involved here; e.g. I could not find a cleaner<br />
% way to specify a header which is to be used for only one page and has a<br />
% different height than that of the following ...<br />
%<br />
% I'd be glad about any hints for improvement of this style!<br />
%<br />
<br />
\startenvironment letterstyle<br />
<br />
%=============================================================================<br />
% Default values<br />
<br />
% Standard Dimensions<br />
\def\firstpageheaderheight{9.5cm}<br />
%\def\firstpagetextheight{8.0cm}<br />
\def\normalheaderheight{1.0cm}<br />
\def\logoboxheight{3.4cm}<br />
\def\normaltextheight{27.4cm}<br />
\def\normalfooterheight{1.0cm}<br />
\def\sendervalwidth{5.05cm}<br />
\def\senderkeywidth{1.85cm}<br />
<br />
%% Standard Styles<br />
\def\keystyle{\tfxx}<br />
\def\valstyle{}<br />
<br />
%=============================================================================<br />
% Initializations<br />
<br />
\def\\{\vskip0mm}<br />
\def\|{\vskip1.5ex}<br />
<br />
\def\letterdate{}<br />
\def\letterplace{}<br />
\def\lettershortsender{}<br />
\def\letterdisposal{}<br />
\def\letteraddressee{}<br />
<br />
\def\lettersenderkeyone{}<br />
\def\lettersendervalone{}<br />
\def\lettersenderkeytwo{}<br />
\def\lettersendervaltwo{}<br />
\def\lettersenderkeythree{}<br />
\def\lettersendervalthree{}<br />
\def\lettersenderkeyfour{}<br />
\def\lettersendervalfour{}<br />
\def\lettersenderkeyfive{}<br />
\def\lettersendervalfive{}<br />
\def\lettersenderkeysix{}<br />
\def\lettersendervalsix{}<br />
\def\lettersenderkeyseven{}<br />
\def\lettersendervalseven{}<br />
\def\lettersenderkeyeight{}<br />
\def\lettersendervaleight{}<br />
\def\lettersenderkeynine{}<br />
\def\lettersendervalnine{}<br />
<br />
\def\letterheadertext{}<br />
\def\letterfootertext{}<br />
<br />
%=============================================================================<br />
<br />
\setuppapersize[A4][A4]<br />
\setuplayout[location=doublesided]<br />
%\setuppagenumbering[alternative=doublesided]<br />
%\setuppagenumbering[alternative={singlesided,doublesided}]<br />
%\setuppagenumbering[alternative=singlesided}]<br />
\setuppagenumbering[location=]<br />
<br />
%=============================================================================<br />
%% Header and footer initializations<br />
<br />
%% Start of a new letter; heading text is used only in an optional table of contents<br />
\def\letter#1{%<br />
\setuplayer[normalheaderlayer][state=reset]%<br />
\setuplayer[allpagefooterlayer][state=reset]%<br />
\letterhead{#1}%<br />
\setuplayer[firstheaderlayer][state=reset]%<br />
}<br />
\definehead[letterhead][title]<br />
\setuphead [letterhead][<br />
placehead=empty,<br />
before={%<br />
\setups{firstpagelayoutsetup}%<br />
},<br />
after=,<br />
header=firstpageheader,<br />
page=firstpagebreak,<br />
coupling=title]<br />
<br />
%% Making empty pages completely empty (no page numbers):<br />
\definepagebreak<br />
[firstpagebreak]<br />
[yes,header,footer,right] % yes instead of emtpy taken from the sources page-ini.tex line 1611<br />
<br />
%% Layout of first page<br />
\startsetups firstpagelayoutsetup<br />
\setuplayout[<br />
backspace=2.46cm,topspace=1.2cm,<br />
top=0cm,bottom=0cm,topdistance=0cm,bottomdistance=0cm,<br />
header=\firstpageheaderheight,footer=\normalfooterheight,headerdistance=0cm,footerdistance=0cm,<br />
leftedge=0cm,rightedge=0cm,leftedgedistance=0cm,rightedgedistance=0cm,<br />
leftmargin=1.5cm,rightmargin=1.5cm,leftmargindistance=0.42cm,rightmargindistance=0.42cm,<br />
width=16.5cm,height=\normaltextheight,<br />
]<br />
\stopsetups<br />
% Layout of other pages<br />
\startsetups normalpagelayoutsetup<br />
\setuplayout[<br />
backspace=2.46cm,topspace=1.2cm,<br />
top=0cm,bottom=0cm,topdistance=0cm,bottomdistance=0cm,<br />
header=\normalheaderheight,footer=\normalfooterheight,headerdistance=0cm,footerdistance=0cm,<br />
leftedge=0cm,rightedge=0cm,leftedgedistance=0cm,rightedgedistance=0cm,<br />
leftmargin=1.5cm,rightmargin=1.5cm,leftmargindistance=0.42cm,rightmargindistance=0.42cm,<br />
width=16.5cm,<br />
height=\normaltextheight,textheight=\normaltextheight,<br />
]<br />
\stopsetups<br />
<br />
%% Header for first pages<br />
\definetext[firstpageheader][header][\setups{firstpagesetup}]<br />
\startsetups firstpagesetup<br />
\setups{firstpageintrosetup}<br />
\setups{foldingmarkslayersetup}<br />
\framed[width=\makeupwidth,height=\headerheight,<br />
background={firstpagelayer,firstheaderlayer},frame=off]<br />
{}<br />
\stopsetups<br />
<br />
%% Header for other pages<br />
\setups{normalpagelayoutsetup}<br />
\appendtoks\setups{normalpagelayoutsetup}\to\everyaftershipout<br />
\startsetups normalheadersetups<br />
\setups{normalheaderlayersetup}<br />
\framed[width=\makeupwidth,height=\headerheight,<br />
background=normalheaderlayer,frame=off]<br />
{}<br />
\stopsetups<br />
\setupheadertexts[\setups{normalheadersetups}]<br />
<br />
%% Footer for all pages<br />
\startsetups allpagefootersetup<br />
\setups{allpagefooterlayersetup}<br />
\framed[width=\makeupwidth,height=\footerheight,<br />
background=allpagefooterlayer,frame=off]<br />
{}<br />
\stopsetups<br />
\setupfootertexts[\setups{allpagefootersetup}]<br />
<br />
%=============================================================================<br />
%% First page header setups<br />
<br />
\definelayer[firstpagelayer][width=\makeupwidth,height=\firstpageheaderheight]<br />
<br />
\startsetups firstpageintrosetup<br />
%% Logo frame<br />
\setlayerframed[firstpagelayer]<br />
[corner={left,top},location={right,bottom}]<br />
[height=3.4cm,width=\overlaywidth,frame=off,offset=none]<br />
{}<br />
%% Short sender frame<br />
\doiftextelse{\lettershortsender}{<br />
\setlayerframed[firstpagelayer]<br />
[y=3.8cm,location={right,bottom}]<br />
[height=0.3cm,width=8cm,frame=off,bottomframe=on,offset=none,align={right,lohi}]<br />
{\tfxx \lettershortsender}}{<br />
\setlayerframed[firstpagelayer]<br />
[y=3.8cm,location={right,bottom}]<br />
[height=0.3cm,width=8cm,frame=off,bottomframe=off,offset=none,align={right,lohi}]<br />
{\tfxx \lettershortsender}}<br />
%% Addressee frame<br />
\setlayerframed[firstpagelayer]<br />
[y=4.1cm,location={right,bottom}]<br />
[height=3.6cm,width=8cm,frame=off,offset=none,align={right,top}]<br />
{<br />
\doiftextelse{\letterdisposal}{\vskip1.0ex\letterdisposal}{}<br />
\vskip1.5ex<br />
\letteraddressee<br />
}<br />
%% Sender frame<br />
\setlayerframed[firstpagelayer]<br />
[corner={right},y=4.1cm,location={left,bottom}]<br />
[height=4.6cm,width=\dimexpr(\senderkeywidth+\sendervalwidth),frame=off,offset=none,align={left,top}] % [height=4.6cm,width=6.4cm,frame=off,offset=none,align={left,top}]<br />
{\setups{sendertablesetup}}<br />
%% Date field<br />
\setlayerframed[firstpagelayer]<br />
[corner={right},y=8.7cm,location={left,bottom}]<br />
[height=0.5cm,width=\dimexpr(\senderkeywidth+\sendervalwidth),align={left,top},frame=off,offset=none] % [height=0.5cm,width=6.4cm,align={left,top},frame=off,offset=none]<br />
{<br />
\bTABLE<br />
\setupTABLE[frame=off]<br />
\setupTABLE[x][1][width=\senderkeywidth,align=left] % width: std 1.85cm<br />
\setupTABLE[x][2][width=\sendervalwidth,align=right] % width: std 4.55cm<br />
%\setupTABLE[y][maxheight=1ex]<br />
\bTR \bTD<br />
{\keystyle\translate[en=date,de=Datum]:}<br />
\eTD \bTD<br />
\valstyle<br />
\doiftextelse{\letterplace}<br />
{\letterplace,\translate[en=, de=]\ }{}<br />
\doiftextelse{\letterdate}{\letterdate}{\currentdate} % \currentdate[weekday,month,day,{, },year]<br />
\eTD \eTR<br />
\eTABLE<br />
}<br />
\stopsetups<br />
<br />
%% Table with sender information<br />
\startsetups sendertablesetup<br />
\bTABLE<br />
\setupTABLE[frame=off]<br />
\setupTABLE[x][1][width=\senderkeywidth,align=left]<br />
\setupTABLE[x][2][width=\sendervalwidth,align=right]<br />
\bTR \bTD \strut\doiftextelse{\lettersenderkeyone} {\keystyle\lettersenderkeyone:} {} \eTD \bTD \valstyle\lettersendervalone \eTD \eTR<br />
\bTR \bTD \strut\doiftextelse{\lettersenderkeytwo} {\keystyle\lettersenderkeytwo:} {} \eTD \bTD \valstyle\lettersendervaltwo \eTD \eTR<br />
\bTR \bTD \strut\doiftextelse{\lettersenderkeythree}{\keystyle\lettersenderkeythree:}{} \eTD \bTD \valstyle\lettersendervalthree \eTD \eTR<br />
\bTR \bTD \strut\doiftextelse{\lettersenderkeyfour} {\keystyle\lettersenderkeyfour:} {} \eTD \bTD \valstyle\lettersendervalfour \eTD \eTR<br />
\bTR \bTD \strut\doiftextelse{\lettersenderkeyfive} {\keystyle\lettersenderkeyfive:} {} \eTD \bTD \valstyle\lettersendervalfive \eTD \eTR<br />
\bTR \bTD \strut\doiftextelse{\lettersenderkeysix} {\keystyle\lettersenderkeysix:} {} \eTD \bTD \valstyle\lettersendervalsix \eTD \eTR<br />
\bTR \bTD \strut\doiftextelse{\lettersenderkeyseven}{\keystyle\lettersenderkeyseven:}{} \eTD \bTD \valstyle\lettersendervalseven \eTD \eTR<br />
\bTR \bTD \strut\doiftextelse{\lettersenderkeyeight}{\keystyle\lettersenderkeyeight:}{} \eTD \bTD \valstyle\lettersendervaleight \eTD \eTR<br />
\bTR \bTD \strut\doiftextelse{\lettersenderkeynine} {\keystyle\lettersenderkeynine:} {} \eTD \bTD \valstyle\lettersendervalnine \eTD \eTR<br />
\eTABLE<br />
\stopsetups<br />
<br />
%=============================================================================<br />
%% First page header setups<br />
<br />
\definelayer[firstheaderlayer][width=\makeupwidth,height=\logoboxheight,width=\overlaywidth]<br />
<br />
%=============================================================================<br />
%% Normal page header setups<br />
<br />
\definelayer[normalheaderlayer][width=\makeupwidth,height=\normalheaderheight]<br />
<br />
\startsetups normalheaderlayersetup<br />
\setlayerframed[normalheaderlayer]<br />
[corner={top,left},location={bottom,right}]<br />
[height=\normalheaderheight,width=\makeupwidth,frame=off,offset=none,align={high,middle}]<br />
{\letterheadertext}<br />
\stopsetups<br />
<br />
%=============================================================================<br />
%% Footer setups<br />
<br />
\definelayer[allpagefooterlayer][width=\makeupwidth,height=\footerheight]<br />
<br />
\startsetups allpagefooterlayersetup<br />
\setlayerframed[allpagefooterlayer]<br />
[corner={right,bottom},location={left,top}]<br />
[height=\footerheight,width=\makeupwidth,frame=off,offset=none,align={low,middle}]<br />
{\letterfootertext}<br />
\stopsetups<br />
<br />
%=============================================================================<br />
%% Folding marks on left<br />
<br />
\startnotmode[nofold]<br />
\setupbackgrounds[rightpage][page][state=start,background=foldingmarkslayer]<br />
\stopnotmode<br />
<br />
\definelayer[foldingmarkslayer][state=repeat]<br />
<br />
\startsetups foldingmarkslayersetup<br />
\setlayer[foldingmarkslayer][y=10.7cm, x=0.5cm,align={lohi,right}]{---}<br />
\setlayer[foldingmarkslayer][y=14.85cm,x=0.5cm,align={lohi,right}]{--}<br />
\setlayer[foldingmarkslayer][y=20.2cm, x=0.5cm,align={lohi,right}]{---}<br />
\stopsetups<br />
<br />
%=============================================================================<br />
%% Commonly used letter parts<br />
<br />
% Date; if not used, current date is inserted<br />
\def\setdate#1{\def\letterdate{#1}}<br />
% Place, for the date line<br />
\def\place#1{\def\letterplace{#1}}<br />
% Short sender information for address window in envelope<br />
\def\shortsender#1{\def\lettershortsender{#1}}<br />
% Order<br />
\def\disposal#1{\def\letterdisposal{#1}}<br />
% Address of receiver of the letter<br />
\def\addressee#1{\def\letteraddressee{{#1}}} % \let\crlf=\\ <br />
% Information about sender<br />
\def\senderone#1#2{\def\lettersenderkeyone{#1}\def\lettersendervalone{#2}}<br />
\def\sendertwo#1#2{\def\lettersenderkeytwo{#1}\def\lettersendervaltwo{#2}}<br />
\def\senderthree#1#2{\def\lettersenderkeythree{#1}\def\lettersendervalthree{#2}}<br />
\def\senderfour#1#2{\def\lettersenderkeyfour{#1}\def\lettersendervalfour{#2}}<br />
\def\senderfive#1#2{\def\lettersenderkeyfive{#1}\def\lettersendervalfive{#2}}<br />
\def\sendersix#1#2{\def\lettersenderkeysix{#1}\def\lettersendervalsix{#2}}<br />
\def\senderseven#1#2{\def\lettersenderkeyseven{#1}\def\lettersendervalseven{#2}}<br />
\def\sendereight#1#2{\def\lettersenderkeyeight{#1}\def\lettersendervaleight{#2}}<br />
\def\sendernine#1#2{\def\lettersenderkeynine{#1}\def\lettersendervalnine{#2}}<br />
% Subject line<br />
\def\subject#1{{\bf #1}\vskip2ex}<br />
% Signature: Name, Position<br />
\def\greeting#1{\testpage[8]\vskip1ex{#1}}<br />
% Signature: Name, Position<br />
\def\signature#1{{\let\\=\crlf \vskip8ex\vtop{#1}}}<br />
% Attachments included<br />
\def\attachments#1{{\let\\=\crlf \vskip3ex{{\bf\translate[en=Attachments, de=Anlagen]:}\\ #1}}}<br />
<br />
%% First header<br />
%\def\resetfirstheaderlayer{\setuplayer[firstheaderlayer][state=reset]}<br />
\def\addfirstheaderlayer[#1]#2{%<br />
% \setuplayer[firstheaderlayer][state=repeat]%<br />
\setlayer[firstheaderlayer][#1]{#2}%<br />
}<br />
<br />
%% Header<br />
\def\letterheadertext{}<br />
\def\headercontent#1{\def\letterheadertext{#1}}<br />
\def\resetheaderlayer{\setuplayer[normalheaderlayer][state=reset]}<br />
\def\addheaderlayer[#1]#2{%<br />
\def\letterheadertext{}%<br />
\setuplayer[normalheaderlayer][state=repeat]%<br />
\setlayer[normalheaderlayer][#1]{#2}%<br />
}<br />
<br />
%% Footer<br />
\def\letterfootertext{\translate[en=page, de=Seite]~\pagenumber/\totalnumberofpages}<br />
\def\footercontent#1{\def\letterfootertext{#1}}<br />
\def\resetfooterlayer{\setuplayer[allpagefooterlayer][state=reset]}<br />
\def\addfooterlayer[#1]#2{%<br />
\def\letterfootertext{}%<br />
\setuplayer[allpagefooterlayer][state=repeat]%<br />
\setlayer[allpagefooterlayer][#1]{#2}%<br />
}<br />
<br />
%=============================================================================<br />
\stopenvironment<br />
<br />
%=============================================================================<br />
\startmode[demo]<br />
<br />
% Necessary, if you want to print folding marks only on odd pages<br />
\setuppagenumbering[alternative={singlesided,doublesided}]<br />
<br />
% \input letterstyle<br />
<br />
\starttext<br />
\letter{Example Letter}<br />
%\setdate{(string)}<br />
\place{Berlin}<br />
<br />
\shortsender{My Name $\cdot$ My Street 123 $\cdot$ 12345 My Town}<br />
\disposal{confidential}<br />
\addressee{Mr. Example\\ Test Drive 99\| 98765 Other Town}<br />
<br />
\senderone{tel.}{+49 30 12345678}<br />
\sendertwo{email}{xyz@abc.com}<br />
<br />
%\addfirstheaderlayer[corner={top,left},location={bottom,right}]{\framed[width=\overlaywidth,height=\logoboxheight,frame=off]{}}<br />
\headercontent{\hfill test letter, page \pagenumber}<br />
%\addheaderlayer[corner={top,left},location={bottom,right}]{}<br />
\footercontent{From MyName\hfill To Mr. Example}<br />
%\addfooterlayer[corner={bottom,right},location={top,left}]{}<br />
<br />
\subject{What do you think about the Letterstyle?}<br />
<br />
Dear Reader,<br />
<br />
\dorecurse{11}{\input tufte\par}<br />
<br />
\greeting{Best regards,}<br />
\signature{My Name}<br />
<br />
\attachments{The Letterstyle}<br />
<br />
%-----------------------------------------------------------------------------<br />
% Necessary to suppress emtpy last page in doublesided pagenumbering mode<br />
\installpagebreakhandler{last}{}<br />
<br />
\stoptext<br />
<br />
\stopmode<br />
</texcode><br />
<br />
==Another Approach==<br />
<br />
Here is an alternative to the approach suggested by Holger. My university introduced a new official letterhead some months ago, and I was quite impressed to see that they even provided a LaTeX class for it. Of course, there was no ConTeXt support, so I decided to do it myself. My aim was merely to copy the official style, so my approach is far less fancy than the one before: you get a letter with a logo in the upper right corner, fields for information about the sender (assuming that the sender sits in a department of a university), and commands for the parts of a typical letter. <br />
<br />
Instructions: copy the code below into a file, modify the generic information provided there to your needs, and save this file somewhere where ConTeXt can find it (the canonical place would be $HOMETEXMF/tex/context/third) as t-letterhead.tex. See below for usage instructions.<br />
<br />
<texcode><br />
\protect<br />
<br />
\setuppapersize[A4][A4] % or [letter][letter]; in that case, you'll have to fidget with the dimensions<br />
<br />
\setuplayout[header=0mm,topspace=20mm,backspace=22mm,footer=0mm,width=160mm] % margins etc.<br />
<br />
\enableregime[utf] % or whatever you prefer<br />
<br />
\setupcolors[state=start] % in case you want any colored output<br />
<br />
\mainlanguage[en] % or whatever you prefer<br />
<br />
\setupbodyfont[modern,8pt] % this is the small bodyfont for the letterhead; we'll change to a bigger size for the actual letter later<br />
<br />
\setuptabulate[before={\blank[0pt]},after={\blank[0pt]}] % there's a tabular, and I don't want any blank lines around it<br />
<br />
\setuppagenumbering[state=stop] <br />
<br />
\definelayer[myletter][x=1mm,y=1mm,width=\paperwidth,height=22mm] % The elements of the letterhead are defined as layers. This first layer contains the logo; you'll have to<br />
\setlayer[myletter][x=104mm,y=11mm]{\externalfigure[Logo][width=56mm,height=20mm]} % supplyan image file yourself.<br />
<br />
\definelayer[myuni][x=1mm,y=1mm,width=\paperwidth,height=24mm] % Second layer: Small column, right-aligned, with name of university and your name, in a narrow column<br />
\setlayer[myuni][x=110.5mm,y=42mm]{\framed[width=50mm,height=22mm,frame=off]{\lbox to % below the logo.<br />
35mm{\ss Name\\ of My University \\ (My Town) \\<br />
\blank[line] \\ {\bf My Name} \\ Supreme Headmaster}}}<br />
<br />
\definelayer[dept][x=1mm,y=1mm,width=\paperwidth,height=24mm] % Third layer, left-aligned, opposite layer 2. This column contains you contact information and the date.<br />
\setlayer[dept][x=163mm,y=42mm]{\framed[width=40mm,height=22mm,frame=off]{\rbox<br />
to 35mm{\ss Faculty of \\ Arts and Sciences \\<br />
\blank[2*line] \\ Department of \\ High Energe Metaphysics\\<br />
\blank[2*line]\\ 33 Main Street \\ Capital, DC 12345 \\ \starttabulate[|lw(4mm)|lw(36mm)|]<br />
\NC Tel.: \NC (123) 456-7890 \NC\NR \NC Fax.: \NC (098) 7654-321 \NC\NR<br />
\stoptabulate \\ Administrator: Highly Efficient \\<br />
\starttabulate[|lw(4mm)|lw(36mm)|] \NC Tel.: \NC (012) 345-6789 \NC\NR<br />
\stoptabulate \\ mymail@myaddress\\ www.my.website.edu \\ \blank[2*line]\\ Mytown,<br />
\currentdate}}}<br />
<br />
\definelayer[send][x=0mm,y=1mm,width=\paperwidth,height=15mm] % Fourth layer: one line, in fine print, that contains a short sender address; will be on top of the<br />
\setlayer[send][x=9.4mm,y=44mm]{\framed[width=100mm,height=13mm,frame=off]{\ss % envelope's window.<br />
\vii {\bf My University} $\cdot$ My Name $\cdot$<br />
Dept. of Metaphysics $\cdot$ Capital, DC 12345}}<br />
<br />
\startuniqueMPgraphic{fold}<br />
fill unitsquare scaled 1mm withcolor blue ;<br />
\stopuniqueMPgraphic <br />
<br />
\definelayer[foldingmarkslayer][state=repeat] % Fifth layer: the folding marks<br />
\setlayer[foldingmarkslayer][y=101mm, x=11mm]{\useMPgraphic{fold}}<br />
\setlayer[foldingmarkslayer][y=147mm, x=11mm]{\useMPgraphic{fold}}<br />
\setlayer[foldingmarkslayer][y=55mm, x=11mm]{\useMPgraphic{fold}}<br />
<br />
\setupbackgrounds [page][background={foldingmarkslayer,myletter,myuni,dept,send}] % Make all layers active for page.<br />
<br />
\long\def\addressee#1{\strut\blank[23*medium]\switchtobodyfont[11pt]\setupwhitespace[none]#1} % Defines field for receiver's address and places it at right position.<br />
<br />
\long\def\lettersubject#1{\blank[3*line]{\bf Re: #1}} % Subject line, in bold face.<br />
<br />
\long\def\letteropening#1{\blank[line]#1} % opening...<br />
<br />
\long\def\letterbody#1{\blank[line]\setupwhitespace[medium]#1} % the main body<br />
<br />
\long\def\letterclosing#1{\blank[line]#1\blank[3*line]} % and the closing formula<br />
<br />
\setupalign[right] % I prefer letters with a ragged right, but you don't have to...<br />
<br />
\ss % I want the sans font for the entire letter, but of course you can change to \tt or \rm, if you want<br />
<br />
\unprotect<br />
<br />
</texcode><br />
<br />
Here's an example how this module can be used:<br />
<br />
<texcode><br />
\usemodule[t-letterhead]<br />
<br />
\starttext<br />
<br />
\addressee{Prof.\crlf<br />
Heinrich Seltsam\crlf<br />
Dept. of Physics\crlf<br />
University of Southern Wyoming \crlf<br />
123 Einstein Str.\crlf<br />
Scumbag, WY 76543}<br />
<br />
\lettersubject{My New Letterstyle}<br />
<br />
\letteropening{Estimated Colleague,}<br />
<br />
\letterbody{\dorecurse{6}{\input tufte\par}}<br />
<br />
\letterclosing{Sincerely Yours}<br />
<br />
Larry<br />
<br />
\stoptext<br />
</texcode><br />
<br />
Any feedback welcome. I'm not sure if the \long\defs for the several parts of the letters are very elegant and would be grateful if some of the moew knowledgeable folks could suggest something better. But overall, I like the simplicity of this style.<br />
<br />
<br />
== Another Simple Style ==<br />
<br />
<texcode><br />
%Context Environment for a basic Full Block Letter with Letterhead<br />
\enableregime [utf]<br />
\mainlanguage [en]<br />
<br />
%==============Setup Page Layout======================<br />
\def\MyPageNumber#1%<br />
{{--~Page #1 / \lastpage~--}}%use lastpage for total page count<br />
\setuppagenumbering[location={footer,middle},command=\MyPageNumber]<br />
\setuppapersize[letter][letter]<br />
\usetypescript[palatino]<br />
\setupbodyfont[palatino,10pt,rm]<br />
\setuplayout[<br />
topspace=1.7in,<br />
backspace=1.5in,<br />
header=0mm,<br />
footer=.25in,<br />
width=5.5in,<br />
height=8.55in]<br />
\useexternalfigure[logo][letterheadLG][width=\makeupwidth,height=.7in]<br />
\setupbackgrounds<br />
[page]<br />
[background={Letterhead,NextPgHead},state=repeat]<br />
\definelayer[Letterhead]<br />
[x=1.5in,y=1in,width=\makeupwidth,height=.7in,state=start]<br />
\setlayerframed[Letterhead]<br />
[corner={top,left},location={bottom,right},frame=off]<br />
[offset=none,frame=off]<br />
{\externalfigure[logo]}<br />
\definelayer[NextPgHead]<br />
[x=1.5in,y=1in,width=\makeupwidth,height=.7in,state=continue]<br />
<br />
<br />
%==============Setup Paragraph Formatting==============<br />
\setupwhitespace[big]<br />
\setupindenting[no,medium,next]<br />
<br />
%=================Define Letter Elements==================<br />
<br />
\defineblank[FourLines][4*line,flexible]<br />
\defineblank[OneLine][1*line,flexible]<br />
<br />
\def\Regarding#1{\setgvariables[Letter][val={Re: #1}]Re: #1}<br />
\def\RecNameVal{}<br />
\def\RecName#1{<br />
\def\RecNameVal{#1}<br />
\setlayerframed[NextPgHead]<br />
[corner={top,left},location={bottom,right},frame=off]<br />
[offset=none,frame=off]<br />
{\framed[frame=off,width=\makeupwidth,height=.7in,align={right,high}]%<br />
{{\setupinterlinespace \RecNameVal\par<br />
\setupinterlinespace\date\par<br />
\setupinterlinespace\getvariable{Letter}{val}\par}}}<br />
#1}<br />
<br />
\long\def\MailingNote#1{\WORD{#1}\par}%<br />
\long\def\Disposition#1{\WORD{#1}}%<br />
\define[1]\Opening{#1:\blank[OneLine]}%<br />
\define[1]\Closing{#1,\blank[FourLines]}%<br />
\define[1]\Signature{#1\blank[OneLine]}%<br />
\define[1]\Enclosures{\doifelse{#1}{1}{Enclosure}{Enclosures: #1}\blank[OneLine]}%<br />
\definedescription[CC][location=left,distance=-.75in]<br />
<br />
\definestartstop[Sender][before={\startlines},after={\stoplines\blank[FourLines]}]<br />
\definestartstop[Notes][before={\startlines},after={\stoplines\blank[OneLine]}]<br />
\definestartstop[Recipient][before={\startlines},after={\stoplines\blank[OneLine]}]<br />
\definestartstop[Body][before={\startlines},after={\stoplines\blank[OneLine]}]<br />
<br />
<br />
%=============Define Quotes====================<br />
%just use \Qt{} and all nesting should be taken care of<br />
\definedelimitedtext[Qt][quotation]<br />
\setupdelimitedtext<br />
[Qt]<br />
[1]<br />
[left={\symbol[leftquotation]},<br />
right={\symbol[rightquotation]}]<br />
<br />
\setupdelimitedtext<br />
[Qt]<br />
[2]<br />
[left={\symbol[leftquote]},<br />
right={\symbol[rightquote]}]<br />
<br />
\setupdelimitedtext<br />
[Qt]<br />
[3]<br />
[left={\symbol[leftquotation]},<br />
right={\symbol[rightquotation]}]<br />
<br />
%To create blockquotes use \startextract \stopextract<br />
\defineblank[ExtractDistance][3pt]<br />
\definestartstop[Extract][<br />
style=italic,<br />
before={\blank[ExtractDistance]<br />
\setupnarrower[left=1.5pc,right=1.5pc]<br />
\startnarrower[left,right]<br />
\noindent},<br />
after={\stopnarrower<br />
\blank[ExtractDistance]<br />
\indenting[next]}]%Don't indent the immediately following paragraph, but do indent later ones.<br />
<br />
%==================Define Enumerations===========================<br />
\defineitemgroup[Outline][5]%Use with \startOutline ... \item ... \stopOutline<br />
\setupitemgroup[Outline][1][R]%First level, Roman Numerals<br />
\setupitemgroup[Outline][2][A]%Second Level, A,B,C etc.<br />
\setupitemgroup[Outline][3][n]%Third level, Numberd<br />
\setupitemgroup[Outline][4][r][left=(,right=),stopper=]%Fourth level, lowercase roman<br />
\setupitemgroup[Outline][5][m][left=(,right=),stopper=]%Fifth level, lowercase numbered<br />
<br />
\defineitemgroup[Bullet][5]%Use with \startBullet ... \item ... \stopBullet<br />
\setupitemgroup[Bullet][1][1]%First level<br />
\setupitemgroup[Bullet][2][2]%Second Level<br />
\setupitemgroup[Bullet][3][5]%Third level<br />
\setupitemgroup[Bullet][4][1]%Fourth level<br />
\setupitemgroup[Bullet][5][2]%Fifth level<br />
</texcode><br />
<br />
And how to use it:<br />
<br />
<texcode><br />
\environment basicLetterEnv<br />
\starttext<br />
\startSender<br />
Company Name<br />
Your Name, Your Title<br />
1234 AnyStreet<br />
City, ST 75098<br />
Phone: 123-456-7890<br />
Email: asdf@asdf.com<br />
Web: www.asdf.com<br />
\date<br />
\Regarding{The subject of this letter}<br />
\stopSender<br />
<br />
\startNotes<br />
\MailingNote{Certified Mail}%Mailing Notations:Certified,AirMail, Priority...<br />
\Disposition{Confidential}%Disposition: Confidential, personal ...<br />
\stopNotes<br />
<br />
\startRecipient<br />
\RecName{First Last Name}<br />
Company Name<br />
4567 ThisStreet<br />
City, US 12345<br />
\stopRecipient<br />
<br />
\Opening{Dear First Name}<br />
<br />
\startBody<br />
\dorecurse{5}<br />
{Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Cras tellus.<br />
Proin fringilla euismod elit. Donec eleifend purus sed eros. Fusce quis<br />
diam. Donec euismod nisl non dui. Donec eu odio. Nam congue risus in<br />
eros commodo elementum. Duis dolor. Etiam luctus mauris ut mi. Vivamus<br />
vitae sem eu justo pretium ullamcorper. Aliquam ac mauris posuere justo<br />
molestie interdum. Nullam eleifend leo quis justo. Suspendisse tortor<br />
risus, porta a, hendrerit in, facilisis at, lectus.\par}<br />
\stopBody<br />
<br />
\Closing{Sincerely}<br />
<br />
<br />
\Signature{Your Name, General Counsel}<br />
<br />
\Enclosures{1}<br />
\startCC{CC:}<br />
A Name\par<br />
Another Name\par<br />
File<br />
\stopCC<br />
<br />
\stoptext<br />
</texcode><br />
<br />
==Letterhead==<br />
<br />
The following style was presented in the PracTeX Journal by Joseph Hogg, you find the article under the following link:<br />
<br />
* http://www.tug.org/pracjourn/2006-3/hogg/<br />
<br />
<texcode><br />
% Context file for letterhead<br />
\setuppapersize[letter][letter]<br />
\setuplayout[height=9in,backspace=80pt,location=middle]<br />
\setupbodyfont[serif,12pt] \setupwhitespace[big]<br />
\setupcolors[state=start]<br />
% Set up addressee here, From and Date<br />
\define\Toperson{A. U. Thor}<br />
\define\Totitle{Editor}<br />
\define\Tocompany{Great \TeX\ Journal}<br />
\define\Tostreet{P. O. Box 3.1415926}<br />
\define\TocityStateZip{\TeX town, 67890-12345}<br />
\define\Tocountry{USA}<br />
\define\Fromperson{Ben Lee User}<br />
\define\Mydate{\currentdate}<br />
% End addressee, From and Date<br />
\setupheader[state=none] \setupfooter[state=empty]<br />
\setupfootertexts[{\ssx {\Mydate} --- {\em from}<br />
{\Fromperson} {\em to} {\Toperson} --- page {\pagenumber}<br />
of {\totalnumberofpages}}]<br />
%\showframe<br />
%\showboxes<br />
%\showsetups<br />
<br />
\starttext<br />
% Heading<br />
{\ssb Ben Lee User} \hfill {\ssx voice: (123) 456-7890}\crlf {\ssx P. O.<br />
Box 2.718281} \hfill {\ssx fax: (123) 456-7891}\crlf<br />
{\ssx Punktown, 12345-67890} \hfill {\ssx email: ben.lee.user@tex.edu}%<br />
\textrule \blank[10*medium]<br />
% Address<br />
\Toperson\crlf \Totitle\crlf \Tocompany\crlf \Tostreet\crlf<br />
\TocityStateZip%\crlf<br />
%\Tocountry<br />
\blank[8*medium] \textrule<br />
% Letter<br />
\hfill\Mydate \blank[2*big]<br />
<br />
Dear Thor:<br />
<br />
Here's a setup for a business or personal letter that produces a<br />
letterhead and the addressee's information on the letter. This allows<br />
the sender to use envelopes with windows to avoid separately addressing<br />
envelopes. I usually print a dozen or so of these envelopes with my<br />
return address in advance.<br />
<br />
Vertical spacing of addresses and other features is controlled by the<br />
\type{\blank[..]} command. I experiment with this depending on the<br />
number of lines in the address or where I want to place horizontal<br />
lines.<br />
<br />
% Jump to a new page to see the footer<br />
I'll jump to a new page to illustrate the footer for the second and<br />
subsequent pages. \page<br />
<br />
There is no footer on the first page and no page number. Many letters<br />
are only one page long. But on those with two or more pages, it is<br />
useful to have page numbers and other identifying information.<br />
<br />
\blank[2*big]<br />
<br />
Very truly yours,<br />
<br />
[signature space]<br />
<br />
\blank[4*big]<br />
<br />
Ben Lee User<br />
<br />
\stoptext<br />
</texcode><br />
<br />
Thanks to all those who contributed the original suggestions, they have been a great inspiration!<br />
<br />
[[User:Thomas|Thomas]]<br />
<br />
[[Category:Sample documents]]</div>Wolfgang Schusterhttps://wiki.contextgarden.net/index.php?title=Letter&diff=9207Letter2009-01-26T14:01:42Z<p>Wolfgang Schuster: link to the manual</p>
<hr />
<div>< [[Modules]] | [[User:Wolfgang_Schuster]] ><br />
<br />
{{note|This module is still in development}}<br />
<br />
The letter module provides a interface to write different kinds of correspondence<br />
with the support for different styles and extensions.<br />
<br />
== Example ==<br />
<br />
<texcode><br />
\usemodule[letter]<br />
<br />
\starttext<br />
<br />
\startletter<br />
[opening={Dear Reader,},<br />
closing={Best regards,},<br />
signature={The TeXnician}]<br />
<br />
\input knuth<br />
<br />
\stopletter<br />
<br />
\stoptext<br />
</texcode><br />
<br />
== Styles ==<br />
<br />
The layout of the letter can be changed with styles, the module comes<br />
with styles for:<br />
<br />
* Germany<br />
* Netherlands<br />
* France<br />
* America<br />
<br />
== Features ==<br />
<br />
It is possible to change the default input method to the one use by Hans<br />
Hagen in the m-letter module or Donald Knuths letter style in the TeXbook.<br />
<br />
== Further Information ==<br />
<br />
You can find more informations here: <br />
<br />
* http://modules.contextgarden.net/letter<br />
* http://wolfgang.schuster.googlepages.com/letter<br />
* http://www.ctan.org/tex-archive/macros/context/contrib/context-letter/<br />
<br />
The manual for module is included in newer versions of the package or available from:<br />
<br />
* http://dl.contextgarden.net/modules/t-letter/doc/context/third/letter/lm.pdf<br />
* http://wolfgang.schuster.googlepages.com/lm.pdf</div>Wolfgang Schusterhttps://wiki.contextgarden.net/index.php?title=Letter_style&diff=9206Letter style2009-01-26T13:57:16Z<p>Wolfgang Schuster: shortened example text</p>
<hr />
<div>< [[Sample documents]]<br />
<br />
<br />
== Wolfgang's Letter Module ==<br />
<br />
[[Letter]]<br />
<br />
== German Letter style ==<br />
<br />
The following is thought to be a(n early version of a) template for DIN (Deutsches Institut für Normung, German Standardization Institute) conforming letters. Using some provided commands, it should be easy to set sender and receiver addresses for window envelopes, include text or a logo at the top, and contact information to the right of the window space.<br />
<br />
If you want to use it, save the following as <tt>letterstyle.tex</tt> and follow the usage instructions. A downloadable version is available [[media:letterstyle.tex|here]].<br />
<br />
'''Beware:''' This style redefines <cmd>subject</cmd> as letter subject line and thus disables header setup!<br />
<br />
<texcode><br />
%<br />
% Style (environment) for writing letters<br />
%<br />
% (c) 2004 Holger Schöner hfsch@cs.tu-berlin.de<br />
% with contributions from Stefan Bunzel<br />
%<br />
% Feel free to use as you like. If modified, please remove the above<br />
% copyright notice.<br />
%<br />
<br />
%=============================================================================<br />
% Usage:<br />
%<br />
% \environment letterstyle<br />
% \starttext<br />
% \letter{<string>}<br />
% \setdate{(string)}<br />
% \place{(string)}<br />
% \shortsender{(one-line address of sender)}<br />
% \disposal{(orders)}<br />
% \addressee{(address of receiver; use \\ and \| for new lines)}<br />
% % Block with information about sender on the right hand side (name, phone,<br />
% % fax, email, etc.). (key) is set flush right in a very small font (by<br />
% % default, see \keystyle) and specifies the type of information, and (value)<br />
% % is the actual information.<br />
% \senderone{(key)}{(value)}<br />
% \sendertwo{(key)}{(value)}<br />
% ...<br />
% \sendernine{(key)}{(value)}<br />
% \addfirstheaderlayer[corner={top,left},location={bottom,right}]{\framed[width=\overlaywidth,height=\logoboxheight,frame=off]{}}<br />
% \headercontent{(text)} % Text placed in the header of every page except the first<br />
% \addheaderlayer[corner={top,left},location={bottom,right}]{}<br />
% \footercontent{(text)} % Text placed in the footer of every page<br />
% \addfooterlayer[corner={bottom,right},location={top,left}]{}<br />
% \subject{(subject)}<br />
% \greeting{(greetings formulation)}<br />
% \signature{(name)}<br />
% \attachments{(text)}<br />
%<br />
% ----------------------------------------------------------------------------<br />
% Modes:<br />
% demo: Set an example letter specified at the end of this file for<br />
% test/demo purposes.<br />
% nofold: Determines whether folding marks are set or not. By default,<br />
% they are printed; using this mode they are left out.<br />
%<br />
% Set modes by using<br />
% texexec -pdf --mode=(mode1,mode2,...) (file)<br />
% or specify \enablemode[(mode)] in your input (before including the style)<br />
%<br />
% ----------------------------------------------------------------------------<br />
% There are some nasty tricks involved here; e.g. I could not find a cleaner<br />
% way to specify a header which is to be used for only one page and has a<br />
% different height than that of the following ...<br />
%<br />
% I'd be glad about any hints for improvement of this style!<br />
%<br />
<br />
\startenvironment letterstyle<br />
<br />
%=============================================================================<br />
% Default values<br />
<br />
% Standard Dimensions<br />
\def\firstpageheaderheight{9.5cm}<br />
%\def\firstpagetextheight{8.0cm}<br />
\def\normalheaderheight{1.0cm}<br />
\def\logoboxheight{3.4cm}<br />
\def\normaltextheight{27.4cm}<br />
\def\normalfooterheight{1.0cm}<br />
\def\sendervalwidth{5.05cm}<br />
\def\senderkeywidth{1.85cm}<br />
<br />
%% Standard Styles<br />
\def\keystyle{\tfxx}<br />
\def\valstyle{}<br />
<br />
%=============================================================================<br />
% Initializations<br />
<br />
\def\\{\vskip0mm}<br />
\def\|{\vskip1.5ex}<br />
<br />
\def\letterdate{}<br />
\def\letterplace{}<br />
\def\lettershortsender{}<br />
\def\letterdisposal{}<br />
\def\letteraddressee{}<br />
<br />
\def\lettersenderkeyone{}<br />
\def\lettersendervalone{}<br />
\def\lettersenderkeytwo{}<br />
\def\lettersendervaltwo{}<br />
\def\lettersenderkeythree{}<br />
\def\lettersendervalthree{}<br />
\def\lettersenderkeyfour{}<br />
\def\lettersendervalfour{}<br />
\def\lettersenderkeyfive{}<br />
\def\lettersendervalfive{}<br />
\def\lettersenderkeysix{}<br />
\def\lettersendervalsix{}<br />
\def\lettersenderkeyseven{}<br />
\def\lettersendervalseven{}<br />
\def\lettersenderkeyeight{}<br />
\def\lettersendervaleight{}<br />
\def\lettersenderkeynine{}<br />
\def\lettersendervalnine{}<br />
<br />
\def\letterheadertext{}<br />
\def\letterfootertext{}<br />
<br />
%=============================================================================<br />
<br />
\setuppapersize[A4][A4]<br />
\setuplayout[location=doublesided]<br />
%\setuppagenumbering[alternative=doublesided]<br />
%\setuppagenumbering[alternative={singlesided,doublesided}]<br />
%\setuppagenumbering[alternative=singlesided}]<br />
\setuppagenumbering[location=]<br />
<br />
%=============================================================================<br />
%% Header and footer initializations<br />
<br />
%% Start of a new letter; heading text is used only in an optional table of contents<br />
\def\letter#1{%<br />
\setuplayer[normalheaderlayer][state=reset]%<br />
\setuplayer[allpagefooterlayer][state=reset]%<br />
\letterhead{#1}%<br />
\setuplayer[firstheaderlayer][state=reset]%<br />
}<br />
\definehead[letterhead][title]<br />
\setuphead [letterhead][<br />
placehead=empty,<br />
before={%<br />
\setups{firstpagelayoutsetup}%<br />
},<br />
after=,<br />
header=firstpageheader,<br />
page=firstpagebreak,<br />
coupling=title]<br />
<br />
%% Making empty pages completely empty (no page numbers):<br />
\definepagebreak<br />
[firstpagebreak]<br />
[yes,header,footer,right] % yes instead of emtpy taken from the sources page-ini.tex line 1611<br />
<br />
%% Layout of first page<br />
\startsetups firstpagelayoutsetup<br />
\setuplayout[<br />
backspace=2.46cm,topspace=1.2cm,<br />
top=0cm,bottom=0cm,topdistance=0cm,bottomdistance=0cm,<br />
header=\firstpageheaderheight,footer=\normalfooterheight,headerdistance=0cm,footerdistance=0cm,<br />
leftedge=0cm,rightedge=0cm,leftedgedistance=0cm,rightedgedistance=0cm,<br />
leftmargin=1.5cm,rightmargin=1.5cm,leftmargindistance=0.42cm,rightmargindistance=0.42cm,<br />
width=16.5cm,height=\normaltextheight,<br />
]<br />
\stopsetups<br />
% Layout of other pages<br />
\startsetups normalpagelayoutsetup<br />
\setuplayout[<br />
backspace=2.46cm,topspace=1.2cm,<br />
top=0cm,bottom=0cm,topdistance=0cm,bottomdistance=0cm,<br />
header=\normalheaderheight,footer=\normalfooterheight,headerdistance=0cm,footerdistance=0cm,<br />
leftedge=0cm,rightedge=0cm,leftedgedistance=0cm,rightedgedistance=0cm,<br />
leftmargin=1.5cm,rightmargin=1.5cm,leftmargindistance=0.42cm,rightmargindistance=0.42cm,<br />
width=16.5cm,<br />
height=\normaltextheight,textheight=\normaltextheight,<br />
]<br />
\stopsetups<br />
<br />
%% Header for first pages<br />
\definetext[firstpageheader][header][\setups{firstpagesetup}]<br />
\startsetups firstpagesetup<br />
\setups{firstpageintrosetup}<br />
\setups{foldingmarkslayersetup}<br />
\framed[width=\makeupwidth,height=\headerheight,<br />
background={firstpagelayer,firstheaderlayer},frame=off]<br />
{}<br />
\stopsetups<br />
<br />
%% Header for other pages<br />
\setups{normalpagelayoutsetup}<br />
\appendtoks\setups{normalpagelayoutsetup}\to\everyaftershipout<br />
\startsetups normalheadersetups<br />
\setups{normalheaderlayersetup}<br />
\framed[width=\makeupwidth,height=\headerheight,<br />
background=normalheaderlayer,frame=off]<br />
{}<br />
\stopsetups<br />
\setupheadertexts[\setups{normalheadersetups}]<br />
<br />
%% Footer for all pages<br />
\startsetups allpagefootersetup<br />
\setups{allpagefooterlayersetup}<br />
\framed[width=\makeupwidth,height=\footerheight,<br />
background=allpagefooterlayer,frame=off]<br />
{}<br />
\stopsetups<br />
\setupfootertexts[\setups{allpagefootersetup}]<br />
<br />
%=============================================================================<br />
%% First page header setups<br />
<br />
\definelayer[firstpagelayer][width=\makeupwidth,height=\firstpageheaderheight]<br />
<br />
\startsetups firstpageintrosetup<br />
%% Logo frame<br />
\setlayerframed[firstpagelayer]<br />
[corner={left,top},location={right,bottom}]<br />
[height=3.4cm,width=\overlaywidth,frame=off,offset=none]<br />
{}<br />
%% Short sender frame<br />
\doiftextelse{\lettershortsender}{<br />
\setlayerframed[firstpagelayer]<br />
[y=3.8cm,location={right,bottom}]<br />
[height=0.3cm,width=8cm,frame=off,bottomframe=on,offset=none,align={right,lohi}]<br />
{\tfxx \lettershortsender}}{<br />
\setlayerframed[firstpagelayer]<br />
[y=3.8cm,location={right,bottom}]<br />
[height=0.3cm,width=8cm,frame=off,bottomframe=off,offset=none,align={right,lohi}]<br />
{\tfxx \lettershortsender}}<br />
%% Addressee frame<br />
\setlayerframed[firstpagelayer]<br />
[y=4.1cm,location={right,bottom}]<br />
[height=3.6cm,width=8cm,frame=off,offset=none,align={right,top}]<br />
{<br />
\doiftextelse{\letterdisposal}{\vskip1.0ex\letterdisposal}{}<br />
\vskip1.5ex<br />
\letteraddressee<br />
}<br />
%% Sender frame<br />
\setlayerframed[firstpagelayer]<br />
[corner={right},y=4.1cm,location={left,bottom}]<br />
[height=4.6cm,width=\dimexpr(\senderkeywidth+\sendervalwidth),frame=off,offset=none,align={left,top}] % [height=4.6cm,width=6.4cm,frame=off,offset=none,align={left,top}]<br />
{\setups{sendertablesetup}}<br />
%% Date field<br />
\setlayerframed[firstpagelayer]<br />
[corner={right},y=8.7cm,location={left,bottom}]<br />
[height=0.5cm,width=\dimexpr(\senderkeywidth+\sendervalwidth),align={left,top},frame=off,offset=none] % [height=0.5cm,width=6.4cm,align={left,top},frame=off,offset=none]<br />
{<br />
\bTABLE<br />
\setupTABLE[frame=off]<br />
\setupTABLE[x][1][width=\senderkeywidth,align=left] % width: std 1.85cm<br />
\setupTABLE[x][2][width=\sendervalwidth,align=right] % width: std 4.55cm<br />
%\setupTABLE[y][maxheight=1ex]<br />
\bTR \bTD<br />
{\keystyle\translate[en=date,de=Datum]:}<br />
\eTD \bTD<br />
\valstyle<br />
\doiftextelse{\letterplace}<br />
{\letterplace,\translate[en=, de=]\ }{}<br />
\doiftextelse{\letterdate}{\letterdate}{\currentdate} % \currentdate[weekday,month,day,{, },year]<br />
\eTD \eTR<br />
\eTABLE<br />
}<br />
\stopsetups<br />
<br />
%% Table with sender information<br />
\startsetups sendertablesetup<br />
\bTABLE<br />
\setupTABLE[frame=off]<br />
\setupTABLE[x][1][width=\senderkeywidth,align=left]<br />
\setupTABLE[x][2][width=\sendervalwidth,align=right]<br />
\bTR \bTD \strut\doiftextelse{\lettersenderkeyone} {\keystyle\lettersenderkeyone:} {} \eTD \bTD \valstyle\lettersendervalone \eTD \eTR<br />
\bTR \bTD \strut\doiftextelse{\lettersenderkeytwo} {\keystyle\lettersenderkeytwo:} {} \eTD \bTD \valstyle\lettersendervaltwo \eTD \eTR<br />
\bTR \bTD \strut\doiftextelse{\lettersenderkeythree}{\keystyle\lettersenderkeythree:}{} \eTD \bTD \valstyle\lettersendervalthree \eTD \eTR<br />
\bTR \bTD \strut\doiftextelse{\lettersenderkeyfour} {\keystyle\lettersenderkeyfour:} {} \eTD \bTD \valstyle\lettersendervalfour \eTD \eTR<br />
\bTR \bTD \strut\doiftextelse{\lettersenderkeyfive} {\keystyle\lettersenderkeyfive:} {} \eTD \bTD \valstyle\lettersendervalfive \eTD \eTR<br />
\bTR \bTD \strut\doiftextelse{\lettersenderkeysix} {\keystyle\lettersenderkeysix:} {} \eTD \bTD \valstyle\lettersendervalsix \eTD \eTR<br />
\bTR \bTD \strut\doiftextelse{\lettersenderkeyseven}{\keystyle\lettersenderkeyseven:}{} \eTD \bTD \valstyle\lettersendervalseven \eTD \eTR<br />
\bTR \bTD \strut\doiftextelse{\lettersenderkeyeight}{\keystyle\lettersenderkeyeight:}{} \eTD \bTD \valstyle\lettersendervaleight \eTD \eTR<br />
\bTR \bTD \strut\doiftextelse{\lettersenderkeynine} {\keystyle\lettersenderkeynine:} {} \eTD \bTD \valstyle\lettersendervalnine \eTD \eTR<br />
\eTABLE<br />
\stopsetups<br />
<br />
%=============================================================================<br />
%% First page header setups<br />
<br />
\definelayer[firstheaderlayer][width=\makeupwidth,height=\logoboxheight,width=\overlaywidth]<br />
<br />
%=============================================================================<br />
%% Normal page header setups<br />
<br />
\definelayer[normalheaderlayer][width=\makeupwidth,height=\normalheaderheight]<br />
<br />
\startsetups normalheaderlayersetup<br />
\setlayerframed[normalheaderlayer]<br />
[corner={top,left},location={bottom,right}]<br />
[height=\normalheaderheight,width=\makeupwidth,frame=off,offset=none,align={high,middle}]<br />
{\letterheadertext}<br />
\stopsetups<br />
<br />
%=============================================================================<br />
%% Footer setups<br />
<br />
\definelayer[allpagefooterlayer][width=\makeupwidth,height=\footerheight]<br />
<br />
\startsetups allpagefooterlayersetup<br />
\setlayerframed[allpagefooterlayer]<br />
[corner={right,bottom},location={left,top}]<br />
[height=\footerheight,width=\makeupwidth,frame=off,offset=none,align={low,middle}]<br />
{\letterfootertext}<br />
\stopsetups<br />
<br />
%=============================================================================<br />
%% Folding marks on left<br />
<br />
\startnotmode[nofold]<br />
\setupbackgrounds[rightpage][page][state=start,background=foldingmarkslayer]<br />
\stopnotmode<br />
<br />
\definelayer[foldingmarkslayer][state=repeat]<br />
<br />
\startsetups foldingmarkslayersetup<br />
\setlayer[foldingmarkslayer][y=10.7cm, x=0.5cm,align={lohi,right}]{---}<br />
\setlayer[foldingmarkslayer][y=14.85cm,x=0.5cm,align={lohi,right}]{--}<br />
\setlayer[foldingmarkslayer][y=20.2cm, x=0.5cm,align={lohi,right}]{---}<br />
\stopsetups<br />
<br />
%=============================================================================<br />
%% Commonly used letter parts<br />
<br />
% Date; if not used, current date is inserted<br />
\def\setdate#1{\def\letterdate{#1}}<br />
% Place, for the date line<br />
\def\place#1{\def\letterplace{#1}}<br />
% Short sender information for address window in envelope<br />
\def\shortsender#1{\def\lettershortsender{#1}}<br />
% Order<br />
\def\disposal#1{\def\letterdisposal{#1}}<br />
% Address of receiver of the letter<br />
\def\addressee#1{\def\letteraddressee{{#1}}} % \let\crlf=\\ <br />
% Information about sender<br />
\def\senderone#1#2{\def\lettersenderkeyone{#1}\def\lettersendervalone{#2}}<br />
\def\sendertwo#1#2{\def\lettersenderkeytwo{#1}\def\lettersendervaltwo{#2}}<br />
\def\senderthree#1#2{\def\lettersenderkeythree{#1}\def\lettersendervalthree{#2}}<br />
\def\senderfour#1#2{\def\lettersenderkeyfour{#1}\def\lettersendervalfour{#2}}<br />
\def\senderfive#1#2{\def\lettersenderkeyfive{#1}\def\lettersendervalfive{#2}}<br />
\def\sendersix#1#2{\def\lettersenderkeysix{#1}\def\lettersendervalsix{#2}}<br />
\def\senderseven#1#2{\def\lettersenderkeyseven{#1}\def\lettersendervalseven{#2}}<br />
\def\sendereight#1#2{\def\lettersenderkeyeight{#1}\def\lettersendervaleight{#2}}<br />
\def\sendernine#1#2{\def\lettersenderkeynine{#1}\def\lettersendervalnine{#2}}<br />
% Subject line<br />
\def\subject#1{{\bf #1}\vskip2ex}<br />
% Signature: Name, Position<br />
\def\greeting#1{\testpage[8]\vskip1ex{#1}}<br />
% Signature: Name, Position<br />
\def\signature#1{{\let\\=\crlf \vskip8ex\vtop{#1}}}<br />
% Attachments included<br />
\def\attachments#1{{\let\\=\crlf \vskip3ex{{\bf\translate[en=Attachments, de=Anlagen]:}\\ #1}}}<br />
<br />
%% First header<br />
%\def\resetfirstheaderlayer{\setuplayer[firstheaderlayer][state=reset]}<br />
\def\addfirstheaderlayer[#1]#2{%<br />
% \setuplayer[firstheaderlayer][state=repeat]%<br />
\setlayer[firstheaderlayer][#1]{#2}%<br />
}<br />
<br />
%% Header<br />
\def\letterheadertext{}<br />
\def\headercontent#1{\def\letterheadertext{#1}}<br />
\def\resetheaderlayer{\setuplayer[normalheaderlayer][state=reset]}<br />
\def\addheaderlayer[#1]#2{%<br />
\def\letterheadertext{}%<br />
\setuplayer[normalheaderlayer][state=repeat]%<br />
\setlayer[normalheaderlayer][#1]{#2}%<br />
}<br />
<br />
%% Footer<br />
\def\letterfootertext{\translate[en=page, de=Seite]~\pagenumber/\totalnumberofpages}<br />
\def\footercontent#1{\def\letterfootertext{#1}}<br />
\def\resetfooterlayer{\setuplayer[allpagefooterlayer][state=reset]}<br />
\def\addfooterlayer[#1]#2{%<br />
\def\letterfootertext{}%<br />
\setuplayer[allpagefooterlayer][state=repeat]%<br />
\setlayer[allpagefooterlayer][#1]{#2}%<br />
}<br />
<br />
%=============================================================================<br />
\stopenvironment<br />
<br />
%=============================================================================<br />
\startmode[demo]<br />
<br />
% Necessary, if you want to print folding marks only on odd pages<br />
\setuppagenumbering[alternative={singlesided,doublesided}]<br />
<br />
% \input letterstyle<br />
<br />
\starttext<br />
\letter{Example Letter}<br />
%\setdate{(string)}<br />
\place{Berlin}<br />
<br />
\shortsender{My Name $\cdot$ My Street 123 $\cdot$ 12345 My Town}<br />
\disposal{confidential}<br />
\addressee{Mr. Example\\ Test Drive 99\| 98765 Other Town}<br />
<br />
\senderone{tel.}{+49 30 12345678}<br />
\sendertwo{email}{xyz@abc.com}<br />
<br />
%\addfirstheaderlayer[corner={top,left},location={bottom,right}]{\framed[width=\overlaywidth,height=\logoboxheight,frame=off]{}}<br />
\headercontent{\hfill test letter, page \pagenumber}<br />
%\addheaderlayer[corner={top,left},location={bottom,right}]{}<br />
\footercontent{From MyName\hfill To Mr. Example}<br />
%\addfooterlayer[corner={bottom,right},location={top,left}]{}<br />
<br />
\subject{What do you think about the Letterstyle?}<br />
<br />
Dear Reader,<br />
<br />
\dorecurse{11}{\input tufte\par}<br />
<br />
\greeting{Best regards,}<br />
\signature{My Name}<br />
<br />
\attachments{The Letterstyle}<br />
<br />
%-----------------------------------------------------------------------------<br />
% Necessary to suppress emtpy last page in doublesided pagenumbering mode<br />
\installpagebreakhandler{last}{}<br />
<br />
\stoptext<br />
<br />
\stopmode<br />
</texcode><br />
<br />
==Another Approach==<br />
<br />
Here is an alternative to the approach suggested by Holger. My university introduced a new official letterhead some months ago, and I was quite impressed to see that they even provided a LaTeX class for it. Of course, there was no ConTeXt support, so I decided to do it myself. My aim was merely to copy the official style, so my approach is far less fancy than the one before: you get a letter with a logo in the upper right corner, fields for information about the sender (assuming that the sender sits in a department of a university), and commands for the parts of a typical letter. <br />
<br />
Instructions: copy the code below into a file, modify the generic information provided there to your needs, and save this file somewhere where ConTeXt can find it (the canonical place would be $HOMETEXMF/tex/context/third) as t-letterhead.tex. See below for usage instructions.<br />
<br />
<texcode><br />
\protect<br />
<br />
\setuppapersize[A4][A4] % or [letter][letter]; in that case, you'll have to fidget with the dimensions<br />
<br />
\setuplayout[header=0mm,topspace=20mm,backspace=22mm,footer=0mm,width=160mm] % margins etc.<br />
<br />
\enableregime[utf] % or whatever you prefer<br />
<br />
\setupcolors[state=start] % in case you want any colored output<br />
<br />
\mainlanguage[en] % or whatever you prefer<br />
<br />
\setupbodyfont[modern,8pt] % this is the small bodyfont for the letterhead; we'll change to a bigger size for the actual letter later<br />
<br />
\setuptabulate[before={\blank[0pt]},after={\blank[0pt]}] % there's a tabular, and I don't want any blank lines around it<br />
<br />
\setuppagenumbering[state=stop] <br />
<br />
\definelayer[myletter][x=1mm,y=1mm,width=\paperwidth,height=22mm] % The elements of the letterhead are defined as layers. This first layer contains the logo; you'll have to<br />
\setlayer[myletter][x=104mm,y=11mm]{\externalfigure[Logo][width=56mm,height=20mm]} % supplyan image file yourself.<br />
<br />
\definelayer[myuni][x=1mm,y=1mm,width=\paperwidth,height=24mm] % Second layer: Small column, right-aligned, with name of university and your name, in a narrow column<br />
\setlayer[myuni][x=110.5mm,y=42mm]{\framed[width=50mm,height=22mm,frame=off]{\lbox to % below the logo.<br />
35mm{\ss Name\\ of My University \\ (My Town) \\<br />
\blank[line] \\ {\bf My Name} \\ Supreme Headmaster}}}<br />
<br />
\definelayer[dept][x=1mm,y=1mm,width=\paperwidth,height=24mm] % Third layer, left-aligned, opposite layer 2. This column contains you contact information and the date.<br />
\setlayer[dept][x=163mm,y=42mm]{\framed[width=40mm,height=22mm,frame=off]{\rbox<br />
to 35mm{\ss Faculty of \\ Arts and Sciences \\<br />
\blank[2*line] \\ Department of \\ High Energe Metaphysics\\<br />
\blank[2*line]\\ 33 Main Street \\ Capital, DC 12345 \\ \starttabulate[|lw(4mm)|lw(36mm)|]<br />
\NC Tel.: \NC (123) 456-7890 \NC\NR \NC Fax.: \NC (098) 7654-321 \NC\NR<br />
\stoptabulate \\ Administrator: Highly Efficient \\<br />
\starttabulate[|lw(4mm)|lw(36mm)|] \NC Tel.: \NC (012) 345-6789 \NC\NR<br />
\stoptabulate \\ mymail@myaddress\\ www.my.website.edu \\ \blank[2*line]\\ Mytown,<br />
\currentdate}}}<br />
<br />
\definelayer[send][x=0mm,y=1mm,width=\paperwidth,height=15mm] % Fourth layer: one line, in fine print, that contains a short sender address; will be on top of the<br />
\setlayer[send][x=9.4mm,y=44mm]{\framed[width=100mm,height=13mm,frame=off]{\ss % envelope's window.<br />
\vii {\bf My University} $\cdot$ My Name $\cdot$<br />
Dept. of Metaphysics $\cdot$ Capital, DC 12345}}<br />
<br />
\startuniqueMPgraphic{fold}<br />
fill unitsquare scaled 1mm withcolor blue ;<br />
\stopuniqueMPgraphic <br />
<br />
\definelayer[foldingmarkslayer][state=repeat] % Fifth layer: the folding marks<br />
\setlayer[foldingmarkslayer][y=101mm, x=11mm]{\useMPgraphic{fold}}<br />
\setlayer[foldingmarkslayer][y=147mm, x=11mm]{\useMPgraphic{fold}}<br />
\setlayer[foldingmarkslayer][y=55mm, x=11mm]{\useMPgraphic{fold}}<br />
<br />
\setupbackgrounds [page][background={foldingmarkslayer,myletter,myuni,dept,send}] % Make all layers active for page.<br />
<br />
\long\def\addressee#1{\strut\blank[23*medium]\switchtobodyfont[11pt]\setupwhitespace[none]#1} % Defines field for receiver's address and places it at right position.<br />
<br />
\long\def\lettersubject#1{\blank[3*line]{\bf Re: #1}} % Subject line, in bold face.<br />
<br />
\long\def\letteropening#1{\blank[line]#1} % opening...<br />
<br />
\long\def\letterbody#1{\blank[line]\setupwhitespace[medium]#1} % the main body<br />
<br />
\long\def\letterclosing#1{\blank[line]#1\blank[3*line]} % and the closing formula<br />
<br />
\setupalign[right] % I prefer letters with a ragged right, but you don't have to...<br />
<br />
\ss % I want the sans font for the entire letter, but of course you can change to \tt or \rm, if you want<br />
<br />
\unprotect<br />
<br />
</texcode><br />
<br />
Here's an example how this module can be used:<br />
<br />
<texcode><br />
\usemodule[t-letterhead]<br />
<br />
\starttext<br />
<br />
\addressee{Prof.\crlf<br />
Heinrich Seltsam\crlf<br />
Dept. of Physics\crlf<br />
University of Southern Wyoming \crlf<br />
123 Einstein Str.\crlf<br />
Scumbag, WY 76543}<br />
<br />
\lettersubject{My New Letterstyle}<br />
<br />
\letteropening{Estimated Colleague,}<br />
<br />
\letterbody{\dorecurse{6}{\input tufte\par}}<br />
<br />
\letterclosing{Sincerely Yours}<br />
<br />
Larry<br />
<br />
\stoptext<br />
</texcode><br />
<br />
Any feedback welcome. I'm not sure if the \long\defs for the several parts of the letters are very elegant and would be grateful if some of the moew knowledgeable folks could suggest something better. But overall, I like the simplicity of this style.<br />
<br />
<br />
== Another Simple Style ==<br />
<br />
<texcode><br />
%Context Environment for a basic Full Block Letter with Letterhead<br />
\enableregime [utf]<br />
\mainlanguage [en]<br />
<br />
%==============Setup Page Layout======================<br />
\def\MyPageNumber#1%<br />
{{--~Page #1 / \lastpage~--}}%use lastpage for total page count<br />
\setuppagenumbering[location={footer,middle},command=\MyPageNumber]<br />
\setuppapersize[letter][letter]<br />
\usetypescript[palatino]<br />
\setupbodyfont[palatino,10pt,rm]<br />
\setuplayout[<br />
topspace=1.7in,<br />
backspace=1.5in,<br />
header=0mm,<br />
footer=.25in,<br />
width=5.5in,<br />
height=8.55in]<br />
\useexternalfigure[logo][letterheadLG][width=\makeupwidth,height=.7in]<br />
\setupbackgrounds<br />
[page]<br />
[background={Letterhead,NextPgHead},state=repeat]<br />
\definelayer[Letterhead]<br />
[x=1.5in,y=1in,width=\makeupwidth,height=.7in,state=start]<br />
\setlayerframed[Letterhead]<br />
[corner={top,left},location={bottom,right},frame=off]<br />
[offset=none,frame=off]<br />
{\externalfigure[logo]}<br />
\definelayer[NextPgHead]<br />
[x=1.5in,y=1in,width=\makeupwidth,height=.7in,state=continue]<br />
<br />
<br />
%==============Setup Paragraph Formatting==============<br />
\setupwhitespace[big]<br />
\setupindenting[no,medium,next]<br />
<br />
%=================Define Letter Elements==================<br />
<br />
\defineblank[FourLines][4*line,flexible]<br />
\defineblank[OneLine][1*line,flexible]<br />
<br />
\def\Regarding#1{\setgvariables[Letter][val={Re: #1}]Re: #1}<br />
\def\RecNameVal{}<br />
\def\RecName#1{<br />
\def\RecNameVal{#1}<br />
\setlayerframed[NextPgHead]<br />
[corner={top,left},location={bottom,right},frame=off]<br />
[offset=none,frame=off]<br />
{\framed[frame=off,width=\makeupwidth,height=.7in,align={right,high}]%<br />
{{\setupinterlinespace \RecNameVal\par<br />
\setupinterlinespace\date\par<br />
\setupinterlinespace\getvariable{Letter}{val}\par}}}<br />
#1}<br />
<br />
\long\def\MailingNote#1{\WORD{#1}\par}%<br />
\long\def\Disposition#1{\WORD{#1}}%<br />
\define[1]\Opening{#1:\blank[OneLine]}%<br />
\define[1]\Closing{#1,\blank[FourLines]}%<br />
\define[1]\Signature{#1\blank[OneLine]}%<br />
\define[1]\Enclosures{\doifelse{#1}{1}{Enclosure}{Enclosures: #1}\blank[OneLine]}%<br />
\definedescription[CC][location=left,distance=-.75in]<br />
<br />
\definestartstop[Sender][before={\startlines},after={\stoplines\blank[FourLines]}]<br />
\definestartstop[Notes][before={\startlines},after={\stoplines\blank[OneLine]}]<br />
\definestartstop[Recipient][before={\startlines},after={\stoplines\blank[OneLine]}]<br />
\definestartstop[Body][before={\startlines},after={\stoplines\blank[OneLine]}]<br />
<br />
<br />
%=============Define Quotes====================<br />
%just use \Qt{} and all nesting should be taken care of<br />
\definedelimitedtext[Qt][quotation]<br />
\setupdelimitedtext<br />
[Qt]<br />
[1]<br />
[left={\symbol[leftquotation]},<br />
right={\symbol[rightquotation]}]<br />
<br />
\setupdelimitedtext<br />
[Qt]<br />
[2]<br />
[left={\symbol[leftquote]},<br />
right={\symbol[rightquote]}]<br />
<br />
\setupdelimitedtext<br />
[Qt]<br />
[3]<br />
[left={\symbol[leftquotation]},<br />
right={\symbol[rightquotation]}]<br />
<br />
%To create blockquotes use \startextract \stopextract<br />
\defineblank[ExtractDistance][3pt]<br />
\definestartstop[Extract][<br />
style=italic,<br />
before={\blank[ExtractDistance]<br />
\setupnarrower[left=1.5pc,right=1.5pc]<br />
\startnarrower[left,right]<br />
\noindent},<br />
after={\stopnarrower<br />
\blank[ExtractDistance]<br />
\indenting[next]}]%Don't indent the immediately following paragraph, but do indent later ones.<br />
<br />
%==================Define Enumerations===========================<br />
\defineitemgroup[Outline][5]%Use with \startOutline ... \item ... \stopOutline<br />
\setupitemgroup[Outline][1][R]%First level, Roman Numerals<br />
\setupitemgroup[Outline][2][A]%Second Level, A,B,C etc.<br />
\setupitemgroup[Outline][3][n]%Third level, Numberd<br />
\setupitemgroup[Outline][4][r][left=(,right=),stopper=]%Fourth level, lowercase roman<br />
\setupitemgroup[Outline][5][m][left=(,right=),stopper=]%Fifth level, lowercase numbered<br />
<br />
\defineitemgroup[Bullet][5]%Use with \startBullet ... \item ... \stopBullet<br />
\setupitemgroup[Bullet][1][1]%First level<br />
\setupitemgroup[Bullet][2][2]%Second Level<br />
\setupitemgroup[Bullet][3][5]%Third level<br />
\setupitemgroup[Bullet][4][1]%Fourth level<br />
\setupitemgroup[Bullet][5][2]%Fifth level<br />
</texcode><br />
<br />
And how to use it:<br />
<br />
<texcode><br />
\environment basicLetterEnv<br />
\starttext<br />
\startSender<br />
Company Name<br />
Your Name, Your Title<br />
1234 AnyStreet<br />
City, ST 75098<br />
Phone: 123-456-7890<br />
Email: asdf@asdf.com<br />
Web: www.asdf.com<br />
\date<br />
\Regarding{The subject of this letter}<br />
\stopSender<br />
<br />
\startNotes<br />
\MailingNote{Certified Mail}%Mailing Notations:Certified,AirMail, Priority...<br />
\Disposition{Confidential}%Disposition: Confidential, personal ...<br />
\stopNotes<br />
<br />
\startRecipient<br />
\RecName{First Last Name}<br />
Company Name<br />
4567 ThisStreet<br />
City, US 12345<br />
\stopRecipient<br />
<br />
\Opening{Dear First Name}<br />
<br />
\startBody<br />
\dorecurse{5}<br />
{Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Cras tellus.<br />
Proin fringilla euismod elit. Donec eleifend purus sed eros. Fusce quis<br />
diam. Donec euismod nisl non dui. Donec eu odio. Nam congue risus in<br />
eros commodo elementum. Duis dolor. Etiam luctus mauris ut mi. Vivamus<br />
vitae sem eu justo pretium ullamcorper. Aliquam ac mauris posuere justo<br />
molestie interdum. Nullam eleifend leo quis justo. Suspendisse tortor<br />
risus, porta a, hendrerit in, facilisis at, lectus.\par}<br />
\stopBody<br />
<br />
\Closing{Sincerely}<br />
<br />
<br />
\Signature{Your Name, General Counsel}<br />
<br />
\Enclosures{1}<br />
\startCC{CC:}<br />
A Name\par<br />
Another Name\par<br />
File<br />
\stopCC<br />
<br />
\stoptext<br />
</texcode><br />
<br />
Thanks to all those who contributed the original suggestions, they have been a great inspiration!<br />
<br />
[[User:Thomas|Thomas]]<br />
<br />
[[Category:Sample documents]]</div>Wolfgang Schusterhttps://wiki.contextgarden.net/index.php?title=TextBackground&diff=9203TextBackground2009-01-25T19:11:16Z<p>Wolfgang Schuster: Corrected typos</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.<br />
<br />
(See, eventually, the [[manual:details.pdf| details]] manual for further explanations.)<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 textbackgrounds.<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 />
\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></div>Wolfgang Schusterhttps://wiki.contextgarden.net/index.php?title=Talk:New_Server&diff=9179Talk:New Server2009-01-20T15:05:16Z<p>Wolfgang Schuster: </p>
<hr />
<div>I just uploaded a new t-lettrine without any trouble [[User:Taco|Taco]] 09:29, 20 January 2009 (UTC)<br />
<br />
The “my modules” link did not work and the page for my last module “t-games” got lost. [[User:Wolfgang Schuster|Wolfgang Schuster]] 15:05, 20 January 2009 (UTC)</div>Wolfgang Schusterhttps://wiki.contextgarden.net/index.php?title=Titles&diff=9118Titles2008-12-17T12:07:26Z<p>Wolfgang Schuster: typo</p>
<hr />
<div>< [[Structurals]] | [[Visuals]] ><br />
<br />
==Default==<br />
<br />
Titles define the structure of your document. Decide yourself, how deep you want to nest them:<br />
<br />
<table><br />
<tr bgcolor="#CCCCCC"><br />
<th>numbered</th><br />
<th>unnumbered</th><br />
</tr><br />
<tr><br />
<td><cmd>part</cmd><br />
</td><td>&#151;</td><br />
</tr><br />
<tr><br />
<td><cmd>chapter</cmd></td><br />
<td><cmd>title</cmd></td><br />
</tr><br />
<tr><br />
<td><cmd>section</cmd></td><br />
<td><cmd>subject</cmd></td><br />
</tr><br />
<tr><br />
<td><cmd>subsection</cmd></td><br />
<td><cmd>subsubject</cmd></td><br />
</tr><br />
<tr><br />
<td><cmd>subsubsection</cmd></td><br />
<td><cmd>subsubsubject</cmd></td><br />
</tr><br />
<tr><br />
<td>...</td><br />
<td>...</td><br />
</tr><br />
</table><br />
<br />
The ''unnumbered'' versions don't appear in a table of contents! But you can<br />
switch off the numbering of the ''numbered'' versions with <cmd>setuphead</cmd><br />
to get unnumbered titles ''and'' a toc (confusing?).<br />
<br />
===Referencing Titles===<br />
<br />
Every heading command can take an optional parameter as reference:<br />
<br />
<texcode><br />
\title[hasselt-by-night]{Hasselt by night}<br />
</texcode><br />
<br />
The bracket pair is optional and used for internal [[References]]. If you want<br />
to refer to this header you type for example<br />
<br />
<texcode><br />
\at{page}[hasselt-by-night].<br />
<br />
(see <cmd>at</cmd>)<br />
</texcode><br />
<br />
==Titling Style==<br />
<br />
see <cmd>setuphead</cmd> and some enhanced samples below.<br />
<br />
A FAQ is how to get a line under the title:<br />
<br />
<texcode><br />
\setupbackgrounds[header][text][bottomframe=on]<br />
</texcode><br />
<br />
To make the section numbers appear as characters, do<br />
<br />
<texcode><br />
\setupsection[section-3][bodypartconversion=Character]<br />
</texcode><br />
<br />
The <code>section-3</code> corresponds to <code>section</code>. Similarly,<br />
<code>section-1</code> corresponds to <code>part</code>, <code>section-2</code><br />
corresponds to <code>chapter</code> and so on.<br />
<br />
==Titling Alignment==<br />
<br />
Titles should often be left aligned without hyphenation. Try this:<br />
<br />
<texcode><br />
\setuphead[chapter][align={flushleft, nothyphenated, verytolerant}] % "flushleft" is the same as "right"<br />
</texcode><br />
<br />
===Using colors in chapters and sections===<br />
<br />
If you want you may have colors on your document's chapters or sections.<br />
To do that you should use <cmd>setuphead</cmd>. Take a look at the following<br />
example:<br />
<br />
<texcode><br />
\setupcolors[state=start] % Important. You won't have colors without it.<br />
<br />
\setuphead[chapter][header=empty] % Chapter pages won't have headers<br />
<br />
\setupheadertexts[][chapter] % The header will be the chapter's name<br />
<br />
\starttext<br />
<br />
\completecontent<br />
<br />
\chapter{Black chapter 1}<br />
<br />
\setuphead[section][color=darkcyan] % This is how you change your chapter's color.<br />
<br />
\section{Dark cyan section 1.1}<br />
<br />
\page<br />
Test.<br />
<br />
\setuphead[chapter][color=darkgreen]<br />
<br />
\chapter{Dark green chapter}<br />
<br />
\page<br />
Test.<br />
<br />
\setuphead[chapter][color=red]<br />
<br />
\chapter{Red chapter}<br />
<br />
\page<br />
Test.<br />
<br />
\stoptext <br />
</texcode><br />
<br />
==Your Own Titling Levels==<br />
<br />
Of course you can define your own titling commands and probably must adapt the default settings.<br />
<br />
<texcode><br />
\definehead[myheader][section]<br />
<br />
\setuphead<br />
[myheader]<br />
[numberstyle=bold,<br />
textstyle=cap,<br />
before=\hairline\blank,<br />
after=\nowhitespace\hairline]<br />
<br />
\myheader[hasselt-ref]{Hasselt makes headlines}<br />
</texcode><br />
<br />
A new header <cmd>myheader</cmd> is defined and it inherits the properties<br />
of <cmd>section</cmd> (title, subject, whatever). You can ''define'' several<br />
headers at once!<br />
<br />
==Formatting Titles with <cmd>setuphead</cmd>==<br />
<br />
<cmd>setuphead</cmd> accepts a number of parameters which change the style of<br />
the heading. At least the following commands are available:<br />
<br />
<table><br />
<tr bgcolor="#CCCCCC"><br />
<th>text</th><br />
<th>number</th><br />
</tr><br />
<tr><br />
<td><tt>textstyle</tt></td><br />
<td><tt>numberstyle</tt></td><br />
</tr><br />
<tr><br />
<td><tt>textcommand</tt></td><br />
<td><tt>numbercommand</tt></td><br />
</tr><br />
<tr><br />
<td><tt>deeptextcommand</tt></td><br />
<td><tt>deepnumbercommand</tt></td><br />
</tr><br />
</table><br />
<br />
Quite obviously, the number-commands work on the chapter/section/etc. number,<br />
their text counterparts change the text itself. However, there are differences<br />
between <tt>style</tt>, <tt>command</tt> and <tt>deepcommand</tt>.<br />
<br />
The <tt>style</tt> variants accept a style (<tt>bold</tt>, <tt>cap</tt>, etc.)<br />
or a font switch (<cmd>em</cmd>, <cmd>tfx</cmd>, etc). <tt>texstyle</tt> prepends<br />
the text with the associated style. <tt>textcommand</tt> is a command name which<br />
is given the text (with all markup) as a parameter. <tt>deeptextcommand</tt> is<br />
similar to <tt>textcommand</tt> but it acts only on the text (not on the markup).<br />
<br />
So, if we have <cmd>title{A story}</cmd>, the different parameters have the following results:<br />
<br />
<table><br />
<tr><br />
<td><tt>textstyle=\em</tt></td><br />
<td><tt>=></tt></td><br />
<td><tt>\em A story</tt></td><br />
</tr><br />
<tr><br />
<td><tt>textstyle=\em, textcommand=\uppercase</tt></td><br />
<td><tt>=></tt></td><br />
<td><tt>\uppercase{\em A story}</tt></td><br />
<td><tt>=></tt></td><br />
<td><tt>\em A STORY</tt></td><br />
</tr><br />
<tr><br />
<td><tt>textstyle=\em, deeptextcommand=\uppercase</tt></td><br />
<td><tt>=></tt></td><br />
<td><tt>\em\uppercase{A story}</tt></td><br />
<td><tt>=></tt><br />
</td><td><tt>\em A STORY</tt></td><br />
</tr><br />
</table><br />
<br />
What is the difference between <tt>textcommand</tt> and <tt>deeptextcommand</tt>,<br />
then? With this example there is very little difference, as <tt>uppercase</tt><br />
knows how to handle markup. Sometimes this is not the case. For example, an almost<br />
similar command <tt>WORD</tt> is not compatible with <tt>textcommand</tt>, because<br />
it wreaks havoc with markup:<br />
<br />
<table><br />
<tr><br />
<td><tt>textstyle=\em, textcommand=\WORD</tt></td><br />
<td><tt>=></tt></td><br />
<td><tt>\WORD{\em A story}</tt></td><br />
<td><tt>=></tt></td><br />
<td><tt>\EM A STORY</tt></td><br />
</tr><br />
<tr><br />
<td><tt>textstyle=\em, deeptextcommand=\WORD</tt></td><br />
<td><tt>=></tt></td><br />
<td><tt>\em\WORD{A story}</tt></td><br />
<td><tt>=></tt></td><br />
<td><tt>\em A STORY</tt></td><br />
</tr><br />
</table><br />
<br />
In this case using <tt>deeptextcommand</tt> is the correct solution for capitalizing<br />
headers. (Using <cmd>uppercase</cmd> works in this specific case, but only if you stick<br />
to Latin 1 or Anglo-Saxon characters. Other languages will suffer from lowercase accented<br />
characters, like CAFé.)<br />
<br />
=== Truly empty pagebreak before chapters ===<br />
<br />
Using <cmd>setuppagenumbering[alternative=doublesided]</cmd> makes the chapters start<br />
on the right page. However, the blank page is not truely empty, it contains headers and<br />
footers. To get truely empty pages, use the following<br />
<br />
<texcode><br />
\definepagebreak<br />
[mychapterpagebreak]<br />
[yes,header,right]<br />
%[yes,header,left]<br />
%[yes,header,footer,right]<br />
<br />
\setuphead<br />
[chapter]<br />
[page=mychapterpagebreak]<br />
%[page=Mychapterpagebreak,header=empty,footer=empty]<br />
<br />
%\setupsectionblock[frontpart][page=chapter]<br />
%\setupsectionblock[bodypart][page=chapter]<br />
%\setupsectionblock[backpart][page=chapter]<br />
%\setupsectionblock[appendix][page=chapter]<br />
<br />
\setuppagenumbering[alternative=doublesided,location={header,margin}]<br />
\setupheadertexts[{My special headertext}]<br />
\setupfootertexts[This is a text in the footer]<br />
%\setupbackgrounds[header][text][bottomframe=on]<br />
<br />
\starttext<br />
\chapter{testA} \dorecurse{10}{\input tufte }<br />
\chapter{testB} \dorecurse{10}{\input tufte }<br />
\chapter{testC} \dorecurse{10}{\input tufte }<br />
\stoptext<br />
</texcode><br />
<br />
Explaination (provided by Willi Egger on the mailing list)<br />
<br />
* You define a new pagebreak rule. It has the name <code>mychapterpagebreak</code>. The options set read as: <code>pagebreak=yes</code>, placeheader, use a right page.<br />
* You set options for the header of type chapter and use for the option page the before defined new pagebreak.<br />
* You might want to experiment with the commented lines and see what happens. For example, the <code>\setupsectionblock</code> commands will give a truly blank page (if needed) after the specified \stop*part command.<br />
<br />
== Independent Section Numbering ==<br />
<br />
If you want section numbering to be independent of chapter numbering, use<br />
<br />
<texcode><br />
\setuphead [chapter][resetnumber=no]<br />
\setupsection[section][previousnumber=no]<br />
</texcode><br />
<br />
==Your Own Title Styles==<br />
<br />
Sometimes the possibilities of <cmd>setuphead</cmd> aren't enough. You can define<br />
your own styling commands, as shown in the following examples.<br />
<br />
===Expanded chapter titles===<br />
<br />
This example illustrates expanded chapter titles.<br />
<br />
<texcode><br />
\def\MyChapterCommand#1#2% #1 is number, #2 is text<br />
{\framed[frame=off,bottomframe=on,topframe=on]<br />
{\vbox{\headtext{chapter} #1\blank#2}}} % \vbox is needed for \blank to work<br />
<br />
\setuphead[chapter][command=\MyChapterCommand, style={\ss\bfa}]<br />
<br />
\setupheadtext[chapter=Chapter] % used by \headtext<br />
</texcode><br />
<br />
so <tt>\chapter{My First Chapter}</tt> looks like:<br />
<br />
<context><br />
\def\MyChapterCommand#1#2%<br />
{\framed[frame=off,bottomframe=on,topframe=on]<br />
{\vbox{\headtext{chapter} #1\blank#2}}}<br />
<br />
\setuphead[chapter][command=\MyChapterCommand, style={\ss\bfa}]<br />
\setupheadtext[chapter=Chapter]<br />
<br />
\chapter{My First Chapter}<br />
</context><br />
<br />
===Exercise numbers===<br />
<br />
For a textbook, suppose that you collect the exercises in a section at the end<br />
of each chapter, with each exercise a subsection having a short title, and the<br />
exercises should be numbered only by the subsection (not 1.6.7 for example,<br />
just 7). The usage:<br />
<br />
<texcode><br />
\section{Exercises}<br />
<br />
\exercise{Batteries}<br />
What is the cost of energy from a 9V battery? From a wall socket (the mains)?<br />
</texcode><br />
<br />
The setup code:<br />
<texcode><br />
\definehead[exercise][subsection]<br />
<br />
\setuphead<br />
[exercise]<br />
[style=italic, <br />
numbercommand={\determineheadnumber[subsection]\currentheadnumber\gobbleoneargument}]<br />
</texcode><br />
<br />
===A complex graphical element under the chapter title===<br />
<br />
<texcode><br />
\setupcolors[state=start]<br />
\startuseMPgraphic{HeaderDeco}<br />
numeric w, h, repeats;<br />
path p[];<br />
w := OverlayWidth ; h := OverlayHeight ;<br />
repeats := abs(TextWidth/BodyFontSize);<br />
p[1] := unitsquare xscaled w yscaled h ;<br />
draw p[1] withcolor white;<br />
p[2] := fullcircle scaled BodyFontSize;<br />
p[3] := fullcircle scaled .25BodyFontSize;<br />
draw p[2] shifted (.5BodyFontSize,0);<br />
for i = 1 upto repeats:<br />
if odd i :<br />
filldraw p[3] shifted (i*BodyFontSize+.5BodyFontSize,0);<br />
else :<br />
draw p[2] shifted (i*BodyFontSize+.5BodyFontSize,0);<br />
fi;<br />
endfor;<br />
\stopuseMPgraphic<br />
<br />
\setuphead[chapter][command=\Myheader]<br />
\setupheadtext[chapter=Chapitre]<br />
\defineoverlay[HeaderDeco][\uniqueMPgraphic{HeaderDeco}]<br />
<br />
\def\Myheader#1#2{%<br />
\framedtext<br />
[width= \overlaywidth,<br />
height=6\bodyfontsize,<br />
background={foreground,HeaderDeco},<br />
offset=0pt,<br />
strut=no,<br />
frame=off,<br />
align=middle]{%<br />
\headtext{chapter} #1<br />
\blank[small]<br />
#2}}<br />
<br />
\starttext<br />
\chapter{Here we go!}<br />
\stoptext<br />
</texcode><br />
<br />
It looks like:<br />
<br />
<context><br />
\setupcolors[state=start]<br />
\startuseMPgraphic{HeaderDeco}<br />
numeric w, h, repeats;<br />
path p[];<br />
w := OverlayWidth ; h := OverlayHeight ;<br />
repeats := abs(TextWidth/BodyFontSize);<br />
p[1] := unitsquare xscaled w yscaled h ;<br />
draw p[1] withcolor white;<br />
p[2] := fullcircle scaled BodyFontSize;<br />
p[3] := fullcircle scaled .25BodyFontSize;<br />
draw p[2] shifted (.5BodyFontSize,0);<br />
for i = 1 upto repeats:<br />
if odd i :<br />
filldraw p[3] shifted (i*BodyFontSize+.5BodyFontSize,0);<br />
else :<br />
draw p[2] shifted (i*BodyFontSize+.5BodyFontSize,0);<br />
fi;<br />
endfor;<br />
\stopuseMPgraphic<br />
<br />
\setuphead[chapter][command=\Myheader]<br />
\setupheadtext<br />
[chapter=Chapitre]<br />
\defineoverlay[HeaderDeco][\uniqueMPgraphic{HeaderDeco}]<br />
<br />
\def\Myheader#1#2{%<br />
\framedtext<br />
[width= \overlaywidth,<br />
height=6\bodyfontsize,<br />
background={foreground,HeaderDeco},<br />
offset=0pt,<br />
strut=no,<br />
frame=off,<br />
align=middle]{%<br />
\headtext{chapter} #1<br />
\blank[small]<br />
#2}}<br />
<br />
\starttext<br />
\chapter{Here we go!}<br />
\stoptext<br />
</context><br />
<br />
===Titles in margin===<br />
<br />
It is sometimes wanted to place the title of a section/subject etc in the margin next to the section text (instead of above it).<br />
This is achieved by the following setup:<br />
<br />
<texcode><br />
\setuphead<br />
[subject]<br />
[alternative=text,distance=0pt,command=\MyHead]<br />
<br />
\def\MyHead#1#2{\inmargin{#1 #2}}<br />
</texcode><br />
<br />
This (with 'style=\sc' added in setuphead) gives:<br />
<br />
<context><br />
\setuphead<br />
[subject]<br />
[alternative=text,distance=0pt,command=\MyHead,style=\sc]<br />
<br />
\def\MyHead#1#2{\inmargin{#1 #2}}<br />
<br />
\starttext<br />
<br />
\subject{First Subject}<br />
This is the text in the first subject. This is the text in the first subject.<br />
This is the text in the first subject. This is the text in the first subject.<br />
This is the text in the first subject. This is the text in the first subject.<br />
This is the text in the first subject. This is the text in the first subject.<br />
<br />
\subject{Second Subject}<br />
This is the text in the second subject. This is the text in the second subject.<br />
This is the text in the second subject. This is the text in the second subject. <br />
This is the text in the second subject. This is the text in the second subject. <br />
This is the text in the second subject. This is the text in the second subject. <br />
<br />
\stoptext<br />
</context><br />
<br />
See the mailing list thread [[http://www.ntg.nl/pipermail/ntg-context/2003/002053.html]] for more on this.<br />
<br />
===Headings numbered independent of chapters or other headings===<br />
<br />
If you want a heading that gets numbered without resetting at new sections or chapters (for example, for problems whose numbers increment throughout a book), here is a solution due to Hans [http://archive.contextgarden.net/message/20030415.153451.374310d8.en.html on the mailing list]:<br />
<br />
<texcode><br />
% use a lower level head<br />
<br />
\definehead<br />
[Problem]<br />
[subsubsubsection]<br />
<br />
% cleaned up<br />
<br />
\setuphead<br />
[Problem]<br />
[style=\ss\bf,<br />
color=red,<br />
before=\blank]<br />
<br />
% use a label text<br />
<br />
\setuplabeltext<br />
[Problem=Problem ]<br />
<br />
% use your own numbers<br />
<br />
\setuphead<br />
[Problem]<br />
[ownnumber=yes]<br />
<br />
% increment and feed<br />
<br />
\newcounter\ProblemNumber<br />
<br />
\def\problem#1%<br />
{\doglobal\increment\ProblemNumber<br />
\Problem{\ProblemNumber}{#1}}<br />
<br />
% nicer here<br />
<br />
\setuplist<br />
[Problem]<br />
[alternative=c,<br />
criterium=all,<br />
width=2em,<br />
interaction=all]<br />
<br />
% the test<br />
<br />
\starttext<br />
<br />
List of Problems<br />
<br />
\blank[big] \placelist[Problem] \blank[big]<br />
<br />
\section{Tufte}<br />
<br />
\input tufte<br />
<br />
\problem{First problem}<br />
<br />
The first problem description.<br />
<br />
\section{Another Tufte}<br />
<br />
\input tufte<br />
<br />
\problem{Second problem}<br />
<br />
Second problem description.<br />
<br />
\stoptext<br />
</texcode><br />
<br />
===Chapter headers===<br />
<br />
Setup of headers like chapters.<br />
<br />
While reading Pixar docs about Renderman, I've found their headers nice and wanted to copy this style.<br />
I found a premise in Metafun manual, p.187 (Hello text), and Hans email me ([http://archive.contextgarden.net/message/20041020.100630.d531bb1d.en.html 20/10/2004 ]) on the context list a more simple solution than using metapost. The minimum is to put it here, for others who are like me, wandering for source code.<br />
Feel free to adapt code below to your langage specific settings, mine is french.<br />
<br />
<texcode><br />
\useencoding[ffr]<br />
\mainlanguage[fr]<br />
\enableregime[utf] %for UTF8<br />
<br />
% \enableregime[il1] %for ISO 8859-1 8859-15<br />
<br />
\usetypescript[palatino][texnansi]<br />
\setupbodyfont[palatino,rm,12pt]<br />
<br />
\setupcolors[state=start]<br />
<br />
\definefont[BigFontOne][Regular sa 3] %RegularSlanted sa 3(ori)%Sans sa 3:don't work (pb accents)<br />
\definefont[BigFontTwo][RegularBold sa 2] %%RegularSlanted<br />
<br />
\definecolor[BigColorOne][r=.86,g=.850,b=.54]<br />
\definecolor[BigColorTwo][r=.43,g=.425,b=.27]<br />
<br />
\setuphead<br />
[chapter]<br />
[textcommand=\MyChapterText,<br />
color=BigColorTwo,<br />
style=\BigFontTwo]<br />
<br />
\def\MyChapterText#1{\rlap{\BigFontOne\BigColorOne#1}\kern15pt#1}<br />
<br />
\starttext<br />
<br />
\chapter[chap:ques]{Question}<br />
\chapter[chap:answ]{Answer}<br />
\chapter[chap:answ]{Remarque}<br />
\chapter[chap:answ]{Cours}<br />
\chapter[chap:answ]{Exercice}<br />
\chapter[chap:answ]{Travail dirigé}<br />
\chapter[chap:answ]{Exposé}<br />
\stoptext<br />
</texcode><br />
<br />
I've tryed to change a bit Hans code, by putting \kern15pt, for moving backgroundtext to the left of \rlap alignment, and an unsuccess one to switch same backgroundtext in Sans font (no french accents).<br />
<br />
olivier<br />
<br />
<context><br />
\useencoding[ffr]<br />
\mainlanguage[fr]<br />
<br />
% fonts currently don't work this way,<br />
% I'll fix that soon. Patrick<br />
<br />
% \usetypescript[palatino][texnansi]<br />
% \setupbodyfont[palatino,rm,12pt]<br />
<br />
\setupcolors[state=start]<br />
<br />
\definefont[BigFontOne][Regular sa 3] %RegularSlanted sa 3(ori)%Sans sa 3:don't work (pb accents)<br />
\definefont[BigFontTwo][RegularBold sa 2] %%RegularSlanted<br />
<br />
\definecolor[BigColorOne][r=.86,g=.850,b=.54]<br />
\definecolor[BigColorTwo][r=.43,g=.425,b=.27]<br />
<br />
\setuphead<br />
[chapter]<br />
[textcommand=\MyChapterText,<br />
color=BigColorTwo,<br />
style=\BigFontTwo]<br />
<br />
\def\MyChapterText#1{\rlap{\BigFontOne\BigColorOne#1}\kern15pt#1}<br />
<br />
\starttext<br />
<br />
\chapter[chap:ques]{Question}<br />
<br />
% only one page please, since this is displayed inline. Patrick<br />
% \chapter[chap:answ]{Answer}<br />
% \chapter[chap:answ]{Remarque}<br />
% \chapter[chap:answ]{Cours}<br />
% \chapter[chap:answ]{Exercice}<br />
% \chapter[chap:answ]{Travail dirigé}<br />
% \chapter[chap:answ]{Exposé}<br />
\stoptext<br />
</context><br />
<br />
===Figures in Headings===<br />
<br />
This example shows how to completely replace the chapter text and number by an image:<br />
<br />
<texcode><br />
\useexternalfigure[chapter-1][cow.pdf]<br />
\useexternalfigure[chapter-2][hacker.jpg]<br />
<br />
\setuphead<br />
[chapter]<br />
[command=\MyChapterCommand]<br />
<br />
\def\MyChapterCommand#1#2%<br />
{\externalfigure[chapter-\currentheadnumber][height=5cm]}<br />
<br />
\starttext<br />
<br />
\chapter{One}<br />
\section{First section of Chapter One}<br />
<br />
\chapter{Two}<br />
<br />
\stoptext<br />
</texcode><br />
<br />
<context><br />
\useexternalfigure[chapter-1][cow.pdf]<br />
\useexternalfigure[chapter-2][hacker.jpg]<br />
<br />
\setuphead<br />
[chapter]<br />
[command=\MyChapterCommand]<br />
<br />
\def\MyChapterCommand#1#2%<br />
{\externalfigure[chapter-\currentheadnumber][height=5cm]}<br />
<br />
\starttext<br />
<br />
\chapter{One}<br />
\section{First section of Chapter One}<br />
<br />
\stoptext<br />
</context><br />
<br />
However, this "forgets" to put the chapter in the TOC. So you have to set<br />
the <tt>textcommand</tt> and <tt>numbercommand</tt> separately instead<br />
(thus retaining the command that puts the chapter in the TOC), rather than<br />
setting the overall <tt>command</tt>, if you need a complete TOC.<br />
<br />
<texcode><br />
\setuphead<br />
[chapter]<br />
[textcommand=\MyChapterTextCommand,<br />
numbercommand=\MyChapterNumberCommand]<br />
<br />
\def\MyChapterNumberCommand#1{} % hide chapter number<br />
<br />
\def\MyChapterTextCommand#1%<br />
{\externalfigure[chapter-\currentheadnumber][height=5cm]}<br />
</texcode><br />
<br />
[http://archive.contextgarden.net/message/20050519.215526.df7c5cd1.html]<br />
<br />
===Chapter head with absolute positioning of following text===<br />
<br />
<texcode><br />
\setuphead[chapter][before=\vbox to 4cm\bgroup,after=\vss\egroup]<br />
\starttext<br />
\chapter{test} \input tufte<br />
\stoptext<br />
</texcode><br />
<br />
No matter how many lines the chapter head runs to, the text will always start, e.g. 4cm below the top of the heading:<br />
<br />
<context><br />
\setuppapersize[A6][A6]<br />
\setuphead[chapter][before=\vbox to 4cm\bgroup,after=\vss\egroup]<br />
\setupbodyfont[8pt]<br />
\starttext<br />
\chapter{test} \input tufte<br />
\stoptext<br />
</context><br />
<br />
====Bug and proposed workaround====<br />
<br />
I tried this sample and <cmd>getmarking[chapter]</cmd>, used in my headers,<br />
stopped to work properly. Proposed workaround below.<br />
--[[User:Sebastian.rooks|SeR]] 00:52, 27 January 2006 (CET)<br />
<br />
<texcode><br />
\def\MyChapterCommand#1#2%<br />
{\vbox to 4cm\bgroup<br />
{#1\hskip.75em #2}<br />
\vss<br />
\egroup}<br />
<br />
\setuphead[chapter][header=nomarking,command=\MyChapterCommand]<br />
\starttext<br />
\chapter{test} \input tufte<br />
\stoptext<br />
</texcode><br />
<br />
<context><br />
\setuppapersize[A6][A6]<br />
\setupbodyfont[8pt]<br />
\def\MyChapterCommand#1#2%<br />
{\vbox to 4cm\bgroup<br />
{#1\hskip.75em #2}<br />
\vss<br />
\egroup}<br />
\setuphead[chapter][header=nomarking,command=\MyChapterCommand]<br />
\starttext<br />
\chapter{test} \input tufte<br />
\stoptext<br />
</context><br />
<br />
===Section head with underlining to width of last line===<br />
<br />
A style called for section headings to be followed by a rule which extends only the width of the text. More tricky was the need to make sure that if the text ran onto another line, it was the length of the ''last'' line that was to be followed. <br />
<br />
Hans came up with this cleverness, showing two alternate ways of doing it:<br />
<br />
<context source="yes" text="produces"><br />
\def\FirstSolution#1#2%<br />
{\vbox\bgroup<br />
\setbox0\hbox{#1}<br />
\hsize.4\textwidth<br />
\beginshapebox#2\endshapebox<br />
\gdef\SetLastLineWidth{\xdef\LastLineWidth{\the\wd\scratchbox}}%<br />
\reshapebox<br />
{\setbox\scratchbox\hbox{\unhbox\shapebox}%<br />
\SetLastLineWidth<br />
\globallet\SetLastLineWidth\relax<br />
\box\scratchbox}%<br />
\scratchdimen\dimexpr\wd0+.25em+\LastLineWidth\relax<br />
% \setbox2\ruledvbox {\innerflushshapebox} <br />
% why is correction needed<br />
\setbox2\vbox {\vskip-\lineskip\innerflushshapebox}<br />
\setbox0\vbox to \ht2{\box0}<br />
\hbox{\box0\hskip.25em\box2}<br />
\offinterlineskip<br />
\vskip.25ex<br />
\blackrule[width=\scratchdimen,height=1pt]<br />
\egroup}<br />
<br />
\doglobal\newcounter\NextLinePos<br />
<br />
\def\SecondSolution#1#2%<br />
{\vbox\bgroup<br />
\hsize.4\textwidth<br />
\doglobal\increment\NextLinePos<br />
\setbox\scratchbox\hbox{#1}<br />
\hbox{\vtop{\copy\scratchbox}\hskip.25em\vtop{#2}}%<br />
\offinterlineskip<br />
\scratchdimen\dimexpr\wd\scratchbox+.25em+<br />
\MPx{e:npl:\NextLinePos}-\MPx{b:npl:\NextLinePos}\relax<br />
\vskip.25ex<br />
\blackrule[width=\scratchdimen,height=1pt]<br />
\egroup}<br />
<br />
\def\DoSecondSolution#1%<br />
{\bpos{npl:\NextLinePos}#1\epos{npl:\NextLinePos}}<br />
<br />
% \showstruts<br />
<br />
\setuphead[section][command=\FirstSolution]<br />
<br />
\starttext<br />
<br />
\section{is this nice or not}<br />
<br />
\section{is this nice or not nice, that's the question}<br />
<br />
\setuphead[section][command=\SecondSolution,deeptextcommand=\DoSecondSolution]<br />
<br />
\section{is this nice or not}<br />
<br />
\section{is this nice or not nice, that's the question}<br />
<br />
\stoptext<br />
</context><br />
<br />
As if that wasn't enough, Taco pointed out that <cmd>lastlinewidth</cmd><br />
is the easy route to finding the width of the last line. Use something like:<br />
<br />
<code><br />
\optimizedisplayspacingtrue\setlastlinewidth % core-mat macro<br />
\global\advance\lastlinewidth-\hangindent\par % adjust<br />
\blackrule[width=\lastlinewidth,height=1pt]<br />
</code><br />
<br />
<br />
[[Category:Fonts]]<br />
[[Category:Graphics]]<br />
[[Category:Text elements]]</div>Wolfgang Schuster