lvjr / tabularray

Typeset tabulars and arrays with LaTeX3
https://ctan.org/pkg/tabularray
247 stars 22 forks source link

If there are multiple `\TblrNote`s with multiple characters in the same cell, the characters will be duplicated #473

Open Yarakashi-Kikohshi opened 4 months ago

Yarakashi-Kikohshi commented 4 months ago

If you place multiple \TblrNote with tag name of two or more characters in the same cell, the characters will overlap.

To reproduce

\documentclass{article}
\usepackage{tabularray}
\SetTblrStyle{note}{ hang = 2em, }
\begin{document}

\begin{talltblr}[
  label = none, entry = none,
  note{1st} = {The first table footnote},
  note{2nd} = {The second table footnote},
  note{3rd} = {The third table footnote},
]{
  colspec = {XXX}, width = 0.5\linewidth, hlines,
}
Alpha   & Beta  & Gamma   \\
Epsilon & Zeta  & Eta
                      \TblrNote{1st}
                      \TblrNote{2nd}
                      \TblrNote{3rd}
                          \\
Iota    & Kappa & Lambda  \\
\end{talltblr}

\end{document}

note-tag-image-1

muzimuzhi commented 4 months ago

Ignoring hyperlink operations, current \TblrNote{<tag>} acts similar to \rlap{\textsuperscript{<tag>}}. So not only multiple \TblrNote in the same cell overlap, but also long note <tag> may go beyond the cell's right border. https://github.com/lvjr/tabularray/blob/c9691e97c0db9222efcbdd033856068fa05040fc/tabularray.sty#L5127-L5137

\documentclass{article}
\usepackage{tabularray}
\SetTblrStyle{note}{ hang = 2em, }
\begin{document}

\begin{talltblr}[
  label = none, entry = none,
  note{1st} = {The first table footnote},
  note{2nd} = {The second table footnote},
  note{3rd} = {The third table footnote},
]{
%  colspec = {XXX}, width = 0.5\linewidth, 
  hlines,
}
Alpha   & Beta  & Gamma   \\
Epsilon & Zeta  & Eta%
                      \TblrNote{1st looooooong}
%                      \TblrNote{2nd}
%                      \TblrNote{3rd}
                          \\
Iota    & Kappa & Lambda  \\
\end{talltblr}

\end{document}

image

muzimuzhi commented 4 months ago

Redefining \TblrNote from \rlap to something equivalent to \use_i:n works.

\documentclass{article}
\usepackage{tabularray}
\SetTblrStyle{note}{ hang = 2em, }

\begin{document}

\begin{talltblr}[
  caption = Default \texttt{\string\TblrNote},
  label = none, entry = none,
  note{1st} = {The first table footnote},
  note{2nd} = {The second table footnote},
  note{3rd} = {The third table footnote},
]{
%  colspec = {XXX}, width = 0.5\linewidth,
  hlines,
}
Alpha   & Beta  & Gamma   \\
Epsilon & Zeta  & Eta%
                      \TblrNote{1st looooooong}
                          \\
Iota    & Kappa & Lambda%
                      \TblrNote{2nd}\,%
                      \TblrNote{3rd}
                        \\
\end{talltblr}
\bigskip

\renewcommand\TblrOverlap[1]{#1}

\begin{talltblr}[
  caption = Modified \texttt{\string\TblrNote},
  label = none, entry = none,
  note{1st} = {The first table footnote},
  note{2nd} = {The second table footnote},
  note{3rd} = {The third table footnote},
]{
%  colspec = {XXX}, width = 0.5\linewidth,
  hlines,
}
Alpha   & Beta  & Gamma   \\
Epsilon & Zeta  & Eta%
                      \TblrNote{1st looooooong}
                          \\
Iota    & Kappa & Lambda%
                      \TblrNote{2nd}\,%
                      \TblrNote{3rd}
                          \\
\end{talltblr}

\end{document}

image

Yarakashi-Kikohshi commented 4 months ago

@muzimuzhi, thank you for showing me how to redefine \TblrOverlap.

This method requires you to know which columns have multiple table footnotes and avoid using X (colspec) or co, which honestly feels inconvenient. It would be convenient if it could be used effectively even in columns where the column width is automatically adjusted.

At the same time, I have doubts about the purpose of including such a \rlap...

muzimuzhi commented 4 months ago

I infer the intension of applying \rlap on note tags is to not interfere the typesetting (especially horizontal alignment) of normal cell contents. It works well until multiple note tags are encountered, note tag is long compared to the column separation.

Apart from missing or incomplete documentation, these special cases lead to one question: how are note tags expected to be typeset in cells.

This method requires you to know which columns have multiple table footnotes and avoid using X (colspec) or co, which honestly feels inconvenient.

You can still use X columns with modified \TblrOverlap, I commented colspec = {XXX}, width = 0.5\linewidth out because the so configured column width (0.1666\linewidth) is too narrow.