【问题标题】:Knitr and tikzDevice not working together with article optionsKnitr 和 tikzDevice 不能与文章选项一起使用
【发布时间】:2013-04-04 02:46:35
【问题描述】:

我对@9​​87654322@ 和tikzDevice 有疑问,就像我之前的人一样。 (参见https://tex.stackexchange.com/questions/106057/tikzdevice-is-not-getting-sizes-right-knitr/106595#106595 。)他使用dev.args 来消除这个错误,但是如果我通过knitr 运行这段代码(使用rstudio),字体大小仍然是一团糟。 dev.args=list(pointsize=12) 对我不起作用。唯一有效的方法是删除a4paper,12pt。关于我做错了什么有什么想法吗?

\documentclass[a4paper,12pt]{scrartcl}
\begin{document}

\begin{figure}
<<dev='tikz', dev.args=list(pointsize=12)>>=
x<-1
plot(x)
@
\end{figure}

\end{document}

【问题讨论】:

    标签: font-size knitr tikz


    【解决方案1】:

    这原来是tikzDevice 包的一个错误,它一直是reported long time ago(但仍未修复)。问题是用于检测点大小的正则表达式错误(他们应该使用pt 而不是[pt]):

    > tikzDevice:::getDocumentPointsize
    function (docString) 
    {
        psLocation <- regexpr("\\d+[pt]", docString, ignore.case = T, 
            perl = T)
        if (psLocation == -1) {
            return(NA)
        }
        else {
            pointsize <- substr(docString, psLocation, psLocation + 
                attr(psLocation, "match.length") - 2)
            return(as.numeric(pointsize))
        }
    }
    

    有多种方法可以解决此问题。当然,最好的方法是在tikzDevice 中修复它。在此之前,您可以使用这个简单的技巧:

    \documentclass[12pt,a4paper]{scrartcl}
    

    也就是说,将12pta4paper 切换,以便可以检测到12 而不是4

    【讨论】:

    • 一辉,你成就了我的一天。谢谢你,先生。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-01-18
    • 1970-01-01
    • 2016-06-23
    • 1970-01-01
    • 2017-03-03
    • 2019-08-20
    • 2016-05-29
    相关资源
    最近更新 更多