olivierverdier / python-latex-highlighting

LaTeX style for Python highlighting
BSD 3-Clause "New" or "Revised" License
453 stars 125 forks source link

Issues with KOMA-Script / scrhack-package #19

Closed NeverGameStar closed 3 months ago

NeverGameStar commented 3 months ago

One of the past updates to this package (within the last ~5 months) has brought up two issues:

  1. Including \usepackage{pythonhighlight} when using a KOMA-Script class (scrreprt) in combination with: \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage[ngerman]{babel} will still prevent German Umlaute (ß, ä, ö, ü) from being printed properly (in the entire document). Excluding the package solves the issue.

  2. When using the packages together with \usepackage{scrhack}, following warning is printed: "unknown \lstlistoflistings definition found!(scrhack) Maybe you are using a unsupported listings version."

Log:

(C:\Program Files\MiKTeX\tex/latex/pythonhighlight\pythonhighlight.sty
Package: pythonhighlight 2024/03/18 python code highlighting; provided by Olivi
er Verdier <olivier.verdier@gmail.com>
(C:\Program Files\MiKTeX\tex/latex/listings\listings.sty
\lst@mode=\count319
\lst@gtempboxa=\box66
\lst@token=\toks29
\lst@length=\count320
\lst@currlwidth=\dimen169
\lst@column=\count321
\lst@pos=\count322
\lst@lostspace=\dimen170
\lst@width=\dimen171
\lst@newlines=\count323
\lst@lineno=\count324
\lst@maxwidth=\dimen172
(C:\Program Files\MiKTeX\tex/latex/listings\lstpatch.sty
File: lstpatch.sty 2024/05/25 1.10b (Carsten Heinz)
)
(C:\Program Files\MiKTeX\tex/latex/listings\lstmisc.sty
File: lstmisc.sty 2024/05/25 1.10b (Carsten Heinz)
\c@lstnumber=\count325
\lst@skipnumbers=\count326
\lst@framebox=\box67
)
(C:\Program Files\MiKTeX\tex/latex/listings\listings.cfg
File: listings.cfg 2024/05/25 1.10b listings configuration
))
Package scrhack Info: loading listings hack on input line 9.
(C:\Program Files\MiKTeX\tex/latex/koma-script\listings.hak
File: listings.hak 2023/07/07 v3.41 KOMA-Script scrhack part (hacking package l
istings)
Package scrhack Warning: unknown \lstlistoflistings definition found!
(scrhack) Maybe you are using a unsupported listings version.
Package: listings 2024/05/25 1.10b (Carsten Heinz)

Before the update, these issues were not there.

olivierverdier commented 3 months ago

It would help if you could instead post a minimum working example.

When it comes to using accents, I would strongly, strongly suggest to use XeLaTeX instead. You'll have to remove the fontenc and inputenc lines.

NeverGameStar commented 3 months ago

Minimum working example:

\documentclass[fontsize=12pt, oneside]{scrreprt}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}

%\usepackage{pythonhighlight} % uncomment this to fuck up the Umlaute
%\usepackage{scrhack} % uncomment this as well for "Package scrhack Warning: unknown \lstlistoflistings definition found!"-Warning

\begin{document}
\chapter{German Umlaute}
\centering
Ä and ä can also be written as Ae and ae \\
Ö and ö can also be written as Oe and oe \\
Ü and ö can also be written as Ue and ue \\
ß can also be written as ss \\
\end{document}

Using XeLaTeX is not an option for me since I use other packages that are incompatible with it. I have to use PdfLaTex...

olivierverdier commented 3 months ago

The problem is an incompatibility with babel.

Loading pythonhighlight before babel solves the problem for me.

Can you confirm?

If you do, we can close this issue. I do not know what exactly the problem is, but I am not willing to investigate since I consider pdfLaTeX to be superseded by XeLaTeX nowadays. Feel free to take a look, though, maybe there is an easy explanation/fix which would allow to load the packages in an arbitrary order.

NeverGameStar commented 3 months ago

Loading pythonhighlight before babel solves the problem for me.

Can you confirm?

Nope, but for me loading it at the beginning of the document (before \usepackage[utf8]{inputenc}) solves the first issue and Umlaute are displayed properly.

I therefore guess the issue is related to the \UseRawInputEncoding command, which was pushed on March 4th, 2024. I'd suggest to remove the command again since the reason for pushing it in the first place seemed to be an incorrect utf-8 codec implementation on the contributors behalf.

olivierverdier commented 3 months ago

Thank you, you found the culprit! I'll remove \UseRawInputEncoding shortly.

olivierverdier commented 3 months ago

For completeness, here is a guide to the recent changes about LaTeX and encodings. From this document one sees that \usepackage[utf8]{inputenc} is no longer necessary, and that \UseRawInputEncoding is almost never useful, and should certainly never be in a package. Apologies for my oversight here.