Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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:

+-----------------+
|                 |
+-----------------+
share|improve this question
1  
Can you post a minimum working example ? –  codebeard Jul 7 '12 at 3:04
    
@codebeard FYI. –  Summer_More_More_Tea Jul 7 '12 at 3:19
add comment

2 Answers

up vote 12 down vote accepted

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}
share|improve this answer
    
Thanks, it works:) –  Summer_More_More_Tea Jul 7 '12 at 3:15
add comment

As Boris mentioned, you can use verbatim which will not add anything to \lstlistoflistings, but if you still wanted to use the listings package for some reason (e.g. if you need more advanced formatting than provided by verbatim), just use the nolol (no list-of-listings) option:

\begin{figure}
    \lstinputlisting[nolol]{xxx.ascii}
    \caption{xxx}
    \label{fig:xxx}
\end{figure}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.