ho-tex / oberdiek

Updating the oberdiek bundle
Other
16 stars 6 forks source link

\CatchFileDef does not allow \@noligs in its "setup" argument #48

Closed jfbu closed 5 years ago

jfbu commented 5 years ago
\documentclass{article}

\usepackage{catchfile}

\makeatletter
\newcommand\myVerbInput[1]
{\CatchFileDef{\my@file}{#1}{\@vobeyspaces\@noligs}\my@file}
\makeatother

\usepackage{filecontents}
\begin{filecontents*}{\jobname.txt}
'
\end{filecontents*}

\begin{document}
% for comparison, no problem here
% \makeatletter
% \begingroup\@vobeyspaces\@noligs
% '
% \endgroup
% \makeatother

\myVerbInput{\jobname.txt}
\end{document}

produces

./catchfilebug.tex:27: Missing $ inserted.
<inserted text> 
                $
l.27 \myVerbInput{\jobname.txt}

I've inserted a begin-math/end-math symbol since I think
you left one out. Proceed, with fingers crossed.

Note: the \@vobeyspaces is only there because \do@noligs is lacking a space

$ latexdef do@noligs

\do@noligs:
macro:#1->\catcode `#1\active \begingroup \lccode `\~`#1\relax \lowercase {\endgroup \def ~{\leavevmode \kern \z@ \char `#1}}

after \char#1hence normal space may be gobbled. Thus I made the space active (usually in such a "verbatim" like setting but with normal spaces, I modify the\do@noligs`). But the problem shows the same without it.

davidcarlisle commented 5 years ago

I'm not sure that this is a bug, or if the package can do anything about it, you locally (via \do@noligs) make ' active, so \my@file ends up being a macro that holds a single token, a catcode 13 '. But unlike your commented out "no problem here" case, you evaluate \my@file in a different scope where the noligs definition is not in force so you get the usual active definition which assumes math mode ^{\prime}

If you locally restore the noligs definition when using the macro it works as expected

\newcommand\myVerbInput[1]
{\CatchFileDef{\my@file}{#1}{\@vobeyspaces\@noligs}{\@noligs\my@file}}
jfbu commented 5 years ago

oh yes I had not looked closely. The token is active but not with the definition done by \@noligs. Obvious in retrospect... feel free to close this. (sorry I did not look at a trace nor did I do any thinking before raising "issue", I had been too busy trimming out things to get to mwe first... )

jfbu commented 5 years ago

(sorry for noise... my brain disconnects more and more areas...)