lvjr / tabularray

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

Changing `note-tag` and `note-sep` with `\DefTblrTemplate` does not give the expected results #456

Open Yarakashi-Kikohshi opened 10 months ago

Yarakashi-Kikohshi commented 10 months ago

To reproduce

I have created a simple example below.

% !TeX program = lualatex
\documentclass[ class = article, border = 5pt]{standalone}
\usepackage{tabularray}
\listfiles
%
%% Add an asterisk to the left of the tag
\DefTblrTemplate{note-tag}{default}{ \textsuperscript{\textasteriskcentered \InsertTblrNoteTag} }
%
%% Change the space between the tag and the text to a colon
\DefTblrTemplate{note-sep}{default}{:}
%
\begin{document}

\begin{talltblr}[
    note{a} = {This is a note.},
    caption = {This is a table with footnote.},
  ]{
    colspec = {*{2}{X[c]}},
    width = {0.5\linewidth},
    vlines, hlines,
  }
  This & is                 \\
  a    & table \TblrNote{a}
\end{talltblr}

\end{document}

note-settings-image-1

Logs

log file ```log This is LuaHBTeX, Version 1.17.0 (TeX Live 2023) (format=lualatex 2023.11.22) 23 NOV 2023 14:09 restricted system commands enabled. file:line:error style messages enabled. **d:/vsnotes/EDiT-notes/issue/lvjr_tabularray/note-settings (d:/vsnotes/EDiT-notes/issue/lvjr_tabularray/note-settings.tex LaTeX2e <2023-11-01> L3 programming layer <2023-11-09> Lua module: luaotfload 2023-08-31 3.26 Lua based OpenType font support Lua module: lualibs 2023-07-13 2.76 ConTeXt Lua standard libraries. Lua module: lualibs-extended 2023-07-13 2.76 ConTeXt Lua libraries -- extended collection. luaotfload | conf : Root cache directory is "D:/texlive/2023/texmf-var/luatex-cache/generic/names". luaotfload | init : Loading fontloader "fontloader-2023-08-19.lua" from kpse-resolved path "d:/texlive/2023/texmf-dist/tex/luatex/luaotfload/fontloader-2023-08-19.lua". Lua-only attribute luaotfload@noligature = 1 luaotfload | init : Context OpenType loader version 3.133 Inserting `luaotfload.node_processor' in `pre_linebreak_filter'. Inserting `luaotfload.node_processor' in `hpack_filter'. Inserting `luaotfload.glyph_stream' in `glyph_stream_provider'. Inserting `luaotfload.define_font' in `define_font'. Lua-only attribute luaotfload_color_attribute = 2 luaotfload | conf : Root cache directory is "D:/texlive/2023/texmf-var/luatex-cache/generic/names". Inserting `luaotfload.harf.strip_prefix' in `find_opentype_file'. Inserting `luaotfload.harf.strip_prefix' in `find_truetype_file'. Removing `luaotfload.glyph_stream' from `glyph_stream_provider'. Inserting `luaotfload.harf.glyphstream' in `glyph_stream_provider'. Inserting `luaotfload.harf.finalize_vlist' in `post_linebreak_filter'. Inserting `luaotfload.harf.finalize_hlist' in `hpack_filter'. Inserting `luaotfload.cleanup_files' in `wrapup_run'. Inserting `luaotfload.harf.finalize_unicode' in `finish_pdffile'. Inserting `luaotfload.glyphinfo' in `glyph_info'. Lua-only attribute luaotfload.letterspace_done = 3 Inserting `luaotfload.aux.set_sscale_dimens' in `luaotfload.patch_font'. Inserting `luaotfload.aux.set_font_index' in `luaotfload.patch_font'. Inserting `luaotfload.aux.patch_cambria_domh' in `luaotfload.patch_font'. Inserting `luaotfload.aux.fixup_fontdata' in `luaotfload.patch_font_unsafe'. Inserting `luaotfload.aux.set_capheight' in `luaotfload.patch_font'. Inserting `luaotfload.aux.set_xheight' in `luaotfload.patch_font'. Inserting `luaotfload.rewrite_fontname' in `luaotfload.patch_font'. Inserting `tracingstacklevels' in `input_level_string'. (d:/texlive/2023/texmf-dist/tex/latex/standalone/standalone.cls Document Class: standalone 2022/10/10 v1.3b Class to compile TeX sub-files standalone (d:/texlive/2023/texmf-dist/tex/latex/tools/shellesc.sty Package: shellesc 2023/07/08 v1.0d unified shell escape interface for LaTeX Package shellesc Info: Restricted shell escape enabled on input line 77. ) (d:/texlive/2023/texmf-dist/tex/generic/iftex/ifluatex.sty Package: ifluatex 2019/10/25 v1.5 ifluatex legacy package. Use iftex instead. (d:/texlive/2023/texmf-dist/tex/generic/iftex/iftex.sty Package: iftex 2022/02/03 v1.0f TeX engine tests )) (d:/texlive/2023/texmf-dist/tex/latex/xkeyval/xkeyval.sty Package: xkeyval 2022/06/16 v2.9 package option processing (HA) (d:/texlive/2023/texmf-dist/tex/generic/xkeyval/xkeyval.tex (d:/texlive/2023/texmf-dist/tex/generic/xkeyval/xkvutils.tex \XKV@toks=\toks17 \XKV@tempa@toks=\toks18 (d:/texlive/2023/texmf-dist/tex/generic/xkeyval/keyval.tex)) \XKV@depth=\count184 File: xkeyval.tex 2014/12/03 v2.7a key=value parser (HA) )) \sa@internal=\count185 \c@sapage=\count186 (d:/texlive/2023/texmf-dist/tex/latex/standalone/standalone.cfg File: standalone.cfg 2022/10/10 v1.3b Default configuration file for 'standalone' class ) (d:/texlive/2023/texmf-dist/tex/latex/base/article.cls Document Class: article 2023/05/17 v1.4n Standard LaTeX document class (d:/texlive/2023/texmf-dist/tex/latex/base/size10.clo File: size10.clo 2023/05/17 v1.4n Standard LaTeX file (size option) luaotfload | db : Font names database loaded from D:/texlive/2023/texmf-var/luatex-cache/generic/names/luaotfload-names.luc.gz) \c@part=\count187 \c@section=\count188 \c@subsection=\count189 \c@subsubsection=\count190 \c@paragraph=\count191 \c@subparagraph=\count192 \c@figure=\count193 \c@table=\count194 \abovecaptionskip=\skip48 \belowcaptionskip=\skip49 \bibindent=\dimen139 ) (d:/texlive/2023/texmf-dist/tex/generic/luatex85/luatex85.sty Package: luatex85 2016/06/15 v1.4 pdftex aliases for luatex ) (d:/texlive/2023/texmf-dist/tex/generic/pdftexcmds/pdftexcmds.sty Package: pdftexcmds 2020-06-27 v0.33 Utility functions of pdfTeX for LuaTeX (HO) (d:/texlive/2023/texmf-dist/tex/generic/infwarerr/infwarerr.sty Package: infwarerr 2019/12/03 v1.5 Providing info/warning/error messages (HO) ) (d:/texlive/2023/texmf-dist/tex/generic/ltxcmds/ltxcmds.sty Package: ltxcmds 2020-05-10 v1.25 LaTeX kernel commands for general use (HO) ) Package pdftexcmds Info: \pdf@primitive is available. Package pdftexcmds Info: \pdf@ifprimitive is available. Package pdftexcmds Info: \pdfdraftmode found. \pdftexcmds@toks=\toks19 ) \sa@box=\box51 ) (d:/texlive/2023/texmf-dist/tex/latex/tabularray/tabularray.sty (d:/texlive/2023/texmf-dist/tex/latex/l3kernel/expl3.sty Package: expl3 2023-11-09 L3 programming layer (loader) (d:/texlive/2023/texmf-dist/tex/latex/l3backend/l3backend-luatex.def File: l3backend-luatex.def 2023-11-09 L3 backend support: PDF output (LuaTeX) \l__color_backend_stack_int=\count195 Inserting `l3color' in `luaotfload.parse_color'. \l__pdf_internal_box=\box52 )) Package: tabularray 2023-03-01 v2023A Typeset tabulars and arrays with LaTeX3 \l__tblr_a_int=\count196 \l__tblr_c_int=\count197 \l__tblr_r_int=\count198 \l__tblr_d_dim=\dimen140 \l__tblr_h_dim=\dimen141 \l__tblr_o_dim=\dimen142 \l__tblr_p_dim=\dimen143 \l__tblr_q_dim=\dimen144 \l__tblr_r_dim=\dimen145 \l__tblr_s_dim=\dimen146 \l__tblr_t_dim=\dimen147 \l__tblr_v_dim=\dimen148 \l__tblr_w_dim=\dimen149 \l__tblr_a_box=\box53 \l__tblr_b_box=\box54 \l__tblr_c_box=\box55 \l__tblr_d_box=\box56 \g__tblr_table_count_int=\count199 \c@rownum=\count266 \c@colnum=\count267 \c@rowcount=\count268 \c@colcount=\count269 \abovesep=\dimen150 \belowsep=\dimen151 \leftsep=\dimen152 \rightsep=\dimen153 \g_tblr_level_int=\count270 \g__tblr_data_row_key_count_int=\count271 \g__tblr_data_column_key_count_int=\count272 \g__tblr_data_cell_key_count_int=\count273 \g__tblr_array_int=\count274 \l__tblr_key_count_int=\count275 \l__tblr_key_quotient_int=\count276 \l__tblr_key_quotient_two_int=\count277 \l__tblr_key_remainder_int=\count278 \g__tblr_data_str_value_count_int=\count279 \rulewidth=\dimen154 \l__tblr_strut_dp_dim=\dimen155 \l__tblr_strut_ht_dim=\dimen156 \g__tblr_cell_wd_dim=\dimen157 \g__tblr_cell_ht_dim=\dimen158 \g__tblr_cell_head_dim=\dimen159 \g__tblr_cell_foot_dim=\dimen160 \l__column_target_dim=\dimen161 \l__tblr_caption_box=\box57 \l__tblr_caption_left_box=\box58 \l__tblr_row_head_box=\box59 \l__tblr_row_foot_box=\box60 \l__tblr_row_head_foot_dim=\dimen162 \tablewidth=\dimen163 \l__tblr_table_firsthead_box=\box61 \l__tblr_table_middlehead_box=\box62 \l__tblr_table_lasthead_box=\box63 \l__tblr_table_firstfoot_box=\box64 \l__tblr_table_middlefoot_box=\box65 \l__tblr_table_lastfoot_box=\box66 \l__tblr_remain_height_dim=\dimen164 \l__tblr_long_from_int=\count280 \l__tblr_long_to_int=\count281 \l__tblr_curr_i_int=\count282 \l__tblr_prev_i_int=\count283 \l__tblr_table_page_int=\count284 \l__tblr_table_head_box=\box67 \l__tblr_table_foot_box=\box68 \l__tblr_table_head_foot_dim=\dimen165 \l__tblr_table_head_body_foot_dim=\dimen166 \l__tblr_table_box=\box69 \l__tblr_table_hlines_box=\box70 \l__tblr_hline_box=\box71 \l__tblr_row_box=\box72 \l__tblr_col_o_wd_dim=\dimen167 \l__tblr_col_b_wd_dim=\dimen168 \l__tblr_hline_leftskip_dim=\dimen169 \l__tblr_hline_rightskip_dim=\dimen170 \l__tblr_row_ht_dim=\dimen171 \l__tblr_row_dp_dim=\dimen172 \l__tblr_row_abovesep_dim=\dimen173 \l__tblr_row_belowsep_dim=\dimen174 \l__tblr_row_vlines_box=\box73 \l__tblr_vline_box=\box74 \l__tblr_cell_box=\box75 \l__row_upper_dim=\dimen175 \l__row_lower_dim=\dimen176 \l__row_vpace_dim=\dimen177 \l__tblr_vline_aboveskip_dim=\dimen178 \l__tblr_vline_belowskip_dim=\dimen179 \l__tblr_cell_wd_dim=\dimen180 \l__tblr_cell_ht_dim=\dimen181 \l__tblr_diag_box=\box76 ) (./note-settings.aux) \openout1 = note-settings.aux LaTeX Font Info: Checking defaults for OML/cmm/m/it on input line 8. LaTeX Font Info: ... okay on input line 8. LaTeX Font Info: Checking defaults for OMS/cmsy/m/n on input line 8. LaTeX Font Info: ... okay on input line 8. LaTeX Font Info: Checking defaults for OT1/cmr/m/n on input line 8. LaTeX Font Info: ... okay on input line 8. LaTeX Font Info: Checking defaults for T1/cmr/m/n on input line 8. LaTeX Font Info: ... okay on input line 8. LaTeX Font Info: Checking defaults for TS1/cmr/m/n on input line 8. LaTeX Font Info: Trying to load font information for TS1+cmr on input line 8. (d:/texlive/2023/texmf-dist/tex/latex/base/ts1cmr.fd File: ts1cmr.fd 2023/04/13 v2.5m Standard LaTeX font definitions ) LaTeX Font Info: ... okay on input line 8. LaTeX Font Info: Checking defaults for TU/lmr/m/n on input line 8. LaTeX Font Info: ... okay on input line 8. LaTeX Font Info: Checking defaults for OMX/cmex/m/n on input line 8. LaTeX Font Info: ... okay on input line 8. LaTeX Font Info: Checking defaults for U/cmr/m/n on input line 8. LaTeX Font Info: ... okay on input line 8. > Step: init table outer spec. > Step: parse table options. > Step: split table. > Step: init table inner spec. > Step: parse table inner spec. > Step: execute table commands. > Step: calculate cell and line sizes. LaTeX Font Info: External font `cmex10' loaded for size (Font) <7> on input line 20. LaTeX Font Info: External font `cmex10' loaded for size (Font) <5> on input line 20. > Step: build the whole table. Overfull \hbox (2.43204pt too wide) detected at line 20 $[][]$ [] [1 {d:/texlive/2023/texmf-var/fonts/map/pdftex/updmap/pdftex.map}] (./note-settings.aux) *********** LaTeX2e <2023-11-01> L3 programming layer <2023-11-09> *********** *File List* standalone.cls 2022/10/10 v1.3b Class to compile TeX sub-files standalone shellesc.sty 2023/07/08 v1.0d unified shell escape interface for LaTeX ifluatex.sty 2019/10/25 v1.5 ifluatex legacy package. Use iftex instead. iftex.sty 2022/02/03 v1.0f TeX engine tests xkeyval.sty 2022/06/16 v2.9 package option processing (HA) xkeyval.tex 2014/12/03 v2.7a key=value parser (HA) standalone.cfg 2022/10/10 v1.3b Default configuration file for 'standalone' class article.cls 2023/05/17 v1.4n Standard LaTeX document class size10.clo 2023/05/17 v1.4n Standard LaTeX file (size option) luatex85.sty 2016/06/15 v1.4 pdftex aliases for luatex pdftexcmds.sty 2020-06-27 v0.33 Utility functions of pdfTeX for LuaTeX (HO) infwarerr.sty 2019/12/03 v1.5 Providing info/warning/error messages (HO) ltxcmds.sty 2020-05-10 v1.25 LaTeX kernel commands for general use (HO) tabularray.sty 2023-03-01 v2023A Typeset tabulars and arrays with LaTeX3 expl3.sty 2023-11-09 L3 programming layer (loader) l3backend-luatex.def 2023-11-09 L3 backend support: PDF output (LuaTeX) ts1cmr.fd 2023/04/13 v2.5m Standard LaTeX font definitions *********** ) Here is how much of LuaTeX's memory you used: 3272 strings out of 476598 100000,1977958 words of node,token memory allocated 3899 words of node memory still in use: 69 hlist, 42 vlist, 33 rule, 4 disc, 6 local_par, 6 math, 151 glue, 5 kern, 6 penalty, 63 glyph, 157 attribute, 48 glue_spec, 157 attribute_list, 2 write nodes avail lists: 2:24,3:18,4:3,5:24,6:14,7:454,8:2,9:294,10:1,11:8 25226 multiletter control sequences out of 65536+600000 30 fonts using 2003495 bytes 65i,11n,99p,254b,536s stack positions out of 10000i,1000n,20000p,200000b,200000s Output written on note-settings.pdf (1 page, 7154 bytes). PDF statistics: 29 PDF objects out of 1000 (max. 8388607) 16 compressed objects within 1 object stream 0 named destinations out of 1000 (max. 131072) 1 words of extra memory for PDF output out of 10000 (max. 100000000) ```

What is required

  1. note-tag defined in \DefTblrTemplate etc. should be changed in the same way whether inside or outside the table.

    In fact, changing the style with \SetTblrStyle affects both the inside and outside of the table.

  2. note-sep does not seem to be working, so you need to modify it to make it work.

Additional

While reading the documentation regarding note, I discovered a defect in the documentation. The explanation for note-text is the same as for note-tag.

image

Table 4.4: Elements for Table Heads and Table Foots, 4.2.1 Overview of Templates, page.40

Version

muzimuzhi commented 10 months ago

Unfortunately the actual definition of note template initially set is https://github.com/lvjr/tabularray/blob/0970bab0433d6899d839993f34049e0ae476c9d8/tabularray.sty#L5169-L5188 https://github.com/lvjr/tabularray/blob/0970bab0433d6899d839993f34049e0ae476c9d8/tabularray.sty#L5205

This is quite different from the one shown in package documentation (v2023A, sec. 4.2.4), following text "The templates for table notes can be defined like this:".

From this \DefTblrTemplate { note } { normal } { ... } definition, you can see

\documentclass[class=article, border=5pt]{standalone}
\usepackage{tabularray}
\listfiles

\DefTblrTemplate{note-tag}{default}{%
  \textsuperscript{\textasteriskcentered\InsertTblrNoteTag}:}
\SetTblrStyle{note}{hang=1.5em}

\begin{document}

\begin{talltblr}[
    note{a} = {This is a note.},
    note{b} = {This is another note. It's long long loong loong looong looong.},
    caption = {This is a table with footnote.},
  ]{
    colspec = {*{2}{X[c]}},
    width = {0.5\linewidth},
    vlines, hlines,
  }
  This & is                \\
  a    & table\TblrNote{a} \\
  b    & with notes\TblrNote{b}
\end{talltblr}

\end{document}

image

Personally I think tabularray's template system is a bit over-designed.

muzimuzhi commented 10 months ago

This is quite different from the one shown in package documentation (v2023A, sec. 4.2.4), following text "The templates for table notes can be defined like this:".

The version shown in documentation is defined as plain, https://github.com/lvjr/tabularray/blob/0970bab0433d6899d839993f34049e0ae476c9d8/tabularray.sty#L5157-L5168

It has no hanging indent.

\documentclass[class=article, border=5pt]{standalone}
\usepackage{tabularray}

\SetTblrTemplate{note}{plain}
\DefTblrTemplate{note-tag}{default}{%
  \makebox[.9em][l]{\textsuperscript{\textasteriskcentered\InsertTblrNoteTag}}}
\DefTblrTemplate{note-sep}{default}{:\space}

\begin{document}

\begin{talltblr}[
    note{a} = {This is a note.},
    note{b} = {This is another note. It's long long loong loong looong looong.},
    caption = {This is a table with footnote.},
  ]{
    colspec = {*{2}{X[c]}},
    width = {0.5\linewidth},
    vlines, hlines,
  }
  This & is                \\
  a    & table\TblrNote{a} \\
  with & notes\TblrNote{b}
\end{talltblr}

\end{document}

image

Yarakashi-Kikohshi commented 10 months ago

@muzimuzhi, thank you for your replies.

I didn't look too closely at the implementation and wasn't sure, but I see that not all note's keys are used in a given template. I didn't expect this.

I have a deeper understanding of tabularray by looking at your replies and implementations. At the same time, it was a bit difficult for beginners to use, and I wondered if there were pelple who could understand it only buy reading the manual...


I understand about the colon in note-sep.

However am I correct in understanding that tags within tables cannot currently be changed using note-tag? In general, I believe that tags should be the same both inside and outside the table.

image

muzimuzhi commented 10 months ago

I didn't look too closely at the implementation and wasn't sure, but I see that not all note's keys are used in a given template. I didn't expect this.

Depending on how @lvjr designed it to be, this might either be a documentary issue or a bug.

However am I correct in understanding that tags within tables cannot currently be changed using note-tag?

Unfortunately, your understanding is right https://github.com/lvjr/tabularray/blob/0970bab0433d6899d839993f34049e0ae476c9d8/tabularray.sty#L5125-L5133

muzimuzhi commented 10 months ago

In fact, in tabularray v2023A, note inner option and \TblrNote command work independently.

Yarakashi-Kikohshi commented 10 months ago

I'm sorry it took a while for me to reply.

It is strange that the tag inside the table is not changed when changing from note-tag key, and I hope this will be resolved.