daqana / tikzDevice

A R package for producing graphics output as PGF/TikZ code for use in TeX documents.

Home Page:https://daqana.github.io/tikzDevice

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

(another) TeX was unable to calculate metrics for the following string or character: m

opened this issue · comments

I'm trying to use knitr with lualatex using (as far as I can tell) texlive 2016 (I'm working on updating it) on nixos with lyx 2.2.3 and I can't get the basic example working. I've attached my lyx file.

hu.zip

I've gone through the other related issues here but haven't managed to fix the problem.

I tried tikzTest("m") but I don't know how to get any useful information from it. Also I can't really tell how I'm supposed to be able to get to the output if Rscript removes any temporary files when it closes. I also can't really get the file paths either since they get truncated by the edge of the page in the pdf and I don't know how to deal with that either yet....

Thanks in advance... sigh

Here's my lyx log and the resulting pdf:

pdf.zip

11:44:34.031: Rscript --verbose --no-save --no-restore "/nix/store/n5jrsxhvk6wa2i1w9s8av4qvla66y17n-lyx-2.2.3/share/lyx/scripts/lyxknitr.R" "/run/user/1000/lyx_tmpdir.oVQgVarO9108/lyx_tmpbuf1/""hu.Rnw" "/run/user/1000/lyx_tmpdir.oVQgVarO9108/lyx_tmpbuf1/""hu.tex" UTF-8 "/mnt/data/egyetem2/6felev/labs/env/templates/lyx/"
11:44:34.035: running
11:44:34.036:   '/nix/store/gabn1nxvi6izdpic65basr2df66ib65l-R-3.4.1/lib/R/bin/R --slave --no-restore --no-save --no-restore --file=/nix/store/n5jrsxhvk6wa2i1w9s8av4qvla66y17n-lyx-2.2.3/share/lyx/scripts/lyxknitr.
11:44:34.038: R --args /run/user/1000/lyx_tmpdir.oVQgVarO9108/lyx_tmpbuf1/hu.Rnw /run/user/1000/lyx_tmpdir.oVQgVarO9108/lyx_tmpbuf1/hu.tex UTF-8 /mnt/data/egyetem2/6felev/labs/env/templates/lyx/'
11:44:34.039: 
11:44:34.349: 
11:44:34.350: 
11:44:34.352: processing file: /run/user/1000/lyx_tmpdir.oVQgVarO9108/lyx_tmpbuf1/hu.Rnw
11:44:34.447: 
  |                                                                       
  |                                                                 |   0%
  |                                             
11:44:34.448:                           
  |......................                                           |  33%
11:44:34.450:   ordinary text without R code
11:44:34.451: 
11:44:34.452: 
  |                                                                       
  |...........................................                      |  67%
11:44:34.453: label: cars-demo (with options) 
11:44:34.454: List of 4
11:44:34.455:  $ dev       : chr "tikz"
11:44:34.455:  $ fig.width : num 4
11:44:34.456:  $ fig.height: num 2.8
11:44:34.457:  $ out.width : chr ".45\\textwidth"
11:44:34.458: 
11:44:38.790: 
  |                                                                       
  |.................................................................| 100%
