Title: | Integrated Code Chunk Anchoring and Referencing for R Markdown Documents |
Version: | 1.2.1 |
Author: | Michael C Koohafkan [aut, cre] |
Maintainer: | Michael C Koohafkan <michael.koohafkan@gmail.com> |
Description: | A streamlined cross-referencing system for R Markdown documents generated with 'knitr'. R Markdown is an authoring format for generating dynamic content from R. 'kfigr' provides a hook for anchoring code chunks and a function to cross-reference document elements generated from said chunks, e.g. figures and tables. |
Depends: | R (≥ 3.1.0) |
Imports: | stats, knitr (≥ 1.6) |
Suggests: | ggplot2, markdown |
VignetteBuilder: | knitr |
License: | GPL (≥ 3) |
URL: | https://github.com/mkoohafkan/kfigr |
BugReports: | https://github.com/mkoohafkan/kfigr/issues |
RoxygenNote: | 7.1.1 |
Encoding: | UTF-8 |
NeedsCompilation: | no |
Packaged: | 2021-06-10 03:25:39 UTC; michael |
Repository: | CRAN |
Date/Publication: | 2021-06-10 04:50:05 UTC |
Integrated Code Chunk Anchoring and Referencing for R Markdown Documents
Description
A streamlined cross-referencing system for R Markdown documents
generated with 'knitr'. It provides the chunk hook anchor
and a cross-referencing function figr
. See the vignette to
get started.
Anchor Information
Description
Retrieves diagnostics such as the anchor index and history. Use for code verification and troubleshooting. Also used internally by kfigr.
Usage
anchors(tag)
Arguments
tag |
Optional specification of return type. |
Value
If tag = "index"
, a dataframe listing all anchored chunks. If
tag = "history"
, a dataframe listing all references made, in order.
If the value of tag
matches a specific type
, all references
of that type
are provided in a list. If tag
is missing, all
references of all types are provided in a nested list.
Examples
figr("foo", type="figure")
figr("bar", type="table")
figr("test", type="figure")
anchors()
Code Chunk Reference
Description
Reference a code chunk.
Usage
figr(label, prefix, link, type)
Arguments
label |
The code chunk label. |
prefix |
Logical: return the prefix (chunk type) along with the rank. |
link |
### Logical: Place an HTML link to the anchor? |
type |
The type of the referenced chunk. |
Value
A text or url reference to the code chunk.
Examples
figr("test", type="reference")
figr("test")
figr("test", TRUE, link=FALSE)
if(interactive()){
require(knitr)
opts_knit$set(kfigr.prefix=TRUE, kfigr.link=TRUE)
figr("test")
}
Anchor Chunk Hook Extension for package:knitr
Description
knitr hook functions are called when the corresponding chunk options
are not NULL
to do additional jobs beside the R code in chunks.
kfigr provides the hook "anchor" which adds an HTML anchor tag
immediately above a code chunk.
Usage
hook_anchor(before, options, envir)
Arguments
before , options , envir |
see references |
Details
the function hook_anchor is set as a hook in knitr when
kfigr is attached (and removed when kfigr is detached). It
writes an HMTL anchor tag directly above a code chunk in the form
<a name="chunk-name"></a>
where chunk-name
is the chunk
label contained in options$label
.
References
http://yihui.org/knitr/hooks#chunk-hooks
See Also
Examples
## Not run:
require(knitr)
knit_hooks$set(anchor = hook_anchor)
# then in code chunks, use e.g. the option anchor = "figure"
## End(Not run)
Chunk Indexing
Description
(Internal) index a chunk. Should not be called by the user directly.
Usage
index(label, type)
Arguments
label |
The chunk label. |
type |
The type of chunk to be indexed. |
Value
The rank of the indexed chunk.