# Tag Info

13

If you look at your example, the table does not have a number. I assume you want to reference the table number, so first we must give the table a number. To do this, use the caption argument. Second, when using xtable, you have to be careful with which arguments you want to give to xtable and which arguments to print.xtable. You are currently passing the ...

11

The basic idea of this is that you need to make sure that the tables generated by xtable don't float; instead you should put them in your own floating environment. In the example below, I've generated two side-by-side tables, each within a {minipage} environment and each with their own caption using the \captionof command of the caption package. I've ...

9

Use align argument of xtable, setting alignment string to empty. This produces an empty group after \begin{bmatrix}, which is harmless: > a <- matrix(rnorm(25), 5 ,5) > x=xtable(a,align=rep("",ncol(a)+1)) # We repeat empty string 6 times > print(x, floating=FALSE, tabular.environment="bmatrix", hline.after=NULL, include.rownames=FALSE, ...

8

I would define a new column as in the following example. The newcolumntype command can be very useful for achieving the sorts of affects you're looking for. \newcolumntype{B}{>{\begin{minipage}[b]{6.6cm}\raggedright{}}c<{\end{minipage}}} It's not essential to use \raggedright, but I think fully justified text in rather narrow columns looks ...

8

First all your rules should be done with booktabs, as it adds some padding to your table rules (table rows in basic latex of often much too tight). Second, table captions should be above tables, as tables may spread over pages, and readers shouldn't have to turn the page to know what the table is about. For this the caption package is useful, basic latex ...

6

