1

I want to create a table which may contain multiple notes like : enter image description here which I found here.

This works fine in a pure LaTeX context, yet I'm using knitr to convert my Rnw files (under R) to pdf, because there are too many tables to do by hand in LaTeX.

\documentclass[11]{article}
\author{''}
\usepackage{float}
\usepackage{array}
\usepackage{fullpage}
\usepackage{pdflscape}
\usepackage{cite}
\usepackage{booktabs}
\usepackage[top = 0.5in, bottom = 0.5in, left = 0.5in, right = 0.5in]{geometry}
\begin{document}

print(xtable(x, digits = c(0, 0, 0, 3,3, 0, 3,3), # first zero "represents" row numbers which we skip later
                 align = "llcccccc",  # align and put a vertical line (first "l" again represents column of row numbers)
                 caption = strCaption, label = "yearlyprivatization"),
          size = "normalsize", #Change size; useful for bigger tables "normalsize" "footnotesize"
          include.rownames = FALSE, #Don't print rownames
          include.colnames = TRUE, #We create them ourselves
          caption.placement = "top", #"top", NULL
          hline.after=NULL, #We don't need hline; we use booktabs
          floating=TRUE, # whether \begin{Table} should be created (TRUE) or not (FALSE)
          sanitize.text.function = force, # Important to treat content of first column as latex function
          add.to.row = list(pos = list(-1,0,nrow(x)-1,
                                       nrow(x)),
                            command = c(paste("\\hline \n",  # NEW row
                                              "\\multicolumn{1}{c}{} & \\multicolumn{3}{c}{\\textbf{Consecutive Sample}} & 
                                              \\multicolumn{3}{c}{\\textbf{Entire Sample}} \\\\\n","\\cmidrule(l){2-4} \\cmidrule(l){5-7}\n"),
                                        paste("\\hline \n"),  # NEW row
                                        paste("\\hline \n"),
                                        paste0("\\hline \n \\multicolumn{",dim(beforeTable)[2],"}{p}",
                                               "",paste("{\\scriptsize{", "1 PS= number of privatized frims/number of SOEs \\newline 1 PS= number of privatized frims/number of SOEs","}}",sep = " "))
                                        # paste0("\\multicolumn{",dim(beforeTable)[2],"}{l}",
                                        #        "",paste("{\\scriptsize{", "2,Total of PS is yearly average;" ,"}}",sep = " "),"\n")
                 # paste is used as it is more flexible regarding adding lines

                                        )
                            )
          )
\end{document}

Above is the code I'm currently using, which works fine when I only need one table note, enter image description here

but always gets wrong when I want more than one? How can I fix this?

2
  • Welcome to TeX.SX! Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem.
    – jjdb
    Commented May 12, 2017 at 7:59
  • Is this sort of thing what threeparttable is for? Commented May 12, 2017 at 23:28

0

You must log in to answer this question.

Browse other questions tagged .