[Tex/LaTex] How to compose figure from text with latex

graphicslistingstable of contents

I have an ascii image like

+---------------
|  xxxxxxx
+---------------
|  xxxxxxx
+---------------

I want to show this in figure environment. So currently I try like this:

\begin{figure}
    \lstinputlisting{src.ascii}
    \caption{xxx}
    \label{fig:xxx}
\end{figure}

which works, except for some subtlities with table of listings and table of figures settings. The above codes treat src.ascii as listing which counters my mind that src.ascii is, exactly, a figure.

I think I should either export the ascii file as an eps file or set listing package to omit some source input. How could I achieve it?

Thanks and Best regards.


A MWC

\documentclass{report}
\usepackage[procnames]{listings}

\begin{document}

\lstlistoflistings
\listoffigures

\begin{figure}
    \lstinputlisting{xxx.ascii}
    \caption{xxx}
    \label{fig:xxx}
\end{figure}
\end{document}

And an example ascii image:

+-----------------+
|                 |
+-----------------+

Best Answer

There are many ways to have "real" figures in LaTeX text, but if you insist on ASCII art (e.g. to show old-fashioned illustrations in RFCs), then the following works:

\begin{figure}
\begin{verbatim}
 +-----------------+
 |                 |
 +-----------------+
\end{verbatim}
\caption{Box in an old RFC}
\label{fig:ascii-box}
\end{figure}