Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am trying to make a table using ScribTeX using the following code:

\documentclass[12pt,oneside,reqno]{amsart}
\usepackage{amssymb}
\usepackage{mathtools}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\makeatletter
\def\@setcopyright{}
\def\serieslogo@{}
\makeatother
\begin{document}
\begin{center}
\label{T1} 
\begin{tabular}{|1|1|1|1|1|1|1|}              
\hline 
$r/r_b$ & $\frac{8\pi G}{c^4}pr_b^2$ & $\frac{8\pi G}{c^2}\rho r_b^2$ & $\Big (    \frac{p}{\rho c^2} \Big )$ & $\frac{1}{c^2}\Big(\frac{dp}{d\rho}\Big)$ & $Z$ & $E\times r_b^2$ \\ \hline
0 & 0.095358 & 1.753927 & 0.054368 & 0.141513 & 0.502225 & 0 \\ \hline
0.1 & 0.093012 & 1.741188 & 0.053419 & 0.140512 & 0.499676 & 0.0000044\\ 
\hline
\end{tabular}
\end{center}
\end{document}​

When I run the code it returns 7 errors, although the table is made perfectly. What is the cause of these harmless errors and how do I remove them. A second question I wish to ask is how do I give a title to the table?

share|improve this question

3 Answers 3

up vote 6 down vote accepted

Yes, you need to use either l, r, or c for your tabular column specifiers, not 1, unless you make this a \newcolumntype{1}{<col spec>} using array. You can place a heading as normal text just before the tabular, or insert it as part of the table using a \multicolumn{7}{c}{<heading>} \\ statement:

enter image description here

\documentclass{amsart}
\begin{document}
\begin{center}
\textbf{This is a heading}
\begin{tabular}{|l|l|l|l|l|l|l|}              
\hline 
$r/r_b$ & $\frac{8\pi G}{c^4}pr_b^2$ & $\frac{8\pi G}{c^2}\rho r_b^2$ & $\Big (    \frac{p}{\rho c^2} \Big )$ & $\frac{1}{c^2}\Big(\frac{dp}{d\rho}\Big)$ & $Z$ & $E\times r_b^2$ \\ \hline
0 & 0.095358 & 1.753927 & 0.054368 & 0.141513 & 0.502225 & 0 \\ \hline
0.1 & 0.093012 & 1.741188 & 0.053419 & 0.140512 & 0.499676 & 0.0000044\\ 
\hline
\end{tabular}
\end{center}
\end{document}
share|improve this answer

As Martin and Werner said, 1 is not a column format specifier, you could use l instead. The seven 1s result in the seven errors.

Regarding your second question: to get a title for the table, use \caption{title}. For this it's recommendable to use a table environment, see below.

Some recommendations:

  • Instead of writing the same format seven times, you could load the array package and say

    \begin{tabular}{|*7{l|}}
    
  • You could raise \arraystretch to get a better vertical spacing.

  • It could be nicer to avoid vertical rules, just using horizontal rules.

  • The booktabs package provides nice rules.

  • Don't use \label without \caption before.

  • Consider using a floating environment such as table for good placement done by LaTeX.

  • Perhaps center the heading cells using \multicolum{1}{c}{...}.

table example

\documentclass[12pt,oneside,reqno]{amsart}
\usepackage{amssymb}
\usepackage{mathtools}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\makeatletter
\def\@setcopyright{}
\def\serieslogo@{}
\makeatother
\usepackage{booktabs}
\begin{document}
\begin{table}[ht]
\centering
\caption{First table}
\label{T1}
\renewcommand*{\arraystretch}{1.6}
\begin{tabular}{*7l}
\toprule[1.5pt]
  $r/r_b$ & $\frac{8\pi G}{c^4}pr_b^2$ & $\frac{8\pi G}{c^2}\rho r_b^2$ &
    $\Big (    \frac{p}{\rho c^2} \Big )$ &
    $\frac{1}{c^2}\Big(\frac{dp}{d\rho}\Big)$ & $Z$ & $E\times r_b^2$ \\
\midrule
  0 & 0.095358 & 1.753927 & 0.054368 & 0.141513 & 0.502225 & 0 \\
  0.1 & 0.093012 & 1.741188 & 0.053419 & 0.140512 & 0.499676 & 0.0000044\\ 
\bottomrule[1.5pt]
\end{tabular}
\end{table}
\end{document}​
share|improve this answer

The issue is that you use a 1 (one) not a l (lowercase L) as the columns specification:

This means:

\begin{tabular}{|1|1|1|1|1|1|1|}

should be:

\begin{tabular}{|l|l|l|l|l|l|l|}

This might be difficult to separate in your used font.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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