JelteF / PyLaTeX

A Python library for creating LaTeX files
https://jeltef.github.io/PyLaTeX/
MIT License
2.24k stars 287 forks source link

fontenc and inputenc should not be included #356

Open petaflot opened 1 year ago

petaflot commented 1 year ago

I am using pylatex -> xelatex to generate some documents ; I notice that some symbols are not rendered correctly : in the present case, a ² (two as exponent) is rendered as an 'e' with a bottom-pointing hat (almost like ê but not quite). similarly, the ° (symbol used iie. for celsius degrees) is shown as an 'r' with the same downwards hat.

From a discussion on #latex (see below), it seems that

usepackage[T1]{fontenc}

and

usepackage[utf8]{inputenc}

must not be added to the tex file

22:45 < hrnz> leslie-bot only tries to compile files from the pastebin in the topic automatically
22:45 < hrnz> and the file doesn't look fine
22:46 < hrnz> @cx https://dpaste.com/EZT3Q5LVQ.txt
22:46 < leslie-bot> hrnz: The build failed. The build log is https://tex.builders/pue5d_nk.log
22:46 < hrnz> looks like something tries to interpret \ escape sequences in strings
22:48 < pavonia> As for the issues above, the cause seems to be \usepackage[T1]{fontenc}
22:48 < petaflot> on my machine it builds... no errors at all except those two characters
22:48 < pavonia> \usepackage[utf8]{inputenc} is als unnecessary, if not wrong
22:50 < petaflot> a while back, when I was writing my tex files manually, I found it to be absolultely necessary. if that has changed, I did not 
                  specify any encoding in my python script so it must have to do with pylatex
22:51 < petaflot> I manually deleted those two lines, and it works
22:52 < pavonia> Well, xelatex is different from pdflatex. It's necessary in pdflatex
22:53 < hrnz> (\usepackage[T1]{fontenc}, [utf8]inputenc is preloaded these days)
22:53 < hrnz> and "neccessary" also is debatable
22:54 < hrnz> both OT1 and T1 have drawbacks
22:54 < hrnz> so it's best to avoid them both :>

there.. it's almost fixed :-)