Search code examples
fontslatexfiguremonospace

LaTeX: changing the fonts inside figures


I am using some terminal output as a figure in a report I am writing and need to change just the text within the figure to monospace.

\begin{figure}[ht]

%bunch of text here

\caption{Mass calculation program output}           
\label{fig:calcMass}                                
\end{figure}    

Solution

  • Take a look at the (usually built-in) listings package. A tutorial can be found here.

    The package includes syntax highlighting (if you're using bash) and can read input from external files (which can be useful if you're documenting a program you're writing and don't want to manually change the LaTeX code if you make a change in the program).