I want to define a new environment to display blocks of plain text in a titled box, with whitespace reproduced exactly. Something like this
\begin{PlainText}{My Title}
Foo
Bar
\end{PlainText}
I'm putting a definition together by gathering various tips, but it doesn't work.
\newenvironment{TextFile}[1]{\ttfamily}{\par}
{
#1\\[1ex]
\begin{center}
\begin{tabular}{|p{0.9\textwidth}|}
\hline
\\
}
{
\\ \\
\hline
\end{tabular}
\end{center}
}
I only 80% understand how this is intended to work, I read the first line as meaning
TextFile is a new environment which takes one parameter, within it the font is monospace and \par means retain whitespace like HTML <pre>
I get an error at the #1\\[1ex]
line
You can't use `macro parameter character #' in vertical mode.
When it works, it should look like this:
\newenvironment{TextFile}[1]{\ttfamily}{\par}
is wrong, of course and 'plain' text could be difficult. You should rather think of a verbatim environment. And don't forget to accept answers to your other questions#1
, even worse, it's outside of the environment definition