3

I would like to achieve, what in Adobe InDesign is called a paragraph rule over a figure's caption, i.e a line on top of the caption, while keeping the caption itself right-aligned (actually aligned to the inner edge).

Here's an MWE (note that this MWE is similar to what I posted for a previous question and will soon be reworked to incorporate the suggestions I received there):

\setuppapersize[A4][A4]
\setuplayout
[
  backspace=11.67mm,        width=131.25mm,
  topspace=21.21mm,         height=254.57mm,
  headerdistance=13pt,      header=13pt,
  footerdistance=13pt,      footer=13pt,
  rightmargindistance=13pt, rightmargin=39.5mm,
]

\setuppagenumbering[alternative=doublesided, location=]

\setuphead[section][
  page=right,
  continue=no,
  style=\ssb\bf,
]


\definefloat[pagefloat][pagefloats][graphic]
\setupfloat[pagefloat][
  default={page,header,footer},
]
\setupcaption[pagefloat][
  width=max,
  location=top,
  topframe=on,
  toffset=\dimexpr 0.25\lineheight \relax,
  headstyle=\ss\bf,
  style=\tfx,
  align=inner,
  spaceinbetween=nowhite,
]

\def\PageFigure#1#2%
  {
  \placepagefloat[]{#2}{
    \offset[
      leftoffset=\dimexpr -\rightmarginwidth - \lineheight \relax,
    ]{
      \externalfigure[#1][
        width=\dimexpr \textwidth + \rightmarginwidth + \lineheight \relax,
        height=\textheight,
        factor=fit,
      ]
    }
  }
}


\starttext

\chapter{Testing Ruled Captions}

\dorecurse{3}{\input{knuth}}

\PageFigure{https://via.placeholder.com/1600x900.png?text=Wide+Test+Image}{First line\\Second line of the caption}

\section{First Section}

\dorecurse{4}{\input{knuth}}

\stoptext

This is what it looks like, when I remove the line topframe=on,: This is how I would like to align the text.

enter image description here

But here's, what it looks like with the topframe on:

enter image description here

Why does merely adding the top frame change the alignment of the text? Can this be prevented or, better even, adjusted separately?

Any help would be much appreciated.

1 Answer 1

2

Not sure that I understand what you want, but maybe something like this? Note the location={top,right}. In your definition of PageFigure you had spurious spaces (try the example with your definition, and you will see how they show). Also, setting the size of the paper to A4 is not necessary, that is the default.

I first forgot. The topframe=on makes your code go into a different path (with a frame), and that is responsible for the effect you see.

\setuppapersize[A4][A4]
\setuplayout
[
  backspace=11.67mm,        width=131.25mm,
  topspace=21.21mm,         height=254.57mm,
  headerdistance=13pt,      header=13pt,
  footerdistance=13pt,      footer=13pt,
  rightmargindistance=13pt, rightmargin=39.5mm,
]

\setuppagenumbering[alternative=doublesided, location=]

\setuphead[section][
  page=right,
  continue=no,
  style=\ssb\bf,
]


\definefloat[pagefloat][pagefloats][graphic]
\setupfloat[pagefloat][
  default={page,header,footer},
]

\setupcaption[pagefloat][
   location={top,right},
   topframe=on,
   toffset=0.25\lineheight,
   headstyle=\ss\bf,
   style=\tfx,
   align=inner,
   spaceinbetween=nowhite,
]

\starttexdefinition PageFigure #1#2
  \placepagefloat
    {#2}
    {\offset
      [leftoffset=\dimexpr - \rightmarginwidth - \lineheight \relax] 
      {\externalfigure
         [#1]
         [width=\dimexpr \textwidth + \rightmarginwidth + \lineheight \relax,
          height=\textheight,
          factor=fit]}}
\stoptexdefinition

\showframe

\starttext

\chapter{Testing Ruled Captions}

\dorecurse{3}{\input{knuth}}

\PageFigure{https://via.placeholder.com/1600x900.png?text=Wide+Test+Image}{First line\par Second line of the caption}

\section{First Section}

\dorecurse{4}{\input{knuth}}

\stoptext

caption over figure

Update Hans has now opened up the possibilities a bit. Note the loffset that will take care of the extra piece of the bar.

In addition, I have done a few modifications:

  • Added location=inner to the float, and also removed the offset (I did not understand the \lineheight you had there).
  • Changed to \start...\stop syntax.

If we (you) are lucky, there will be a new release soon where this is included.


\useMPlibrary[dum]

\setuplayout
  [backspace=11.67mm,        width=131.25mm,
   topspace=21.21mm,         height=254.57mm,
   headerdistance=13pt,      header=13pt,
   footerdistance=13pt,      footer=13pt,
   rightmargindistance=13pt, rightmargin=39.5mm]

\setuppagenumbering
  [alternative=doublesided,location=]

\setuphead
  [section]
  [page=right,
   continue=no,
   style=\ssb\bf]

\defineframed
  [MyCaptionFramed]
  [align={lohi,flushleft},
   width=fit,
   frame=off,
   strut=no,
   topframe=on,
   loffset=3cm,
   toffset=0.25\lineheight]

\starttexdefinition protected MyCaption #1
  \MyCaptionFramed {
    % we ignore #1 as we want to unpack
    \unvbox\floatcaptionbox
  }
\stoptexdefinition

\definefloat[pagefloat][pagefloats][graphic]

\setupfloat
  [pagefloat]
  [default={page,header,footer},
   location=inner]

\setupcaption
  [pagefloat]
  [location={top,inner},
   align=inner,
   command=\MyCaption,
   spaceinbetween=nowhite]

\starttexdefinition PageFigure #1#2
  \startplacefloat
    [pagefloat]
    [title={#2}]
      \externalfigure
        [#1]
        [width=\dimexpr \textwidth + \rightmargintotal \relax,
         height=\textheight,
         factor=fit]
  \stopplacefloat
\stoptexdefinition

\showframe

\starttext

\startchapter[title={Testing Ruled Captions}]

  \dorecurse{3}{\input{knuth}}

  \PageFigure
    {some dummy}
    {First line\\Second line of the caption}

  \startsection[title={First Section}]

    \dorecurse{4}{\input{knuth}}

  \stopsection

\stopchapter

\stoptext

Result:

updated version

3
  • Thank you very much for your reply. However, unfortunately, this is not exactly what I wanted to achieve. If you look at the first of the two screenshots you can see that the caption's text is right-aligned (inner), as long as the topframe is turned off (i.e. when the line topframe=on, is commented out). But, as soon as I add the topframe, the text becomes left-aligned: see my second screenshot or your example. I'm not sure, how to keep the text right-aligned, while adding a line above the caption...
    – Marcus C.
    Feb 10 at 19:44
  • 1
    The configuration possibilities can indeed be improved here. I will discuss this with Hans in the near future. He sent me a first draft, so locally I currently have this.
    – mickep
    Feb 11 at 8:58
  • Thanks, that looks more or less exactly like what I would like to achieve. (It would be perfect, if it was also possible to adjust the length of the topframe, but that's a minor point.) So, is this only possible in your local draft version?
    – Marcus C.
    Feb 11 at 21:05

You must log in to answer this question.

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