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.

Im using \lstdefinelanguage to add some new languages. Now everything is fine, I just would like to add another font to my language. I would like to use inconsolata.

I have now this:

%...
\usepackage{inconsolata}
\lstdefinelanguage{Scala}
{
  %...
  basicstyle=\small %what else do i have to add to use inconsolata?
}

Any ideas? Thanks

share|improve this question
add comment

1 Answer 1

up vote 3 down vote accepted

Just loading the inconsolata package, the monospaced font is redefined, so it's enough to add \ttfamily (you could also access the font using \fontfamily{fi4}\selectfont):

\documentclass{article}
\usepackage{listings}
\usepackage{inconsolata}
\lstdefinelanguage{Scala}
{
  %...
  basicstyle=\ttfamily\small
}
\begin{document}

\begin{lstlisting}[language=Scala]
object HelloWorld {
    def main(args: Array[String]) {
      println("Hello, world!")
    }
  }
\end{lstlisting}

\end{document}

enter image description here

share|improve this answer
    
Thank you, this is working. Im just asking myself why "fi4"? And also, how to add the same font in a bold format? –  LissyA Oct 6 '12 at 18:38
    
Shouldn't basicstyle=\ttfamily\small suffice? –  cgnieder Oct 6 '12 at 18:41
    
@LissyA unfortunately the inconsolata package doesn't offer a bold version of the font. –  Gonzalo Medina Oct 6 '12 at 18:41
    
@cgnieder you're absolutely right; I'll edit the answer. Thank you. –  Gonzalo Medina Oct 6 '12 at 18:42
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.