Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Offers a config option to choose the default LaTeX engine #2513

Closed
nowox opened this issue May 1, 2016 · 9 comments
Closed

Offers a config option to choose the default LaTeX engine #2513

nowox opened this issue May 1, 2016 · 9 comments
Assignees
Labels
builder:latex type:enhancement enhance or introduce a new feature
Milestone

Comments

@nowox
Copy link

nowox commented May 1, 2016

Sphinx currently uses two LaTeX engines: latex and pdflatex. They are called from the main Makefile with the rules latex and latexpdf.

I read some users would like to use a different engine such as lualatex or xelatex. I don't think adding a new recipe on the main Makefile is a good solution. Instead I would add a latex option to choose both the LaTeX engine and the build options.

Moreover, I would choose the default engine to be latexmk -xelatex since this Perl script will automatically rebuild the latex file if needed.

@jfbu
Copy link
Contributor

jfbu commented May 1, 2016

The default font setup is to use T1 encoded 8bit fonts Times, Helvetica and Courier (via package times). There are hyphenation issues when compiling such documents with xelatex for example in German:

Quoted from http://www.texdev.net/2015/01/

Some years ago now the hyphenation patterns used by TeX were translated to Unicode form, and these are read natively by XeTeX (more on LuaTeX below). That means that at present XeTeX will only hyphenate text correctly if it’s either using a Unicode font set up or if it’s in a language that is covered by the Latin-1/T1 range: for example English, French or Spanish but not German (as ß is different in T1 from the Latin-1 position).

LuaTeX is something of a special case as it doesn’t save patterns into the format and as the use of ‘callbacks’ allows behaviour to be modified ‘on the fly’. However, at least without some precautions the same ideas apply here: things are not really quite ‘right’ if you try to use a traditional encoding. (Using LuaLaTeX today you get the same result as with XeTeX.)

Besides, neither XeLaTeX not LuaLaTeX render mathematics exactly as classic TeX: there are (subtle) differences. Arguably this is however marginal and possibly not much relevant to typical Sphinx projects.

Thus should be kept in mind that xelatex and lualatex work best with Unicode fonts (and utf8 sources but that we can pretty much assume).

But I am not sure there are .otf or .ttf fonts universally available under the same name on all systems, be it Windows, Linux, Mac OS X. Thus it is harder to set up a default regarding fonts when using xelatex/lualatex, in contrast to pdflatex which we can assume has access to the standard fonts long distributed together with TeXLive/MikTeX or in Linux packaging.

LuaLaTeX is still at times undergoing drastic changes, and currently the switch from 0.80 to 0.95 has sweeping modifications. But I understand 1.0 is for next year. From then on, situation will probably stabilize.

@jfbu
Copy link
Contributor

jfbu commented May 2, 2016

Just an add-on regarding using xelatex for example as default. I mentioned in my previous comment that if the default engine is XeTeX or LuaTeX, the default fonts must be OpenType fonts too.

I misleadingly said I was not aware if some fonts were universally found on all OSs, I had forgotten that
for some years now, there is a choice which is available from TeXLive or MikTeX, but I don't know about Linux distros packaging of TeXLive: TeX Gyre Termes, TeX Gyre Heros and TeX Gyre Cursor for times+helvetica+courier. I don't know the optimal way of calling them via fontspec, perhaps some Scale=MatchLowerCase would be in order for adjust the size of the helvetica clone compared to times clone, etc...

http://www.gust.org.pl/projects/e-foundry/tex-gyre/

@jfbu
Copy link
Contributor

jfbu commented May 2, 2016

regarding the OP, I forgot to comment the obvious: one can already do make latexpdf PDFLATEX=lualatex for example (or xelatex). But it is true that a make lualatex, make lualatexpdf could be the opportunity to use different default set-up with fontspec replacing fontenc, dropping of inputenc and package times for using OpenType default fonts rather.

@ghost
Copy link

ghost commented May 24, 2016

Note that I put a fully working xelatex configuration for sphinx in #1923, including preamble with font setup, utf8 input and polyglossia etc. Would that be useful as an example?

I think it would be fairly reasonable to default to Tex Gyre Termes, given that it's in all common TeX distributions. It's certainly present in Debian/Ubuntu, and in TeXLive/MacTeX/MikTeX.

@cpitclaudel
Copy link
Contributor

I've used the following myself:

latex_elements = {
    'babel': r'',
    'fontenc': '',
    'inputenc': '',
    'utf8extra': '',
    'cmappkg': '',
}
from sphinx.builders.latex import LaTeXBuilder
LaTeXBuilder.usepackages.append(("polyglossia", []))
LaTeXBuilder.usepackages.append(("unicode-math", []))

@rleigh-dundee I didn't need to set fonts explicitly. Should I have?

@ghost
Copy link

ghost commented May 24, 2016

@cpitclaudel I don't think they need setting explicitly, but if you don't then you get the OpenType version of Computer Modern (or at least, I think that was the case last time I tried it). I might be wrong on that count--I set this up back in 2012 and haven't played with the settings much since.

@tk0miya
Copy link
Member

tk0miya commented Jul 13, 2016

Now I proposed the new config value latex_engine in #2774.
I believe this enables to give a good default LaTeX settings for each engines.

Please try and review this.

@tk0miya
Copy link
Member

tk0miya commented Oct 20, 2016

Now I propose the default settings for LuaLaTeX and XeLaTeX at #3064.
Please review it :-)

@tk0miya
Copy link
Member

tk0miya commented Oct 25, 2016

Now #3064 is merged into master branch.
Unfortunately, to support TeXLive 2009, we could not give a better default settings to LuaTeX at next release.
But we will improve it later (maybe in 1.6).

Thank you for comments!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
builder:latex type:enhancement enhance or introduce a new feature
Projects
None yet
Development

No branches or pull requests

4 participants