I've written a program in python, about 2500 lines in total, that I wish to include segments from into my report. Normally I use listings to do that but in this case, the .py files include many unicode characters which are necessary for the understanding of the files.
These characters, e.g. ⇒, cause these errors in latex
! Package inputenc Error: Unicode char �\lst@FillFixed@ (U+5B4) (inputenc) not set up for use with LaTeX.
! Package inputenc Error: Keyboard character used is undefined (inputenc) in inputencoding `utf8'.
MWE:
\documentclass[a4paper, 11pt]{report}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel} % English language/hyphenation
\usepackage{xcolor}
\usepackage{listings}
\usepackage[T1]{fontenc}
\begin{document}
\chapter{Fists Chapter}
Some text
\lstinputlisting[language=Python, inputencoding=utf8, extendedchars=true]{code.py}
\end{document}
.py file
def Code(self):
print("Some code with comments"):
# Comments with unicode characters
# β∠ζπ⇒
literateset for Spanish language, that's quite easy --- but doing that for a lot of chars is difficult). – Rmano Nov 16 '18 at 11:29\usepackage[utf8]{inputenc}and\usepackage[T1]{fontenc}, switch to\usepackage{fontspec}\setmainfont{Linux Libertine O}and compile with LuaLaTeX the code prints as expected. Oh, and if you are a Python person anyway, you may want to trymintedinstead oflistings: https://tex.stackexchange.com/q/300719/35864 – moewe Nov 16 '18 at 11:31