# [NTG-context] Maximum width of a caption

Mojca Miklavec mojca.miklavec.lists at gmail.com
Mon Jan 5 11:22:52 CET 2015

On Sun, Jan 4, 2015 at 12:30 PM, Hans Hagen wrote:
> On 1/3/2015 11:11 AM, Mojca Miklavec wrote:
>>
>> Hi,
>>
>> Is there any way to set the maximum width of a caption? I would like
>> to make sure that no figure caption exceeds, say, 75% of text width.
>>
>> Here's an example of "bad behaviour" in the second figure:
>>
>> \starttext
>>
>> \reservefigure
>> [width=5cm,height=2cm,frame=on][force]
>> {Some very small figure with not too much text: OK}
>>
>> \input tufte
>>
>> This can hardly be distinguished from the main text:
>>
>> \reservefigure
>> [width=\textwidth,height=.2\textwidth,frame=on][force]
>> {\input tufte}
>>
>> \input tufte
>>
>> Desired behaviour:
>>
>> \placefigure[force]{\input tufte}
>> {\hbox to
>> .75\textwidth{\hss\framed[width=\textwidth,height=.2\textwidth]{}\hss}}
>>
>> \input tufte
>>
>> \stoptext
>>
>> I've seen an option maxwidth, but only in connection to
>> \externalfigure[...][maxwidth=...].
>>
>> I can cheat as on the third figure above, but that seems like an ugly
>> approach to me.
>
>
> can you test this a bit:
>
> \unprotect
>
> \setupcaptions
>   [\c!maxwidth=.75\hsize]

Thank you very much. The patch that you sent me for strc-flt.mkvi
seems to work as expected on a long document with many figures.

The only exception are one-liners. The following creates a caption
that extends to almost the whole text width:

\placefigure
% Why are there two spaces between "dummy" and "text"?
{Some \dorecurse{7}{dummy } text}
{\externalfigure[dummy][width=\textwidth,height=.2\textwidth]}

As soon as slightly more text is added, it shrinks to the desired text width.

(But then again I'm not sure if that is a bug or a feature ;)

Mojca