3

I need to write a large portion of text in 'code font' that includes an enumerate. I like the style provided by texttt, but it doesn't work in my case.

I would like something like this:

\documentclass[12pt]{report}
\begin{document}

\texttt{Report:
\begin{enumerate}
\item First Observation
\item Second Observation
\end{enumerate}
}

\end{document}

Thanks.

1 Answers1

2

To typeset text in typewriter font ("code font") use the ttfamily environment:

\documentclass[12pt]{report}
\begin{document}

\begin{ttfamily}% switch to tt font
 Report:
\begin{enumerate}
  \item First Observation
  \item Second Observation
\end{enumerate}
\end{ttfamily}
% back in normal font
More text in text font.

\end{document}

enter image description here

If, however, your goal is to write code, using the verbatim environment (or, for syntax highlighting, the listings package) will be a better fit.

Daniel
  • 37,517
  • ttfamily change indeed the font but it only does this and cannot handle properly code sample (spaces and line break manager, ...). – ppr Nov 12 '13 at 15:59
  • @ppr then please explain to us exactly what it is you want to accomplish, because we do not understand. – daleif Nov 12 '13 at 16:05
  • I don't want to accomplish anything (I'm not the one who asked the question). I just indicated that ttfamily isn't a good way to print code. It just changes the font and printing code is not just about the font... – ppr Nov 12 '13 at 16:07
  • @ppr: Your comment about verbatim is right, but does not address the OP's question. AFAIU the OP does not want to typeset LaTeX code, but wants some piece of text (including an itemize list) to be typeset in a typewriter font. – Daniel Nov 12 '13 at 16:13
  • @Daniel ok I missed this point. – ppr Nov 12 '13 at 16:19