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

Xelatex for PDF generation #1556

Closed
NoralK opened this issue Aug 12, 2015 · 55 comments · Fixed by #5437
Closed

Xelatex for PDF generation #1556

NoralK opened this issue Aug 12, 2015 · 55 comments · Fixed by #5437
Labels
Community Effort Improvement Minor improvement to code Needed: patch A pull request is required

Comments

@NoralK
Copy link

NoralK commented Aug 12, 2015

I was wondering if xelatex is supported for PDF generation? If so is the font Symobla.ttf installed as well? If not do you know when it will be supported.

Thank you

@gregmuellegger gregmuellegger added the Support Support question label Aug 17, 2015
@gregmuellegger
Copy link
Contributor

That's a question for @agjohnson or @ericholscher. Let's see what they say :)

@agjohnson
Copy link
Contributor

Ubuntu offers the texlive-xetex package, which is installed. Past that, I don't know anything about xelatex, so I don't know if your case would be supported. You can certainly try though.

Symbola.ttf is installed via ttf-ancient-fonts-symbola, which is not installed, and isn't on or backported to the ubuntu 14.04 release. We would install this if there was a supported package, but won't install and support third party packages like this manually.

@NoralK
Copy link
Author

NoralK commented Aug 20, 2015

Locally, I had to modify the Make.bat to give an option for xelatex and then script changes to the makefile using SED. RFTD is calling the pdflatex option and a new option would need to be created for xelatex.

For this to work I am guessing an advanced option preference would need to be added to select pdflatex (recommended) and xelatex. Based on that option there would be scripting to correct the makefile then build using xelatex.

BTW - It would also be nice to add in some "preprocessing" capabilities. I currently use SED to make changes to the "whateverthefilenameis.tex". Some changes I do before calling the makefile is sed -i s/\\RequirePackage{color}/\\RequirePackage{xcolor}/ sphinx.sty and sed -i s/]{hyperref}/,unicode]{hyperref}/ sphinx.sty - these are some changes that may be needed, not all the time required, when using xelatex.

Thank you for the help.

@NoralK
Copy link
Author

NoralK commented Aug 20, 2015

BTW - here is my xelatex section of make.bat:

if "%1" == "xelatex" (
    %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
    cd %BUILDDIR%/latex
    echo "Running XeLaTeX files through xelatex..."
    sed -i s/pdflatex/xelatex/ Makefile
    sed -i s/\\RequirePackage{color}/\\RequirePackage{xcolor}/ sphinx.sty
    sed -i s/]{hyperref}/,unicode]{hyperref}/ sphinx.sty

    rem WINDOWS batch files require an escape for & using ^!
    sed -i s#\\{\\textbackslash{}faWrench\s\\}\s\\^&\\\#x1F527#{\\faWrench}#g whateverthefilenameis.tex

    del sed*
    make all-pdf
    cd %~dp0
    echo.
    echo ****
    echo %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
    echo ****
    echo "xelatex finished; the PDF files are in $(BUILDDIR)/latex."
    goto end
    )

@agjohnson
Copy link
Contributor

Running xelatex would require special processing in our build environments. Our build environments disregard makefiles completely, you would probably want to implement your special processing as a sphinx extension. The changes you are describing are slightly outside the realm of RTD though.

Marking this community support if anyone wants to take this on, it's off our roadmap for now.

@agjohnson agjohnson added Community Effort Needed: patch A pull request is required and removed Support Support question labels Aug 26, 2015
@gregmuellegger gregmuellegger added the Improvement Minor improvement to code label Sep 14, 2015
ghost referenced this issue in labopp/guideb2rm-sphinx Jun 30, 2016
@skirpichev
Copy link
Contributor

Running xelatex would require special processing in our build environments.

I think that no severe changes would be needed. Just a replacement pdflatex -> xelatex - will work for most cases.

@agjohnson, what about extending yml config with options to allow this?

I see following variants:

  • boolean option (e.g. use_xelatex)
  • string option, i.e. "command name" for pdflatex-replacement

@asr
Copy link

asr commented Oct 8, 2016

Blocking agda/agda#2153.

@skirpichev
Copy link
Contributor

@agjohnson, there is a patch that sits in queue for month. Apparently, this is an important issue for several projects and require minimal changes. How else I can help to get it fixed?

BTW, another possible option (other than those mentioned above) is to query conf.py for 'latex_engine' value. Let me know if you prefer this.

@ricpelo
Copy link

ricpelo commented Feb 7, 2017

It seems that the latex_engine option doesn't work because readthedocs uses sphinx-build -b latex and then pdflatex over the .tex files that sphinx-build generates.

@skirpichev
Copy link
Contributor

It seems that the latex_engine option

Yes, because readthedocs doesn't use it now, which I suggest.

