Table of content issue

rev0luti0n's picture

 Hi,

I was wondering if anyone could please help me with the following problem I am having using SW:

When I try compiling the following code through PDF preview in scientific workplace, instead of getting my content page as in the attached PDF Test, I get the content page on the very first page of my document as in the attached  Untitled1.pdf.

Code:

\documentclass{article}

\begin{document}

\section{A test section}
Some text\ldots

\subsection{A test subsection}
Some text\ldots

\newpage

\tableofcontents

\newpage

And here's the text that should come on the page after the one containing TOC.

\end{document}

Many thanks.

 

Regards,

Bouba

AttachmentSize
Test.pdf37.75 KB
Untitled1.pdf37.71 KB

When SW opens the document it

When SW opens the document it sees the \tableofcontents command as a front matter element and moves this macro to the front matter.  It keep the \tableofcontents command in the body of the document you will need to place the command inside an encapsulated TeX field.  Use Insert, Typeset Object, TeX Field and turn on the Encapsulated check box. 

You could also replace \tableofcontents with:

\TeXButton{Table of Contents}{\tableofcontents}

using a text editor (since you are showing the contents of the .tex file I've included this solution).

SW will not know that three LaTeX passes are needed to produce a correct table of contents.  You will have to increment the number of LaTeX passes during the compile.  Another method is to use Typeset, General Settings and turn on the check box for "Use old .aux files if possible" and then three individual compiles should give the same results as a single compile with three LaTeX passes.