mkoohafkan / kfigr

A streamlined cross-referencing package designed specifically for use with knitr.
GNU General Public License v3.0
25 stars 10 forks source link

Link not displayed in PDF #7

Closed ismayc closed 7 years ago

ismayc commented 9 years ago

I'm trying to use kfigr to produce links to figures/chunks, but when I Knit PDF using knitr only the figure/chunk number is shown and not the link to the figure. It works just fine when I Knit HTML, but I'd like to use this on a PDF.

mkoohafkan commented 9 years ago

Hi ismayc,

kfigr does not currently support PDF documents; if you look at the code, you can see that it writes HTML tags to do the anchoring/cross-referencing. I'm considering adding LaTeX/PDF support and it should be fairly straight-forward (just need a switch to detect the output format and write LaTeX instead of HTML), but it's hard to find the time---if you feel like contributing this functionality yourself it probably wouldn't actually be too tough.

If you are writing in markdown and going to PDF using rmarkdown, that's actually a pandoc issue rather than a kfigr issue. pandoc does a lot of non-standard things with markdown and is still under active development, so it's too large of a burden to support for pandoc in kfigr. You may want to check out the captioner package, which apparently supports pandoc (although I have not used it).

ismayc commented 9 years ago

Thanks, @mkoohafkan! I think I'm going to try out the pandoc route: https://github.com/lierdakil/pandoc-crossref . I am using rmarkdown to PDF using a custom LaTeX template and was hoping to avoid messing around more with pandoc if possible, but I'll check it out.

mkoohafkan commented 9 years ago

If you are writing an Rnw file (dynamic document in LaTeX) you might want to consider just using Latex's built-in support for cross-referencing. You can embed a plot-producing code chunk inside a figure environment and anchor/cross-reference with \label and \ref, respectively. Good luck!

ismayc commented 9 years ago

I'm writing Rmd files and then converting to either HTML or PDF based on an rticles template. I've done the Rnw and LaTeX stuff in the past, but would like to stay away from using LaTeX code as much as possible. Thanks for the well wishes and for this cool package! I'll certainly be using this with HTML documents I produce.