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 having a problem where the page numbers in the table of contents do not match actual page numbers while using memoir class. I read elsewhere that if one rebuilds the project the problem will go away. Since I am using Pandoc I have no idea how to rebuild the project. I have asked the same question in a Pandoc forum also. I am asking here also as I think this might be a LaTeX issue.

share|improve this question
1  
Welcome to TeX.sx! Please add a minimal working example (MWE) that illustrates your problem. –  N.N. Oct 8 '11 at 9:02
2  
"rebuild" means to "rerun latex". on the first pass, latex collects the page numbers in a separate file, and only includes the toc with page numbers in a second or later run. if the page numbers change in the second or a subsequent run, the correct page numbers won't be seen in the toc until still another run of latex has completed. yes, this is a "latex issue", but not in the sense that it is an error. –  barbara beeton Oct 8 '11 at 15:31

2 Answers 2

"rebuild" means to "rerun latex".

on the first pass, latex collects the page numbers in a separate file, and only includes the toc with page numbers in a second or later run.

if the page numbers change in the second or a subsequent run, the correct page numbers won't be seen in the toc until still another run of latex has completed.

yes, this is a "latex issue", but not in the sense that it is an error. it is an intentional feature.

share|improve this answer
    
Many thanks for the input. I am able to understand what is happening but I would like some specific guidance on how to run LaTex twice or more number of times when using Pandoc. Thanks once again for all the help. –  Mohan Chunkath Oct 9 '11 at 11:54

Pandoc is a document conversion utility and will not fix any incorrect references in your table of contents (or any other cross references in your document). So, you need to "fix" this on the LaTeX side of your production. As @barbara mentioned in her answer, you need to compile your LaTeX document a couple of times (at least twice) for the references to be accurate. I'll try and elaborate on this here by referencing The Not So Short Introduction to LATEX 2ε:

1.7 Files You Might Encounter (p 14)

.toc Stores all your section headers. It gets read in for the next compiler run and is used to produce the table of content.

.aux Another file that transports information from one compiler run to the next. Among other things, the .aux file is used to store information associated with cross-references.

...

2.7 Titles, Chapters, and Sections (p 40)

... LaTeX creates a table of contents by taking the section headings and page numbers from the last compile cycle of the document. The command

\tableofcontents

expands to a table of contents at the place it is issued. A new document has to be compiled ("LaTeXed") twice to get a correct table of contents. Sometimes it might be necessary to compile the document a third time. LaTeX will tell you when this is necessary.

...

2.8 Cross Reference (p 42)

... As with section titles and page numbers for the table of contents, the numbers from the previous compile cycle are used.

In essence, LaTeX uses files to store information about a specific run/compile of your document (rather than storing it in memory at compile time). And, these items may shift around in your document as it is compiled - just like your luggage on an airplane... This commonly occurs when using floats, since they may "float around" in your document, but may also occur with other sectional commands. Consequently, at a second compile, if no further shifting has occurred, the .aux and .toc file will be accurate (or up-to-date), resulting in the correct references.

share|improve this answer
    
Many thanks for the input. I am able to understand what is happening but I would like some specific guidance on how to run LaTex twice or more number of times when using Pandoc. In the directory where the .pdf file was created there are no .aux or .toc files. Does this mean that I should first create a LaTex file rather than try creating a .pdf file? I am using Pandoc and MikTex under Windows. Thanks once again for all the help. –  Mohan Chunkath Oct 9 '11 at 11:53
1  
Using Pandoc as a document conversion utility to produce a PDF file from a LaTeX file is not necessary. PDF files can be created directly using pdflatex. As in, pdflatex file.tex (from the command prompt). In addition to this, using pdflatex will show you a log of the processing. If you need to do this again (due to cross referencing issues), you'll see LaTeX Warning: Label(s) may have changed. Rerun to get cross-references right. in the console. Then you rerun until this warning is not issued anymore. It may be that Pandoc removes this information as well as .aux and .toc. –  Werner Oct 9 '11 at 15:21
    
Thanks once again. I first used Pandoc to create a latex file using the following command at the command prompt.C:\temp>pandoc -f markdown blogwork.txt -t latex --template=booktemplate.tex>blo gwork.tex. The resulting latex file was rerun using pdflatex and I got the cross-references right in the new .pdf file. –  Mohan Chunkath Oct 10 '11 at 4:09

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.