https://wiki.contextgarden.net/api.php?action=feedcontributions&user=193.167.195.60&feedformat=atomWiki - User contributions [en]2024-03-28T15:55:07ZUser contributionsMediaWiki 1.34.1https://wiki.contextgarden.net/index.php?title=Modules&diff=6580Modules2006-09-19T12:16:13Z<p>193.167.195.60: minor syntax correction and added a link to R-project</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 />
==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-gnuplot.tex|m-gnuplot]]: support for direct inclusion of [[Gnuplot]] graphs out of the source<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 />
* [[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 />
<br />
File names of included modules start with "m-", but third party (contributed) modules should start with "t-".<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>193.167.195.60https://wiki.contextgarden.net/index.php?title=Table&diff=6293Table2006-07-20T10:09:33Z<p>193.167.195.60: Fixed HTML. Previous version didn't render correctly with Mozilla 1.7.</p>
<hr />
<div>< [[Tables Overview]] | [[tabulate]] | [[Tables]] ><br />
<br />
This is ConTeXts oldest table module. It uses the same formatting as [[tabulate]] (see [[Tables Overview]]).<br />
<br />
This mode is based on Michael Wichura's TaBlE package for PlainTeX. The official manual for it is commercial (about 40 USD), see [http://www.pctex.com/books.html PCTeX] -- but note that the TaBlE manual only talks about the original syntax, which does not use <cmd>NC</cmd>, <cmd>HL</cmd> cum suis.<br />
<br />
The only ConTeXt docs are in [[manual:ms-cb-en.pdf|ConTeXt - an excursion]].<br />
<br />
== Basic Commands ==<br />
<br />
<table cols="2"><tr valign="top"><td><br />
<texcode><br />
\starttable[|l|l|]<br />
\HL<br />
\NC Command \VL Meaning \SR % or \NC\AR<br />
\HL<br />
\NC \tex{NC} \VL next column \AR<br />
\NC \tex{HL} \VL horizontal line \AR<br />
\NC \tex{VL} \VL vertical line \AR<br />
\NC \tex{NR} \VL next row \LR<br />
\HL<br />
\NC \tex{SR} \VL single row \AR<br />
\NC \tex{FR} \VL first row \AR<br />
\NC \tex{MR} \VL middle row \AR<br />
\NC \tex{LR} \VL last row \LR % or \NC\AR<br />
\HL<br />
\NC \tex{AR} \VL automatic row \SR % or \NC\AR<br />
\HL<br />
\stoptable<br />
</texcode><br />
</td><td><br />
<context><br />
\switchtobodyfont[ss, 8pt]<br />
\starttable[|l|l|]<br />
\HL<br />
\NC Command \VL Meaning \SR % or \NC\AR<br />
\HL<br />
\NC \tex{NC} \VL next column \AR<br />
\NC \tex{HL} \VL horizontal line \AR<br />
\NC \tex{VL} \VL vertical line \AR<br />
\NC \tex{NR} \VL next row \LR<br />
\HL<br />
\NC \tex{SR} \VL single row \AR<br />
\NC \tex{FR} \VL first row \AR<br />
\NC \tex{MR} \VL middle row \AR<br />
\NC \tex{LR} \VL last row \LR % or \NC\AR<br />
\HL<br />
\NC \tex{AR} \VL automatic row \SR % or \NC\AR<br />
\HL<br />
\stoptable<br />
</context><br />
</td></tr></table><br />
<br />
* You get vertical lines (rules), if you use <cmd>VL</cmd> instead of <cmd>NC</cmd>.<br />
* Better use <cmd>SR</cmd>, <cmd>FR</cmd>, <cmd>MR</cmd>, <cmd>LR</cmd> instead of <cmd>NR</cmd>.<br />
* You can also use <cmd>AR</cmd> instead of <cmd>SR</cmd>, <cmd>FR</cmd>, <cmd>MR</cmd> and <cmd>LR</cmd> (AR for automatic row).<br />
* You can leave out the <cmd>NC</cmd> before the "row" command, but not if you use <cmd>AR</cmd> in a last or single row (see example).<br />
* You can influence the table with <cmd>setuptables</cmd>.<br />
* There are also <cmd>BL</cmd> and <cmd>CL</cmd> for colored backgrounds, see below.<br />
<br />
==Column Definition==<br />
<br />
The table is defined by the template enclosed in square brackets after <cmd>starttable</cmd>. The template has the form<br />
<tt>|keys for the first column|keys for the second column|...|keys for the last column|</tt>. Please note that the each column is surrounded by <tt>|</tt> signs. These are necessary. The formatting keys for each column can be a choice of<br />
<br />
<table width="100%" cols="2"><tr valign="top"><td><br />
<context><br />
\switchtobodyfont[ss, 8pt]<br />
\starttable[|l|lp(.5\textwidth)|]<br />
\HL<br />
\NC \bf Key \VL \bf Meaning \SR<br />
\HL<br />
\NC \NC Primitive Keys \SR<br />
\HL<br />
\NC \type{a{tokens}}\VL Adds \type{tokens} {\em after} the column content\AR<br />
\NC \type{b{tokens}}\VL Adds \type{tokens} '''before''' the column content\AR<br />
\NC {\tt \backslash\{ } \VL Enclose the column in braces \AR<br />
\NC \type{*{n}{keys}}\VL Equivalent to repeating the formatting keys \type{keys} \type{n} times\NC\LR<br />
\HL<br />
\NC \NC Positioning Keys\SR<br />
\HL<br />
\NC \type{\LeftGlue} \VL Specifies the left glue to be used before the column\AR<br />
\NC \type{\RightGlue} \VL Specifies the right glue to be used after the column\AR<br />
\NC \type{l} \VL left-aligned column\AR<br />
\NC \type{c} \VL centered column\AR<br />
\NC \type{r} \VL right-aligned column\AR<br />
\NC \type{p(width)} \VL Set each cell as a paragraph\AR<br />
\NC \type{w} \VL Set minimum column width\AR<br />
\NC \type{k} \VL Insert a kern both left and right of the column\AR<br />
\NC \type{i} \VL Add a kern to the left of the column\AR<br />
\NC \type{j} \VL Add a kern to the right of the column\LR<br />
\HL<br />
\NC \NC Numeric and Math Item Keys \SR<br />
\HL<br />
\NC \type{n} \VL Numeric item not in math mode\AR<br />
\NC \type{N} \VL Numeric item in math mode\AR<br />
\NC \type{m} \VL Each cell is in (inline) math mode. Equivalent to \type{b$ a$}\AR<br />
\NC \type{M} \VL Each cell is in display math mode. Equivalent to \type{\{b{$\displaystyle}a$}} \AR<br />
\NC \type{\m} \VL Equivalent to \type{l b{{}}m}\AR<br />
\NC \type{\M} \VL Equivalent to \type{l b{{}}M}\LR<br />
\HL<br />
\NC \NC Style Keys \SR<br />
\HL<br />
\NC \type{f\command} \VL Set font according to following \tex{command}\AR<br />
\NC \type{B} \VL Bold. Equivalent to \type{f\bf}\AR<br />
\NC \type{I} \VL Italic. Equivalent to \type{f\it}\AR<br />
\NC \type{S} \VL Slanted. Equivalent to \type{f\sl}\AR<br />
\NC \type{R} \VL Roman. Equivalent to \type{f\rm}\AR<br />
\NC \type{T} \VL Teletype. Equivalent to \type{f\tt}\LR<br />
\HL<br />
\NC \NC Tabskip Keys \SR<br />
\HL<br />
\NC \type{s} \VL Set the tabskip to the right of this column and of all following columns up to the next \type{s} or \type{o} key\AR<br />
\NC \type{o} \VL Set the tabskip to the right of this column only\LR<br />
\HL<br />
\stoptable<br />
</context><br />
</td><td><br />
===Examples===<br />
; <code>|l|</code> : a left aligned column, as wide as necessary<br />
; <code>|lw(2cm)|</code> : a left aligned column of at least 2 cm width<br />
; <code>|p(2cm)|</code> : a centered(!) paragraph of 2 cm width<br />
; <code>|lp(.5\textwidth)|</code> : a left aligned paragraph of specified width<br />
; <code>...</code> : Please add more<br />
; <code>...</code> : <br />
<br />
{{todo|add more examples of column definitions}}<br />
</td></tr></table><br />
<br />
==Column Spans==<br />
<br />
It's possible to create columnspans (i.e. cells that span more than one column) with the command <cmd>use{<i>N</i>}</cmd> where ''N'' is the number of columns spanned by the cell. It's often necessary to use <cmd>ReFormat[<i>new keys</i>]{}</cmd> to reformat this specific cell according to the ''new keys''.<br />
<br />
<br />
<table cols="2"><tr valign="top"><td><br />
<texcode><br />
\starttable[s(0pt)|ls(10pt)|rs(0pt)|]<br />
\HL<br />
\NC \use{2}\ReFormat[cB]{Spanning head} \SR<br />
\HL<br />
\NC left column text \VL right column text \NC \AR<br />
\NC new row \VL new row \NC \AR<br />
\NC left column text \VL \ReFormat[l]{reformatted} \NC \AR<br />
\HL<br />
\NC \use{2}Spanning entry \SR <br />
\HL<br />
\stoptable<br />
</texcode><br />
</td><td><br />
<context><br />
\starttable[s(0pt)|ls(10pt)|rs(0pt)|]<br />
\HL<br />
\NC \use{2}\ReFormat[cB]{Spanning head} \SR<br />
\HL<br />
\NC left column text \VL right column text \NC \AR<br />
\NC new row \VL new row \NC \AR<br />
\NC left column text \VL \ReFormat[l]{reformatted} \NC \AR<br />
\HL<br />
\NC \use{2}Spanning entry \SR <br />
\HL<br />
\stoptable<br />
</context><br />
</td></tr></table><br />
<br />
==Table as Floating Object==<br />
<br />
<texcode><br />
\placetable[here][tab:sample]{sample table}<br />
\starttable ...<br />
</texcode><br />
<br />
* See [[Floating Objects]] in general.<br />
* If you need information about <cmd>placetable</cmd> look after <cmd>placefloat</cmd> in the manual or texshow!<br />
* If you'd like to leave out the table's caption (here: "sample table"), you can't simply leave the braces empty but must write <tt>none</tt>!<br />
<br />
==Background Colors==<br />
<br />
A very nice application in table are background colors for rows/cells (a feature that doesn't work in [[tabulate]]):<br />
<br />
<table cols="2"><tr valign="top"><td><br />
<texcode><br />
\setupcolors[state=start]<br />
\starttable[|l|l|]<br />
\HL<br />
\BL[1]\SR<br />
\NC Command \NC Meaning \SR<br />
\HL<br />
\NC \tex{NC} \NC next column \FR<br />
\NC \tex{NR} \NC next row \LR<br />
\HL<br />
\CL[green]\SR<br />
\NC \tex{AR} \NC automatic row \SR<br />
\HL<br />
\stoptable<br />
</texcode><br />
</td><td><br />
<context><br />
\setupcolors[state=start]<br />
\starttable[|l|l|]<br />
\HL<br />
\BL[1]\SR<br />
\NC Command \NC Meaning \SR<br />
\HL<br />
\NC \tex{NC} \NC next column \FR<br />
\NC \tex{NR} \NC next row \LR<br />
\HL<br />
\CL[green]\SR<br />
\NC \tex{AR} \NC automatic row \SR<br />
\HL<br />
\stoptable<br />
</context><br />
</td><br />
</tr></table><br />
The commands work something like this: first, you say what background colour you want for the next row<br />
and then you typeset the row. Observe: the line with the colour-command and the row it is supposed<br />
to colour should end in the same command (i.e. both \SR, \LR, \FR, ...). If they don't, the background<br />
won't cover the whole cell.<br />
<br />
* <cmd>BL</cmd> makes a gray background: the optional argument tells BL how many cells it should color<br />
* <cmd>CL</cmd> makes a colored line<br />
<br />
==Fit Table Width==<br />
<br />
Hans posted a solution to the list for fitting a wide table (with paragraphs and vertical lines) to the page width. The key to his solution is the <code>.45\textwidth</code> settings when setting each cell as a paragraph.<br />
<br />
<texcode><br />
\SetTableToWidth{\textwidth}<br />
<br />
\starttable[|p(.45\textwidth)|p(.45\textwidth)|]<br />
\HL<br />
\VL foo foo foo foo foo foo \VL bar bar bar bar bar bar \VL\AR<br />
\HL<br />
\stoptable<br />
</texcode><br />
<!-- It makes no sense to typeset this here. --><br />
<br />
[[Category:Tables]]</div>193.167.195.60