3

With example

\RequirePackage{filecontents}
\begin{filecontents*}{main.tex}
%<*example>
\verb|This is an example|
%</example>
\end{filecontents*}
\documentclass{article}
\usepackage{catchfilebetweentags}
\CatchFileBetweenTags{\test}{main.tex}{example}
\begin{document}
\test
\end{document}

I get output:

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

Everything else is working properly. If I copy/paste the piece of code directly in the main.tex file it works properly.

1
  • the catch commands take a fragment of the file and pass them as an argument of a macro, it is a documented restriction that \verb doesn't work in the argument of another command, Oct 2, 2014 at 8:16

1 Answer 1

2

The \verb command works only if the the argument is not already tokenized. The classical situation this shows up in is that you cannot use \verb in the argument of another command. However, the same problem applies here: to save the input to a macro, the 'caught' information has to be tokenized. That can't work, I'm afraid.

You must log in to answer this question.

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