Sharpie / RTikZDevice

A R package for producing graphics output as PGF/TikZ code for use in TeX documents.
32 stars 36 forks source link

fix getDocumentPointsize to work with "a4paper" documentclass option #61

Open corecode opened 12 years ago

corecode commented 12 years ago

The previous regexp would match any number that was followed by either "p" or "t" and use this as the document point size. This led to

\documentclass[a4paper]{artice}

being interpreted as a 4pt document. As a result, plotted figures wound up with grossly scaled font nodes (scale=3 or similar).

We instead want to only match digits at the beginning of a word, followed by the string "pt".

yihui commented 11 years ago

This is not a complete fix. I think you should use '\\<\\d+pt\\>' to avoid cases like 12ptabc. Accordingly there should be a change later in this function: increase 2 to 3 because pt has two characters

pointsize <- substr(docString, psLocation, psLocation + 
            attr(psLocation, "match.length") - 3)
corecode commented 11 years ago

Thanks, I fixed accordingly.