TransWikia.com

Typing code with minted and Greek: "! Package polyglossia Error: The current roman font does not contain the Greek"

TeX - LaTeX Asked on May 7, 2021

I have made my first tex text in order to test how to use it on my essays:

% !TEX TS-program = XeLaTeX

documentclass[a4paper,draft]{article} 
usepackage{minted}
usepackage[Greek,Latin]{ucharclasses}
% Language declaration
usepackage{xltxtra}
usepackage{polyglossia}

setmainlanguage{greek}
setotherlanguages{english}
setTransitionsForGreek{selectlanguage{greek}}{selectlanguage{english}}

% Fonts
usepackage{fontspec}
setmainfont[Kerning=On,Mapping=tex-text]{Linux Libertine O}
setmainfont{Times New Roman}
setsansfont{Arial}
newfontfamilygreekfont[Script=Greek]{Linux Libertine O}
newfontfamilygreekfontsf[Script=Greek]{Linux Libertine O}


title{My first document}
date{2018-03-17}
author{Dimitrios Desyllas}

begin{document}
 maketitle
 newpage

 section{Πρώτο κεφάλαιο}
    Καλημέρα Greece. This is an English paragraph
    subsection{Υποκεφάλαιο 1}
    Στην Ελλάδα έχει ήλιο
    subsubsection{Υποκεφάλαιο }
    Που καίει πολύ
    subsubsection{Υπουπόκεφάλαιο 1.1}
    Πάρα πολύ
    subsection{Υποκεφάλαιο 2}
    Στην Ελλάδα έχει θάλλασα
 section{Δεύτερο κεφάλαιο}
 Όλα πάνε ρόδινα

begin{english}
begin{minted}{java}
import javax.swing.JApplet;
import java.awt.Graphics;

public class Hello extends JApplet {
    public void paintComponent(Graphics g) {
        g.drawString("Hello, world!", 65, 95);
    }    
}
end{minted}
end{english}

end{document}

But on the section:

begin{english}
begin{minted}{java}
import javax.swing.JApplet;
import java.awt.Graphics;

public class Hello extends JApplet {
    public void paintComponent(Graphics g) {
        g.drawString("Hello, world!", 65, 95);
    }    
}
end{minted}
end{english}

I get the following error:

! Package polyglossia Error: The current roman font does not contain the Greek

How I can solve it?

One Answer

The error message is unfortunately misleading, as it refers to the “roman font” rather than the mono font.

Add a declaration for greekfonttt choosing a font that supports Greek.

documentclass[a4paper,draft]{article} 
usepackage{minted}
usepackage[Greek,Latin]{ucharclasses}
% Language declaration
usepackage{polyglossia}

setmainlanguage{greek}
setotherlanguages{english}
setTransitionsForGreek{selectlanguage{greek}}{selectlanguage{english}}

% Fonts
usepackage{fontspec}
setmainfont[Kerning=On,Mapping=tex-text]{Linux Libertine O}
setmainfont{Times New Roman}
setsansfont{Arial}
newfontfamilygreekfont[Script=Greek]{Linux Libertine O}
newfontfamilygreekfontsf[Script=Greek]{Linux Libertine O}


title{My first document}
date{2018-03-17}
author{Dimitrios Desyllas}

begin{document}
 maketitle
 newpage

 section{Πρώτο κεφάλαιο}
    Καλημέρα Greece. This is an English paragraph
    subsection{Υποκεφάλαιο 1}
    Στην Ελλάδα έχει ήλιο
    subsubsection{Υποκεφάλαιο }
    Που καίει πολύ
    subsubsection{Υπουπόκεφάλαιο 1.1}
    Πάρα πολύ
    subsection{Υποκεφάλαιο 2}
    Στην Ελλάδα έχει θάλασσα
 section{Δεύτερο κεφάλαιο}
 Όλα πάνε ρόδινα

begin{english}
begin{minted}{java}
import javax.swing.JApplet;
import java.awt.Graphics;

public class Hello extends JApplet {
    public void paintComponent(Graphics g) {
        g.drawString("Hello, world!", 65, 95);
    }    
}
end{minted}
end{english}

end{document}

I removed the useless bits, particularly the loading of xltxtra and the confusing font setting.

enter image description here

Correct answer by egreg on May 7, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP