5

Using minted for code listings I have set my font to inconsolata and get the wargning:

LaTeX Font Warning: Font shape `T1/zi4/m/it' undefined

when using Inconsolata font and Python documentation strings -- e.g.:

def foo():
    """ Docstring
    """ 
    return 0

If the documentation string is not present, there is no warning.

Minimal example:

\documentclass[                                                                 
    12pt,
    paper=a4
]{scrreprt}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}
\usepackage{libertine}                                                           
\usepackage[libertine,cmintegrals,cmbraces,vvarbb]{newtxmath}
\usepackage{inconsolata}
\usepackage{minted}

\begin{document}
    Some Text. 

    \inputminted{Python}{some_code.py}
\end{document}

Edit: The Warning still appears, despite your solution. Could it be because I defined my own environment:

\documentclass[
    12pt,
    paper=a4
]{scrreprt}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}
\usepackage{libertine}
\usepackage[libertine,cmintegrals,cmbraces,vvarbb]{newtxmath}
\usepackage{inconsolata}
\usepackage{minted}
\usepackage{etoolbox}
\AtBeginEnvironment{minted}{\let\itshape\relax}

\newmintedfile[Python]{python}{
    fontsize=\small,
    %bgcolor=mintedback,
    linenos=true,
    numberblanklines=true,
    numbersep=12pt,
    numbersep=5pt,
    gobble=0,
    frame=leftline,
    framerule=1pt,
    framesep=2mm,
    funcnamehighlighting=true,
    tabsize=4,
    obeytabs=false,
}

\begin{document}
    Some Text.

    \Python{test.py}

\end{document}
ap0
  • 329
  • 1
    Please show us a complete MWE which allows us to reproduce your error. Thanks. – LaRiFaRi Jan 21 '15 at 11:52
  • The warning means that you have asked for a character that is not in the font. – musarithmia Jan 21 '15 at 12:14
  • 1
    Note that Inconsolata has neither italic nor smallcaps shape. – egreg Jan 21 '15 at 12:30
  • @egreg, In none of my TikZ I use Italic. Only single letters. I would create a minimal example but I can't find the correct spot which is causing the error myself. I have removed the font=\ttfamily option but the error still occures. – ap0 Jan 21 '15 at 13:05
  • Present the minimum document that issues the warning; finding where it comes from is what you want to know, don't you? – egreg Jan 21 '15 at 13:11
  • @egreg, As it looks like it is not \texttt or \ttfamily that is causing the error. It is minted! I have no idea why the warning message (from vim-latex-suite btw) was pointing to that tikzpicture. After removing all minted code includes the warning was gone and it comes back after I put them back again. If I can not find the cause by my own I will ask here again. But should I now delete the question and start a new one or edit it? – ap0 Jan 21 '15 at 13:23
  • Now that you know better about it, rewrite this question with the relevant information. – egreg Jan 21 '15 at 13:24
  • @egreg, thanks for the patience. I have rewritten my question. I also found the error but don't know why it occures. – ap0 Jan 21 '15 at 13:46
  • Essentially all minted styles use italic text, which inconsolata doesn't provide. You can use a different font that does provide italics. Or you can disable the italics within minted environments by loading etoolbox and then using something like \AtBeginEnvironment{minted}{\let\textit\relax}. – G. Poore Jan 21 '15 at 14:39

1 Answers1

5

You can't avoid the warning, because the Pygments lexer for Python chooses italics for triple quoted strings.

If I don't load inconsolata, the output is

enter image description here

The Inconsolata font has no italic/slanted shapes, so the warning is issued and the upright font is used. You should use a monospaced font that has italic shape, probably.

You can avoid the warning either by choosing a monospaced font that has italics or by providing the missing font substitutions.

Note that filecontents* is used just for making the example self contained.

\begin{filecontents*}{\jobname.py}
def foo():
    """ Docstring
    """ 
    return 0
\end{filecontents*}

\documentclass[
    12pt,
    paper=a4
]{scrreprt}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}
\usepackage{libertine}
\usepackage[libertine,cmintegrals,cmbraces,vvarbb]{newtxmath}
\usepackage{inconsolata}
\usepackage{minted}

\makeatletter
% there's no italic/slanted for Inconsolata
\@namedef{T1/zi4/m/it}{<->ssub*zi4/m/n}
\@namedef{T1/zi4/b/it}{<->ssub*zi4/b/n}
\@namedef{T1/zi4/bx/it}{<->ssub*zi4/b/n}
\@namedef{T1/zi4/m/sl}{<->ssub*zi4/m/n}
\@namedef{T1/zi4/b/sl}{<->ssub*zi4/b/n}
\@namedef{T1/zi4/bx/sl}{<->ssub*zi4/b/n}
\makeatother

\newmintedfile[Python]{python}{
    fontsize=\small,
    %bgcolor=mintedback,
    fontfamily=tt,
    linenos=true,
    numberblanklines=true,
    numbersep=12pt,
    numbersep=5pt,
    gobble=0,
    frame=leftline,
    framerule=1pt,
    framesep=2mm,
    funcnamehighlighting=true,
    tabsize=4,
    obeytabs=false,
}

\begin{document}
Some Text.

\begin{minted}{python}
def foo():
    """ Docstring
    """
    return 0
\end{minted}

\Python{\jobname.py}


\end{document}

enter image description here

egreg
  • 1,121,712