Couldn't make a table float work inside the preview environment:
\documentclass[fontsize=16pt]{scrartcl}
\usepackage[active,tightpage]{preview}
\setlength{\PreviewBorder}{25pt}
\begin{document}
\begin{preview}
\begin{table}
\centering
\begin{tabular}{c|c}
a & b\\
\hline
c & d\\
\end{tabular}
\caption{testing}
\label{tab:testing}
\end{table}
\end{preview}
\end{document}
gives error "Not in outer par mode". The manual of preview mentions a "floats" option, but adding it makes no difference. I know that making a table "float" don't make much sense in a single preview page, I just want them to become non-float and stay in the place where it's defined and show up in the preview.
And then I found this question. It says that standalone package would work. But I couldn't get it to work either:
\documentclass{standalone}
\begin{document}
\begin{table}
\centering
\begin{tabular}{c|c}
a & b\\
\hline
c & d\\
\end{tabular}
\caption{testing}
\label{tab:testing}
\end{table}
\end{document}
gives error "Something's wrong–perhaps a missing \item". And even if it works, it raises a serious problem, that is, it occupies the documentclass but I must use KOMA-Script. By the way, I use xelatex, don't know if it matters.
Any ideas?
Edit: I think I have mentioned in the post that I know what a "float" means and that it does not make "much" sense. But it does make some sense: I use preview for, literally, preview. So every element in the document should show up in the preview so I can "preview" it. And for a table float the proper way of show up is to become a non-float and stay at where it's defined. This is exactly what this post says standalone is supposed to do. Then after the preview, if I comment out the preview package or make it inactive, every thing should work in the normal way again (table floats float normally, etc). So I'm not asking for a method of making a table float sticky, but how to make it show up in preview/standalone environment.
Solution:The solution turns out to be
\documentclass[preview,class=scrartcl,fontsize=20pt]{standalone}
This will automatically turn table floats into non-float while retaining the original document class. Also see Jesse's answer for a clever but a little more sophisticated solution.
Best Answer
Update
In the link you have posted, the author of the
standalone
package mentions that floats are now possible instandalone
and that one should have a look into the manual on thefloat
option.Doing this for you, I got the following code, which should work for you.
Edit I also included the required option to get the
scrartcl
-look and the desired fontsize.Original Answer
You should not use floating environments in the
standalone
class, as it makes no sense. Labels make no sense either. I would recommend to use thecaption
package for your caption (as this package is often used in normal articles as well) and to wrap you table in a minipage.