Fonts & Character SetsHow to: Consolas font in listing

Information and discussion about fonts and character sets (e.g. how to use language specific characters)
Post Reply
Thuleman
Posts: 6
Joined: Tue Oct 12, 2010 12:11 pm

How to: Consolas font in listing

Post by Thuleman »

Hi.

How do I change the font in the listing package to consolas font?
Right now I have:

Code: Select all

\lstset{
	language=[Visual]C++,
	frame=single,
	backgroundcolor=\color{lbcolor},
	keywordstyle=\bfseries\ttfamily\color[rgb]{0,0,1},
	identifierstyle=\ttfamily,
	commentstyle=\color[rgb]{0.133,0.545,0.133},
	stringstyle=\color[rgb]{0.8,0,0},
	showstringspaces=false,
	basicstyle=\small,
	numberstyle=\footnotesize,
	numbers=left,
	stepnumber=1,
	numbersep=10pt,
	tabsize=4,
	breaklines=true,
	prebreak = \raisebox{0ex}[0ex][0ex]{\ensuremath{\hookleftarrow}},
	breakatwhitespace=false,
	aboveskip={1.5\baselineskip},
  columns=fixed,
  upquote=true,
  extendedchars=true,
}
I would like all output to be consolas font - how to?
Last edited by Thuleman on Wed Oct 13, 2010 1:02 pm, edited 2 times 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.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

How to: Consolas font in listing

Post by localghost »

If you want to use Consolas directly, you may switch to XeLaTeX as your compiler engine and the necessary packages. With (PDF)LaTeX you can use inconsolata, which mimics Consolas very good.


Best regards and welcome to the board
Thorsten
Thuleman
Posts: 6
Joined: Tue Oct 12, 2010 12:11 pm

Re: How to: Consolas font in listing

Post by Thuleman »

Thank you very much. Is it possible for you to show me how to implement it in my code? I cannot figure it out. I have googled it and tried
Thuleman
Posts: 6
Joined: Tue Oct 12, 2010 12:11 pm

Fixed

Post by Thuleman »

It works!

I downloaded the inconsolata package, and then used \ttfamily
Post Reply