The problem is that I have code fragment looking like this:

\detokenize{Some Funky Stuff 20%}

And texlive is saying that ! File ended while scanning use of \tabu@collectbody.. If I remove the % sign, the error goes away, but this sign has to be present there. If I however escape the % sign with a backslash \, then PDF is being generated, but with a backslash visible - in other words I see \% in PDF. How to do it the right way?


Didn't know it's important, but it seems it is - I'm experiencing this problem when working with tables, for example:

\begin{longtabu} to \linewidth {b{80pt}b{78pt}b{40pt}P{100pt}P{70pt}b{35pt}}
Start & End & Duration & Comment & Category & Lost Prod. {[kWh]} \\  \noalign{\vskip 2pt} \hline 
    \noalign{\vskip 4pt} \multicolumn{6}{l}{ \setrow{\bfseries} SOMETHING } \\
        \rowfont{\small\baselineskip=5pt} 2016-09-02 19:20:00 & 2016-09-02 22:50:00 & 03,5:30:00 & {\catcode`\%=12 \detokenize{Some Funky Stuff 20%}} & \detokenize{Utility} & 0 \\
    \noalign{\vskip 2pt} \hline \noalign{\vskip 2pt}
    \rowfont{\small\baselineskip=5pt} \multicolumn{2}{l}{Total for the stuff: } & \multicolumn{3}{l}{24.22:02:33 } & 640239,4 \\
  • 1
    why do you need detokenize here? just Funky Stuff 20\% would work, other use cases may need other solutions, \verb|Funky Stuff 20%| perhaps but.... Jul 20 '17 at 10:02
  • Because sometimes other characters are appearing - like ampersand for example.
    – Marek M.
    Jul 20 '17 at 10:05

The \detokenize macro is similar to , but not the same as verbatim. In particular, braces need to be matched, and % are still used to discard the remains of the input record. One can work around that by redefining % to be the same catcode as a numerical digit, within the scope of the \detokenize.

{\catcode`\%=12 \detokenize{Some Funky Stuff 20%}}

Here it is a comment again% BLAH

enter image description here

  • It doesn't work :( . I'm using lualatex btw.
    – Marek M.
    Jul 20 '17 at 10:07
  • @SzwornyDziąch What doesn't work about it? Do you mean in the context of your own code, or directly as my small example? For me, it works both in pdflatex as well as lualatex. Jul 20 '17 at 10:09
  • Please see my edited question. Indeed your solution works in general, but my special case is tables :(
    – Marek M.
    Jul 20 '17 at 10:11
  • 1
    Ok, I moved \catcode couple levels higher - to surround my table and now it works. Thanks!
    – Marek M.
    Jul 20 '17 at 10:14
  • @SzwornyDziąch Seeing your tabu example, I was going to suggest exactly that... moving the \catcode scope around the complete longtabu. Jul 20 '17 at 10:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.