JuliaDocs / Documenter.jl

A documentation generator for Julia.
https://documenter.juliadocs.org
MIT License
799 stars 476 forks source link

Is it possible to add an options to use other latex engines? #1341

Open likanzhan opened 4 years ago

likanzhan commented 4 years ago

My documents include Mandarin Chinese characters. So I'm wondering whether it is possible to add an argument to allowing switching latex engines?

Thanks.

mortenpi commented 4 years ago

What exactly would you like to change about the LaTeX call? If Chinese characters are not getting rendered it might actually be a font issue?

likanzhan commented 4 years ago

@mortenpi

  1. In a normal .tex file, I need to load the \usepackage{ctex} in the preamble and use the xelatex engine to compile the file.

  2. I intend to test whether engine xelatex works or not. I change the peperun from lualatex to xelatex:

piperun(`latexmk -f -interaction=nonstopmode -view=none -xelatex -shell-escape $texfile`)
  1. But I get the following error
    
    localhost:~ lzhan$ julia /Users/lzhan/Downloads/ZL/docs/make.jl

[ Info: SetupBuildDirectory: setting up build directory. [ Info: Doctest: running doctests. [ Info: ExpandTemplates: expanding markdown templates. [ Info: CrossReferences: building cross-references. [ Info: CheckDocument: running document checks. [ Info: Populate: populating indices. [ Info: RenderDocument: rendering document. [ Info: LaTeXWriter: rendering PDF. [ Info: LaTeXWriter: using latexmk to compile tex. localhost:~ lzhan$ julia /Users/lzhan/Downloads/ZL/docs/make.jl [ Info: SetupBuildDirectory: setting up build directory. [ Info: Doctest: running doctests. [ Info: ExpandTemplates: expanding markdown templates. [ Info: CrossReferences: building cross-references. [ Info: CheckDocument: running document checks. [ Info: Populate: populating indices. [ Info: RenderDocument: rendering document. [ Info: LaTeXWriter: rendering PDF. [ Info: LaTeXWriter: using latexmk to compile tex. ┌ Error: LaTeXWriter: failed to compile tex with latexmk. Logs and partial output can be found in /var/folders/qz/0srg88cd2459h1cbn623wrt00000gq/T/jl_e3R1H8. │ exception = │ failed process: Process(latexmk -f -interaction=nonstopmode -view=none -xelatex -shell-escape TEST.tex, ProcessExited(12)) [12] │ └ @ Main ~/Downloads/ZL/contrib/LaTeXWriter.jl:19 ERROR: LoadError: Compiling the .tex file failed. See logs for more information. Stacktrace: [1] error(::String) at ./error.jl:33 [2] (::Documenter.Writers.LaTeXWriter.var"#5#8"{Documenter.Documents.Document,Documenter.Writers.LaTeXWriter.LaTeX})() at /Users/lzhan/.julia/packages/Documenter/PLD7m/src/Writers/LaTeXWriter.jl:153 [3] cd(::Documenter.Writers.LaTeXWriter.var"#5#8"{Documenter.Documents.Document,Documenter.Writers.LaTeXWriter.LaTeX}, ::String) at ./file.jl:104 [4] (::Documenter.Writers.LaTeXWriter.var"#4#7"{Documenter.Documents.Document,Documenter.Writers.LaTeXWriter.LaTeX})(::String) at /Users/lzhan/.julia/packages/Documenter/PLD7m/src/Writers/LaTeXWriter.jl:100 [5] mktempdir(::Documenter.Writers.LaTeXWriter.var"#4#7"{Documenter.Documents.Document,Documenter.Writers.LaTeXWriter.LaTeX}, ::String; prefix::String) at ./file.jl:682 [6] mktempdir at ./file.jl:680 [inlined] (repeats 2 times) [7] render(::Documenter.Documents.Document, ::Documenter.Writers.LaTeXWriter.LaTeX) at /Users/lzhan/.julia/packages/Documenter/PLD7m/src/Writers/LaTeXWriter.jl:98 [8] runner(::Type{Documenter.Writers.LaTeXFormat}, ::Documenter.Writers.LaTeXWriter.LaTeX, ::Documenter.Documents.Document) at /Users/lzhan/.julia/packages/Documenter/PLD7m/src/Writers/Writers.jl:41 [9] dispatch(::Type{Documenter.Writers.FormatSelector}, ::Documenter.Writers.LaTeXWriter.LaTeX, ::Vararg{Any,N} where N) at /Users/lzhan/.julia/packages/Documenter/PLD7m/src/Utilities/Selectors.jl:167 [10] render(::Documenter.Documents.Document) at /Users/lzhan/.julia/packages/Documenter/PLD7m/src/Writers/Writers.jl:107 [11] runner(::Type{Documenter.Builder.RenderDocument}, ::Documenter.Documents.Document) at /Users/lzhan/.julia/packages/Documenter/PLD7m/src/Builder.jl:245 [12] dispatch(::Type{Documenter.Builder.DocumentPipeline}, ::Documenter.Documents.Document) at /Users/lzhan/.julia/packages/Documenter/PLD7m/src/Utilities/Selectors.jl:167 [13] #2 at /Users/lzhan/.julia/packages/Documenter/PLD7m/src/Documenter.jl:240 [inlined] [14] cd(::Documenter.var"#2#3"{Documenter.Documents.Document}, ::String) at ./file.jl:104 [15] #makedocs#1 at /Users/lzhan/.julia/packages/Documenter/PLD7m/src/Documenter.jl:239 [inlined] [16] top-level scope at /Users/lzhan/Downloads/ZL/docs/make.jl:7 [17] include(::Module, ::String) at ./Base.jl:377 [18] exec_options(::Base.JLOptions) at ./client.jl:288 [19] _start() at ./client.jl:484 in expression starting at /Users/lzhan/Downloads/ZL/docs/make.jl:7

fredrikekre commented 4 years ago

The easiest might be to have an option to change the docker image.

fredrikekre commented 4 years ago

See https://github.com/JuliaDocs/Documenter.jl/issues/979

likanzhan commented 4 years ago

@fredrikekre Thanks, if I want to the option platform = native and want to use the xelatex engine, what is the correct way to manually set this?

I've tried to edit the latexwriter.jl from

piperun(`latexmk -f -interaction=nonstopmode -view=none -lualatex -shell-escape $texfile`)

to

piperun(`latexmk -f -interaction=nonstopmode -view=none -xelatex -shell-escape $texfile`)

But I got the errors mentioned above.

Any suggestion to correct this?

Thanks.

fredrikekre commented 4 years ago

I guess you have to look at the logs to really see what the problem was.

mortenpi commented 4 years ago

FWIW, with #1339 it will be possible to easily extract the compiled TeX files and then experiment with build commands.

Regarding the issue, I'd say that if someone needs it, it would not hurt being able to pass customized compilation commands to LaTeX. It should be reasonably straightforward to generalize compile_tex for this.

likanzhan commented 4 years ago

@mortenpi

To extract the compile TeX files is very helpful. And It seems that my problems is indeed related to fonts.

It is strange, however, why no error is observed when the latex engine is lualatex.

BambOoxX commented 8 months ago

I think I have found a way to make "native" more generic than latexmk. I will try to propose a PR this week-end.