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 was using the amspset document class for generating exam practice problems. I had wanted to add some referencing to the problems so I started a new counter like this (adapted from some Tex Exchange post)

\newcounter{P}
\newcommand{\plb}[1]{\refstepcounter{P}\label{#1} \textbf{P-\ref{#1}.}}

\begin{problem}
\plb{p1}
A parallel-wire transmission line is constructed of \#6 AWG copper wire
(diameter $d=0.162$ in., conductivity $\sigma_c=5.8\times 10^7$ S/m) with a
12-inch separation in air. Assuming no leakage between the two wires, find
$R'$, $L'$, $G'$, and $C'$. Assume a working frequency of 1 MHz.
\end{problem}

\begin{solution}
Using Table.~\ref{tab:tlparam} and Fig.~\ref{fig:tlempl}, 
\[ Rs = \sqrt{\pi f \mu_c/\sigma_c} = 2.61\times10^{-4}~ \Omega\]
\[ R' = \frac{2R_s}{\pi d} = 4.04\times10^{-2} ~\Omega\text{/m} \]
\[ L' = \frac{\mu_0}{\pi} \ln{\frac{2D}{d}}=2.0~\mu \text{H/m} \]
\[ C' = \frac{\pi \epsilon}{\displaystyle\ln{\frac{2D}{d}}}=5.56 ~\text{pF/m}
\] $G'=0$ because the problem states that there is no leakage between the two
wires.
\end{solution}

\begin{figure}[ht]
\begin{centering}
    \includegraphics{fig24}
    \caption{(Fig.2-4 from FAE) A few examples of transmission lines.}
\end{centering}
\label{fig:tlempl}
\end{figure}

\begin{table}[ht]
\caption{(Table 2-1 from FAE)Transmission-line parameters $R'$, $L'$, $G'$,
and $C'$ for three types of lines.}
    \begin{tabular}{c}
        \hspace{3cm}\includegraphics{tb21}
    \end{tabular}
\label{tab:tlparam}
\end{table}
... and more

Now all the figure references stop working, I get "Fig. " instead of "Fig. 1". The table references are alright though. Any idea what the problem could be?

share|improve this question
2  
Could you turn your code snippet into a complete MWE? It will help folks who want to try and help. –  cmhughes Feb 6 '12 at 2:33

1 Answer 1

You are incorrectly using the \centering instruction:

\begin{figure}[ht]
\begin{centering} % <- wrong!
    \includegraphics{fig24}
    \caption{(Fig.2-4 from FAE) A few examples of transmission lines.}
\end{centering}
\label{fig:tlempl}
\end{figure}

There is a \centering command, not a centering environment (even though LaTeX doesn't raise an error and works). Rather write

\begin{figure}[ht]
\centering
  \includegraphics{fig24}
  \caption{(Fig.2-4 from FAE) A few examples of transmission lines.}
  \label{fig:tlempl}
\end{figure}

The problem with your code is that the reference from \caption is formed inside a group, so the subsequent \label command cannot "see" it.

share|improve this answer
    
That fixed the problem! Thanks! –  Liu Feb 6 '12 at 8:43

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.