Graphics, Figures & TablesInserting empty cells

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
ileenka
Posts: 3
Joined: Sat Oct 10, 2009 4:55 am

Inserting empty cells

Post by ileenka »

I'm trying to replicate this table:
imgsd.jpg
imgsd.jpg (52.55 KiB) Viewed 42312 times
And this is my code

Code: Select all

\begin{table}[h]
\centering
\begin{tabular}{ccccccccccccccc}
\hline
\multicolumn{10}{c}{Outputs} & $a_0$ & $a_1$ & $a_2$ & $a_3$ & Time\\
\hline
& & & & & & & & & & & 1 & 1 & 0 & 1 & $t_0$ \\
& & & & & & & & & 1 & 1 & 0 & 1 & 0 & $t_1$ \\
\hline
\end{tabular}
\caption{A Repeated Vector}
\label{tab:Repeated Vector}
\end{table}
I don't know why simply using '&' doesn't work.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Inserting empty cells

Post by localghost »

You had just one alignment character (ampersand, "&") too much in the second row.

Code: Select all

\documentclass[11pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage{booktabs}
\usepackage[font=small,labelfont=bf,tableposition=top]{caption}

\begin{document}
  \begin{table}[!ht]
    \caption{A Repeated Vector}\label{tab:RepVec}
    \centering
    \begin{tabular}{*{15}{c}}\toprule
      \multicolumn{10}{c}{Outputs} & $a_0$ & $a_1$ & $a_2$ & $a_3$ & Time \\ \midrule
      & & & & & & & & & & 1 & 1 & 0 & 1 & $t_0$ \\
      & & & & & & & & & 1 & 1 & 0 & 1 & 0 & $t_1$ \\
      & & & & & & & & & & & & & & \vdots \\
      1 & 1 & 0 & 1 & 0 & 0 & 0 & 1 & 1 & 0 & 1 & 0 & 0 & 0 & $t_{10}$ \\       
      $a_0$ & $a_1$ & $a_2$ & $a_3$ & $a_4$ & $a_5$ & $a_6$ & $a_0$ & $a_1$ & $a_2$ & $a_3$ & $a_4$ & $a_5$ & $a_6$ & \\ \bottomrule
    \end{tabular}
  \end{table}
\end{document}
There can't be no more than n-1 ampersands in one row (with n as the number of columns).


Best regards and welcome to the board
Thorsten¹
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Inserting empty cells

Post by frabjous »

Thorsten beat me to reporting what was wrong, but here's the whole table.

Code: Select all

\begin{table}[h]
\centering
\begin{tabular}{ccccccccccccccc}
\hline
\multicolumn{10}{c}{Outputs} & $a_0$ & $a_1$ & $a_2$ & $a_3$ & Time\\
\hline
  &  &  &   &   &   &   &   &   &   & 1 & 1 & 0 & 1 & $t_0$ \\
  &  &  &   &   &   &   &   &   & 1 & 1 & 0 & 1 & 0 & $t_1$ \\
  &  &  &   &   &   &   &   & 1 & 1 & 0 & 1 & 0 & 0 & $t_2$ \\
  &  &  &   &   &   &   & 1 & 1 & 0 & 1 & 0 & 0 & 0 & $t_3$ \\
  &  &  &   &   &   & 1 & 1 & 0 & 1 & 0 & 0 & 0 & 1 & $t_4$ \\
  &  &  &   &   & 1 & 1 & 0 & 1 & 0 & 0 & 0 & 1 & 1 & $t_5$ \\
  &  &  &   & 1 & 1 & 0 & 1 & 0 & 0 & 0 & 1 & 1 & 0 & $t_6$ \\
  &  &  & 1 & 1 & 0 & 1 & 0 & 0 & 0 & 1 & 1 & 0 & 1 & $t_7$ \\
  &  &  &   &   &   &   &   &   &   &   & $\vdots$ & & & \\
1 & 1 & 0 & 1 & 0 & 0 & 0 & 1 & 1 & 0 & 1 & 0 & 0 & 0 & $t_{10}$ \\
$a_0$ & $a_1$ & $a_2$ & $a_3$ & $a_4$ & $a_5$ & $a_6$ &
$a_0$ & $a_1$ & $a_2$ & $a_3$ & $a_4$ & $a_5$ & $a_6$ &\\ 
\hline
\end{tabular}
\caption{A Repeated Vector}
\label{tab:Repeated Vector}
\end{table}
ileenka
Posts: 3
Joined: Sat Oct 10, 2009 4:55 am

Re: Inserting empty cells

Post by ileenka »

Thank you so much.
Post Reply