4

Consider the following MWE:

\documentclass{article}
\usepackage[export]{adjustbox}
\usepackage{rotating, makecell}
\usepackage{tabularray}
\usepackage[skip=0.5ex, belowskip=1ex]{subcaption}
\renewcommand*{\thesubfigure}{\arabic{subfigure}}

\begin{document} \begin{figure} \settowidth\rotheadsize{3em} % from makecell \adjustboxset{width=\linewidth, valign=c} % from adjustbox \begin{tblr}{%hlines, vlines, colspec={r X[c,h]X[c,h]X[c,h]X[c,h]}, colsep=3pt, column{1}={cmd=\rotcell, font=\bfseries}, row{1}={font=\bfseries}, } & A & B & C & D \[-2ex] one & \subfloat[\label{fig5a1}]{\adjincludegraphics{example-image-duck}} & \subfloat[\label{fig5b1}]{\adjincludegraphics{example-image-duck}} & \subfloat[\label{fig5c1}]{\adjincludegraphics{example-image-duck}} & \subfloat[\label{fig5d1}]{\adjincludegraphics{example-image-duck}} \ two & \subfloat[\label{fig5a2}]{\adjincludegraphics{example-image-duck}} & \subfloat[\label{fig5b2}]{\adjincludegraphics{example-image-duck}} & \subfloat[\label{fig5c2}]{\adjincludegraphics{example-image-duck}} & \subfloat[\label{fig5d2}]{\adjincludegraphics{example-image-duck}} \ \end{tblr} \end{figure} \end{document}

Why numbering of subfloats captions start with 41? Even if I before compilation delete files .aux and .log, the result is the same.

enter image description here

If i use tabularx table (see answer), caption numbering is correct. So I wondering, if in tabularray settings is missed something or it interact with subcaption (with subfig is the same) on unexpected way?

In compilation I use tabularray version 2021N (temporary available on github see link 2021N), which is announced for September 1st.

Zarko
  • 296,517
  • @JohnKormylo, this may be workaround, however as package author said (in his answer), this is bug which will be handled in one of the next package version. I will wait to bug fix. – Zarko Aug 28 '21 at 16:24
  • 1
    I have fixed this bug. Please see my updated answer. – L.J.R. Sep 10 '21 at 07:35

1 Answers1

3

Updated on 2021-09-10: I have added counter library to tabularray package for resetting LaTeX counters when needed. This bug should has been fixed. You may download the latest package file from https://github.com/lvjr/tabularray/raw/main/tabularray.sty and test whether there are other problems.

\documentclass{article}
\usepackage[export]{adjustbox}
\usepackage{rotating, makecell}
\usepackage{tabularray}
\UseTblrLibrary{counter}
\usepackage[skip=0.5ex, belowskip=1ex]{subcaption}
\renewcommand*{\thesubfigure}{\arabic{subfigure}}

\begin{document} \begin{figure} \settowidth\rotheadsize{3em} % from makecell \adjustboxset{width=\linewidth, valign=c} % from adjustbox \begin{tblr}{%hlines, vlines, colspec={r X[c,h]X[c,h]X[c,h]X[c,h]}, colsep=3pt, column{1}={cmd=\rotcell, font=\bfseries}, row{1}={font=\bfseries}, } & A & B & C & D \[-2ex] one & \subfloat[\label{fig5a1}]{\adjincludegraphics{example-image-duck}} & \subfloat[\label{fig5b1}]{\adjincludegraphics{example-image-duck}} & \subfloat[\label{fig5c1}]{\adjincludegraphics{example-image-duck}} & \subfloat[\label{fig5d1}]{\adjincludegraphics{example-image-duck}} \ two & \subfloat[\label{fig5a2}]{\adjincludegraphics{example-image-duck}} & \subfloat[\label{fig5b2}]{\adjincludegraphics{example-image-duck}} & \subfloat[\label{fig5c2}]{\adjincludegraphics{example-image-duck}} & \subfloat[\label{fig5d2}]{\adjincludegraphics{example-image-duck}} \ \end{tblr} \end{figure} \end{document}

enter image description here


It is a recently known bug ( see https://github.com/lvjr/tabularray/discussions/83 ).

To build a nice table, tabularray need to measure every cell several times, therefore the counters inside the cell will be increased several times.

As David Carlisle has commented there, tabularx has some code to save the values of all LaTeX counters and reset them for each trial. Therefore counters in tabularx are correct.

I need some time to look into this problem. And it is too late for version 2021N. I will update this answer after I have solved this problem.

L.J.R.
  • 10,932