3

I'd like to use Metapost to format my titles like this (not exactly like this, so no need to complain about design issues :)): format I would like to have

The problem is that when I try to use the following macro I get an error:

tex error       > error on line 4 in file 
/------------/minimal-mpgraph.tex: ! Undefined control sequence

<argument> \setstrut \begstrut \getheadtitle 
                                  \endstrut 
\MPLIBgraphictext ...\startTEXpage [scale=10000]#1
                                                  \stopTEXpage 
l.4 ...\setstrut \begstrut \getheadtitle \endstrut }


1     \starttext
2     \def\MPLIBgraphictext#1{\startTEXpage[scale=10000]#1\stopTEXpage}
3     
4 >>  \MPLIBgraphictext{\setstrut \begstrut \getheadtitle \endstrut }
5     \stoptext

I'm guessing here that the problem is internally the \getheadtitle. I'm quite clueless how to solve this though. Is there something wrong with my macro or is it just impossible to pass section titles to macros using Metapost? Any help is appreciated. Code:

\define[1]\DashedText%
    {%
    \startuseMPgraphic{dashed_number}
        graphictext "#1" % the part "#1" does not work :(
            scaled 5
            dashed evenly
            withdrawcolor (0.1,0.4,0.1)
            withfillcolor (0.6,0.8,0.9)
            withpen pencircle scaled 3.0pt
    \stopuseMPgraphic
    \useMPgraphic{dashed_number}{}%
    }

\setuphead [section]
    [
        number=no, 
        textcommand=\DashedText,
    ]

\starttext

\startsection [title={Fancy Title}]
\input knuth
\stopsection

\stoptext
2
  • I managed to get this to work by: graphictext "\currentstructuretitle", still have no idea why \getheadtitle is not working... Commented Sep 11, 2015 at 9:06
  • Well, seems like I found the proper solution (though not yet quite sure why): deeptextcommand instead of textcommand, and everything works like a charm. Commented Sep 11, 2015 at 11:04

1 Answer 1

1

This isn't what I would call a definitive answer, but here's what I found in my investigation.

It does look like using deeptextcommand is your best option here. As seen on the Context Wiki, deeptextcommand gives you access to the full text of the command without anything else. When I look at the -mpgraph.tex file generated by running context using textcommand, I see that your macro is passed

\setstrut \begstrut \getheadtitle \endstrut

as the parameter, and (this is a guess) \getheadtitle is undefined outside of a sectioning context since this is in a separate .tex file. Using deeptextcommand gives you just the text used in the \startsection command, so the -mpgraph.tex file sees

Fancy Title

as its argument.

Here's one thing I noticed while tinkering. If you want to change the text style of your fancy section heads, I think you'll need to include it in your MPgraphic, as deeptextcommand is applied before the style setup. Alternatively, you can change the style of individual sections by using

\startsection[title={\em Fancy Title}]

You must log in to answer this question.

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