1

I am writing a document using Latex. I have group pf codes in my document and I wanted to show it in the list of contents. I managed to do so, but I still have (contents) appearing in table additional to (List of Code). You can find below what I have used :

\documentclass[11pt, oneside]{Thesis} % The default font size and one-sided printing (no margin offsets)
\begin{document}
\frontmatter % Use roman page numbering style (i, ii, iii, iv...) for the pre-content pages
\setstretch{1.3} % Line spacing of 1.3
\begin{titlepage}
\begin{center}
\lhead{\emph{Contents}} % Set the left side page header to "Contents"
\tableofcontents % Write out the Table of Contents
\lhead{\emph{List of Figures}} % Set the left side page header to "List of Figures"
\listoffigures % Write out the List of Figures
\lhead{\emph{List of Tables}} % Set the left side page header to "List of Tables"
\listoftables % Write out the List of Tables
\lhead{\emph{List of Listings}}
\addcontentsline{toc}{chapter}{Listings} %to show the listings as a chapter.
\lstlistoflistings
\end{center}
\end{titlepage}
\end{document} 

Please help me to figure out this issue since I have deadline to submit the document.

Sarah
  • 11
  • 2
    Welcome to TeX.SX! Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. –  Sep 27 '14 at 06:41
  • 1
    Your question is still unclear -- provide the MWE as I have already asked you once. A screen shot would be nice –  Sep 27 '14 at 07:08
  • I updated my question after giving up to reach a solution without help.... – Sarah Sep 27 '14 at 14:10
  • 4
    @Sarah You need to clarify what's going wrong. Besides, your code cannot be compiled. 1) Thesis is not a common document class. 2) Some environments are not properly closed. 3) There is an extra }. You need to fix all that. – jub0bs Sep 27 '14 at 14:35
  • The code now compiled. The problem is : I have in my list of contents (Listings) which doesn't have the correct page number ! additional there is contents which points out to the correct Listings page. what I want simply leaving the contents out and have listings point out to the correct listings page number. the code is part of long main.tex and I cant provide everything. – Sarah Sep 27 '14 at 15:18
  • If you want to tag a user, use @ followed by their name (e.g. @Sarah) otherwise they won't be notified of your response. As for the question, please try to replicate the problem for a smaller .tex file (MWE) and then post it. – Pier Paolo Sep 27 '14 at 15:22
  • @ChristianHupfer, would you please help. – Sarah Sep 27 '14 at 15:24
  • @PierPaolo thanks for your response, I have compiled the code and I think is describes the issue clearly. – Sarah Sep 27 '14 at 15:26
  • The page number for the "Listings" entry in your ToC should be the right one if you write \addcontentsline after the command for the list: \lstlistoflistings\addcontentsline{toc}{chapter}{Listings}. As for the rest of what you're asking, it is difficult to say because the code is still not compilable (I don't have the Thesis document class, I don't know the definitions of or the packages used for commands like \lhead, \setstretch...) – Pier Paolo Sep 27 '14 at 15:48
  • 2
    @PierPaolo The problem with your approach is that, if the List of Listings is several pages long, the page number in the ToC entry will correspond to the last page, not the first, of the List of Listing. – jub0bs Sep 27 '14 at 17:03
  • @Sarah We can't have a complete picture of what's going on, because we don't know what's in that Thesis class that you're using. Is it available somewhere on the Internet? If so, please edit your question to add a link to the Thesis.cls file. – jub0bs Sep 27 '14 at 22:05
  • @Jubobs hello, I solved the issue without the need to use \addcontentsline{toc}{chapter}{List of Listings}, I just simply specified \renewcommand\lstlistingname{List of Listings} \renewcommand\lstlistlistingname{List of Listings}, and it works now ! Now I have in my table of contents (List of Listings) instead of (Contents) the issue was with \lstlistoflistings which adds the listings as Contents in ToC. Thanks for your time. – Sarah Sep 28 '14 at 06:05

1 Answers1

0

To clarify more, the issue was: the generated list of listings is included in the ToC as Contents instead of List of Listings. The solution is: as a first step is adding

\renewcommand\lstlistlistingname{List of Listings}

in the preamble to change the name from being Contents to List of Listings, inside the document (after \begin{document}) just include

\addcontentsline{toc}{chapter}{\lstlistlistingname}{\lstlistoflistings}

in the desired position. I hope the answer helps.

jub0bs
  • 58,916
Sarah
  • 11