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

Error [!Misplaced \noalign] for PDF output when using row_group_label_position ='stack' #740

Open
hgong1 opened this issue Jan 6, 2023 · 0 comments

Comments

@hgong1
Copy link

hgong1 commented Jan 6, 2023

Describe the bug
Creating PDF output using collapse_rows & row_group_label_position ='stack' will generate [!Misplaced \noalign] errors in some cases. No error will be shown if not using "stack" for row_group_label_position. I am using kableExtra version 1.3.4. Here is the error message:

! Misplaced \noalign.
\addlinespace ->\noalign 
                         {\ifnum 0=`}\fi \@ifnextchar [{\@addspace }{\@addsp...
l.92 \hspace{1em}\addlinespace
                              [0.3em] 

To Reproduce
The following code will generate the error:

data <- data.frame (
  rowGroup = c("row_group1", "row_group1", "row_group1", "row_group2", "row_group2"),
  rowName = c(1, 2, 3, 1, 2),
  A = c("1.83", "58.23", "0.29", "1.83", "57.62"),
  B = c("3.00", "1.00", "3.00", "3.00", "1.00"),
  C = c("80.00", "80.00", "80.00", "80.00", "80.00")
)
kbl(data, booktabs = T, align = "c") %>% 
  collapse_rows(1:2, latex_hline = 'custom', custom_latex_hline = 1:2, row_group_label_position = 'stack')

I have looked into the generated .tex file. The following content has been put in the wrong location in the file:

\hspace{1em}\addlinespace[0.3em]
\multicolumn{5}{l}{\textbf{\textbf{row\_group2}}}\\

The error will not appear if I change the first data point in C from "80.00" to any other number. For example: C = c("80.01", "80.00", "80.00", "80.00", "80.00").

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

No branches or pull requests

1 participant