Ok, sorry to have asked this. It did take me a fair amount of searching to figure this out though (as I mentioned I'm just learning!) so hopefully this answer will be useful to someone else. The caption package provides an answer to my question. Using \captionsetup{labelformat=empty} before the table and captionsetup{lableformat=default} after the table ...

6

Thanks to @Tyler, I went browsing the knitr issues page and learned that xtable has an argument to suppress the comments (upvote to Tyler for that). It is a bit hard to use because you have to pass the argument to xtable's print method. The code that solves my problem looks like: print(xtable(table,include.colnames=TRUE),comment=FALSE)

6

There are not threeparttable environment in your MWE. \documentclass[ 10pt, a4paper, oneside, headinclude,footinclude, BCOR5mm, ]{scrartcl} \usepackage[scale=0.8]{geometry} \usepackage[flushleft]{threeparttable} \usepackage{gensymb} \usepackage{amsfonts} \usepackage{booktabs} \usepackage{amsmath} \usepackage{caption} \begin{document} \begin{table}[hbt] \...

6

The main problem with the table is that you are not using the booktabs rules, but instead a mixture of standard tabular rules (\hline and \cline) and booktabs rules (\toprule). Replacing these rules with the booktabs versions (\midrule, \cmidrule and \bottomrule) gives you the nice formatting you want. I've removed the multirow stuff. This adds nothing to ...

5

The tabularx package provides the tabularx environment with the format \begin{tabularx}{<width>}{<col spec>} % tabularx contents \end{tabularx} It also provides the X column type that stretches the column to fill the remaining length of <width> given the other elements in <col spec>. It is most often used with <width> given ...

5

Explanation to my comment: The columntype b{<width>} vertically aligns at the bottom (p aligns at the top, m at the middle). You may further define minimum row (where in that vertical space should be the text’s baseline?). For a tabular-globe use you can redefine \arraystretch, e.g. \renewcommand{\arraystretch}{1.5}. The column type b{<width>}...

5

The problem is that R tables are also floats, so you need include the floating=F option. Then the R chunks can be turned or rotated as showed in the MWE: A problem with this is that the caption cannot be generated by R in no floatings tables, and \caption or \captionof of package caption cannot be placed inside a rotating object, but you can put the rotate ...

5

\documentclass[a5paper]{article} \usepackage{booktabs,colortbl,xcolor} \begin{document} A simple raw \texttt{xtable}: <<before,results='asis',echo=F>>= library(xtable) df <- data.frame( One=c(101.000,22.345), Two=c(3.45,74.34), Three=c(65,6.1234)) print(xtable(df)) @ The same table with some formatting: <<after,results='asis', ...

4

Set by step: Suppose that you have a file.xlsx that look like: To convert to R, first export to file.csv: ,apples,tomatoes,babanas Jinks,3,12,15 Pixie,4,5,6 Dixie,2,8,9 Then import as a data frame mytable in R: > mytable <- read.table("file.csv", header=TRUE, sep=",") > mytable X apples tomatoes babanas 1 Jinks 3 12 ...

4

Try using the tabularx package, see tabularx documentation for how to use align to further refine your formatting \documentclass[a4paper]{article} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage[english]{babel} \usepackage{booktabs} \usepackage{colortbl, xcolor} \usepackage{tabularx} \begin{document} <<do_table,echo=FALSE, results = ...

4

From the comment of the OP: "adding \clearpage to the end of every table removed the issue entirely". It is nice that it works, but it does not really solve the problem behind it. Therefore I cite the whole section of the morefloats package here as more general reference: 3 Alternatives (kind of) If you really want to increase the number of (possible)...

4

The problem seems to be in the fact that each table environment is passed the [h] option; if a table can be placed respecting this option (or the automatically provided [ht]), it and all subsequent tables will be queued and after other 17 tables LaTeX will hit the limit. Enlarging the queue is not a suitable answer, because in that situation all tables will ...

4

How to put a "continued on next page" at the page bottom of a longtable is described in the documentation of longtable. Instead of telling you to read the manual, I will show you my code, which solves these issues: xtab.table <- xtable('your dataframe') names(xtab.table) <- c("{Col1}", "{Col2}", "{Col3") digits(xtab.table) <- c(0, ...

4

I think I found an acceptable solution. Assume that the statistical table is schematically as follows: Short label Very long description Three letter label 1 1 5 9 2 2 6 10 3 3 7 11 4 4 ...

4

We can resolve this permanently by setting an xtable option: options(xtable.comment = FALSE) See ?print.xtable; since the comment argument defaults to getOption("xtable.comment", TRUE), any calls to print.xtable will thereafter exclude the comment. Much credit due to mnel on SO for suggesting to do it permanently.

4

Use instead results='asis': asis: output as-is, i.e., write raw results from R into the output document. If you switch from Sweave to knitr, you probably need to read this page: http://yihui.name/knitr/demo/sweave/

4

The etoolbox package provides a string equality test, which can be used like in the macro \cfootnote below. If you are happy to call the macro from the relevant cells, as in the first example below, then the footnotes will be added based on the cell value. Note the % at the end of the macro rows to prevent unwanted whitespace etc. during macro expansion. If ...

3

I have a package called printr, which has not been published to CRAN but might be useful to you. See its vignette for more information. Note you need to install the development versions of knitr and printr from Github. Here is a preview of results from R Markdown, and it should not make a difference if you use it .Rnw documents. The positions of x and y may ...

3

This is an xtable issue: xtable is designed for use within a LaTeX source document, and when you try to use it in a Markdown document instead, the formatting of comments becomes difficult to control as it passes from Md -> pandoc -> LaTeX -> pdf. There is some discussion on the knitr issues page. Knitr now includes the function kable to deal with simple ...

3

This is a documented issue affecting the display of \hline lines in PDFs, and affects some PDF viewers (Adobe's Acrobat may not display the line while Apple's Preview might display it fine). In most cases, the problem should not affect the printed output you see on paper. If it still bothers you, however, you can swap out your \hline with the \midrule of ...

3

There are already possibilities to use tabularx builtin xtable. Use tabular.environment = "tabularx" in combination with width="\\textwidth". Now you can define the alignment with align="rXXXXXX" where X denotes columns that get stretched to fill the desired width. You end up with a LaTeX table that begins with: \begin{tabularx}{\textwidth}{rXXXXXX} A ...

3

some combination of these might work.... \documentclass{article} \usepackage{graphicx} \begin{document} \def\tst{ \hline 1 & bar\_SOSo\_top & 0.88869 & 0.86281 & 0.88794 & 0.86281 & 0.88266 & 0.85779 \\ 2 & bar\_SOSo\_left & 0.88618 & 0.81281 & 0.88593 & 0.81307 & 0.87362 & 0.80704 \\ 3 &...

3

This can happen if your row names start with a left bracket, in which case you get the problem that David described in his comment. I've not seen it be a problem with brackets in the body of the table (but it may happen in some case). If that is what you are seeing, you can add a custom sanitize.rownames.function argument to the print.xtable function to wrap ...

3

Try this: <<results='asis',echo=FALSE>>= # row.names(Count) = stringr::str_wrap(row.names(Count), width=50) print(xtable(Count, caption='test', label='tab:example', align=c('p{1in}',rep('|c', ncol(Count)))),scalebox = 0.75) @ The only change made is for the parameter align. The insertion of p{1in} tells that the first column should have the ...

Only top voted, non community-wiki answers of a minimum length are eligible