I want to build a table with a column of verbatim, but I don't want to use \verb command for every line (too many rows), how should I do it? I tried to use array package to define new column type but unsuccessful, anyone can shed some light? An example of what I wanna achieve:
\documentclass{article}
\begin{document}
\begin{tabular}{l l}
\verb|some text here| & some text here \\
\verb|some text here| & some text here \\
\verb|some text here| & some text here \\
\end{tabular}
\end{document}
- I need verbatim (instead of just
begin{tabular}{>{\ttfamily}l<{\ttfamily}}
as the first row contained many reserved characters.
Thank you!
Best Answer
Verbatim mode is really very special. In some cases one can use the
&
for delimiting an argument (see thecollcell
package), but with verbatim this becomes essentially impossible, because the&
is not the cell delimiter any more as soon as verbatim mode is started.The
shortvrb
package allows to saythereby declaring that, from the point on,
|...|
is equivalent to\verb|...|
. Of course you'll need\verb+...+
(or similar) if the verbatim text contains|
.Note however that this will make
|
illegal in math, but there's the substitute\vert
(or better the pair\lvert
and\rvert
provided byamsmath
) for it.So the best you can have is