2

I am using Inconsolata for code in paragraphs, and would like to use it for code in verbatim environments as well. I have tried using fancyvrb's Verbatim environment to do this, but cannot get any font except Courier. My document starts like this:

\documentclass{book}

\usepackage{fancyvrb}
\usepackage{inconsolata}

\DefineVerbatimEnvironment{VerbOut}{Verbatim}{fontfamily=courier}

\begin{document}

Normal paragraph with \texttt{code using texttt}.

\begin{VerbOut}
VerbOut environment.
\end{VerbOut}

\end{document}
  1. If I change the fontfamily in the definition of VerbOut to inconsolata, the verbatim block displays the normal (Times Roman) font.
  2. If I change it to \sffamily, I get an error: ! Missing \endcsname inserted.
  3. I get the same error with {\sffamily}, \protect\sffamily, and other variations.

Questions:

  1. What's the right way to change the font to Inconsolata?
  2. What's the right way to change it to whatever is being used by \texttt (in case we change our minds about fonts again)?

migrated from stackoverflow.com Jun 5 '14 at 11:26

This question came from our site for professional and enthusiast programmers.

1

The font family for inconsolata is actually zi4:

enter image description here

\documentclass{book}

\usepackage{fancyvrb}
\usepackage{inconsolata}

\DefineVerbatimEnvironment{VerbOutA}{Verbatim}{fontfamily=courier}% Courier
\DefineVerbatimEnvironment{VerbOutB}{Verbatim}{fontfamily=cmtt}% Computer Modern Typewriter
\DefineVerbatimEnvironment{VerbOutC}{Verbatim}{fontfamily=zi4}% Inconsolata

\begin{document}

Normal paragraph with \texttt{code using texttt}.

\begin{VerbOutA}
VerbOut environment.
\end{VerbOutA}

\begin{VerbOutB}
VerbOut environment.
\end{VerbOutB}

\begin{VerbOutC}
VerbOut environment.
\end{VerbOutC}

\end{document}

Here is my \listfiles:

 *File List*
    book.cls    2007/10/19 v1.4h Standard LaTeX document class
    bk10.clo    2007/10/19 v1.4h Standard LaTeX file (size option)
fancyvrb.sty    2008/02/07
  keyval.sty    1999/03/16 v1.13 key=value parser (DPC)
inconsolata.sty    2013/06/09 zi4a
textcomp.sty    2005/09/27 v1.99g Standard LaTeX package
  ts1enc.def    2001/06/05 v3.0e (jk/car/fm) Standard LaTeX file
  ts1cmr.fd    1999/05/25 v2.5h Standard LaTeX font definitions
 upquote.sty    2012/04/19 v1.3 upright-quote and grave-accent glyphs in verbat
im
  ot1zi4.fd    2013/06/09 OT1/zi4 (Inconsolata)
  ot1pcr.fd    2001/06/04 font definitions for OT1/pcr.
 ***********
  • Thx for the quick reply, but still not working for me: if I set fontfamily=zi4, I'm told "Font shape `OT1/zi4/m/n' undefined" & get Times Roman, but if I \usepackage{zi4} as per mirror.jmu.edu/pub/CTAN/fonts/inconsolata/doc/…, I'm told "'zi4.sty' not found". After downloading, it looks like the only diff between 'inconsolata.sty' and 'zi4.sty' is the name in the \ProvidesPackage{} decl at the top. Any suggestions? Thanks. – Greg Wilson Jun 2 '14 at 11:25
  • @GregWilson: I've added my \listfiles to the post so you can see the font definitions used for zi4. It seems like you may have only downloaded inconsolata.sty and placed it in your working folder - you need the font definition files as well, properly installed. Are you compiling with pdfLaTeX? What operating system are you running? What TeX distribution? Is your distribution up to date? – Werner Jun 2 '14 at 15:34
  • OK, updating everything has mostly worked - thanks. Only problem now is that zi4 doesn't seem to have italics, but that's a separate issue (?). Thanks for your help. – Greg Wilson Jun 3 '14 at 20:07
  • @GregWilson: That is covered in your question: Inconsolate italics? – Heiko Oberdiek Jun 5 '14 at 13:42
0

Run

\listfiles
\documentclass{book}
\usepackage[T1]{fontenc}% always a good idea
\usepackage{inconsolata}
\usepackage{fancyvrb}
\DefineVerbatimEnvironment{VerbOut}{Verbatim}{fontfamily=courier}
\begin{document}

Normal paragraph with \texttt{code using texttt}.

\begin{VerbOut}
VerbOut environment.
\end{VerbOut}

\end{document}

and have alook into the file list (at the end of the log file. It shows at the end the internal family name of Inconsolata:

*File List*
book.cls 2007/10/19 v1.4h Standard LaTeX document class
bk10.clo 2007/10/19 v1.4h Standard LaTeX file (size option)
fancyvrb.sty 2011/04/06
keyval.sty 2014/05/08 v1.15 key=value parser (DPC)
fontenc.sty
t1enc.def 2005/09/27 v1.99g Standard LaTeX file
inconsolata.sty 2013/06/09 zi4a
textcomp.sty 2005/09/27 v1.99g Standard LaTeX package
ts1enc.def 2001/06/05 v3.0e (jk/car/fm) Standard LaTeX file
ts1cmr.fd 1999/05/25 v2.5h Standard LaTeX font definitions
upquote.sty 2012/04/19 v1.3 upright-quote and grave-accent glyphs in verbat
im
t1zi4.fd 2013/06/09 T1/zi4 (Inconsolata)
t1pcr.fd 2001/06/04 font definitions for T1/pcr.
***********

t1zi4.fd is the font definition file of Inconsolata. t1 is the font encoding and zi4 the family name.

\DefineVerbatimEnvironment{VerbOut}{Verbatim}{fontfamily=zi4}

should word if you have Inconsolata installed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.