mossr / julia-mono-listings

LaTeX listings style for Julia and Unicode support for the JuliaMono font
Other
52 stars 9 forks source link

Error: I can't find file `JuliaMono-Regular'. #11

Open GiggleLiu opened 1 year ago

GiggleLiu commented 1 year ago

I tried to compile the example/example.tex on my local host, but got the following error message.

$ latexmk -xelatex example.tex
...
kpathsea: Running mktexmf JuliaMono-Regular
! I can't find file `JuliaMono-Regular'.
<*> ...:=1; ; nonstopmode; input JuliaMono-Regular

Please type another input file name
! Emergency stop.
<*> ...:=1; ; nonstopmode; input JuliaMono-Regular

Transcript written on mfput.log.
grep: JuliaMono-Regular.log: No such file or directory
mktextfm: `mf-nowin -progname=mf \mode:=ljfour; mag:=1; ; nonstopmode; input JuliaMono-Regular' failed to make JuliaMono-Regular.tfm.
kpathsea: Appending font creation commands to missfont.log.

! Package fontspec Error: The font "JuliaMono-Regular" cannot be found.

For immediate help type H <return>.
 ...                                              

l.9 \newfontface
                \JuliaMonoBold{JuliaMono-Bold}

I have copied the example.tex file into the root folder, so there is a JuliaMono-Regular.ttf file in the compiling folder.

$ ls
example              example.tex                 JuliaMono-Bold.ttf     missfont.log
example.aux          img                         JuliaMono-Medium.ttf   README.md
example.fdb_latexmk  julia_font.tex              JuliaMono-Regular.log  test
example.fls          julia_listings.tex          JuliaMono-Regular.ttf
example.log          julia_listings_unicode.tex  LICENSE.md

Need some help to get over the error.

rikhuijzer commented 1 year ago

According to https://github.com/mossr/julia-mono-listings/blob/master/julia_font.tex, the path is specified relatively for JuliaMono, so maybe you are not in the right folder when running latexmk.

Alternatively, what you can try to do is to remove the path specification and install the font JuliaMono globally on your system.

GiggleLiu commented 1 year ago

Thanks for the reply. The path of the ttf file is maybe correct. If I remove the ttf file, the error is different. Or do you have any suggested changes? My file structure is as above.

I did not install the ttf file because I wish the project can be compiled on different machines. I can do that if there is no elegant solutions to the path issue.

rikhuijzer commented 1 year ago

If I remove the ttf file, the error is different.

That's an interesting observation. Can you try compiling with tectonic --print <input>? It probably won't change much but maybe it's good to check anther build system.

Can you also try specifying an absolute path for Path in julia_font.tex? Make sure to append a trailing slash (I don't know why but that's necessary).

I did not install the ttf file because I wish the project can be compiled on different machines. I can do that if there is no elegant solutions to the path issue.

In Books.jl, I'm interpolating the absolute path to JuliaMono inside the template.tex and that works (https://github.com/JuliaBooks/Books.jl/blob/a9cfb52e81cd6d554b3406cd40e0e67ed48032e1/defaults/template.tex#L48-L53) reliably on multiple systems including MacOS and Linux, so your plan should also work. Debugging LaTeX is a pain though. For me what worked was lots of trial and error.

dpo commented 1 year ago

@GiggleLiu I had the same error and this worked for me:

diff --git a/julia-mono-listings.sty b/julia-mono-listings.sty
index cac02d0..a29e400 100644
--- a/julia-mono-listings.sty
+++ b/julia-mono-listings.sty
@@ -19,7 +19,6 @@
 \newfontfamily\JuliaMono{JuliaMono}[
     UprightFont = *-Regular,
     BoldFont = *-Bold,
-    Path = ./,
     Extension = .ttf]
 \newfontface\JuliaMonoRegular{JuliaMono-Regular}
 \newfontface\JuliaMonoBold{JuliaMono-Bold}