Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recipes to convert tiktz figures to png #133

Closed
cderv opened this issue Nov 17, 2018 · 4 comments
Closed

Recipes to convert tiktz figures to png #133

cderv opened this issue Nov 17, 2018 · 4 comments
Labels
review later An issue which should be come back to at a later date

Comments

@cderv
Copy link
Collaborator

cderv commented Nov 17, 2018

I don't know if it is useful or not as I don't do a lot of Latex. I let you decide.

knit_hooks$set(tikz2png = function(before, options, envir) {
  # use this hook only for dev='tikz' and externalized tikz graphics
  if (before || options$dev != 'tikz' || !options$external || options$fig.num == 0) return()
  figs = knitr:::all_figs(options, ext = 'pdf')  # all figure names
  # note the tikz2png option is the extra parameters passed to 'convert'
  for (fig in figs) {
    system(sprintf('convert %s %s %s', options$tikz2png, fig, sub('\\.pdf$', '.png', fig)))
  }
})

https://github.com/yihui/knitr-examples/blob/master/047-tikz-png.Rnw

@dr-harper
Copy link
Contributor

I might put this in the category of "could be useful, but probably not for many people". @yihui wrote the original function so has the strongest opinion, so I will leave it open until he reviews it.

I see you have linked this to the knitrhooks so will probably let it rest there for now.

@dr-harper dr-harper added the review later An issue which should be come back to at a later date label Dec 3, 2018
@yihui
Copy link
Member

yihui commented Dec 3, 2018

I think it is useful, but I'd use the R magick package to do the conversion instead of requiring users to install ImageMagick.

@dr-harper
Copy link
Contributor

Thanks for the input! I will check out the magick package. Installing ImageMagick was one of the things putting me off from the original solution.

@yihui
Copy link
Member

yihui commented Apr 29, 2020

@yihui yihui closed this as completed Apr 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
review later An issue which should be come back to at a later date
Projects
None yet
Development

No branches or pull requests

3 participants