5

Goal

I want to be able to put the caption (I will use no text, but only the "Figure X" label) centered in the margin, below the image, without disturbing the space between the image and the text that comes after.

Try 1

My first try was to put the image anchored to inner and then put the caption in the margin. But then the caption is not below the image:

\setuppapersize[A5]

\definefloat[widefigure][figure]

\setupfloat[widefigure]
    [location=inner,
    ]

\setupcaption[widefigure]
    [location={rightmargin,low},
     style=\tfxx,
     align=middle,
     width=\rightmarginwidth,
    ]

\showframe

\starttext
\input ward
\startplacewidefigure
\blackrule[width=\dimexpr(\textwidth+\rightmargindistance+\rightmarginwidth),height=1in,color=darkyellow]
\stopplacewidefigure
\input ward
\stoptext

caption in the wrong place

Try 2

My second try was to put the image in the rightmargin (allowing it to be wider to stick into the text). Then I can use the bottom key for the margin. Now the status between the image and caption looks fine, but there is instead vertical space between the image and the text that comes after that I don't know how to get rid of. Example:

\setuppapersize[A5]

\definefloat[widefigure][figure]

\setupfloat[widefigure]
    [location=rightmargin,
     spaceafter=,
    ]

\setupcaption[widefigure]
    [location={bottom},
     style=\tfxx,
     align=middle,
     width=\rightmarginwidth,
     height=0pt,
     spaceafter=,
    ]

\showframe

\starttext
\input ward
\startplacewidefigure
\blackrule[width=\dimexpr(\textwidth+\rightmargindistance+\rightmarginwidth),height=1in,color=darkyellow]
\stopplacewidefigure
\input ward
\stoptext

too much space below the figure

Where I have looked

I'm reading the ConTeXt command's reference, but I cannot find a suitable option for \setupfloatcaption (which seem to be the correct place to look) that gives what I'm looking for. Also, from the final section on caption handling in the details manual I'm not able to see how to achieve this.

Summary

Is there a way to either 1) lower the caption in the first example so that it is below the image or 2) reduce the space after the image in the second one (the caption should be independent of what is coming next)?

  • 1
    Based on a quick scan of strc-flt.mkiv, I don't think that what you are trying to do is possible with the built in options. One option that I can think of is to use ornaments (see Chapter 7 of The Details manual), and create an ornament which includes the figure number. But you may also with to ask on the context mailing list – Aditya Dec 12 '17 at 15:43
  • Many thanks, @Aditya! I realized that I actually can get rid of the white space after if I add \blank[overlay] before the text that comes after. But that does not work well if I postpone images. I should perhaps either try to use the ornaments (I guess that should, in principle, work), or send an email to the email list. – mickep Dec 12 '17 at 19:21
2

As suggested by @Aditya, one can use ornaments. I leave that as an answer since it might be useful for others, but wait for other answers that might be cleaner.

\setuppapersize[A5]

\definefloat[widefigure][figure]

\setupfloat[widefigure]
    [location=rightmargin,
    ]

\setupcaption[widefigure]
    [location=none,
    ]

\define[2]\WideFigure{%
\startplacewidefigure[reference={#1}]
\layeredtext
[corner={right,bottom},location={left,bottom}]
[offset=0pt]
{\framed[width=\rightmarginwidth,height=5ex,frame=off]{\bfxx\in{Figure}[#1]}}
{#2}
\stopplacewidefigure
}

\showframe

\starttext
\input ward
\WideFigure{fig:test}{%
\blackrule[width=\dimexpr(\textwidth+\rightmargindistance+\rightmarginwidth),height=1in,color=darkyellow]}
\input ward
\stoptext

Result:

Solution using ornaments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.