1

first of I do very thank both contributors from the "Creating simple table (picture included)" topic -- I'm not able to mark the right answer as I was anonymous; both suggestions were very helpful, even the deleted one.

Now to the problem:

\documentclass{article}

\usepackage{booktabs}
\usepackage{caption}
\usepackage{siunitx}


\usepackage{etoolbox}
\preto\tabular{\shorthandoff{-}}
%As I am using Czech babel, I have to include two aforementioned commands 
%(I was not able to use cline, cmidrule, bottomrule, toprule etc. without them)



\begin{document}

\begin{table}[h]
    \captionsetup%
    {%
        singlelinecheck = off,
        justification   = raggedright,
        labelfont       = bf,
    }
    \centering
    \begin{minipage}[b]{1.0\textwidth}
        \caption{name}%
        \begin{tabular}{@{}l SS }
            \toprule
                                & \multicolumn{2}{l}{blaaaa of Ah ($j$)}  \\
            \cmidrule{2-3}
          Blaueue ($i$) &   $i-2$       &   $i-1$     \\
    \midrule
    1       &   $X_{a,b}$   &   $\dots$ \\
    $j-1$       &   $999.9$ &   $\dots$ \\
    \bottomrule
        \end{tabular}
    \end{minipage}


\end{table}

\noindent Reference: J. Johnson -- Whatever

\end{document}

Things, which quite bother me, are:

1) I'm getting an incredible amount of error messages, e.g.:

! Missing $ inserted. 
<inserted text> 
                $
l.30           Blaueue ($i$)    &   $i-2$       &
                                            $i-1$     \\)

or

! Missing $ inserted.
<inserted text> 
                $
l.33    $j-1$       &   $999.9$ &
                            $\dots$ \

or

l.26    \midrule
l.34    \bottomrule

I don't think I've forgotten to include $ anywhere? I'm getting same problems even while excluding

\usepackage{etoolbox}
\preto\tabular{\shorthandoff{-}}

2) Is there any command for reference under the table? Google didn't help me with this one.

3) Any way to avoid that the table will be larger then the size of page?

4) I'm still new to (La)TeX. Do your codes look as bad as mine? I mean the mathematical mode part, where it seems to be utterly full of $$ :-).

5

The S column specification is from siunitx, and expects columns of decimal numbers. If some of your entries in these columns are not decimals, then you need to surround them with {...} to be correctly processed. Thus the direct fix of your code is:

Sample output

\documentclass{article}

\usepackage[czech]{babel}
\usepackage{booktabs}
\usepackage{caption}
\usepackage{siunitx}

\usepackage{etoolbox}
\preto\tabular{\shorthandoff{-}}
%As I am using Czech babel, I have to include two aforementioned commands 
%(I was not able to use cline, cmidrule, bottomrule, toprule etc. without them)

\begin{document}

\begin{table}[h]
  \centering
  \captionsetup%
  {%
  singlelinecheck = off,
  justification   = raggedright,
  labelfont       = bf,
  }
  \begin{minipage}[b]{1.0\linewidth}
    \caption{name}%
    \begin{tabular}{@{}l SS }
      \toprule
      & \multicolumn{2}{l}{blaaaa of Ah ($j$)}  \\
      \cmidrule{2-3}
      Blaueue ($i$) & {$i-2$}     & {$i-1$}   \\
      \midrule
      1             & {$X_{a,b}$} & {$\dots$} \\
      $j-1$         & 999.9       & {$\dots$} \\
      \bottomrule
    \end{tabular}

    \smallskip \noindent Reference: J. Johnson -- Whatever
  \end{minipage}
\end{table}

\end{document}

It makes most sense to include the reference as text under the table. I have spaced if off vertically via \smallskip, you could use \medskip or \bigskip instead.

The minipage with specification 1.0\textwidth produces a box of the current width for the main text, so latex will warn you if the material is wider than this.

The switiching in and out of math mode in this example is almost unavoidable. The array package allows you to set up columns that are in math mode by default so can simplify some tables.

  • Thank you! Not only does it work perfectly, but I also understand everything more. – Vochmelka Nov 23 '13 at 17:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.