and then pdflatex

To select correct binary, we can query 'latex_engine' option.

@agjohnson
Copy link
Contributor

@skirpichev it seems the purposed fix would be to simply just replace the binary executed with the binary name from the readthedocs-build config module? If there is feature parity there, this sounds fine, however I'd want to note that we only officially support pdflatex in the docs. A PR should update our docs to describe this change.

@skirpichev
Copy link
Contributor

@skirpichev it seems the purposed fix would be to simply just replace the binary executed with the binary name from

Yes. But after "from" - a number of options.

  1. We can configure binary name in readthedocs-build
    a. string option
    b. boolean option (like "use_xelatex")
  2. We can configure binary name from the projects conf.py option "latex_engine".

I'd want to note that we only officially support pdflatex in the docs.

But can we be sure that xelatex doesn't disappear from the environment in future?

@cyberorg
Copy link

#2620

Sphinx allows the use of following:

make PDFLATEX=xelatex -e SPHINXOPTS="-D language='gu'" latexpdf

All we need on readthedocs is the way to set PDFLATEX=xelatex

@humitos
Copy link
Member

humitos commented Feb 26, 2017

To add more info to this issue, I did this stupid change in my local instance and it built the PDF from #2620 (https://readthedocs.org/projects/mss-doc-gu)

