lvjr / tabularray

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

Footnotes in regular tblr #420

Closed niveK77pur closed 11 months ago

niveK77pur commented 11 months ago

As mentioned in #336 one can create footnotes using a combination of note and \TblrNote. However, when using the "default" tblr table, this does not work. Also, the examples in the documentation only illustrate this for tall and long tables.

Would it be handy and possible to allow these footnotes for all types of tables? I have a very short table where I want to put a footnote for additional context, but the text is not strictly relevant to the table's content so I want to avoid cluttering it with the help of a footnote.

Note that I am not asking for page footnotes as in the linked issue #336. I merely want the ability to create footnotes like is already possible for long and tall tables.

Example

In this example, the footnote does not appear anywhere. The footnote also does not appear when setting baseline or expand outer specifications (sec 3.2, table 3.2 in the documentation).

\documentclass{scrartcl}
\usepackage{tabularray}
\usepackage{blindtext}

\begin{document}

\blindtext

\begin{table}[ht]
  \caption{Normal table}
  \centering
  \begin{tblr}[
      %baseline,
      note{a} = {Footnote in a normal table},
    ]{
      colspec = {cc},
    }
    Key             & Value \\
    abc             & 1     \\
    def\TblrNote{a} & 2     \\
    ghi             & 3     \\
  \end{tblr}
\end{table}

\blindtext

\end{document}

image

Workaround

I can fool the package into putting a footnote by using tall or long for the table. I want the table to remain floating however, which is why I still keep it inside the table environment. However, the spacing above and below the table has increased, and I cannot quite figure out how to reduce it (I was looking at sec. 4.2.1, table 4.4 in the documentation)

\documentclass{scrartcl}
\usepackage{tabularray}
\usepackage{blindtext}

\begin{document}

\blindtext

\begin{table}[ht]
  \begin{tblr}[
      long,
      caption = {Long table},
      note{a} = {Footnote in a long table},
    ]{
      colspec = {cc},
    }
    Key             & Value \\
    abc             & 1     \\
    def\TblrNote{a} & 2     \\
    ghi             & 3     \\
  \end{tblr}
\end{table}

\blindtext

\end{document}

image

muzimuzhi commented 11 months ago

However, when using the "default" tblr table, this does not work. Also, the examples in the documentation only illustrate this for tall and long tables.

"Default" tblr table has no head and foot components (they are ignores even if specified). You need "tall" tblr here. "Tall" table works just like "default" tblr table but typesets table head and foot components. Footnotes are part of the table head.

However, the spacing above and below the table has increased, and I cannot quite figure out how to reduce it (I was looking at sec. 4.2.1, table 4.4 in the documentation)

You used "long" tblr table, which is typeset in its own paragraph, surrounded by (extra) vertical spaces presep and postsep.

An example for "tall" tblr tables is given below.

Full example

```tex \documentclass[twocolumn]{article} \usepackage{tabularray} \usepackage{lipsum} \begin{document} \lipsum[1][1-3] \begin{table}[ht] \centering \caption{Normal table} \begin{tblr}{ colspec = {cc}, } Key & Value \\ abc & 1 \\ def & 2 \\ ghi & 3 \\ \end{tblr} \end{table} \lipsum[1][1-3] \leavevmode\rule{\linewidth}{.4pt}\par \newpage \lipsum[1][1-3] \begin{table}[ht] \centering \caption{Tall table} \begin{tblr}[ tall, label=none, ]{ colspec = {cc}, } Key & Value \\ abc & 1 \\ def & 2 \\ ghi & 3 \\ \end{tblr} \end{table} \lipsum[1][1-3] \leavevmode\clap{\rule{2\linewidth}{.4pt}}\par \lipsum[1][1-3] \begin{table}[ht] \centering \caption{Tall table} \begin{tblr}[ tall, label=none, note{a} = {Footnote in a tall table}, ]{ colspec = {cc}, } Key & Value \\ abc & 1 \\ def\TblrNote{a} & 2 \\ ghi & 3 \\ \end{tblr} \end{table} \lipsum[1][1-3] \end{document} ```

image

niveK77pur commented 11 months ago

Thank you very much for the detailed information! I did notice that there was a distinction being made between tall and long tables, but it was not clear to me what exactly the differences were; hence I did not try using the tall table in this case.

Also thanks a lot for providing such a thorough example, you definitely showed me something new and neat there with the label=none as well!

I shall close this issue as my initial concern has been resolved; thanks again!