4

I'm using polyglossia for writing a document in Serbian cyrillic script, but when I try to use minted for source code syntax highlighting there's an error (although pdf is generated):

polyglossia: The current roman font does not contain the Cyrill(polyglossia) Please define \cyrillicfont with \newfontfamily. ...l=lst:rssfeeder,caption=RssItemView.java]

Pdf is generated, but without cyrillic words in minted environment. Note that there is no error if I don't use minted.

I defined cyrillicfont in premble:

\documentclass[12pt,a4paper,serbian,oneside]{book}

% minted  - paket za prikaz programa
\usepackage{minted}

% srpski jezik
\usepackage{fontspec}
\usepackage{polyglossia}
\setmainlanguage[Script=Cyrillic]{serbian}
\setmainfont{Times New Roman}
\newfontfamily\cyrillicfont{Times New Roman}

\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{textcomp}
\usepackage{amsfonts}
\usepackage{graphicx}
\usepackage{ucs}
\usepackage{pdfsync}
\usepackage[left=2.5cm,right=2.5cm,top=2.5cm,bottom=2.5cm]{geometry}


% Numerisanje subsubcetion
\setcounter{secnumdepth}{3}

%Prikaz subsubsection u sadrzaju
%\setcounter{tocdepth}{3}

% Komanda za horizontal ruler
\newcommand{\HRule}{\rule{\linewidth}{0.5mm}}

I'm trying to show this coffeescript snippet with minted:

\begin{minted}[mathescape,
               linenos]{coffeescript}
  http = require 'http'

  app.get '/', (req, res) =>
    res.send 'cao'
  # Коментар / Comment : const double pi = 3.1415926535
\end{minted}

Pdf is generated, the code is shown, but instead of Коментар there are blanks. Following errors and warnings are displayed:

polyglossia: The current roman font does not contain the Cyrill(polyglossia) Please define \cyrillicfont with \newfontfamily. ...\catcode`\$=3\catcode`\^=7\catcode`\_=8}, ]
Unused global option(s): [serbian].
Font shape `EU1/TimesNewRoman(0)/m/sc' undefined(Font) using `EU1/TimesNewRoman(0)/m/n' instead
Some font shapes were not available, defaults substituted.

I'm using TexStudio and xelatex with --shell-escape option for minted.

  1. Why is the error with defining cyrillic font displayed when I included it in the preamble?
  2. How to show cyrillic words in minted environment?
4

You have to define a monospaced font that supports Cyrillic; the default one (Latin Modern Mono) doesn't.

\documentclass[12pt,a4paper,serbian,oneside]{book}

% minted  - paket za prikaz programa
\usepackage{minted}

% srpski jezik
\usepackage{fontspec}
\usepackage{polyglossia}
\setmainlanguage[Script=Cyrillic]{serbian}
\setmainfont{Times New Roman}
\newfontfamily\cyrillicfont{Times New Roman}
\setmonofont{CMU Typewriter Text}

\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{textcomp}
\usepackage{amsfonts}
\usepackage{graphicx}
\usepackage[left=2.5cm,right=2.5cm,top=2.5cm,bottom=2.5cm]{geometry}


% Numerisanje subsubcetion
\setcounter{secnumdepth}{3}

%Prikaz subsubsection u sadrzaju
%\setcounter{tocdepth}{3}

% Komanda za horizontal ruler
\newcommand{\HRule}{\rule{\linewidth}{0.5mm}}

\begin{document}
I'm trying to show this coffeescript snippet with minted:

\begin{minted}[mathescape,
               linenos]{coffeescript}
  http = require 'http'

  app.get '/', (req, res) =>
    res.send 'cao'
  # Коментар / Comment : const double pi = 3.1415926535
\end{minted}
\end{document}

Find a monospaced font you have available. If CMU Typewriter Text is not installed as system font, you should do with

\setmonofont{cmuntt.otf}

provided you have a full TeX distribution.

Don't load ucs with XeLaTeX; also pdfsync should be avoided: its synchronization capabilities are much worse than the modern SyncTeX mechanism which is provided automatically by the more recent TeX distributions (add the option -pdfsync=1, which most front-ends already do).

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.