2

I cannot get to work my special chars in listings, my texmaker is configurated to use utf8 in options, but I get error:

! Package inputenc Error: Unicode char \u8:�\lst@FillFixed@ not set up for use with LaTeX.

With XeLatex i dont get any errors but it doesn't show any ą in pdf. Could i import the content of file.txt and show it in C# colors without copy-paste to .tex file?

\documentclass[titlepage, a4paper]{mwart}
\usepackage{amsmath,amsfonts,amssymb,amsthm}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{polski}
\usepackage{graphicx}
\usepackage{listings}
\usepackage{xcolor}
\lstdefinestyle{sharpc}{language=[Sharp]C, frame=lr, rulecolor=\color{blue!80!black}}
\begin{document}
ą
\begin{lstlisting}
ą
\end{lstlisting}


\end{document}
2

You can use literate to replace the char with a suitable command:

\documentclass[titlepage, a4paper]{mwart}
\usepackage{amsmath,amsfonts,amssymb,amsthm}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{polski}
\usepackage{graphicx}
\usepackage{listings}
\usepackage{xcolor}
\lstdefinestyle{sharpc}{language=[Sharp]C, frame=lr, rulecolor=\color{blue!80!black}}

\lstset{literate=%
    {ą}{{\k a}}1    
}
\begin{document}
ą 
\begin{lstlisting}
ą
\end{lstlisting}

\end{document}
  • What is the meaning of 1 in the code? – Sigur Feb 11 '16 at 14:04
  • 1
    The number of chars the replacement will produce. – Ulrike Fischer Feb 11 '16 at 14:06
2

From Section 2.5 of documentation simply use

\begin{lstlisting}[extendedchars=false]
ą
\end{lstlisting}

enter image description here

  • Did you try it in an utf8 encoded file? – Ulrike Fischer Feb 11 '16 at 14:00
  • @UlrikeFischer, yes. – Sigur Feb 11 '16 at 14:01
  • Sorry, I thought you had used true, and not false. Well this will not give an error, but try out ą and some more text (in one line) – Ulrike Fischer Feb 11 '16 at 14:05
  • @UlrikeFischer, a new line appears. I'm afraid I would have to delete the answer. – Sigur Feb 11 '16 at 14:07

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.