-
-
Notifications
You must be signed in to change notification settings - Fork 878
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
Assign default id to each fig for html output #2169
Comments
I've added a chunk option Detailed documentation at https://yihui.org/knitr/options/ |
Fantastic! This works nicely :) Thanks for the implementation, @yihui ! |
@yihui -- I was wondering if you would mind advising me how to obtain current function(options) {
id <- sprintf("%s%s-%s", options$fig.lp, options$label, options$fig.cur)
id <- xfun::alnum_id(id)
} |
I'm not sure what your use case is, but I'm afraid it would be too late for |
This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary. |
I am not sure whether this is a reasonable feature request, but it would be great if
knitr
could assign defaultid
attribute to each fig element for html output. I think the best default would be the same as image file name (chunk label and fig.cur suffix).There would be many possible use cases, but I am working on accessibility manipulation and accessing to id attribute is necessary.
In #2163, @yihui kindly explained how to assign
id
the same asoptions$label
to out.extra via knitr hooks, however, that way cannot assign uniqueid
value for sub-figs plotted within the same chunk.I assume that I can employ
fig.cur
andfig.num
options to address this, but I need more time to figure out how to make them work.In the following code example, fig.num and fig.cur options return NULL instead of specific figure numbers.
Therefore, I cannot assign unique suffix to each sub-fig via knitr hooks:
The text was updated successfully, but these errors were encountered: