stat_poly_eq() fails when used with tikzDevice using ?plotmath annotation. "italic(hat(y))~`=`~"

Create issue
Issue #1 resolved
Former user created an issue

Pedro,

An interesting problem came up on StackOverflow:

Essentially, if you try to use stat_poly_eq() in conjunction with tikzDevice::tikz() to try to produce latex output you get an error in the .tex file output process.

 log output:

Measuring dimensions of: \itshape ^ \documentclass[10pt]{article}

\usepackage{tikz}

\usepackage[active,tightpage,psfixbb]{preview}

\PreviewEnvironment{pgfpicture}

\setlength\PreviewBorder{0pt}

\usepackage[T1]{fontenc}

\usetikzlibrary{calc}

\batchmode \begin{document} \begin{tikzpicture} \node[inner sep=0pt, outer sep=0pt, scale=1.104] (TeX) {\itshape ^}; \path let \p1 = ($(TeX.east) - (TeX.west)$), \n1 = {veclen(\x1,\y1)} in (TeX.east) -- (TeX.west) node{ \typeout{tikzTeXWidth=\n1} }; \makeatletter \@@end This is pdfTeX, Version 3.14159265-2.6-1.40.16 (TeX Live 2015) (preloaded format=pdflatex 2015.11.22) 22 MAY 2016 12:10 entering extended mode restricted \write18 enabled. %&-line parsing enabled. **/private/var/folders/md/03gdc4c14z18kbqwpfh4jdfc0000gp/T/Rtmpbda96N/tikzStrin gWidthCalc.tex

(/private/var/folders/md/03gdc4c14z18kbqwpfh4jdfc0000gp/T/Rtmpbda96N/tikzString WidthCalc.tex LaTeX2e <2015/10/01> patch level 2 Babel <3.9m> and hyphenation patterns for 79 languages loaded. (/usr/local/texlive/2015/texmf-dist/tex/latex/base/article.cls Document Class: article 2014/09/29 v1.4h Standard LaTeX document class (/usr/local/texlive/2015/texmf-dist/tex/latex/base/size10.clo File: size10.clo 2014/09/29 v1.4h Standard LaTeX file (size option) ) \c@part=\count79 \c@section=\count80 \c@subsection=\count81 \c@subsubsection=\count82 \c@paragraph=\count83 \c@subparagraph=\count84 \c@figure=\count85 \c@table=\count86 \abovecaptionskip=\skip41 \belowcaptionskip=\skip42 \bibindent=\dimen102 ) (/usr/local/texlive/2015/texmf-dist/tex/latex/pgf/frontendlayer/tikz.sty (/us r/local/texlive/2015/texmf-dist/tex/latex/pgf/basiclayer/pgf.sty (/usr/local/te xlive/2015/texmf-dist/tex/latex/pgf/utilities/pgfrcs.sty (/usr/local/texlive/2015/texmf-dist/tex/generic/pgf/utilities/pgfutil-common.te x \pgfutil@everybye=\toks14 \pgfutil@tempdima=\dimen103 \pgfutil@tempdimb=\dimen104

(/usr/local/texlive/2015/texmf-dist/tex/generic/pgf/utilities/pgfutil-common-li sts.tex)) (/usr/local/texlive/2015/texmf-dist/tex/generic/pgf/utilities/pgfutil-latex.def \pgfutil@abb=\box26 (/usr/local/texlive/2015/texmf-dist/tex/latex/ms/everyshi.sty Package: everyshi 2001/05/15 v3.00 EveryShipout Package (MS) )) (/usr/local/texlive/2015/texmf-dist/tex/generic/pgf/utilities/pgfrcs.code.te x Package: pgfrcs 2015/08/07 v3.0.1a (rcs-revision 1.31) )) Package: pgf 2015/08/07 v3.0.1a (rcs-revision 1.15) (/usr/local/texlive/2015/texmf-dist/tex/latex/pgf/basiclayer/pgfcore.sty (/usr/ local/texlive/2015/texmf-dist/tex/latex/graphics/graphicx.sty Package: graphicx 2014/10/28 v1.0g Enhanced LaTeX Graphics (DPC,SPQR) (/usr/local/texlive/2015/texmf-dist/tex/latex/graphics/keyval.sty Package: keyval 2014/10/28 v1.15 key=value parser (DPC) \KV@toks@=\toks15 ) (/usr/local/texlive/2015/texmf-dist/tex/latex/graphics/graphics.sty Package: graphics 2014/10/28 v1.0p Standard LaTeX Graphics (DPC,SPQR) (/usr/local/texlive/2015/texmf-dist/tex/latex/graphics/trig.sty Package: trig 1999/03/16 v1.09 sin cos tan (DPC) ) (/usr/local/texlive/2015/texmf-dist/tex/latex/latexconfig/graphics.cfg File: graphics.cfg 2010/04/23 v1.9 graphics configuration of TeX Live ) Package graphics Info: Driver file: pdftex.def on input line 94. (/usr/local/texlive/2015/texmf-dist/tex/latex/pdftex-def/pdftex.def File: pdftex.def 2011/05/27 v0.06d Graphics/color for pdfTeX (/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/infwarerr.sty Package: infwarerr 2010/04/08 v1.3 Providing info/warning/error messages (HO) ) (/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/ltxcmds.sty Package: ltxcmds 2011/11/09 v1.22 LaTeX kernel commands for general use (HO) ) \Gread@gobject=\count87 )) \Gin@req@height=\dimen105 \Gin@req@width=\dimen106 ) (/usr/local/texlive/2015/texmf-dist/tex/latex/pgf/systemlayer/pgfsys.sty (/usr/local/texlive/2015/texmf-dist/tex/generic/pgf/systemlayer/pgfsys.code.tex Package: pgfsys 2014/07/09 v3.0.1a (rcs-revision 1.48) (/usr/local/texlive/2015/texmf-dist/tex/generic/pgf/utilities/pgfkeys.code.tex \pgfkeys@pathtoks=\toks16 \pgfkeys@temptoks=\toks17

(/usr/local/texlive/2015/texmf-dist/tex/generic/pgf/utilities/pgfkeysfiltered.c ode.tex \pgfkeys@tmptoks=\toks18 )) \pgf@x=\dimen107 \pgf@y=\dimen108 \pgf@xa=\dimen109 \pgf@ya=\dimen110 \pgf@xb=\dimen111 \pgf@yb=\dimen112 \pgf@xc=\dimen113 \pgf@yc=\dimen114 \w@pgf@writea=\write3 \r@pgf@reada=\read1 \c@pgf@counta=\count88 \c@pgf@countb=\count89 \c@pgf@countc=\count90 \c@pgf@countd=\count91 \t@pgf@toka=\toks19 \t@pgf@tokb=\toks20 \t@pgf@tokc=\toks21 (/usr/local/texlive/2015/texmf-dist/tex/generic/pgf/systemlayer/pgf.cfg File: pgf.cfg 2008/05/14 (rcs-revision 1.7) ) Driver file for pgf: pgfsys-pdftex.def

(/usr/local/texlive/2015/texmf-dist/tex/generic/pgf/systemlayer/pgfsys-pdftex.d ef File: pgfsys-pdftex.def 2014/10/11 (rcs-revision 1.35)

(/usr/local/texlive/2015/texmf-dist/tex/generic/pgf/systemlayer/pgfsys-common-p df.def File: pgfsys-common-pdf.def 2013/10/10 (rcs-revision 1.13) ))) (/usr/local/texlive/2015/texmf-dist/tex/generic/pgf/systemlayer/pgfsyssoftpath. code.tex File: pgfsyssoftpath.code.tex 2013/09/09 (rcs-revision 1.9) \pgfsyssoftpath@smallbuffer@items=\count92 \pgfsyssoftpath@bigbuffer@items=\count93 ) (/usr/local/texlive/2015/texmf-dist/tex/generic/pgf/systemlayer/pgfsysprotocol. code.tex File: pgfsysprotocol.code.tex 2006/10/16 (rcs-revision 1.4) )) (/usr/local/texlive/2015/texmf-dist/tex/latex/xcolor/xcolor.sty Package: xcolor 2007/01/21 v2.11 LaTeX color extensions (UK) (/usr/local/texlive/2015/texmf-dist/tex/latex/latexconfig/color.cfg File: color.cfg 2007/01/18 v1.5 color configuration of teTeX/TeXLive ) Package xcolor Info: Driver file: pdftex.def on input line 225. Package xcolor Info: Model cmy' substituted bycmy0' on input line 1337. Package xcolor Info: Model hsb' substituted byrgb' on input line 1341. Package xcolor Info: Model RGB' extended on input line 1353. Package xcolor Info: ModelHTML' substituted by rgb' on input line 1355. Package xcolor Info: ModelHsb' substituted by hsb' on input line 1356. Package xcolor Info: ModeltHsb' substituted by hsb' on input line 1357. Package xcolor Info: ModelHSB' substituted by hsb' on input line 1358. Package xcolor Info: ModelGray' substituted by gray' on input line 1359. Package xcolor Info: Modelwave' substituted by `hsb' on input line 1360. ) (/usr/local/texlive/2015/texmf-dist/tex/generic/pgf/basiclayer/pgfcore.code.tex Package: pgfcore 2010/04/11 v3.0.1a (rcs-revision 1.7) (/usr/local/texlive/2015/texmf-dist/tex/generic/pgf/math/pgfmath.code.tex (/usr /local/texlive/2015/texmf-dist/tex/generic/pgf/math/pgfmathcalc.code.tex (/usr/ local/texlive/2015/texmf-dist/tex/generic/pgf/math/pgfmathutil.code.tex) (/usr/local/texlive/2015/texmf-dist/tex/generic/pgf/math/pgfmathparser.code.tex \pgfmath@dimen=\dimen115 \pgfmath@count=\count94 \pgfmath@box=\box27 \pgfmath@toks=\toks22 \pgfmath@stack@operand=\toks23 \pgfmath@stack@operation=\toks24 ) (/usr/local/texlive/2015/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.code. tex (/usr/local/texlive/2015/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.basic .code.tex) (/usr/local/texlive/2015/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.trigo nometric.code.tex) (/usr/local/texlive/2015/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.rando m.code.tex) (/usr/local/texlive/2015/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.compa rison.code.tex) (/usr/local/texlive/2015/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.base. code.tex) (/usr/local/texlive/2015/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.round .code.tex) (/usr/local/texlive/2015/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.misc. code.tex) (/usr/local/texlive/2015/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.integ erarithmetics.code.tex))) (/usr/local/texlive/2015/texmf-dist/tex/generic/pgf/m ath/pgfmathfloat.code.tex \c@pgfmathroundto@lastzeros=\count95 )) (/usr/local/texlive/2015/texmf-dist/tex/generic/pgf/basiclayer/pgfcorepoints.co de.tex File: pgfcorepoints.code.tex 2013/10/07 (rcs-revision 1.27) \pgf@picminx=\dimen116 \pgf@picmaxx=\dimen117 \pgf@picminy=\dimen118 \pgf@picmaxy=\dimen119 \pgf@pathminx=\dimen120 \pgf@pathmaxx=\dimen121 \pgf@pathminy=\dimen122 \pgf@pathmaxy=\dimen123 \pgf@xx=\dimen124 \pgf@xy=\dimen125 \pgf@yx=\dimen126 \pgf@yy=\dimen127 \pgf@zx=\dimen128 \pgf@zy=\dimen129 ) (/usr/local/texlive/2015/texmf-dist/tex/generic/pgf/basiclayer/pgfcorepathconst ruct.code.tex File: pgfcorepathconstruct.code.tex 2013/10/07 (rcs-revision 1.29) \pgf@path@lastx=\dimen130 \pgf@path@lasty=\dimen131 ) (/usr/local/texlive/2015/texmf-dist/tex/generic/pgf/basiclayer/pgfcorepathusage .code.tex File: pgfcorepathusage.code.tex 2014/11/02 (rcError in getMetricsFromLatex(TeXMetrics, verbose = verbose) : TeX was unable to calculate metrics for the following string or character:

^

Common reasons for failure include: * The string contains a character which is special to LaTeX unless escaped properly, such as % or $. * The string makes use of LaTeX commands provided by a package and the tikzDevice was not told to load the package.

The contents of the LaTeX log of the aborted run have been printed above, it may contain additional details as to why the metric calculation failed. ```

Comments (5)

  1. Pedro J. Aphalo repo owner

    Done. Working in the latest commit here. See attached file for a simpler code that produces the desired figure.

  2. Log in to comment