I am using knitr to create the output of the table. The problem here is when I try to avoid float to the xtable the caption doesn't appear. The option I used to avoid float is floating="F"
in print(xtable)
I have the following sample code used on the knitr.
\documentclass[12pt,Arial]{article}
\usepackage[sc]{mathpazo}
\usepackage[T1]{fontenc}
\usepackage[left=0.7in, right=0.8in, bottom=0.6in, top=0.8in]{geometry}
\usepackage{float}
\begin{document}
\section{start}
<<comment=NA,results='asis',echo=FALSE>>=
library(xtable)
jd1 <- structure(c(23.16, 27.14, 31.03, 30.11, 33.03, 38.78, 23.45,
26.96, 30.93, 29.85, 32.53, 35.99, -2.965, -0.1998, 0.08065,
0.2588, 0.5829, 6.042, 0.0001466, 0.1369, 0.3252, 0.629, 0.9057,
6.042), .Dim = c(6L, 4L), .Dimnames = list(c("Min.", "1st Qu.",
"Median", "Mean", "3rd Qu.", "Max."), c("observed", "modeled",
"obsdmod", "aobsdmod")))
names(jd1)<- c("Observed","Modeled","Observed-Modeled","|Observed-Modeled|")
print(xtable(jd1,caption="Summary of table for observed and modeled temperatures at station T1"),type="latex",floating="F")
@
\end{document}
Yes, only floats have captions. If it's not floating, you'll have to use some other mechanism to document it. Maybe just put text immediately before it telling what it is?
It does feel, though, like you're not really asking the question you want to ask. Why don't you want it to float? If you want it to look like a float, but don't want LaTeX to have any say in the placement, there are better methods.
EDIT: Aha, I thought so. You can achieve \begin{table}[H]
with the table.placement
option.
> print(xtable(cbind(1,2)), table.placement="H")
% latex table generated in R 2.15.1 by xtable 1.7-0 package
% Sat Jul 6 08:06:52 2013
\begin{table}[H]
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With