diff --git a/readthedocs/doc_builder/backends/sphinx.py b/readthedocs/doc_builder/backends/sphinx.py
index c6bd529e..45ad7e32 100644
--- a/readthedocs/doc_builder/backends/sphinx.py
+++ b/readthedocs/doc_builder/backends/sphinx.py
@@ -292,7 +292,7 @@ class PdfBuilder(BaseSphinx):
 
         # Run LaTeX -> PDF conversions
         pdflatex_cmds = [
-            ['pdflatex',
+            ['xelatex',  # 'pdflatex',
                 '-interaction=nonstopmode',
                 tex_file]
             for tex_file in tex_files]

Besides, I uncommented the lines from conf.py regarding latex_elements. So, giving an experimental way of changing the pdflatex command to xelatex to the user could be a way to build, at least, a couple of builds.

The result, that wasn't linked in the Downloads section of the project for some reason, but I opened it from user_builds/h-gu/artifacts/xelatex/sphinx_pdf/h-gu.pdf

captura de pantalla_2017-02-26_05-25-48

@skirpichev
Copy link
Contributor

@humitos, please see readthedocs/readthedocs-build#18

The result, that wasn't linked in the Downloads section of the project for some reason

I don't know you local settings, but perhaps that could be #2582 (which also has patch, awaiting for review).

@agjohnson
Copy link
Contributor

@humitos good point. Seems we'll need more logic on the RTD side than just swapping out the binary used. The download path is probably because of some difference in the output, and may take a patch to fix the sphinx builder in RTD.

@skirpichev
Copy link
Contributor

@agjohnson, what about conf.py option? Should we add something to yml config or just utilize 'latex_engine'?

Correct me, but rtd now don't parse & query for any conf.py settings, right?

@stale
Copy link

stale bot commented Jan 10, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Status: stale Issue will be considered inactive soon label Jan 10, 2019
@skirpichev
Copy link
Contributor

Wow, an original method of fixing issues.

@asr
Copy link

asr commented Jan 10, 2019

Indeed!

@stale stale bot removed the Status: stale Issue will be considered inactive soon label Jan 10, 2019
@stsewd
Copy link
Member

stsewd commented Jan 10, 2019

This is still valid, but we haven't had the time to check in to this yet.

@skirpichev
Copy link
Contributor

we haven't had the time to check in

(You had a working PR (or PRs) year ago (or more?), but prefer the Code of Conduct, instead of code...)

@humitos
Copy link
Member

humitos commented Jan 10, 2019

We can use sphinx-doc/sphinx:sphinx/config.py@bc02abc#L183 to read the file from the rtd application.

This will be a problem.

If the user is executing code that writes a file, calculate something or whatever this will be executed twice and, besides it's a waste of resources, it could bring other issues.

@agjohnson
Copy link
Contributor

Feature flag is a good direction temporarily. How we arrive at a binary to use will probably end up being a config file change, as it seems we can't automate this before we execute the conf.py. We can't rely on the makefile, but there might be a third option such as using a custom RTD builder that is a wrapper for pdflatex/xelatex depending on the conf. Keeping this out of our config would be helpful.

Either way PRs welcome here. Our code of conduct is not going to be removed, please stop implying we should remove it.

@skirpichev
Copy link
Contributor

please stop implying we should remove it.

Sorry, unsubscribed.

waveform80 added a commit to gpiozero/gpiozero that referenced this issue Feb 10, 2019
and ditch the fancy UTF-8 sharp/flat chars because of
readthedocs/readthedocs.org#1556 ... again
@stale
Copy link

stale bot commented Feb 24, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Status: stale Issue will be considered inactive soon label Feb 24, 2019
@stevepiercy
Copy link
Contributor

Please remove the status: stale label.

There is some relevant discussion taking place in #4454 about how to avoid a makefile.

@stale stale bot removed the Status: stale Issue will be considered inactive soon label Feb 24, 2019
humitos added a commit that referenced this issue Mar 6, 2019
humitos added a commit that referenced this issue Mar 12, 2019
New versions of Sphinx use `latexmk` to build the PDF files. This
command uses a file called `latexmkrc` (or `latexmkjarc` for Japanese)
which contains all the proper commands that needs to be ran depending
on different Sphinx configurations.

`latexmk` will take care by itself on the amount of phases that need
to be ran without us worrying about it.

Currently, this is not considering LATEXMKOPTS and XINDYOPTS
environment variables configured by Sphinx.

This feature is implemented under a Feature flag so we can test it
easily without breaking other working projects.

References:

- #1556
- #4454
- #5405
- toppers/tecs-docs#7
- https://github.com/sphinx-doc/sphinx/blob/master/sphinx/texinputs/Makefile_t
- https://www.sphinx-doc.org/en/master/usage/builders/index.html#sphinx.builders.latex.LaTeXBuilder
humitos added a commit that referenced this issue Mar 12, 2019
New versions of Sphinx use `latexmk` to build the PDF files. This
command uses a file called `latexmkrc` (or `latexmkjarc` for Japanese)
which contains all the proper commands that needs to be ran depending
on different Sphinx configurations.

`latexmk` will take care by itself on the amount of phases that need
to be ran without us worrying about it.

Currently, this is not considering LATEXMKOPTS and XINDYOPTS
environment variables configured by Sphinx.

This feature is implemented under a Feature flag so we can test it
easily without breaking other working projects.

References:

- #1556
- #4454
- #5405
- toppers/tecs-docs#7
- https://github.com/sphinx-doc/sphinx/blob/master/sphinx/texinputs/Makefile_t
- https://www.sphinx-doc.org/en/master/usage/builders/index.html#sphinx.builders.latex.LaTeXBuilder
humitos added a commit that referenced this issue Mar 13, 2019
New versions of Sphinx use `latexmk` to build the PDF files. This
command uses a file called `latexmkrc` (or `latexmkjarc` for Japanese)
which contains all the proper commands that needs to be ran depending
on different Sphinx configurations.

`latexmk` will take care by itself on the amount of phases that need
to be ran without us worrying about it.

Currently, this is not considering LATEXMKOPTS and XINDYOPTS
environment variables configured by Sphinx.

This feature is implemented under a Feature flag so we can test it
easily without breaking other working projects.

References:

- #1556
- #4454
- #5405
- toppers/tecs-docs#7
- https://github.com/sphinx-doc/sphinx/blob/master/sphinx/texinputs/Makefile_t
- https://www.sphinx-doc.org/en/master/usage/builders/index.html#sphinx.builders.latex.LaTeXBuilder
@skirpichev
Copy link
Contributor

@ericholscher, you closed this issue.

Unless I misunderstood something, new feature (from #5437) is not working on the https://readthedocs.org/, it may be enabled only for custom installations.

If so, I don't think the original issue was solved. Or this is closed as "will not fix" and the https://readthedocs.org/ will never support xelatex?

@stevepiercy
Copy link
Contributor

stevepiercy commented Mar 19, 2019

I followed this issue in hopes that it would resolve Pylons/pyramid#3290. Although #5437 was merged, this issue was not resolved, unless I have missed some configuration or other user-configurable option. Should I open a new issue or is there another that I should follow?

@stsewd
Copy link
Member

stsewd commented Mar 19, 2019

Please see #5453

@skirpichev
Copy link
Contributor

@stsewd, it seems - it's impossible to use xelatex on the readthedocs.org, I don't think your reference to #5453 could help. For example, I set latex_engine="xelatex" in conf.py, but rtfd still uses pdflatex: see failed build.

@humitos
Copy link
Member

humitos commented Mar 19, 2019

The issue was closed automatically because the PR was merged.

If you want to test/try this new feature in your project, please open a new issue asking to enable USE_PDF_LATEXMK (https://docs.readthedocs.io/en/latest/guides/feature-flags.html)

Thanks!

@skirpichev
Copy link
Contributor

If you want to test/try this new feature in your project, please open a new issue asking to enable

Ok, thank you for the explanation, see #5494.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Community Effort Improvement Minor improvement to code Needed: patch A pull request is required
Projects
None yet
Development

Successfully merging a pull request may close this issue.