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

Fix bug where un-escaped curly braces can arrive in the styling_latex_font_size() function #767

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

cgrandin
Copy link

@cgrandin cgrandin commented Oct 3, 2023

The user could call kbl(df, align = "C{1.8cm}") and then later kable_styling() will break . This align value will arrive with the curly braces un-escaped in the styling_latex_font_size() function. I just added escaping for those curly braces, leaving the other curly braces that have been escaped alone by using look-behind regular expressions to look for curly braces without preceding backslashes.

Note that latex support for such a column definition looks like this:
\newcommand{\PreserveBackslash}[1]{\let\temp=\#1\let\=\temp}
\newcolumntype{C}[1]{>{\PreserveBackslash\centering}p{#1}}

These definable column definitions are highly useful!

@dmurdoch
Copy link
Collaborator

dmurdoch commented Dec 2, 2023

I'm just getting the error

Error in knitr::kable(x = x, format = format, digits = digits, row.names = row.names,  : 
  'align' must be a character vector of possible values 'l', 'r', and 'c'

Are you depending on other changes, or an unreleased version of knitr?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants