3

I am using the code below to get a simple table but I need to adjust the width of each column.

\begin{table}[H]
\centerline{
\begin{tabular}{|c|c|}
\hline
\textbf{Group} & \textbf{Count} \\ \hline
1 & 1030 \\ \hline
2 & 425 \\ \hline
3 & 274 \\ \hline
4 & 109 \\ \hline
\end{tabular}
}
\end{table}

I tried using the tabular* as shown below but I get a lot of errors

\begin{table}[H]
\centerline{
\begin{tabular*}{.5\linewidth}{@{\extracolsep{\fill}}{|c|c|}}
\hline
\textbf{Group} & \textbf{Count} \\ \hline
1 & 1030 \\ \hline
2 & 425 \\ \hline
3 & 274 \\ \hline
4 & 109 \\ \hline
\end{tabular*}
}
\end{table}
  • http://tex.stackexchange.com/a/12712/31034 –  May 21 '15 at 16:43
  • I already saw that but I did not understand any answer on stack since they seem complicated and I am a beginner. Can you help me with my simple example? – user1930901 May 21 '15 at 16:47
  • saying "you get errors" isn't helpful, you should always show the exact error from the log (I can't test as it is just a fragment, but you have a spurious pair of braces {|c|c|} should be |c|c|) you should however not use \centerline in LaTeX. – David Carlisle May 21 '15 at 18:30

1 Answers1

3

You can adjust the width of columns by using the p column type:

\begin{tabular}{p{2in}p{1in}}

The array package offers some controlled-width column types, as well, along with the ability to define your own column types.

alper
  • 1,389
dgoodmaniii
  • 4,270
  • 1
  • 19
  • 36