When using tabular and p it is possible to insert Verbatim block in a table using minipage
\documentclass[]{article}%
\usepackage{fancyvrb}
\begin{document}
\begin{tabular}{|p{2in}|p{3in}|}
\hline
col 1 & \begin{minipage}{3in}
\begin{Verbatim}
test
\end{Verbatim}
\end{minipage}
\\\hline
\end{tabular}
\end{document}
However, I use tabularx and use X instead of p for that column. But this does not work
\documentclass[]{article}%
\usepackage{tabularx}
\usepackage{fancyvrb}
\begin{document}
\begin{tabularx}{\paperwidth}{|p{2in}|X|}
\hline
col 1 & \begin{minipage}{4in}
\begin{Verbatim}
test
\end{Verbatim}
\end{minipage}
\\\hline
\end{tabularx}
\end{document}
Error is
>pdflatex foo.tex
This is pdfTeX, Version 3.1415926-2.4-1.40.13 (TeX Live 2012/Debian)
restricted \write18 enabled.
.....
Style option: `fancyvrb' v2.7a, with DG/SPQR fixes, and firstline=lastline fix
<2008/02/07> (tvz) (/usr/share/texlive/texmf-dist/tex/latex/graphics/keyval.sty
)) (./foo.aux)
! Argument of \FV@BeginScanning has an extra }.
<inserted text>
\par
l.14 \end{tabularx}
At first I thought may be I need extra {} around the minipage, but that did not help
\documentclass[]{article}%
\usepackage{tabularx}
\usepackage{fancyvrb}
\begin{document}
\begin{tabularx}{\paperwidth}{|p{2in}|X|}
\hline
col 1 & {\begin{minipage}{4in}
\begin{Verbatim}
test
\end{Verbatim}
\end{minipage}
}
\\\hline
\end{tabularx}
\end{document}
Next, I removed the {} and replaced X by p so now it is the same as tabular, but this also did not work:
\documentclass[]{article}%
\usepackage{tabularx}
\usepackage{fancyvrb}
\begin{document}
\begin{tabularx}{\paperwidth}{|p{2in}|p{3in}|}
\hline
col 1 & \begin{minipage}{3in}
\begin{Verbatim}
test
\end{Verbatim}
\end{minipage}
\\\hline
\end{tabularx}
\end{document}
Next, I put back the {} and kept p in there, but this did not work either
\documentclass[]{article}%
\usepackage{tabularx}
\usepackage{fancyvrb}
\begin{document}
\begin{tabularx}{\paperwidth}{|p{2in}|p{3in}|}
\hline
col 1 & {\begin{minipage}{3in}
\begin{Verbatim}
test
\end{Verbatim}
\end{minipage}
}
\\\hline
\end{tabularx}
\end{document}
question is: How to use Verbatim in tabularx ?
Assuming it is possible with a magic trick, I'd like to use X actually instead of p since I want to tell it to use all the remaining space left.
But with minipage it needs a width, but when it is in an X column, I do not know the width of that column. How to handle that minipage wants width value, but it is sitting in an X column ?
But first, I'd to know even if Verbatim is possible inside tabularx


tabularxallows only a restricted form of\verb. – egreg Jun 18 '13 at 21:08