# [NTG-context] Maximum width of a caption

Hans Hagen pragma at wxs.nl
Mon Jan 5 11:51:10 CET 2015

On 1/5/2015 11:22 AM, Mojca Miklavec wrote:
> 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.

oneliners have a separate branch

> (But then again I'm not sure if that is a bug or a feature ;)
>
> Mojca
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
>
> maillist : ntg-context at ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
> archive  : http://foundry.supelec.fr/projects/contextrev/
> wiki     : http://contextgarden.net
> ___________________________________________________________________________________
>

--

-----------------------------------------------------------------