yihui / knitr

A general-purpose tool for dynamic report generation in R
https://yihui.org/knitr/
2.38k stars 873 forks source link

knitr::kable caption position #1189

Open njtierney opened 8 years ago

njtierney commented 8 years ago

Hi Yihui!

I noticed recently that there is captioning available within kable. Awesome!

I can't seem to find a way to change the position of the caption, it was mentioned here, but is not an option within kable, as far as I can see.

Thanks again for doing awesome stuff, just tried out bookdown for the first time the other day and loved it.

yihui commented 8 years ago

Thanks for the kind feedback! Shouldn't table captions always be placed at the top of tables? :) (and figure captions below figures)

Okay, grind your teeth for a couple of days and if the caption still bothers you, I'll grind mine and think if I really want to pour more code to the "simple" function https://github.com/yihui/knitr/blob/master/R/table.R

njtierney commented 8 years ago

Ah! Table captions belonging above the table was something I did not realise was the standard, I'm used to seeing them below the table. But maybe that's my own poor styling shining through.

I'll grind my teeth for a little while and work out what I really need...sorry to be feeding your simple function more tasks!

I'll be in touch, thanks again for building cool, useful stuff, and making my life easier.

ebergelson commented 7 years ago

hi, for APA6 format, the title goes above & table 'notes' go below (e.g. "'den. refers to denominator"--was position ever implemented with kable? (sorry if i missed it!)

yihui commented 7 years ago

@ebergelson The position of table captions is fixed at the top, and there is no way to write notes with kable(). It is a deliberate design choice that kable() only generates simple tables. Anything beyond a caption + a strictly rectangular table (meaning no merged cells or line breaks) is not supported by kable(), and you will have to look for solutions in other packages.

njtierney commented 4 years ago

Hi Yihui,

Perhaps your position is still the same, but I recently got this requirement from JSS for styling:

All captions should appear below the corresponding figure/table. The captions should be in sentence style and end with a period. No additional formatting (such as \emph, f or \it) should be used for the caption.

In case that helps change your mind on your design choice. Thanks again for maintaining kable 😄

yihui commented 4 years ago

I feel so tired and sick of such journal requirements now. This particular feature may well be easy to implement, but honestly speaking, I'm not motivated to do it by myself. If someone wants to contribute a PR, I might be able to review it. Thanks!

BTW, if no one wants to make this contribution, the worse case is that you manually edit the .tex file, or post-process it (look for \caption{} and move it).

njtierney commented 4 years ago

That's fair, Yihui. I'll try and take a look and submit a PR :)

yihui commented 4 years ago

Sounds great. Thank you very much!

colinbrislawn commented 3 years ago

I'm glad I'm not the only person wondering about this!

It is a deliberate design choice that kable() only generates simple tables.

👍 :-)

And we can still get creative with kableExtra!

cars %>%
  head(3) %>%
  kable(caption = "Text Above") %>%
  kableExtra::kable_styling(full_width = F) %>%
  kableExtra::footnote(general = "Text Below")

image

notfound4 commented 3 years ago

Hi. I hope I am not too late. A possibility to modify the caption position is tu use the float package and choose a new style with the command \restylefloat. I hope it helps.

sboge commented 3 years ago

I think one interesting thing are subtables. If I'm correct, then it is possible to generate several tables side by side for PDF and HTML, but not for latex. This is too bad, it would be a great feature in my opinion. When implementing this, sub captions of tables are blow the tables while the caption of the main floating environment "table" is on top.

github-actions[bot] commented 3 years ago

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.