I am trying to define a new command to easily insert SQL queries (from a file) on my document.
I define it like that
\newcommand{\sqlfile}[2]{\lstinputlisting[language=SQL, caption={#1}, label=#2]{../sources/#2.sql}}
And use it like that
\sqlfile{Total number of users}{nb_users}
It works fine. I am able to reference the SQL file \ref{...} and the query is inserted correctly.
Now I want to insert the filename in the query caption, so I just added the #2 in the caption parameter.
\newcommand{\sqlfile}[2]{\lstinputlisting[language=SQL, caption={#1 #2}, label=#2]{../sources/#2.sql}}
But it does not work, and I cannot figure out why.
! Missing $ inserted.
<inserted text>
$
l.1072 \sqlfile{Total number of users}{nb_users}
I've inserted a begin-math/end-math symbol since I think you left one out.
Proceed, with fingers crossed.
I tried adding braces and other, but that was not successful. Thanks
nb_userstonbusers? – cmhughes Mar 13 '12 at 22:53