Changing messages in ConTeXt

While writing papers I normally finish a draft of the text before working on figures. However, I include a placeholder for a figure. ConTeXt makes this very easy, I just type

\placefigure
[here,top]
[fig:reference]
{A long and thoughtful caption that I write with the other text}
{}

Normally, the last argument will be something like

{\externalfigure[filename]}

But, if I omit the information, ConTeXt draws a dummy figure — a text frame with “unknown” written in the center.

original

This is useful, except for the “unknown” part. Other people reading the draft tend to think that something went wrong with the figure syntax and the “unknown” is LaTeX error message. (Yeah, many people think that I use LaTeX. It is not worth the effort to clarify the distinction between LaTeX and ConTeXt). So, I wanted to change the “unknown” to a more sensible message. ConTeXt has a multilingual interface. So, message are not hard-coded, but can be changed depending on the language. So, I just needed to figure out which message was \placefigure calling when the fourth argument was empty. A bit of hunting around in the source files revealed the answer. page-flt.tex file has the following code

\def\doemptyblock#1%
{\localframed
[\??fl#1]
[\c!frame=\v!on,
\c!width=\@@bkwidth,
\c!height=\@@bkheight,
\c!location=\v!normal,
\c!offset=\@@bkoffset]%
{\getmessage\m!floatblocks{12}\empty}}

So, when given an empty block, it typesets a frame with message 12 of float blocks library. So, I need to change that to something more sensible.

\startmessages  english  library: floatblocks
12: To be drawn
\stopmessages

With this, I get

modified

The above exercise also tells me that I can change the width of the framed box. For example, I can say

\setupfloats
[width=8cm,height=5cm]

after which I get a bigger framed box.

modified

The only drawback of this approach is that all float blocks (figures, tables, anything else that you may have defined) use the same error message. A “To be drawn” message for a table looks silly, but I don’t use tables that often, so it is not a big issue for me.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s