Open main menu

Changes

867 bytes added ,  10:11, 16 December 2021
Add hints on bracket usage; c&p from the list: https://www.mail-archive.com/ntg-context@ntg.nl/msg87937.html
* [[Counters]]: Manipulating counters in context
* [[Expressions]]: Evaluating expressions of type number, dimen, glue or muglue
* [[executesystemcommandExecutesystemcommand]]: process contents of an environment by another program
* Loops and expansion [http://randomdeterminism.wordpress.com/2009/03/05/tex-programming-the-past-the-present-and-the-future/ (blog post)]
* [[Console Mode]]: Using ConTeXt on keyboard input directly, rather than loading a <tt>.tex</tt> file.
 
= Use of brackets =
 
One must '''not''' confuse with the LaTeX convention where "mandatory"
arguments are contained in curly braces and brackets indicate
"optional" arguments.
 
Curly braces not only give grouping but generally
are used for objects to be typeset, as for \in{Figure}{a} [fig:ref].
 
For new users, it is worth repeating here that arguments within braces
can be either a comma-separated list of words OR a comma-separated
list of keyword=value pairs, BUT NOT A MIXTURE OF BOTH. Generally, a
keyword=value exists for all words, for example \cite[authoryear][ref]
and \cite[alternative=authoryear,reference=ref]
 
values can be grouped using curly braces, as in
\cite[alternative=authoryear,lefttext={{see },}][ref1,ref2] where the
lefttext is associated with the first cite reference (and none with the
second). This can be tricky but is in fact rather straight-forward.
= Using variables =
'''Ensure that all variables are set before you use them!'''
== CLD ==
How to pass variable from TeX to Lua and vice versa? See [[CLD_passing_variables#Variables|CLD passing variables]].
= Defining new commands =
letters: <tt>@</tt>, <tt>!</tt> and <tt>?</tt>.
Before and after the use or definition of such protected commands in your input files, the catcode of these
characters has to be changed. This is done by <{{cmd>|unprotect</cmd> }} and <{{cmd>|protect</cmd>}}:
<texcode>
</texcode>
The newly defined command <tt>\!test</tt> can of course only be called upon when we are in the <{{cmd>|unprotect</cmd>}}ed state, otherwise TeX reads the command <tt>\!</tt>, followed by the word <tt>test</tt> (and probably complains loudly about not being in math mode). These protection/unprotection commands can be nested. When the nesting becomes deeper than one level, the system reports the current protection level. It is a good habit to always start your macro files with <{{cmd>|unprotect</cmd> }} and end them with <{{cmd>|protect</cmd>}}.
</context>
{{todo|maybe move content from here to [[Tools]] or [[Basics]] pages, in order to focus this page about "Inside ConTeXt"}} [[Category:Inside ConTeXtProgramming and Databases]][[Category:ConTeXt programmingTools]]
57

edits