Comments (10)
I'm still having this issue with table captions using the following:
knitr::opts_chunk$set(echo = TRUE)
library(dplyr)
df <- data.frame(x = rep(1:2, each = 5),
y = rnorm(10))
df %>%
knitr::kable(., caption = "Good caption (no chunk label)")
df %>%
knitr::kable(., caption = "Bad caption (chunk label with period)")
df %>%
knitr::kable(., caption = "Bad caption (chunk label with underscore)")
The bad captions:
from distill.
https://haozhu233.github.io/kableExtra/using_kableExtra_in_radix.html
I just added a quick example of how to use kableExtra in radix. @MarcioFCMartins I hope it helps you feel better. :)
I really love the design of radix!
from distill.
o man! @jrgant thank you. I've been stuck on this issue and could not figure out why my captions were rendering (#tab:caption)
. Only populates correctly with a -
for spaces. No periods or underscores.
from distill.
Yeah, it's difficult to run down every table formatting package and imbue all of their output with correct behavior. So far we've focused on pagedtable and plain kable. We'd welcome contributions to help support others so long as they don't make our core codebase too complicated and/or fragile.
from distill.
Thank you for this post and the discussion. Changing my chunk label allowed the bookdown kable_extra rendered as PDF to correctly add table headings. You have helped my day so much. Thanks!
from distill.
Okay, I've modified the CSS for table captions to appear as follows:
Note that for kable
the caption always appears above the table by design: yihui/knitr#1189
In terms of the other cross references, this is a known limitation of bookdown cross-references: https://bookdown.org/yihui/bookdown/figures.html
I'll add a note about that to the documentation.
from distill.
kable captions are now working, but adding extra formatting via kableExtra::kable_styling still breaks it. Actually, simply loading the package breaks it unless the user setsoptions(kableExtra.auto_format = FALSE)
. This makes me believe that the issue is when the format is set to 'html' via this function.
I have no idea how pratical it is to ensure this formatting works for all package combinations (formattable comes to mind, since it works with kableExtra - https://haozhu233.github.io/kableExtra/use_kableExtra_with_formattable.html), but since kableExtra is recommended in the documentation (https://bookdown.org/yihui/rmarkdown/r-code.html#tables) I think it's worth ensuring it works.
The caption apearing above the table is proper scientific writing behaviour (atleast in most fields and from my experience) so that makes sense and it's exactly as I expect it.
I never realized that bookdown had that issue as well - thank you for the heads up and for the super quick fix - I will simply avoid extra table formatting until everything can be worked out.
from distill.
EDIT: I just submitted my proposed change as a pull request.
I noticed that you can actually break the caption formatting with the base kable
function if you set format to html
rather than pandoc
.
This is because in distill.html
you are setting the caption style for the pandoc table class individually. This means you need to ensure all tables have pandoc-table
class to correctly format their caption - and this has to be done for every package.
Wouldn't it be more efficient to set the style for the table>caption
element? This element is used to create the captions for all tables, regardless of their class (and the same is true for images, but you might want the ability to control the styles separatly).
I tried changing line 835 - currently $('.pandoc-table>caption').addClass("figcaption");
. Changing it to $('caption').parent('table').addClass("figcaption")
changes all table captions (regardless of being tagged as pandoc tables) to the same style as figcaption
.
You could also just set style for all captions, regardless of where they are used by removing the parent. If you have no need for differently formatted captions this might be the best.
from distill.
How do I change things like the caption colour and size, etc? There seems to be no documentation on this
from distill.
How do I change things like the caption colour and size, etc? There seems to be no documentation on this
You could probably use CSS for this - the exact CSS could depend on which format of table you are using. CSS and distill is documented in https://rstudio.github.io/distill/basics.html#theming and https://rstudio.github.io/distill/website.html#custom-style and https://rstudio.github.io/distill/website.html#theming
We don't have built in way to change this using variable, you need to use custom CSS for this.
Hope it helps
from distill.
Related Issues (20)
- Upkeep for distill
- Check and add alt-text to pictures, plots, ... in website
- invalid byte sequence when deploying to github HOT 3
- RSS category-based feeds HOT 1
- Creative Commons Markdown Table Not Rendering Properly
- Warning due to deprecation of 'format' argument to 'as.character.POSIXlt()' HOT 2
- Description in _site.yaml causing Error "STRING_ELT() can only be applied to a 'character vector', not a 'list'" HOT 1
- How to add email and multiple affiliations to a single author? HOT 2
- Article description does not show up when adding posts HOT 1
- Improve alt-text for ORCiD icon HOT 3
- Add <hr> for screen reader accessibility HOT 1
- Space between lines in bulleted lists HOT 1
- Various minor accessibility issues
- Release distill 1.6
- Gallery outdated, remove Quarto pages HOT 1
- Javascript & D3 page error HOT 1
- Journal (site) title is incorrectly prepended to the article title in cititations.
- Has anyone used any alternative to Google analytics? HOT 2
- italicized species names in a Rmarkdown distill package
- Using a `distill` vignette on CRAN HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from distill.