4

I am new to tabularray and I have a problem typesetting tables with code in it.

I see the option verb must be given to environment tblr to allow verbatim text, but even then, characters % and & cause an error :

\documentclass{scrartcl}

\usepackage{tabularray}

\begin{document}
\begin{tblr}{verb,colspec={c}}
\verb!%!
\end{tblr}
\end{document}

gives \verb ended by end of line. \end. The same happens with &.

I am at a loss because giving \% or \& prints out the backslash as well.

I am compiling with lualatex if that matters.

3

2 Answers 2

1

Edit:
It Seems that you find a bug in option verb. In this can help you (us) the package author ...

However meantime you can use \texttt command instead of \verb˙:

\documentclass{scrartcl}
\usepackage{tabularray}

\begin{document}
\verb!%!

\begin{tblr}{colspec={c}}
\texttt{\%}
\end{tblr}
\end{document}

enter image description here

2
  • The code you typed works by me as well. But it produces \% in the output, and I want %.
    – ysalmon
    Jan 28 at 13:39
  • Ah, i overlooked this. It seems that you find a bug in tabularray, so wee need help of package author. Until this see edited answer, if this can be of some help.
    – Zarko
    Jan 28 at 14:00
0
  1. You can temporarily change the category of the comment with \catcode%=12`. A disadvantage: in the source code it always appears as a comment
  2. Create a command to change & to \& and use \texttt

The code

\documentclass{scrartcl}
\usepackage{tabularray}
\ExplSyntaxOn
\NewDocumentCommand{\myverb}{m}{
        \char_set_catcode_other:N \&
        \tl_set:Nn \l_tmpa_tl {#1}
        \regex_replace_all:nnN { & } { \& } \l_tmpa_tl 
        \texttt{\l_tmpa_tl}
        \char_set_catcode_alignment:N \&
        }
\ExplSyntaxOff

\begin{document}
\verb|%abcd&|

\catcode`\%=12
\myverb{%abcd&}
\catcode`\%=14 

\catcode`\%=12
\begin{tblr}{
    colspec={c c},
    vlines}
    \myverb{%abcd&}     & Another word\\
    azerty&\myverb{%a%b&cd}
\end{tblr}
\catcode`\%=14
% comment
\end{document}

enter image description here

You must log in to answer this question.

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