# table with a column of 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

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

\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.

• Thanks for the help. I knew how to use underscores, but I was not sure how to put a column into verb format. – Chen Stats Yu Oct 19 '14 at 20:21

For printing file names you don't need \verb, just that the underscore becomes printable.

\documentclass{article}

\usepackage{amsmath,array,booktabs}

\begin{document}

\begin{tabular}{ >{\ttfamily\catcode_=12 }l l }
% Chap2.nb & notebook \\
PI_all_data_BBB_M15X.pdf      & Results for \texttt{BBB} model with profile plots \\
PI_all_data_BetaBin_M15X.pdf  & Results for \texttt{BetaBin} model with profile plots \\
PI_all_data_BinLNB_M15X.pdf   & Results for \texttt{BinLNB} model with profile plots \\
PI_all_data_Bin_M15X.pdf      & Results for \texttt{Bin} model with profile plots \\
PI_all_data_LogGamma_M15X.pdf & Results for \texttt{LogGamma} model with profile plots \\
PI_all_data_TwoBin_M15X.pdf   & Results for \texttt{TwoBin} model with profile plots \\
\end{tabular}

\end{document}


• What does that =12 do? – Chen Stats Yu Oct 19 '14 at 20:16
• @ChenStatsYu \catcode_=12 is the secret trick that makes the underscore printable, don't tell anybody. ;-) It will do it only for the cells in that column. – egreg Oct 19 '14 at 20:17