# \VerbatimInput gives error when the .dat file contains ( or * symbols

I have a \VerbatimInput call to a test.dat file, as shown here:

 \documentclass[12pt]{article}

\usepackage[left=2.5cm,top=2.5cm,right=2.5cm,bottom=2.5cm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{enumitem}
\usepackage{fancyvrb}
\usepackage{color,soul}
\usepackage[dvipsnames]{xcolor}

\begin{document}

\RecustomVerbatimCommand{\VerbatimInput}{VerbatimInput}%
{fontsize=\footnotesize,
%
frame=lines,  % top and bottom rule only
framesep=2em, % separation between frame and text
rulecolor=\color{Gray},
%
label=\fbox{\color{Black}test.dat},
labelposition=topline,
%
commandchars=\|, % escape character and argument delimiters for
% commands within the verbatim
commentchar=*        % comment character
}

\VerbatimInput{./test.dat}

\end{document}


The test.dat file is the following:

 #l.77:
TEST11

A3

(EL = 4) # this is compiled ok
mH/(C*K) # this is not compiled, giving that error


Due to the ( * ) symbols, the compilation gives this error:

 Runaway definition?
-> mH/(C

l.97 \VerbatimInput{./test.dat}


How could I compile this ?

• It's not clear why you set commentchar=* Feb 2, 2017 at 11:54
• please don't post disconnected fragments, post a single document that people can run to see the error, (you could minimise the preamble to just the packages needed to show the error) don't load enumerate and enumitem at the same time (or enumitem twice) Feb 2, 2017 at 11:58
• As egreg says, what exactly are you tryingwith tht commenchar and commandchars combo? \| means that () acts like {} and since * is the comment char, everything after it is ignored. So the ( (aka {) remains and the data is inconsistent as it is trying to look for the ending ) which is not there. You should probably adjust this into something more suitable for your .dat file. Feb 2, 2017 at 12:33
• @DavidCarlisle Thank you for your comment; I have simplified the preamble and gathered all in a single fragment Feb 2, 2017 at 12:34
• (2/2) So fancyvrb is trying to scan for the start and end part of every (), because these now acts as if they were {} (aka the chars you specify arguments with). These always have to come in pairs. But commentchar=* says everything after * is ignored and this the scanner cannot find the end part to ( in mH/(C*K) Feb 2, 2017 at 13:47

First, I have to say that I have not actually used \VerbatimInput myself. However, that bit of code you posted looks exactly like the one posted in the following answer: Include data from a .txt verbatim

To quote the author:

• specifying | and (/) as the escape character and argument delimiters means these symbols cannot appear as part of the verbatim text (or in this case, the contents of data.txt);
• the line of asterisks in data.txt was removed by specifying * as the comment character (similar to % in LaTeX);

In other words, the code you copied gives special meaning to these four characters, and so it can't be used with files which contain them.

The lines which seem to be doing this are these:

commandchars=\|, % escape character and argument delimiters for
% commands within the verbatim
commentchar=*        % comment character


So, I would suggest removing those from your code or replacing the characters with some others which do not appear in your file.