11:44:38.794:   ordinary text without R code
11:44:38.797: 
11:44:38.808: 
11:44:38.812: output file: /run/user/1000/lyx_tmpdir.oVQgVarO9108/lyx_tmpbuf1/hu.tex
11:44:38.815: 
11:44:38.819: [1] "/run/user/1000/lyx_tmpdir.oVQgVarO9108/lyx_tmpbuf1/hu.tex"
11:44:38.829: lualatex "hu.tex"
11:44:38.992: This is LuaTeX, Version 0.95.0 (Web2C 2016/NixOS.org) 
11:44:38.996:  restricted system commands enabled.
11:44:38.999: (./hu.tex
11:44:39.002: LaTeX2e <2016/03/31> patch level 1
11:44:39.005: Babel <3.9r> and hyphenation patterns for 1 language(s) loaded.
11:44:39.010: 
11:44:39.470: 
11:44:39.479: luaotfload | main : initialization completed in 0.109 seconds
11:44:41.104: Successful preview of format: PDF (LuaTeX)```

Would there be any way to improve the error reporting so that it's sufficient to look at the lyx log and not need to dig around deeply in files to get to the error messages?

Can you please try tikzTest() in the development version?

Here you go:
files.zip

* The original files also used the latest tikzDevice grabbed via remote::

Thanks. Could you please post the output of tikzTest()? I'm not sure how the .zip file is helpful.

Well, that was exactly one of my questions. I don't know how to get the output. The best I was able to get was what's in the PDF.

The temporary files get removed after Rscript finishes running. If I stop it from finishing quickly by adding something like system("sleep 30"); then I don't know the paths, because they are only written to the PDF.

What's the console output?

It's the same as in my first second post, sorry. :/

Can I please see the console output of tikzTest()?

Do you mean in R?

This is my current lyx console output:

01:36:59.639: Rscript --verbose --no-save --no-restore "/nix/store/n5jrsxhvk6wa2i1w9s8av4qvla66y17n-lyx-2.2.3/share/lyx/scripts/lyxknitr.R" "/run/user/1000/lyx_tmpdir.vpPcrSy16910/lyx_tmpbuf0/""HU.Rnw" "/run/user/1000/lyx_tmpdir.vpPcrSy16910/lyx_tmpbuf0/""HU.tex" UTF-8 "/mnt/data/egyetem2/6felev/labs/env/templates/lyx/"
01:36:59.643: running
01:36:59.645:   '/nix/store/gabn1nxvi6izdpic65basr2df66ib65l-R-3.4.1/lib/R/bin/R --slave --no-restore --no-save --no-restore --file=/nix/store/n5jrsxhvk6wa2i1w9s8av4qvla66y17n-lyx-2.2.3/share/lyx/scripts/lyxknitr.
01:36:59.646: R --args /run/user/1000/lyx_tmpdir.vpPcrSy16910/lyx_tmpbuf0/HU.Rnw /run/user/1000/lyx_tmpdir.vpPcrSy16910/lyx_tmpbuf0/HU.tex UTF-8 /mnt/data/egyetem2/6felev/labs/env/templates/lyx/'
01:36:59.648: 
01:37:00.000: 
01:37:00.000: 
01:37:00.001: processing file: /run/user/1000/lyx_tmpdir.vpPcrSy16910/lyx_tmpbuf0/HU.Rnw
01:37:00.108: 
  |                                                                       
  |                                                                 |   0%
  |                                             
01:37:00.110:                           
  |......................                                           |  33%
01:37:00.111:   ordinary text without R code
01:37:00.112: 
01:37:00.113: 
  |                                                                       
  |...........................................                      |  67%
01:37:00.114: label: example (with options) 
01:37:00.115: List of 3
01:37:00.116:  $ dev       : chr "tikz"
01:37:00.118:  $ cache.path: chr "aux/cache/"
01:37:00.119:  $ fig.path  : chr "aux/figure/"
01:37:00.119: 
01:37:00.651: This is LuaTeX, Version 1.0.4 (Web2C 2017/NixOS.org) 
01:37:00.655:  restricted system commands enabled.
01:37:00.778: 
01:37:00.785: luaotfload | main : initialization completed in 0.124 seconds
01:37:04.564: luaotfload | db : Reload initiated (formats: otf,ttf,ttc); reason: "File not found: lmroman12-regular.".
  |                                                                       
  |................
01:37:04.568: .................................................| 100%
01:37:04.571:   ordinary text without R code
01:37:04.575: 
01:37:04.588: 
01:37:04.592: output file: /run/user/1000/lyx_tmpdir.vpPcrSy16910/lyx_tmpbuf0/HU.tex
01:37:04.595: 
01:37:04.599: [1] "/run/user/1000/lyx_tmpdir.vpPcrSy16910/lyx_tmpbuf0/HU.tex"
01:37:04.609: lualatex "HU.tex"
01:37:04.755: This is LuaTeX, Version 1.0.4 (Web2C 2017/NixOS.org) 
01:37:04.759:  restricted system commands enabled.
01:37:04.783: (./HU.tex
01:37:04.789: LaTeX2e <2017-04-15>
01:37:04.793: (using write cache: /home/paprika/.texlive2017/texmf-var/luatex-cache/generic)(
01:37:04.796: using read cache: /nix/store/hkchzp15q9g74fy5vvjz375gnxkwbim0-texlive-combined-
01:37:04.800: full-2017/share/texmf-var/luatex-cache/generic /home/paprika/.texlive2017/texmf
01:37:04.879: -var/luatex-cache/generic)
01:37:04.884: luaotfload | main : initialization completed in 0.120 seconds
01:37:04.888: Babel <3.14> and hyphenation patterns for 1 language(s) loaded.
01:37:04.892: 
01:37:04.896: 
01:37:06.994: biber "HU"
01:37:07.827: INFO - This is Biber 2.7
01:37:07.833: INFO - Logfile is 'HU.blg'
01:37:07.838: INFO - Reading 'HU.bcf'
01:37:07.845: WARN - No data sources defined!
01:37:07.851: lualatex "HU.tex"
01:37:07.996: This is LuaTeX, Version 1.0.4 (Web2C 2017/NixOS.org) 
01:37:08.000:  restricted system commands enabled.
01:37:08.025: (./HU.tex
01:37:08.028: LaTeX2e <2017-04-15>
01:37:08.032: (using write cache: /home/paprika/.texlive2017/texmf-var/luatex-cache/generic)(
01:37:08.035: using read cache: /nix/store/hkchzp15q9g74fy5vvjz375gnxkwbim0-texlive-combined-
01:37:08.039: full-2017/share/texmf-var/luatex-cache/generic /home/paprika/.texlive2017/texmf
01:37:08.124: -var/luatex-cache/generic)
01:37:08.127: luaotfload | main : initialization completed in 0.124 seconds
01:37:08.132: Babel <3.14> and hyphenation patterns for 1 language(s) loaded.
01:37:08.136: 
01:37:08.139: 
01:37:10.211: Successful preview of format: PDF (LuaTeX)

I don't know what else you could mean by the console output of tikzTest(), unless you mean what it wrote to the PDF....

If you run tikzTest() in R, it should print useful information about your setup.

Ok I will do that. Wouldn't this be some kind of interaction problem with lyx/lualatex though?

That's what I'd like to find out.

Ok here's that log:

> library(tikzDevice)
> options(tikzDefaultEngine="luatex")
> tikzTest()

Active compiler:
	/nix/store/hkchzp15q9g74fy5vvjz375gnxkwbim0-texlive-combined-full-2017/bin/lualatex
	This is LuaTeX, Version 1.0.4 (Web2C 2017/NixOS.org)
	

Measuring dimensions of: A
Running command: '/nix/store/hkchzp15q9g74fy5vvjz375gnxkwbim0-texlive-combined-full-2017/bin/lualatex' -interaction=batchmode -halt-on-error -output-directory '/run/user/1000/Rtmpz6Oq2J/tikzDevice68003f02f711' '/run/user/1000/Rtmpz6Oq2J/tikzDevice68003f02f711/tikzStringWidthCalc.tex'
This is LuaTeX, Version 1.0.4 (Web2C 2017/NixOS.org) 
 restricted system commands enabled.

luaotfload | main : initialization completed in 0.119 seconds
luaotfload | db : Reload initiated (formats: otf,ttf,ttc); reason: "File not found: lmroman10-regular.".[1] 7.5

Thanks, tikzTest() doesn't see any problems. (The essential output is [1] 7.5 at the end, and the fact that it has run successfully. We might want to add a newline.)

@yihui: Do you have experience with LyX + knitr?

I forgot to mention because I was tired, but it does work if I don't use the tikz device.
Also I tried a simple switch to xetex and it has the same issue, so I think it might not be a lualatex problem.

Then again, I'm guessing not using the tikz device means its basically just including image/pdf output from R so there are no "callbacks" to latex for rendering info or something.

Is there anything helpful I can do to make progress with this?

I can try running your .lyx file. How do I do that?

You just open it in lyx and find the "render (pdflatex)" or "view" or something in one of the menus, I can't quite remember. There's also a toolbar icon for it. It's the eyes. I'd be more specific but I'm in the middle of building it so I can't run it right now.

Does anything seem to be missing?

Thanks. Can I run it from the command line?

@krlmlr have you had any luck with it?

When running lyx --export pdf4 HU.lyx on your document, I'm seeing:

This is LuaTeX, Version 1.0.4 (TeX Live 2017/Debian) 
 restricted system commands enabled.

! LaTeX Error: *** this package currently works only with XeTeX ***
 You are not using XeTeX, so we are exiting cleanly!
 Continuing may lead to 'unavailable font metrics' errors!
.

Changing to options(tikzDefaultEngine = "xetex") by editing your .lyx document in a text editor allowed me to compile it. Does that help?

Closing this issue since it appears to be resolved. Please feel free, if this is still an issue, to leave a comment requesting this issue be reopened.