21

I'm learning using standalone package. I tried to create a page including a table but I got errors:

Error

Something's wrong--perhaps a missing \item. \begin{table}
Something's wrong--perhaps a missing \item. \begin{table}
Something's wrong--perhaps a missing \item. \begin{table}
Missing \endgroup inserted ...l mese per dispositivo in \si{\tera\byte}}
Missing \endgroup inserted ...l mese per dispositivo in \si{\tera\byte}}
Missing } inserted ...l mese per dispositivo in \si{\tera\byte}}
Undefined control sequence ...l mese per dispositivo in \si{\tera\byte}}
Extra \endgroup ...l mese per dispositivo in \si{\tera\byte}}
Something's wrong--perhaps a missing \item. \end{table}
\begin{document} ended by \end{table}. \end{table}
Extra \endgroup \end{table}
Too many }'s \end{document}

Code

\documentclass[12pt,a4paper]{standalone}

\usepackage{booktabs}
\usepackage{multirow}
\usepackage{siunitx}
\sisetup{
    binary-units = true
}

\begin{document}

    \begin{table}[htp]
        \centering
        \sisetup{table-format=7.0}
        \addtolength{\tabcolsep}{-1.0pt}
        \begin{tabular}{lS[table-format=6.0]
                         S[table-format=6.0]
                         S[table-format=6.0]
                         SSS}
            \toprule
            Device & 2011 & 2012 & 2013 & 2014 & 2015 & 2016 \\
            \midrule
            Non-smarthphones & 22686 & 55813 & 108750 & 196262 & 357797 & 615679 \\
            Smarthphones & 104759 & 365550 & 933373 & 1915173 & 3257030 & 5221497 \\
            Laptops e Netbooks & 373831 & 612217 & 917486 & 1340062 & 1963950 & 2617770\\
            Tablets & 17393 & 63181 & 141153 & 300519 & 554326 & 1083895\\
            Home gateways & 55064 & 108073 & 180562 & 267545 & 376494 & 514777 \\
            M2M & 23009 & 47144 & 92150 & 172719 & 302279 & 508022 \\
            Altri devices & 525 & 1460 & 5429 & 22966 & 84204 & 242681\\
            \bottomrule
        \end{tabular}
        \caption{Traffico mobile globale al mese per dispositivo in \si{\tera\byte}}
    \end{table}

\end{document}

Do I forget some package? Where could be the error?

2 Answers 2

20

it makes no sense to use the standalone class with a floating environment. Use a simple minipage and the \captionof command:

\documentclass[12pt,a4paper]{standalone}
\usepackage{booktabs}
\usepackage{caption}
\usepackage{siunitx}
\sisetup{binary-units = true,table-format=7.0}
\begin{document}

\minipage{1.08\textwidth}
\addtolength{\tabcolsep}{-1.0pt}
\begin{tabular}{lS[table-format=6.0]
                 S[table-format=6.0]
                 S[table-format=6.0]
                 SSS} \toprule
Device & 2011 & 2012 & 2013 & 2014 & 2015 & 2016 \\\midrule
Non-smarthphones & 22686 & 55813 & 108750 & 196262 & 357797 & 615679 \\
Smarthphones & 104759 & 365550 & 933373 & 1915173 & 3257030 & 5221497 \\
Laptops e Netbooks & 373831 & 612217 & 917486 & 1340062 & 1963950 & 2617770\\
Tablets & 17393 & 63181 & 141153 & 300519 & 554326 & 1083895\\
Home gateways & 55064 & 108073 & 180562 & 267545 & 376494 & 514777 \\
M2M & 23009 & 47144 & 92150 & 172719 & 302279 & 508022 \\
Altri devices & 525 & 1460 & 5429 & 22966 & 84204 & 242681\\ \bottomrule
\end{tabular}
\captionof{table}{Traffico mobile globale al mese per dispositivo in \si{\tera\byte}}
\endminipage

\end{document}

Why do you want to use the class?

3
  • 1
    Ok of course.... I'm using this class because I would convert the table in png format
    – Mazzy
    Jan 15, 2013 at 10:20
  • 1
    that's ok. And also the reason why the table environment makes no sense.
    – user2478
    Jan 15, 2013 at 10:24
  • 8
    Makes sense to me. Nobody thinks in terms of floating environments. They think "I want to draw a table", and some happen to know from past experience that if they change \documentclass{article} to \documentclass{standalone}, they'll get a perfectly cropped output – without all the stuff (borders, margins, titles, page numbers, etc.).
    – voices
    Sep 8, 2019 at 2:19
11

I think the key here is to add the [varwidth=\maxdimen] class option to the preamble. It's similar to using minipage. I removed all the unnecessary clutter to keep it clear and simple, but you can add what you like.

You don't really need to use \caption{TEXT} here either, seeing as it's a single table; there's nothing to enumerate. You can just use \centering TEXT and it will look the same – but drop the Table 1: prefix.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\documentclass[varwidth=\maxdimen]{standalone}
\usepackage{booktabs}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
  \begin{table}
    \begin{tabular}{lrrrrrr}
      \toprule%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      Device             & 2011   & 2012   & 2013   & 2014    & 2015    & 2016    \\
      \midrule%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      Non-smarthphones   & 22686  & 55813  & 108750 & 196262  & 357797  & 615679  \\
      Smarthphones       & 104759 & 365550 & 933373 & 1915173 & 3257030 & 5221497 \\
      Laptops e Netbooks & 373831 & 612217 & 917486 & 1340062 & 1963950 & 2617770 \\
      Tablets            & 17393  & 63181  & 141153 & 300519  & 554326  & 1083895 \\
      Home gateways      & 55064  & 108073 & 180562 & 267545  & 376494  & 514777  \\
      M2M                & 23009  & 47144  & 92150  & 172719  & 302279  & 508022  \\
      Altri devices      & 525    & 1460   & 5429   & 22966   & 84204   & 242681  \\
      \bottomrule%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    \end{tabular}\caption{Traffico mobile globale al mese per dispositivo in TB}
  \end{table}
\end{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .