Skip to content

feat: capcont-text#673

Open
sam-maloney wants to merge 1 commit into
TeXackers:mainfrom
sam-maloney:capcont-text
Open

feat: capcont-text#673
sam-maloney wants to merge 1 commit into
TeXackers:mainfrom
sam-maloney:capcont-text

Conversation

@sam-maloney

@sam-maloney sam-maloney commented Jul 1, 2026

Copy link
Copy Markdown

This adds a new template capcont-text (and capcont-pre) so that capcont is no longer hard-coded to use conthead-* templates. This is useful when one wants to format long tables with captions in the footer rather than the header, where otherwise one currently has to either redefine capcont to use contfoot-text or swap the meaning of conthead-text and contfoot-text, which is confusing.

I haven't documented anything in the manual yet, but am happy to do so if others agree with the idea itself; I'm also very open to other suggestions to achieve the desired outcome in a clean manner!

Essentially I would like to be able to do this:

% simply change `capcont-text` to use footer text instead of header text
\DeclareTblrTemplate{capcont-text}{default}{\UseTblrTemplate{contfoot-text}{default}}
\DeclareTblrTemplate{firsthead}{default}{}
% headers then use standard `conthead` template
\DeclareTblrTemplate{middlehead,lasthead}{default}{\UseTblrTemplate{conthead}{default}}
% and `capcont` is used the footer
\DeclareTblrTemplate{firstfoot,middlefoot}{default}{\UseTblrTemplate{capcont}{default}}
\DeclareTblrTemplate{lastfoot}{default}{
  \UseTblrTemplate{caption}{default}
  \UseTblrTemplate{note}{default}
  \UseTblrTemplate{remark}{default}
}

instead of either this:

% swap the header and footer text
\DeclareTblrTemplate{conthead-text}{default}{\tblrcontfootname}
\DeclareTblrTemplate{contfoot-text}{default}{\tblrcontheadname}
\DeclareTblrTemplate{firsthead}{default}{}
% and now the headers use the `contfoot` template, which is semantically confusing
\DeclareTblrTemplate{middlehead,lasthead}{default}{\UseTblrTemplate{contfoot}{default}}
% the rest is the same
\DeclareTblrTemplate{firstfoot,middlefoot}{default}{\UseTblrTemplate{capcont}{default}}
\DeclareTblrTemplate{lastfoot}{default}{
  \UseTblrTemplate{caption}{default}
  \UseTblrTemplate{note}{default}
  \UseTblrTemplate{remark}{default}
}

or having to redefine the entire capcont template, which is annoying for such a simple switch if one wants to preserve the full normal template behaviour:

LaTeX code
\ExplSyntaxOn
% have to copy-and-paste the whole definition from `tabularray.sty`
\DeclareTblrTemplate { capcont } { normal }
  {
    \hbox_set:Nn \l__tblr_caption_box
      {
        \UseTblrTemplate { caption-tag } { default }
        \UseTblrTemplate { caption-sep } { default }
        \UseTblrTemplate { caption-text } { default }
        \UseTblrTemplate { conthead-pre } { default }
        \UseTblrTemplate { contfoot-text } { default } % just to change `conthead-text` to `contfoot-text`
      }
    \dim_compare:nNnTF { \box_wd:N \l__tblr_caption_box } > { \hsize }
      {
        \UseTblrAlign { capcont }
        \UseTblrIndent { capcont }
        \hbox_set:Nn \l__tblr_caption_left_box
          {
            \UseTblrTemplate { caption-tag } { default }
            \UseTblrTemplate { caption-sep } { default }
          }
        \hangindent = \box_wd:N \l__tblr_caption_left_box
        \hangafter = 1
        \UseTblrHang { capcont }
        \leavevmode
        \hbox_unpack:N \l__tblr_caption_box
        \par
      }
      {
        \centering
        \makebox [\hsize] [c] { \box_use:N \l__tblr_caption_box }
        \par
      }
  }
\ExplSyntaxOff
% and the rest is the same as the first example, where the above was simplified to one line
\DeclareTblrTemplate{firsthead}{default}{}
\DeclareTblrTemplate{middlehead,lasthead}{default}{\UseTblrTemplate{conthead}{default}}
\DeclareTblrTemplate{firstfoot,middlefoot}{default}{\UseTblrTemplate{capcont}{default}}
\DeclareTblrTemplate{lastfoot}{default}{
  \UseTblrTemplate{caption}{default}
  \UseTblrTemplate{note}{default}
  \UseTblrTemplate{remark}{default}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant