I use latex2rtf to convert latex documents to .rtf and thence to MS-word (see this thread). To do this, I set up a custom class and limit which packages are used as latex2rtf only accepts a limited subset of commands (see manual pages). latex2rtf provides a booelan, \iflatextortf, that is set to true if you use latex2rtf as your compiler.
I now need to display code listings and maintain the latex2rtf functionality. That means, I want to define something in the preamble to replace calls to \lstlisting{} with something like \begin{verbatim} ... \end{verbatim} when \iflatextortf is true.
Question: Is it possible to use switch between the lstlisting and verbatim environment depending on the value of \iflatextortf, keeping the content of the environment?
The solution would not require any packages to be installed and should work with the limited subset of commands in latex2rtf (see section 8.6.1). This should help me run compile using latex2rtf. Solutions using the verbatim package won't work unfortunately.
My ideal solution looks like this:
\newif\iflatextortf \iflatextortf \documentclass[12pt,letterpaper]{report} % whatever my replacement for lstlistings is % \else \documentclass[10pt,letterpaper]{report} \usepackage{listings} % something fancy with listings \lstnewenvironment{codeenv}[1][]{\lstset{basicstyle=\small\ttfamily}#1}{} \fi And I would like something a little more elegant than using find & replace on the raw .tex!
