I'm trying to write a program in Python that exports data into PDF. Unfortunately, the well known reportlab module is not available on Python 3. (What a shame.) So I have decided to generate TEX files from the program and compile them with TeX.
I know that my operating system have True Type fonts that can handle all of the characters that I need. So all I need is to use such a font for any UTF8 character in the document. I also need to create some tables and figures. It is that simple.
I was trying to do it with pdfLaTex and also with XeLaTex. I'm not sure what is the difference between them. Here is an example generated file for pdfLaTex:
\documentclass[a4paper,11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[hungarian]{babel}
\author{Nagy László}
\title{Elemzés}
\begin{document}
\maketitle
\tableofcontents
\section{Esetleírás}
\subsection{A vizsgálat tárgya}
\begin{itemize}
\item árvíztűrő tükörfórógép
\item ÁRVÍZTŰRŐ TÜKÖRFÚRÓGÉP
\item 80g/m²
\end{itemize}
\end{document}
This throws the error:
! Package inputenc Error: Unicode char \u8:² not set up for use with LaTeX.
Another guy told me to use XeLaTex instead, because it has better unicode support. I don't understand the details, but I have tried that too. With XeLaTex, I got this error:
Runaway argument?
! Paragraph ended before \UTFviii@three@octets was complete.
<to be read again>
\par
l.7 \maketitle
All right, I have no idea what it means, but somebody told me that I should try putting
%%!TEX encoding = UTF-8 Unicode
at the beginning of the file. I'm not sure what this means, because I could not find anything about a special %% macro (???)
in the "not too short introduction into latex2e" documentation. It did not help anyway. So I removed \maketitle
and now I got this:
! Package inputenc Error: Unicode char \u8:írá not set up for use with LaTeX.
Can somebody help me where to start? I don't understand the error message, and I don't know how to fix it.
\usepackage[T1]{fontenc}
after including babel. This should fix your font encoding problem.