0

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
 ! File ended within \read.
 <read 1> 

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

How could I compile this ?

DavidC.
  • 845
  • 3
    It's not clear why you set commentchar=* – egreg Feb 02 '17 at 11:54
  • 2
    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) – David Carlisle Feb 02 '17 at 11:58
  • 2
    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. – daleif Feb 02 '17 at 12:33
  • @DavidCarlisle Thank you for your comment; I have simplified the preamble and gathered all in a single fragment – DavidC. Feb 02 '17 at 12:34
  • @daleif Thank you for your comment. Forgive me if I am wrong, but as far as I am concerned,commandchars=\|\(\) means that whenever the symbols | and () appear in the .dat flie, do not include them in the final latex compilation. Is this true ? I don't really understand why you say that " \|\(\) means that () acts like {}" I would appreciate if you could expand this, thank you very much – DavidC. Feb 02 '17 at 12:44
  • See the fancyvrb manual about commandchars, especially the example with \textcolor{red}{Text}. There commandchars=\\\{\} meaning that \textcolor{red}{Text} is interpreted by LaTeX. If you remove the commentchar=* (so it compiles) and add |emph(test) to test.dat you get italic test in the output. (1/2) – daleif Feb 02 '17 at 13:47
  • 2
    (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) – daleif Feb 02 '17 at 13:47

1 Answers1

5

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.