[Tex/LaTex] table with a column of verbatim

verbatim

\documentclass{article}

\usepackage{amsmath,array,booktabs,multirow}

\begin{document}

\begin{table}[!htb]
    \centering
    %\begin{tabular}{ l l }
    \begin{tabular}{ >{\verb=}l<{=} l }
    %   Chap2.nb & notebook \\
        PI_all_data_BBB_M15X.pdf     & Results for \verb=BBB= model with profile plots \\
        PI_all_data_BetaBin_M15X.pdf & Results for \verb=BetaBin= model with profile plots \\
        PI_all_data_BinLNB_M15X.pdf  & Results for \verb=BinLNB= model with profile plots \\
        PI_all_data_Bin_M15X.pdf     & Results for \verb=Bin= model with profile plots \\
        PI_all_data_LogGamma_M15X.pdf& Results for \verb=LogGamma= model with profile plots \\
        PI_all_data_TwoBin_M15X.pdf  & Results for \verb=TwoBin= model with profile plots \\
    \end{tabular}
\end{table}


\end{document}

I want the first column to be verbatim for every row. Currerntly, the result is very weird, it seems that it goes into the 2nd column as well.

How would I change it?

Thanks

Best Answer

Use collcell to collect the cell contents, and then parse it \detokenized:

enter image description here

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{array,collcell}
\newcommand{\myverb}[1]{\ttfamily\detokenize{#1}}

\begin{document}

\begin{tabular}{ >{\collectcell\myverb}l<{\endcollectcell} l }
  PI_all_data_BBB_M15X.pdf     & Results for \verb=BBB= model with profile plots \\
  PI_all_data_BetaBin_M15X.pdf & Results for \verb=BetaBin= model with profile plots \\
  PI_all_data_BinLNB_M15X.pdf  & Results for \verb=BinLNB= model with profile plots \\
  PI_all_data_Bin_M15X.pdf     & Results for \verb=Bin= model with profile plots \\
  PI_all_data_LogGamma_M15X.pdf& Results for \verb=LogGamma= model with profile plots \\
  PI_all_data_TwoBin_M15X.pdf  & Results for \verb=TwoBin= model with profile plots
\end{tabular}

\end{document}

As reference, see Underscores in words (text) and How to apply a macro to each column of a table.

Related Question