[Tikzdevice-bugs] getMetrics error

Berner Larsen Berner.Larsen at uin.no
Tue Aug 2 09:48:25 CEST 2011


I got the same getMetrics error as is described in the message from Anh Nguyen eatabanana at gmail.com <mailto:tikzdevice-bugs%40lists.r-forge.r-project.org?Subject=Re%3A%20%5BTikzdevice-bugs%5D%20getMetrics%20error&In-Reply-To=%3CAANLkTik5uuZhyPcuWt7B2X9q%2B6%3DrEfFw8e3Qp9zMD7W7%40mail.gmail.com%3E> 

Mon Mar 7 22:47:10 CET 2011. I do not think that the problem is the use of pdflatex instead of xelatex or the Zapfino font as is described in the answer from Sharpie chuck at sharpsteen.net <mailto:tikzdevice-bugs%40lists.r-forge.r-project.org?Subject=Re%3A%20%5BTikzdevice-bugs%5D%20getMetrics%20error&In-Reply-To=%3C1260540.3450.1299563468356.JavaMail.geo-discussion-forums%40prgz35%3E> Tue Mar 8 06:51:08 CET 2011.

 

I think the problem is the string "%\n" in line 364 in the source file latexStrWidth.R of tikzDevice. In the file error-output.txt we see the result of these two characters in latexStrWidth.R as "%" at the end of line 35 and a line break. The % character starts a Latex comment and the end of line character finishes a Latex comment. However, the line break character \n is not (at least in this case)  recognized in Windows as the end of line character which imply that the next } is interpreted as a part of the comment, so the Latex run is aborted due to a missing }. The character \n is the end of line character in the UNIX world, but in Windows \r\n is the end of line character. Windows 7 seems to interpret \n as end of line more often than Windows XP, as the getMetrics error occurs more often on my home PC with Windows XP than on my office PC with Windows 7. E.g. on my office PC,  plot(1:15,main="{-1.5%\vab}") gives a getMetrics error when pgfSweave is run, while plot(1:15,main="{-1.5%\rab}") gives the title "-1.5ab" as expected.

 

As a check of my hypothesis,  I downloaded the source code of version 0.6.1 of the tikzDevice package from CRAN, deleted the character string "%\n" from line 364 in latexStrWidth.R and installed this modified version of the tikzDevice package, and afterwards  I did not get the getMetrics error  described in the file error-output.txt when I ran pgfSweave on my home PC with Windows XP.

 

Naturally, a getMetrics error may occur due to another reason than the bug described above. There are at least two another reasons why a getMetrics error may occur:

1.      When MiKTeX 2.9 is installed the default MiKTeX option of "Install missing packages on-the fly" is "Ask me first". A better choice is probably "Yes". This is due to the fact that when tikzDevice computes the Latex string width it calls Latex and uses the Latex package "preview" which is not part of the basic MiKTeX installation. (I think few persons install the complete MiKTeX system as this is very time and disc consuming.) The pdflatex run is aborted if the preview package is not present and a getMetrics error occurs.

2.      A TeX string with a syntax error, e.g. a missing } or $ or an undefined control sequence, will also cause a getMetrics error.

 

 

 

Berner Larsen                                                 

Tel: +47 75517282     /  +47 48121112

Berner.Larsen at uin.no <mailto:navn.navnesen at uin.no> 

http://www.uin.no <http://www.uin.no/> 


Bodø Graduate School of Business

 

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: error-output.txt
URL: <http://lists.r-forge.r-project.org/pipermail/tikzdevice-bugs/attachments/20110802/9990d7a5/attachment-0001.txt>


More information about the Tikzdevice-bugs mailing list