Fonts & Character SetsBold text in verbatim

Information and discussion about fonts and character sets (e.g. how to use language specific characters)
Post Reply
enrique
Posts: 4
Joined: Wed Jul 11, 2012 2:50 pm

Bold text in verbatim

Post by enrique »

Hello,

I hope I'm posting this in the correct forum.

I am totally new to Latex. I am writing documentation for a program library and would like to emphasize (preferably in bold) some program lines, I am using verbatim to enter the program I want to show. In the following sample document I would like to have the second line of code stand out.

This is what the sample document looks like

Code: Select all

\documentclass[12pt,a4paper]{article}
\usepackage[latin1]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\author{Enrique Nivasch}
\begin{document}
\begin{verbatim}
First line in plain text (actually C# code)
***This line should be bold***
Last line again in plain text
\end{verbatim}
How do I do that?
\end{document}
BTW, I tried using alltt but for some reason some of my code doesn't show up in the final document.

Thanks,
Enrique
Last edited by Stefan Kottwitz on Wed Jul 11, 2012 4:30 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

shadgrind
Posts: 140
Joined: Thu Jul 16, 2009 12:39 am

Bold text in verbatim

Post by shadgrind »

This works for me:

Code: Select all

\documentclass{article}
\usepackage{alltt}
\renewcommand{\ttdefault}{txtt}
\begin{document}
Here's some code:
\begin{alltt}
First line in plain text (actually C# code)
\textbf{***This line should be bold***}
Last line again in plain text
\end{alltt}
\end{document}
System: TeX Live 2012, Fedora 18 x86_64, GNU Emacs 24.2
enrique
Posts: 4
Joined: Wed Jul 11, 2012 2:50 pm

Re: Bold text in verbatim

Post by enrique »

Thanks, it works and I found why most of my program had disappeared. It turns out that the curly braces confused alltt, by preceding each brace with a backslash alltt works well.
Post Reply