1

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}
\newfontfamily\greekfont[Script=Greek]{Linux Libertine O}
\newfontfamily\greekfontsf[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?

  • You might try to use Libertinus Serif instead of Linux Libertine O, for one. Then also, as far as I can see, you are trying to set the Greek sans font to a roman font. I don't know if this might confuse TeX. If you are not going to switch to the newer Libertinus, then at least try using Linux Libertine Sans instead of the O version. That might work. – thymaro Mar 17 '18 at 17:03
1

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{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}
\newfontfamily\greekfont[Script=Greek]{Linux Libertine O}
\newfontfamily\greekfontsf[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

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.