# What is the proper way to format syntax within ConTeXt?

For some time, I have thought, perhaps mistakenly, that the precise placement or spacing around ConTeXt syntax was unimportant, e.g., under this assumption, all of these should produce the same results:

``````\setupbodyfont[stsong,12pt]

\setupbodyfont[stsong, 12 pt]

\setupbodyfont    [stsong, 12 pt]

\setupbodyfont[
stsong, 12 pt
]

\setupbodyfont
[
stsong, 12 pt
]
``````

I have, however, found some small problems appeared in my document, because I was improperly placing the syntax, e.g., this will not work:

``````\setuplayout[
grid=yes,
margin=10cm
]
``````

This suggests that placement is perhaps important.

I have also discovered some additional spaces appearing in my document, e.g., between `)` and `,`, and it is likely the result of improper syntax formatting.

-
You should be safe if you delimit parameters with a comma: `\setuplayout[ grid=yes, margin=10cm, ]`. Also, you can try using setups which make Context ignore non-explicit spaces. –  phg May 14 '12 at 11:40
Is the comma after `margin=10cm` important? What are setups? –  Village May 14 '12 at 11:43
(1) The comma tells the argument parser to finish the current entry, any spaces following this comma will be ignored. (2) Define with `\startsetups [mysetups:foo] foo \stopsetups` and retrieve via `\setups{mysetups:foo}`. Inside the {start|stop}setups environment, trailing spaces are ignored unless specified with `\space` or similar. –  phg May 14 '12 at 11:54

## 1 Answer

Spaces are ignored after control sequences (as is normal in TeX), after commas, and after square brackets (either opening or closing).

Spaces in values become part of the value, which may or may not be harmful depending on the type of the value: for dimension assignments this is often ok, but for keyword values it most often results in ignored settings, and sometimes even in errors.

Imho, the nicest way to format ConTeXt's key-value commands is:

``````\setuplayout
[grid=yes,
margin=10cm]
``````
-