So I have a big number of figures with _ in their names. I want to include them in my document and I want to print the filename for the file. Something like:
\foreach \dataset in {CPD, EPAFHM, FDA, cas_N6512, cox2, dhfr, screen_U251} {
\foreach \height in {0,1,2,3,4,5} {
\begin{minipage}{0.5\textwidth}
\includegraphics[width=0.45\textwidth]{heatmaps/\dataset\height Bit.pdf}
AUC for bit fingerprint of height \height for dataset \dataset.
\end{minipage}
}
}
It works great for the graphics but of course the _ should really be \_ when it comes to printing. How can I fix this? I have looked at this question but it does not seem to be quite the same thing.
Also, if I try the underscore package it works for the text but not for the graphics.

\heightis somewhat reserved... – Werner Aug 14 '13 at 14:15\dataset\heightinto\detokenize\expandafter{\dataset}\height(but it's also best to use a different macro name than\height). – egreg Aug 14 '13 at 14:25