# Multiple line verbatim environment

I want to achieve the output shown below using multiple line verbatim

My attempt so far is

\documentclass[a5paper]{article}
\usepackage{listings}
\begin{document}

\begin{lstlisting}
123
$\times$ 456
=============
738(this is $123 \times 6$)
\end{lstlisting}

\end{document}


This is definitely not what I need and so I didn't write the code further.Can someone help me with the multiplication symbol and the desired result

• Just use \begin{lstlisting}[mathescape,basicstyle=\small\ttfamily]. I think you need 123 x 6 instead of \times.
– user11232
Sep 21, 2015 at 15:41
• @HarishKumar But how can i get the multiplication symbol? Sep 21, 2015 at 15:48
• From the picture, it looks like x is the symbol.
– user11232
Sep 21, 2015 at 15:48
• Isn't this better (typographically) with a tabular environment?
– user31729
Sep 21, 2015 at 16:38

Here's one option, but are you sure you want this formatting?

\documentclass[a5paper]{article}
\usepackage{listings}

\lstset{
columns=flexible,
basicstyle=\small\ttfamily,
mathescape=true,
escapeinside=||
}

\begin{document}

\begin{lstlisting}
123
$\times$ 456
======
738       (this is $123 \times 6$)
615        (this is $123 \times 5$, shifted one position to the left)
+492         (this is $123 \times 4$, shifted two positions to the left)
========
56088
\end{lstlisting}

\end{document}


• Yes... I want exactly like this... Thanks a lot for the answer Sep 21, 2015 at 17:04