Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can't use \verb to print "%" #104

Closed
syvshc opened this issue Sep 12, 2021 · 2 comments
Closed

can't use \verb to print "%" #104

syvshc opened this issue Sep 12, 2021 · 2 comments
Labels
bug Something isn't working next Change in next major version
Milestone

Comments

@syvshc
Copy link

syvshc commented Sep 12, 2021

Here is my mwe:

\documentclass{article}
\usepackage{tabularray}
\usepackage{fancyvrb}
\begin{document}
    \begin{tblr}{verb}
        \verb|a|\\
        \verb|%|\\  % This line doesn't work and will cause an error
        \verb|\%|   % This line works
    \end{tblr}\par
    \begin{tblr}{columns = {appto={|}, preto={\Verb|}}}
        a \\
        % \\        % This line is considered commented
        \%          % This line outputs %, not \%
    \end{tblr}\par
    \verb|%|
\end{document}

The error which \verb|%| gives is

! LaTeX Error: \verb ended by end of line.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...

l.6     \end
            {tblr}
? x
@lvjr
Copy link
Owner

lvjr commented Sep 12, 2021

The % and characters after it are removed by TeX before tabularray or tabularx sees them. You need to change the catcode of % character to make TeX treat it as a normal character.

\documentclass{article}

\usepackage{tabularray}
\usepackage{tabularx}
\usepackage{fancyvrb}

\begin{document}

For \texttt{tabularray}:

\begingroup
\catcode`\%=12
\begin{tblr}{verb}
    \verb|a| \\
    \verb|%| \\
    \verb|\%|
\end{tblr}
\quad
\begin{tblr}{verb,columns={preto={\Verb|},appto={|}}}
    a \\
    % \\
    \% 
\end{tblr}
\endgroup

For \texttt{tabularx}:

\begingroup
\catcode`\%=12
\begin{tabularx}{\linewidth}{X}
    \verb|a|\\
    \verb|%|\\
    \verb|\%|
\end{tabularx}
\endgroup

\end{document}

image

See also https://tex.stackexchange.com/questions/499125/verb-with-in-tabularx

@lvjr
Copy link
Owner

lvjr commented Mar 1, 2023

Since version 2023A, verb option was obsolete. Please use \fakeverb command from codehigh package instead.

@lvjr lvjr added bug Something isn't working next Change in next major version labels Mar 1, 2023
@lvjr lvjr closed this as not planned Won't fix, can't repro, duplicate, stale Mar 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working next Change in next major version
Projects
None yet
Development

No branches or pull requests

2 participants