2

When I try to use czech letters defined like this {Ř}{{\v{R}}}1, I'v got this: enter image description here

My problem is that that letters with hook are not have the right position in the word. When I try compiling MNWE with pdflatex (xltxtra was commented) it works fine. I try to solve my problem with the solution for question "Having problems with listings and UTF-8. Can it be fixed?", but it doesn´t works for me.

Sentence should look like this: "Čeština je překrásný jazyk"

MNWE:

\documentclass[12pt,a4paper]{scrbook}
\KOMAoptions{twoside=false,open=any,chapterprefix=on,parskip=full,fontsize=14pt}

\usepackage{listings}
\usepackage{xltxtra}  
\usepackage{xcolor}

\usepackage{inconsolata}
\lstset{
     literate=%
         {á}{{\'a}}1
         {í}{{\'i}}1
         {é}{{\'e}}1
         {ý}{{\'y}}1
         {ú}{{\'u}}1
         {ó}{{\'o}}1
         {ě}{{\v{e}}}1
         {š}{{\v{s}}}1
         {č}{{\v{c}}}1
         {ř}{{\v{r}}}1
         {ž}{{\v{z}}}1
         {ď}{{\v{d}}}1
         {ť}{{\v{t}}}1
         {ň}{{\v{n}}}1                
         {ů}{{\r{u}}}1
         {Á}{{\'A}}1
         {Í}{{\'I}}1
         {É}{{\'E}}1
         {Ý}{{\'Y}}1
         {Ú}{{\'U}}1
         {Ó}{{\'O}}1
         {Ě}{{\v{E}}}1
         {Š}{{\v{S}}}1
         {Č}{{\v{C}}}1
         {Ř}{{\v{R}}}1
         {Ž}{{\v{Z}}}1
         {Ď}{{\v{D}}}1
         {Ť}{{\v{T}}}1
         {Ň}{{\v{N}}}1                
         {Ů}{{\r{U}}}1    
}

\begin{document}

\begin{lstlisting}
<?php

echo 'Olá mundo!';
print 'Čeština je překrásný jazyk';
\end{lstlisting}

\end{document}
JardaFait
  • 3,922

1 Answers1

2

Unfortunately, listings behaves very badly with UTF-8. There is listingsutf8, which requires loading a separate file for each listing, but only with pdflatex.

Maybe you should consider pythontex, minted or verbments.

\documentclass[12pt,a4paper]{scrbook}
\KOMAoptions{twoside=false,open=any,chapterprefix=on,parskip=full,fontsize=14pt}

\usepackage{pythontex}
\usepackage{fontspec}
\usepackage{xcolor}

\setmonofont{Inconsolatazi4}

\begin{document}

\begin{pygments}{php}
<?php

echo 'Olá mundo!';
print 'Čeština je překrásný jazyk';
\end{pygments}

\end{document}

enter image description here

egreg
  • 1,121,712