I'm writing a book, in which we refer the reader to the CD-ROM for the source code, and tell him the compiler and the result of running the program. Here's an example:
Since this "template" is happening a lot in the book, I decided to define a new environment for it (the command \cprotEnv
used below is from the package cprotect):
\newenvironment{CDROM}[2]
{\begin{tabular}{| m{0.5in} m{0.3in} m{5in} |}
\hline
\includegraphics[width=0.5in]{CD-ROM.pdf} && #1 \\
& \includegraphics[width=0.3in]{Hand.pdf} &
We used the free compiler #2. \\
& \includegraphics[width=0.3in]{Hand.pdf} &
}
{\\ \hline \end{tabular}}
\cprotEnv\begin{CDROM}{\verb"\SampleCodes\C++\GetPageSize"}{Open Watcom}
The page size for this system is 4096 bytes.
\end{CDROM}
However, the output is something peculiar:
Could you please help me to get the expected results?
Best Answer
The problem is that
\cprotEnv
is thought for particular environments such asalign
that don't accept verbatim in their body. If your schemes are always like the example, with two "handed lines", it's easier to define a command rather than an environment:and then use it as
A way that frees you from
\cprotect
isand now
work without
\verb
. This, however, assumes that you don't need spaces in the "verbatim" first argument.By splitting the command into two parts we can ensure that the
#
character is not doubled as it would happen if we added\catcode`\#=12
along with the other settings.