PreTeXtBook / pretext

PreTeXt: an authoring and publishing system for scholarly documents
https://pretextbook.org
Other
264 stars 206 forks source link

Pdflatex listings for greek letters #1454

Open alexjbest opened 3 years ago

alexjbest commented 3 years ago

I have some code that makes use of unicode greek letters for variables (nu, lambda, kappa, mu) (thanks python3!) that I'm trying to include in a pretext program.

However the characters do not display, I believe this is as https://github.com/rbeezer/mathbook/blob/dev/xsl/pretext-latex.xsl#L1450 would need extending to include these letters.

Can we extend the conversion there to include some more (reasonably common) characters from greek?

For example a snippet of my pretext code is

<program language="sage" xml:id="prog-bosma-lenstra"><input><![CDATA[
# Set up the variables for two points on the given curve
R.<a_1,a_2,a_3,a_4,a_6,Z_1,Y_1,X_1,Z_2,Y_2,X_2> = PolynomialRing(QQ)
λ = (y_1 * z_2 - y_2 * z_1)/(x_1 * z_2 - x_2 * z_1)
ν = -(y_1 * x_2 - y_2 * x_1)/(x_1 * z_2 - x_2 * z_1)
]]></input></program>

In my tex output I have added \usepackage{textgreek} and

{ν}{{\textnu }}{1}{λ}{{\textlambda }}{1}{μ}{{\textmu }}{1}{κ}{{\textkappa }}{1}

to the \lstset{literate= but this seems a bit hacky and maybe not the Pretext way to achieve this!

rbeezer commented 3 years ago

My intent with the Unicode characters for listings was to enable comments in different languages, mostly thinking of European accented languages. Now - if Sage is happy with a Greek letter as a variable, I guess we should try to support a nice print version of that! Who knew. (Oh, I see it is Python 3, really. All the moreso.)

Do you want to experiment editing the XSL to support your nu, lambda, mu, and kappa? In other words, are you OK with starting work on this? If there is no (more) messing around with LaTeX encodings and UTF8 support, that'd be the best outcome.

I don't want to step on the possibility of an entire document being authored in Greek, but we accomplish that with xelatex and I guess this is localized to code listings anyway. The textgreek package looks to be last updated 10 years ago, which makes me nervous. But there are subjects (chemistry) where they like the upright Greek letters, so we'd need to see how that goes.

I have some idea that the literate option was limited to the "first" 256 Unicode characters, but perhaps your work already indicates that is nonsense.

jdeisenberg commented 1 year ago

I have a similar problem with the Greek letter lambda and the less-than-or-equal symbol not showing up when I create a PDF via pretext build print (see attached) pretext-unicode.zip

rbeezer commented 1 year ago

Outside of a computer program listing (which I think is the thrust of this issue), we get much better versions of mathematics with LaTeX syntax, and then we process with LaTeX for the PDF and MathJax for HTML. For example, we can turn the below into braille, not so right now when using Unicode.

So try

<m>\lambda</m> for the bare lambda

and

<m>485\leq\lambda\lt 500</m> in the table cells

jdeisenberg commented 1 year ago

OK; will make the change.