I'm trying to define a command that typesets Maxima code by taking three arguments - the command number, the input text, and the output math. I want the input text - the second argument - formatted as a listing. This is the closest I've gotten:
\documentclass{book}
\usepackage{listings}
\newcommand{\maximaio}[3]{
\begin{tabular}{l l}
(\%i#1) &
\lstinline!#2! \\
(\%o#1) &
$ #3 $
\end{tabular}
}
\begin{document}
\maximaio{1}{y
/
(y+1);}{{y}\over{y+1}}
\end{document}
If you run this, you'll see that the newlines aren't correctly formatted in the second argument. Instead of "y", "/", and "(y+1);" on three separate lines, I get "y / (y+1);" on a single line.
Can anybody suggest how to pass a listing into a command like this?

\lstinlinedoesn't print (or like) newlines. – Ulrike Fischer Feb 22 '17 at 09:14