Wrong `\includegraphics` image path at creating LaTeX output
ChromatinRemodeling opened this issue · comments
If I link an image in a deep directory, say, docs/src/buggy/buggyagain/
, instead of
\includegraphics[max width=\linewidth]{buggy/buggyagain/bugtest.png}
the makedocs
function will generate
\includegraphics[max width=\linewidth]{buggy\buggyagain\bugtest.png}
in a .tex document, which will produce an error when compiled.
A rather simple MWE can be seen in here.
This issue seems to be caused by the incorrect handling of image.path
in the function below:
Documenter.jl/src/latex/LaTeXWriter.jl
Lines 681 to 694 in deecbd7
PS: I am using Windows. Here's my versioninfo()
:
julia> versioninfo()
Julia Version 1.10.0
Commit 3120989f39 (2023-12-25 18:01 UTC)
Build Info:
Official https://julialang.org/ release
Platform Info:
OS: Windows (x86_64-w64-mingw32)
CPU: 16 × AMD Ryzen 7 5800H with Radeon Graphics
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-15.0.7 (ORCJIT, znver3)
Threads: 1 on 16 virtual cores
Environment:
JULIA_CONDAPKG_BACKEND = Null
JULIA_PKG_SERVER = https://pkg.julialang.org
JULIA_PYTHONCALL_EXE = D:\Programs\mambaforge\envs\torch\python.exe
JULIA_EDITOR = code
JULIA_NUM_THREADS =
Note: replace(image.path, '\\' => '/')
would be a quick fix in most cases.
Yeah, this looks like missing handling of the windows path separator. We do such replacements in other places, so might just be an oversight.
Which platform
are you using though? I am surprised that Windows native TeX wouldn't be able to handle the \
separator?
I am not sure what you mean by platform
? I am using MiKTeX on Windows, if this is the information you want to know.
You can pass the platform
keyword to LaTeX
to switch to e.g. a Docker-based approach or Tectonic. But you're just relying on the standard pdflatex
and latexmk
in your Windows PATH
then I presume?
Oh I see.
I provided a minimum example here. I use platform = "none"
. The full makedocs
call is:
makedocs(remotes = nothing, sitename = "test",
format = Documenter.LaTeX(platform = "none"),
pages = ["Home" => "index.md", "Buggy" => Any["BuggingMe" => "buggy/buggyagain/buggy.md"]],
build = "build-pdf")
Then I manually compile the .tex file using the standard pdflatex
and latexmk
in my Windows PATH.
I did try Docker. There's no problem with the juliadocs/documenter-latex
Docker. But I didn't try Tectonic.
I also tried to not pass the platform
keyword. Then the compilation of the .tex file failed. If I track down the .tex file that Julia produced, I see the \
path separator in image path instead of /
.
According to this stackexchange answer, the LaTeX paths should always be /
, so I think we should do the replacements. Would be happy to review a PR -- just need to find the right lines in https://github.com/JuliaDocs/Documenter.jl/blob/master/src/latex/LaTeXWriter.jl