Tell me more ×
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 running this LaTeX file through pdflatex and getting these warnings:

latex warning: there were undefined references.
latex warning: label(s) may have changed. Rerun to get cross-reference right.

and also some more warnings like this:

latex warning: reference 'lastpage' on page 76 undefined on input line 3200.

on every page end.

My LaTeX file is like this

\documentclass[a4paper,leqno,twoside]{article}

\usepackage[latin1]{inputenc}
\usepackage[english]{babel}
\usepackage{multirow}

\renewcommand{\familydefault}{\sfdefault}

\usepackage{color}
\usepackage[colorlinks=true]{hyperref}
\usepackage{draftwatermark}
\SetWatermarkText{EXPERIMENTAL}
 \SetWatermarkScale{0.6}
 \usepackage{parskip}

 \graphicspath{{Figure/}}

  \let\oldsection\section
 \renewcommand{\section}{\clearpage\oldsection} 
 \begin{document}



  % Issued by {Name, acronym, department, phone}
 \issuedby{vrebwr}
 % Checked by
  \checkedby{-}
  % Approved by
 \approvedby{-}
  % Document title. Use \doctitleShort{} to insert a shorter title in the header.
  \doctitle{test numbers with id}
  \doctitleShort{document for tests}
  % Publish date
 \publishdate{\today}


  % Titlepage
 \frontmatter % Should be on first page
 \maketitle



 \vspace*{08eX}
  \begin{center}
   \subsection*{Abstract}
   \end{center}

  \noindent
     it contains information about tests.
   \newpage
    \mainmatter
    % Main pages. This command should be on page 2 or later.
    \phantom{phantom}
   \cleardoublepage

   \subsection*{Change Record}

  \begin{itemize}
  \item R.1: Initial version.
   \begin{itemize}
  \item  generation of documentation using the vrebwr
    \end{itemize}
   \end{itemize}

    \cleardoublepage

  \setcounter{tocdepth}{2}
    \tableofcontents 

   \cleardoublepage

   \section{ How to read the tset information}

   \begin{enumerate}
     \item information how to read
    \item information of tests
    \end{enumerate}

    \section{test numbers}

   \subsection*{1, temperature sensor. }
   \addcontentsline{toc}{subsection}{ 1, temperature sensor.}
   \subsubsection*{data}
   some data regarding test where we performed
   \subsubsection*{values}
   temperature sensor value here three or more.
    \subsubsection*{reason}   
    why we get like this.
     \newpage

    \subsection*{2, humidity sensor. }
    \addcontentsline{toc}{subsection}{ 2, humidity sensor.}
   \subsubsection*{data}
   some data regarding test where we performed
   \subsubsection*{values}
   humidity sensor value here three or more.
    \subsubsection*{reason}   
     why we get like this.

  \subsection*{3, pressure sensor. }
   \addcontentsline{toc}{subsection}{ 3, pressure sensor.}
   \subsubsection*{data}
   some data regarding test where we performed
   \subsubsection*{values}
   pressure sensor value here three or more.
   \subsubsection*{reason}   
  why we get like this.
   \newpage
  \end{document}

In the above LaTeX file I have around 100 tests. I used the * symbol to eliminate numbering in subsections, because I am using test names with number so there is no need to add numbering. It looks bad in the PDF, so I tried to add that test name and number in table of contents by using this command:

\addcontentsline{toc}{subsection}{1,temperature sensor.}

When I used this command I am getting errors like as I explained above. I searched and I found some reasons why this error occurred, because of \label{} and \ref{} is not used like that. But I don't know how to use that in my file. Can anyone help me with it?

share|improve this question
Oops, I started editing the title but forgot to finish before I migrated it. Sorry about that. – Michael Myers Nov 15 '11 at 15:31
Welcome to TeX.sx! Your question was migrated here from Stack Overflow. Please register on this site, too, and make sure that both accounts are associated with each other, otherwise you won't be able to comment on or accept answers or edit your question. – Torbjørn T. Nov 15 '11 at 15:34
how to rectify that warning. – pavani Nov 15 '11 at 15:52
10  
Getting a warning about undefined references after the first latex run is nothing to worry about; just rerun latex once or twice more, and all cross-references should be resolved (including the one to lastpage). On the other hand, if you have typos in your labels and/or your cross-referencing commands, the warnings are useful because they tell you so something is amiss and needs to be corrected. – Mico Nov 15 '11 at 16:07
1  
If all your subsections and subsubsections are to be unnumbered, you could add \setcounter{secnumdepth}{1} to your preamble to turn off numbering for these. subsections will still be added to the TOC, without numbering. That will save you the \addcontentslines. – Torbjørn T. Nov 15 '11 at 18:30
show 3 more comments

migrated from stackoverflow.com Nov 15 '11 at 15:30

1 Answer

up vote 10 down vote accepted

Getting a warning about undefined references after the first LaTeX run is nothing to worry about. Just rerun LaTeX once or twice more and all cross-references should be resolved (including the one to lastpage).

On the other hand, if you have typos in your labels and/or in your cross-referencing commands, the warnings won't go away upon recompiling the code once or twice more. At that state, they become useful because they tell you something is amiss and needs to be corrected.

share|improve this answer
1  
17 April 2013: The 10th upvote of this answer got me my 200th "badge" on this fabulous site. Many thanks!! – Mico Apr 19 at 22:23

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.