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.

Please see http://stackoverflow.com/questions/23975828/how-to-specify-non-standard-font-in-fancyvrb-verbatim/ for the start of this discussion.

I am using fancyvrb to create a fancy Verbatim environment. I have

\usepackage{inconsolata}

to load the Inconsolata font, then

\DefineVerbatimEnvironment{VerbOut}
  {Verbatim}{fontfamily=zi4,fontsize=\relsize{-1}}

for the environment itself. I would like it to display in italics, but it appears the inconsolata package doesn't load an italicized version of that font. Is there some other package that does, or some other way I can get it?

share|improve this question
1  
Welcome to TeX.SX! There's no italic version of Inconsolata, I'm afraid. –  egreg Jun 4 at 22:44
    
Reference: Inconsolata in the LaTeX Font Catalogue only shows \normalfont. –  Werner Jun 4 at 23:12

2 Answers 2

The font Inconsolata does not have an italic or slanted variant (June 2014).

Some TeX engines can fake a slanted font, based on a font transformation feature of the PDF format (therefore PDF mode only).

LuaTeX/XeTeX

\documentclass{article}
\usepackage{fontspec}
\setmonofont[
  AutoFakeSlant,
  BoldItalicFeatures={FakeSlant},
]{Inconsolatazi4}

\begin{document}
\ttfamily
Regular
\textbf{Bold}
\textsl{Slanted}
\textit{Italics}
\textbf{\textsl{BoldSlanted}}
\textbf{\textit{BoldItalics}}
\end{document}

Result

The slanted/italic versions are only faked. Also the italics correction is not set.

pdfTeX

A SlantFont operator can be used in the .map file.

The following Perl script zi4-sl.pl reads zi4.map (found via kpsewhich) and modifies the entries:

  • -sl is added to the font (TFM) name,
  • .167 Slantfont is added.

Perl script:

#!/usr/bin/env perl
use strict;
$^W=1;

my $outfile = 'zi4-sl.map';
my $infile = `kpsewhich zi4.map`;
chomp $infile;

open(IN, '<', $infile) or die "!!! Error: Cannot open `zi4.map': $!";
open(OUT, '>', $outfile) or die "!!! Error: Cannot write `$outfile': $!";

while (<IN>) {
    s/^([^- ]+)-([^- ]+)/$1-$2-sl/ or die "!!! Error: Cannot parse TFM name!\n";
    s/ " / " .167 SlantFont / or die "!!! Error: Cannot insert SlantFont!\n";
    print OUT;
}

close(IN);
close(OUT);
__END__

The following example:

  • includes the map file via \pdfmapfile,
  • defines the font shapes (would go into .fd files normally).
\pdfmapfile{+zi4-sl.map}

\documentclass{article}
\usepackage{inconsolata}

\makeatletter
\sbox0{\ttfamily x}% load .fd file
\expandafter\ifx\csname zifour@scaled\endcsname\relax
  \let\zifour@scaled\@empty
\fi
\expandafter\ifx\csname zifour@opt\endcsname\relax
  \def\zifour@opt{\z@}\def\zifour@altopt{\tw@}
\fi
\DeclareFontShape{\f@encoding}{zi4}{m}{sl}{%
  <-> \zifour@scaled ot1-zi4r-sl-\zifour@opt}{}%
\DeclareFontShape{\f@encoding}{zi4}{m}{it}{%
  <-> ssub * zi4/m/sl}{}
\DeclareFontShape{\f@encoding}{zi4}{b}{sl}{%
  <-> \zifour@scaled ot1-zi4b-sl-\zifour@opt}{}
\DeclareFontShape{\f@encoding}{zi4}{bx}{sl}{%
  <-> ssub * zi4/b/sl}{}
\DeclareFontShape{\f@encoding}{zi4}{b}{it}{%
  <-> ssub * zi4/b/sl}{}
\DeclareFontShape{\f@encoding}{zi4}{bx}{it}{%
  <-> ssub * zi4/b/sl}{}
\makeatother

\begin{document}
\ttfamily
Regular  
\textbf{Bold}
\textsl{Slanted}
\textit{Italics}
\textbf{\textsl{BoldSlanted}}
\textbf{\textit{BoldItalics}}
\end{document}

Finally the TFM files are needed. A poor man's solution is to use the TFM files for the original fonts. The example would need (bash syntax):

cp $(kpsewhich ot1-zi4r-0.tfm) ot1-zi4r-sl-0.tfm
cp $(kpsewhich ot1-zi4b-0.tfm) ot1-zi4b-sl-0.tfm

Result

Again, the slanted and italic variants are only faked. Also the italics correction is missing, but it could be added by editing the .tfm files.

share|improve this answer
1  
While I admire the technical wizardry in this answer (+1), I cannot refrain from disparaging the purpose to which it is turned. ;) –  cfr Jun 5 at 1:32
    
Hmm, looks like fontspec should also slant the bold font with AutoFakeSlant. Bug added. –  Will Robertson Jun 5 at 7:01
    
@cfr It should be noted that it's quite common for font designers to simply slant the glyphs for an italic monospaced font. I'd consider this less of a travesty than, say, slanting a text font. –  Will Robertson Jun 5 at 7:03
    
This one might give even another option to slant a font. But haven't tried it, so it might give problems. –  Manuel Jun 5 at 10:18
1  
@Manuel: There are problems with line and page breaks inside the argument. Then the coordinate systems of TeX and the PDF output device get out of sync. Safely it can be used inside \mbox, which forbids line breaks. –  Heiko Oberdiek Jun 5 at 10:48

It seems there is no italic version for your font (at least not that I'm aware of), but you can always search for a monospaced font you like in the LaTeX Font Catalogue

share|improve this answer

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.