1

I want to create a new style alternative, which would allow me to change the text and font (to uppercase bold in this example) while also increasing the letterspacing. However, trying to do this leads to a crash:

\setuppapersize[S3]

\definecharacterkerning [mykerning] [factor=0.16]
\definealternativestyle [mystyle]
  [
    \WORDS\bfx\setcharacterkerning[mykerning]
  ]


\starttext
  {\WORDS\bfx\setcharacterkerning[mykerning] It works here.}
  
  {\mystyle It crashes here.}
\stoptext
tex error       > tex error on line 13 in file /home/…/test.tex: ! Argument of \setcharacterkerning has an extra }

Why does this crash occur? (\WORDS works, why not \setcharacterkerning?) Is there a way to fix it? I want to be able to use it as an argument for style=.

0

1 Answer 1

2

Sorry for the long answer. The bracket issue was discussed elsewhere and I think it's explained in a manual, but I don't remember which, so I'll include a brief note here.

Your problem is: ConTeXt is closing a pair of brackets [] at the first occurrence of the closing bracket. Thus, something like

\setupsomething[key=\value[]]

will read [key=\value[] and crash. For such situations ConTeXt provides \setups to include all your complicated macros:

\startsetups mystyle 
\WORDS\bfx\setcharacterkerning[mykerning]
\stopsetups

Both \setups[mystyle] and \setup{mystyle} work, so we'll choose the latter in order to avoid the bracket issue above.

\setuppapersize[S3]
\definecharacterkerning [mykerning] [factor=0.16]
\startsetups mystyle
\WORDS\bfx\setcharacterkerning[mykerning]
\stopsetups
\definealternativestyle[mystyle][\setups{mystyle}]
\setuphead[title][style=\mystyle]
%Test example
\starttext
\starttitle[title=Hello]
\input jojomayer
\stoptitle
\stoptext

enter image description here

6
  • 4
    A simpler solution is to wrap the content of the argument in curly braces, e.g. \definealternativestyle[mystyle][{\setcharactercasing[WORD]...}]. Jan 4, 2021 at 19:38
  • @WolfgangSchuster I've tried that, but character spacing doesn't have any effect in latest LMTX... I'll see again
    – user226564
    Jan 4, 2021 at 19:41
  • I think I found the problem – encapsulating it with braces does not work with how I format the argument (with new lines and indentation). Why does it affect it here, but not elsewhere? Jan 5, 2021 at 11:54
  • @JurajFiala Your example doesn't include new lines or indentation. Maybe you should include it in your MWE, because I'm testing here and it works across paragraphs.
    – user226564
    Jan 5, 2021 at 12:06
  • It does, see \definealternativestyle. If I join lines 4–7 and encapsulate it with braces, it works. Jan 5, 2021 at 13:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .