5

I am creating a program that produces .pdf files based on .xlsx input through a .py GUI with .tex files.

So far, in order to create the respective .tex file, I have used Overleaf. However, now that I want this program to run locally, I switched first to MiKTeX and now to TeX Live.

While compiling on Overleaf using XeLaTex running on TeX Live Version 2021, my .tex file runs smooth and perfectly.

If I use either MiKTeX or TeX Live however, various "[0]"s appear on the report.

I was able to track down the cause of the problem, which is displayed in the following code:

\documentclass{report}
\usepackage[style=apa, natbib=false]{biblatex}
\usepackage{tabularray}
\usepackage{csquotes}
\usepackage{tcolorbox}

\begin{document}

\begin{tblr}{h{4cm}h{4cm}h{4cm}} 
    \begin{tcolorbox}[width=3.5cm,colback=white,colframe=black] test \end{tcolorbox} 
    & \begin{tcolorbox}[width=3.5cm,colback=white,colframe=black] test \end{tcolorbox} 
    & \begin{tcolorbox}[width=3.5cm,colback=white,colframe=black] test \end{tcolorbox} 
\end{tblr}

\end{document}

It seems as if a tcolorbox inside the tabularray environment creates these random "[0]"s.

Example

Solutions that work - but not for me

  • Using tabular, tabularx or tabulary. (-> I cannot secure a perfect vertical alignment given users varying inputs. My document is immensely extensive - changing the actual latex code and fumbling around with the tabular environment for each table would anyways not be an option. The file works like a charm on Overleaf, changing a perfectly working file for days would be pretty frustrating);
  • Using no tcolorboxes. (-> The colorboxes are a necessary component of the programs purpose).

Solutions I tried that did not work

  • Changing from MiKTeX to Overleaf's compiler TeX Live;
  • Using the version of the tabularray package, that Overleaf uses as well;
  • Anything related to overfull / underfull box errors, which were my initial suspection.

Solutions that I am looking for

  • A way to make Tex Live behave exactly like Overleaf in its compiling result;
  • A way to make the tabularray environment behave in a way that supports tcolorboxes.

I downloaded Tex Live not too long ago. It is therefore running on its most current version. I noticed, that Tex Live on Overleaf is running on an older version:

XeTeX, Version 3.141592653-2.6-0.999993 (TeX Live 2021) (preloaded format=xelatex 2021.9.30)

vs. Tex Live locally:

XeTeX, Version 3.141592653-2.6-0.999994 (TeX Live 2022) (preloaded format=xelatex 2022.5.27)

I tried to download the older version of Tex Live in order to make it behave like in Overleaf, however no downloads of older versions are offered from official sites.

Hope someone can help. Thanks in advance.

1
  • Just a workaround: enclose each the tcolorboxes inside its own minipage. A bit heavy-handed, but it should work until someone can explain what actually happens.
    – Miyase
    Commented Jun 2, 2022 at 17:13

2 Answers 2

8

Use the nobeforeafter key to suppress the code before and after the tcolorbox. (Personally I prefer the raster library of tcolorbox to align tcolorboxes).

\documentclass{report}
\usepackage{tabularray}
\usepackage{tcolorbox}

\begin{document}

\begin{tblr}{h{4cm}h{4cm}h{4cm}}
      \begin{tcolorbox}[nobeforeafter,width=3.5cm,colback=white,colframe=black] test \end{tcolorbox}
    & \begin{tcolorbox}[nobeforeafter,width=3.5cm,colback=white,colframe=black] test \end{tcolorbox}
    & \begin{tcolorbox}[nobeforeafter,width=3.5cm,colback=white,colframe=black] test \end{tcolorbox}
\end{tblr}

\end{document}
1
  • Upvote for the suggestion to use the raster library of tcolorbox.
    – Unknown
    Commented Jun 2, 2022 at 18:34
6

Update: tabularray 2022C, released on 2022-07-01 has fixed this, see CTAN-ann.

But when using it on Overleaf, you still need to work around before Overleaf supports texlive 2022 or even 2023, depending on whether Overleaf's texlive 2022 will include tabularray 2022C. That's because Overleaf uses static yearly texlive "mirrors".

Original answer:

  • tabularray redefines \pagebreak and \nopagebreak when they are seen inside tblr environment, but forgets to allow an optional argument.
  • By default tcolorbox passes \pagebreak[0] to its option before, like \tcbset{before={<code that contains \pagebreak[0]>}}.
  • Hence when a tcolorbox environment inside tblr uses the value of before and encounters \pagebreak[0], surplus [0] is left.

I've reported this to tabularray, see https://github.com/lvjr/tabularray/issues/259.

For a temp workaround from tcolorbox side, see @Ulrike Fischer's answer which suggests tcolorbox option nobeforeafter. nobeforeafter will clear values of before and after. Note this will not only avoid the surplus [0], but also remove the vertical space added above and below tcolorbox environments. Such space may not be needed in a table cell in the first place.

For a temp workaround from tabularray side, see example below which redefines table commands \pagebreak and \nopagebreak.

\documentclass{article}
\usepackage{tabularray}
\usepackage{tcolorbox}

\ExplSyntaxOn
\msg_new:nnn { tabularray } { undefined-table-command }
  { Table ~ commnad ~ #1 has ~ not ~ been ~ defined! }

\NewDocumentCommand \RenewTableCommand { m O{0} o m }
  {
    \clist_if_in:NnTF \g__tblr_table_commands_clist { #1 }
      {
        \__tblr_make_xparse_arg_spec:nnN { #2 } { #3 } \l__tblr_a_tl
        \exp_args:NcV \RenewDocumentCommand
          { __tblr_table_command_ \cs_to_str:N #1 :w } \l__tblr_a_tl { #4 }
        \exp_args:NcV \RenewDocumentCommand
          { __tblr_table_command_ \cs_to_str:N #1 _gobble :w } \l__tblr_a_tl { }
        \IfValueTF { #3 }
          {
            \tl_gset:cn { g__tblr_table_cmd_ \cs_to_str:N #1 _arg_numb_tl } {-#2}
          }
          {
            \tl_gset:cn { g__tblr_table_cmd_ \cs_to_str:N #1 _arg_numb_tl } {#2}
          }
      }
      {
        \msg_error:nnn { tabularray } { undefined-table-command } { #1 }
      }
  }

\RenewTableCommand \pagebreak [1] [4]
  {
    \hborder { pagebreak = yes }
  }

\RenewTableCommand \nopagebreak [1] [4]
  {
    \hborder { pagebreak = no }
  }
\ExplSyntaxOff

\begin{document}

\begin{tblr}{h{4cm}h{4cm}h{4cm}}
    \begin{tcolorbox}[width=3.5cm,colback=white,colframe=black] test \end{tcolorbox} 
    & \begin{tcolorbox}[width=3.5cm,colback=white,colframe=black] test \end{tcolorbox} 
    & \begin{tcolorbox}[width=3.5cm,colback=white,colframe=black] test \end{tcolorbox} 
\end{tblr}

\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .