是否可以在 ConTeXt 中分别对齐图形(表格)的标题和标题文本?

是否可以在 ConTeXt 中分别对齐图形(表格)的标题和标题文本?

选项align=center可以\setupcaptions将图或表的标题居中对齐。单行标题文本还可以,多行标题文本就不太好了,所有行都居中对齐。

如何实现如下例的效果,使第二行开始的字幕文本的第一个单词与字幕标签后的第一个单词对齐?

Figure 1 This is very long caption text as 
         an example.

答案1

2019.12.27 19:26ConTeXt 版本开始,您可以使用\setupcaption[hang=yes]悬挂标题来显示浮动字幕。

\setupexternalfigures[location=default]

\setupcaption
  [figure]
  [align=tolerant]

\starttext

\startplacefigure[title={\samplefile{jojomayer}}]
  \externalfigure[hacker][width=.75\textwidth]
\stopplacefigure

\setupcaption
  [figure]
  [hang=yes]

\startplacefigure[title={\samplefile{jojomayer}}]
  \externalfigure[hacker][width=.75\textwidth]
\stopplacefigure

\stoptext

在此处输入图片描述

答案2

目前,这只能通过修补核心来实现,但我已经通过电子邮件向开发团队发送了有关此事的信息:https://mailman.ntg.nl/pipermail/dev-context/2019/003636.html

\unprotect

\def\strc_floats_make_complete_caption
  {\doifsomething{\floatcaptionparameter\c!spacebefore}{\blank[\floatcaptionparameter\c!spacebefore]}%
   \strc_floats_make_complete_caption_before
   \synchronizedisplaydirection % temp hack, till we have a proper model
   \noindent
   \gdef\lastcaptiontag{\strut\thecurrentfloatnumber}% was xdef ... needs checking
   \begingroup
     \usefloatcaptionstyleandcolor\c!style\c!color
     \clf_doifelselisthastitle{\currentfloat}\numexpr\currentfloatnumber\relax
       \donothing
       \emptyfloatcaptiontrue
     \ifnofloatnumber
     \else
       \floatcaptionparameter\c!headcommand % <- nieuw
         {\usefloatcaptionstyleandcolor\c!headstyle\c!headcolor\thecurrentfloatnumber}%
       \ifnofloatcaption \else \ifemptyfloatcaption \else
         \doifelsenothing{\floatcaptionparameter\c!spaceinbetween}
           {\floatcaptionparameter\c!headseparator\relax
            \scratchskip\floatcaptionparameter\c!distance\relax
            \dotfskip\scratchskip\emergencystretch.5\scratchskip}
           {\blank[\floatcaptionparameter\c!spaceinbetween]}%
       \fi \fi
     \fi
     \ifnofloatcaption
       \global\d_strc_floats_caption_height\zeropoint
       \global\d_strc_floats_caption_depth \zeropoint
     \else
       \usefloatcaptionstyleandcolor\c!textstyle\c!textcolor
       \global\d_strc_floats_caption_height\strutheight
       \global\d_strc_floats_caption_depth \strutdepth
       \thecurrentfloatcaption\endgraf
     \fi
   \endgroup
   \strc_floats_make_complete_caption_after
   \doifsomething{\floatcaptionparameter\c!spaceafter}{\blank[\floatcaptionparameter\c!spaceafter]}}

\protect

\define[1]\hanginghead{\llap{\hbox to 5em{#1\hss}}}

\setupcaption
  [figure]
  [width=\dimexpr\textwidth-5em\relax,
   headcommand=\hanginghead,
   distance=0pt]

\starttext

\startplacefigure[title={\samplefile{knuth}}]
  \externalfigure[cow]
\stopplacefigure

\stoptext

相关内容