daqana / tikzDevice

A R package for producing graphics output as PGF/TikZ code for use in TeX documents.
https://daqana.github.io/tikzDevice
132 stars 26 forks source link

Mitre/miter line join spelling #178

Closed jcaldera314 closed 5 years ago

jcaldera314 commented 6 years ago

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.

bellackn commented 5 years ago

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

jcaldera314 commented 5 years ago

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.

bellackn commented 5 years ago

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.

bellackn commented 5 years ago

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

jcaldera314 commented 5 years ago

Thank you, @bellackn! Happy to help!