table not labeling correctly, ref not working

2,806 views
Skip to first unread message

Juliet Hannah

unread,
Feb 17, 2010, 11:08:57 PM2/17/10
to latexus...@googlegroups.com
Hi Group,

This inquiry is a continuation from earlier, but it is a different topic.

I'm using the template given by Peter. I know you may be wondering why
I still have references like this, but the ASA template in the previous post did
not match the format requested on the journal's website.

I have a new problem. The labels on my table are not showing up
correctly. The tables
don't say Table 1 or Table 2, and when I use \ref{}, the proper number does not
show up. Any ideas on what I'm doing incorrectly?

Thanks,

Juliet

\documentclass[fleqn,12pt]{article}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{amssymb}

\usepackage{sectsty}
\allsectionsfont{\centering}
\usepackage[top=.6in,textwidth=6in,textheight=9in]{geometry}

\pagestyle{plain}
\setlength{\parindent}{.2in}
\setlength{\parskip}{8pt}
\setlength{\mathindent}{18pt}

\usepackage{fancyvrb}
\usepackage{apacite}
\usepackage{setspace}
\onehalfspacing
\newcommand{\mypar}{\vspace{4mm}}
\begin{document}


\section{INTRODUCTION}

My intro

\section{Section 2}


Consider Table \ref{myctable}.

\begin{table}[h]
\begin{tabular}{cccc}
\multicolumn{3}{c}{My Table}\\
\multicolumn{1}{c}{} & \multicolumn{2}{c}{{\bf col}}\\
\bf{row} & $Y_1$ & $Y_2$ \\ \hline
$X_1$ & a & b & c \\
$X_2$ & d & e & f \\ \hline
& g & h & $n$ \\
\end{tabular}
\label{myctable}
\end{table}

We use Table \ref{crossclass}.

\begin{table}[h]
\begin{tabular}{ccccc}
\multicolumn{5}{c}{Other Table}\\
\multicolumn{5}{c}{ }\\
\hline
\hline
\multicolumn{2}{c}{\bf{Var}} & &\multicolumn{2}{c}{{\bf Outcome ($Z$)}}\\
\cline{1-2} \cline{4-5}
%& $ $ & & \\
%\hline
$X$ & $Y$ & & $k=1$ & $k=2$ \\
\hline
$i=1$ & $j=1$ & & $n_{111}$ & $n_{112}$ \\
& $j=2$ & & $n_{121}$ & $n_{122}$ \\
\hline
$i=2$ & $j=1$ & & $n_{211}$ & $n_{212}$ \\
& $j=2$ & & $n_{221}$ & $n_{222}$ \\
\hline
\end{tabular}
\label{crossclass}
\end{table}

\section{Section 3}

\section*{REFERENCES}

\begin{list} %no label
{\mbox{}} %note that the next 7 lines are within { }
{ \setlength{\leftmargin} {20pt}
\setlength{\rightmargin} {0pt}
\setlength{\labelsep} {5pt}
\setlength{\labelwidth} {15pt}
\setlength{\listparindent} {-20pt}
\setlength{\parsep} {.15ex}
\setlength{\itemsep} {-3ex} }

\item \ \par
Stephens, M. A. (1986), ``Tests Based on EDF Statistics'' in
D'Agostino, R. B. (ed.) and Stephens, M. A.,
{\it Goodness-of-fit Techniques}, Marcel Dekker Inc (New York), 97-193.

\end{list}
\end{document}

Peter Flynn

unread,
Feb 18, 2010, 4:19:25 AM2/18/10
to latexus...@googlegroups.com
On Thu, Feb 18, 2010 at 4:08 AM, Juliet Hannah <juliet...@gmail.com> wrote:
I'm using the template given by Peter. I know you may be wondering why
I still have references like this, but the ASA template in the previous post did
not match the format requested on the journal's website.

The trick here is to email the author of asa.bst thanking him for writing it, and asking if it is possible to get it to [insert here what it is that it doesn't do right]. It's possible that the ASA have changed their specification since it was written. Most authors are only too happy to update their stuff and send you a new copy.

Failing that, email us with an exact description of what it's not doing. Better, post it to comp.text.tex, where there are even more people who know the BIBTeX language (it's a *much* more widely-read forum).
 
I have a new problem. The labels on my table are not showing up
correctly.

\label must follow \caption
You need to use \caption to label your figures instead of inserting dummy rows.

Two other points:
1. \bf is obsolete for over a decade and should be avoided. Use \textbf{stuff} instead.
2. If you need space between columns, use the {@{spacing-stuff}} method in the table spec. That way you don't need to add dummy columns (and have to remember them each time).
 
///Peter

\documentclass[fleqn,12pt]{article}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{amssymb}

\usepackage{sectsty}
\allsectionsfont{\centering}
\usepackage[top=.6in,textwidth=6in,textheight=9in]{geometry}

\pagestyle{plain}
\setlength{\parindent}{.2in}
\setlength{\parskip}{8pt}
\setlength{\mathindent}{18pt}

\usepackage{fancyvrb}
\usepackage{apacite}
\usepackage{setspace}
\onehalfspacing
\newcommand{\mypar}{\vspace{4mm}}
\renewcommand{\refname}{REFERENCES}
\begin{document}


\section{INTRODUCTION}

My intro \cite{steph86}


\section{Section 2}


Consider Table \ref{myctable}.

\begin{table}[h]
\centering
\caption{My Table}
\label{myctable}
\medskip
\begin{tabular}{cccc}
\textbf{row} & $Y_1$   & $Y_2$   \\ \hline

$X_1$ & a & b & c \\
$X_2$ & d & e & f \\ \hline
  & g  & h & $n$ \\
\end{tabular}
\end{table}

We use  Table \ref{crossclass}.

\begin{table}[h]
\centering
\caption{Other Table}
\label{crossclass}
\medskip
\begin{tabular}{cc{@{\quad}}cc}
\hline
\hline
\multicolumn{2}{c}{\textbf{Var}} &\multicolumn{2}{c}{{\textbf{Outcome} ($Z$)}}\\
\cline{1-2} \cline{3-4}
 $X$         &  $Y$  & $k=1$            &  $k=2$            \\
\hline
$i=1$        &  $j=1$ & $n_{111}$ & $n_{112}$  \\
          &  $j=2$ & $n_{121}$ & $n_{122}$  \\
\hline
$i=2$        &  $j=1$ & $n_{211}$ & $n_{212}$  \\
          &  $j=2$ & $n_{221}$ & $n_{222}$  \\
\hline
\end{tabular}

\end{table}



\section{Section 3}


\begin{thebibliography}{1}

\bibitem{}

Stephens, M. A. (1986), ``Tests Based on EDF Statistics'' in
D'Agostino, R. B. (ed.) and Stephens, M. A.,
{\it Goodness-of-fit Techniques}, Marcel Dekker Inc (New York), 97-193.

\end{thebibliography}
\end{document}


Reply all
Reply to author
Forward
0 new messages