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

Mitre/miter line join spelling

jcaldera314 opened this issue · comments

In R base graphics, one can specify the linejoin="mitre" option. In tikz, however, this option is spelled "miter." Currently tikzDevice preserves the R spelling when it builds the tikz code. This will generate an error when trying to compile in LaTeX unless one corrects the spelling.

Hi @jcaldera314, could you please provide an example of code which does not work as expected?

I did the following without getting errors:

tikzDevice::tikz(file = "mitre.tex", width = 6, height = 3,
                 standAlone = TRUE)

plot(c(0, 0, 4, 0, 0), c(0, 1, 1.5, 2, 3), type="l", lwd=5, axes=FALSE,
     xlab=NA, ylab=NA, ljoin ="mitre")

dev.off()

I could compile the resulting mitre.tex file without errors (PDFLatex):

mitre

Hi @bellackn, thank you for looking into this. To replicate the error, you apparently have to use the "lmitre=n" option. Modifying your example in the following way should elicit the problem:

tikzDevice::tikz(file = "mitre.tex", width = 6, height = 3,
                 standAlone = TRUE)

plot(c(0, 0, 4, 0, 0), c(0, 1, 1.5, 2, 3), type="l", lwd=5, axes=FALSE,
     xlab=NA, ylab=NA, ljoin ="mitre", lmitre=25)

dev.off()

Interestingly, it looks like your original example didn't generate the error because without the lmitre option it didn't even attempt to implement mitre joins in the first place.

Hi @jcaldera314 , sorry for the late reply. You were right, setting lmitre elicited the error. This will be fixed in the next development release, thanks for reporting this!
Until then, you can just correct the spelling in the resulting *.tex file, as you already mentioned in your initial posting.

The fix for this was just merged into the master branch, @jcaldera314. Thanks again for reporting!

Thank you, @bellackn! Happy to help!