Skip to content
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

remove new line before table with kable for format LaTeX #1768

Open
3 tasks done
srnnkls opened this issue Oct 24, 2019 · 1 comment
Open
3 tasks done

remove new line before table with kable for format LaTeX #1768

srnnkls opened this issue Oct 24, 2019 · 1 comment
Labels
feature Feature requests

Comments

@srnnkls
Copy link

srnnkls commented Oct 24, 2019

When calling cable with format = latex the actual latex output is preceded by a newline. I can write a wrapper that strips it but was curious: Is this intentional?

library(knitr)
a <- c(1, 2, 3) 
b <- kable(a, format = "latex")

b[1]
#> [1] "\n\\begin{tabular}{r}\n\\hline\nx\\\\\n\\hline\n1\\\\\n\\hline\n2\\\\\n\\hline\n3\\\\\n\\hline\n\\end{tabular}"

By filing an issue to this repo, I promise that

  • I have fully read the issue guide at https://yihui.name/issue/.
  • I have provided the necessary information about my issue.
    • If I'm asking a question, I have already asked it on Stack Overflow or RStudio Community, waited for at least 24 hours, and included a link to my question there.
    • If I'm filing a bug report, I have included a minimal, self-contained, and reproducible example, and have also included xfun::session_info('knitr'). I have upgraded all my packages to their latest versions (e.g., R, RStudio, and R packages), and also tried the development version: remotes::install_github('yihui/knitr').
    • If I have posted the same issue elsewhere, I have also mentioned it in this issue.
  • I have learned the Github Markdown syntax, and formatted my issue correctly.

I understand that my issue may be closed if I don't fulfill my promises.

@srnnkls srnnkls changed the title kable output to stdout is preceded by newlines kable output to stdout is preceded by a newline Oct 24, 2019
@cderv
Copy link
Collaborator

cderv commented Feb 25, 2020

digging a bit doing source code archeology, I found that this newline was added in this commit 3dadff2 7 years ago with message

add an empty line before the table; this is to make sure hook_movecode{} works well

and this was before adding some new lines above it in the longtable environment.

I guess only a few tests can tell us if this is still an issue or not...

Hope it helps decide if this \n is needed or not.

@cderv cderv added the feature Feature requests label Jan 29, 2021
@cderv cderv changed the title kable output to stdout is preceded by a newline remove new line before table with kable for format LaTeX Jan 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Feature requests
Projects
None yet
Development

No branches or pull requests

2 participants