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 have a large document (with several directories and files, takes a long time to compile) with a table of contents. I would like to make a short latex document from it with the same table of contents but this time explicitely, so that I can manually edit the table of content (e.g. remove or rename headings, or select only parts of them).

I.e. I would like to edit the table of content without editing the 250 page document. The result should be a new .pdf file (the original project can stay the same, it doesn't need to be changed).

Here is an MNWE:

\documentclass[11pt,a4paper]{book}
\usepackage{a4wide}
%\usepackage{t1enc}
%\usepackage{pslatex}
\usepackage[ansinew]{inputenc}
\usepackage[german]{babel}
\usepackage{graphicx}
\usepackage{epstopdf}
\usepackage{amsbsy,amssymb,latexsym,layout}
\usepackage[centertags]{amsmath}
\usepackage{makeidx}
\usepackage{fancyhdr}
\usepackage[draft=true]{hyperref}
\makeindex
\newcommand{\vektor}[1]{\mathbf{\underline{#1}}}
\newcommand{\tensor}[1]{\mathbf{\underline{\underline{#1}}}}


\begin{document}
\select@language {german}
\contentsline {chapter}{Vorwort}{iii}{chapter*.1}
\end{document}

Usually I have:

\input{Skript.toc}

Instead of:

\select@language {german}
\contentsline {chapter}{Vorwort}{iii}{chapter*.1}

What I did was to just put the first two lines of the Skript.toc that produced the error...

Update: Here's an even shorter MNWE:

\documentclass[11pt,a4paper]{book}
\usepackage[german]{babel}
\makeindex

\begin{document}
\select@language {german}
\contentsline {chapter}{Vorwort}{iii}{chapter*.1}
\end{document}

The full Script.toc can be found here: http://pastebin.com/7MBtznL8

Thanks for any help...

share|improve this question
    
Welcome to TeX.SE! –  Mico Aug 15 '12 at 10:37
2  
Thanks for posting a M(N)WE. I'm afraid I don't understand the purpose or significance of the instruction \select@language {german}. You're already loading the babel package with the german option, so there would seem to be no need for the \select@language command. At any rate, do observe that the \select@language command contains a "special" character (@); hence, it should be used either inside a .sty file or has to be preceded by the \makeatletter command (and, ideally, should be followed by a \makeatother command). –  Mico Aug 15 '12 at 13:24
add comment

3 Answers 3

The contents of the Table of Contents created by the \tableofcontents command are stored in a file named \jobname.toc; here, \jobname is (usually) the name of the main tex input file, e.g., mydoc.tex. After the .toc file has been created by LaTeX, you are free to replace the command \tableofcontents with \input mydoc.toc (note that you need to supply the filename's exension if it's not ".tex"). LaTeX would then no longer update the .toc file during each compilation, and you'd be free to edit its contents by hand.

That said, you may want to think twice about pursuing this approach. You mention that your document takes a long time to compile. Unless there are literally hundreds of sectioning commands in the document, with each one writing information back to the .toc file, I can't imagine that creating the .toc file takes up more than a trivial portion of the total compilation time. Thus, while compile time savings achieved by no longer using the \tableofcontents command would almost certainly be negligible, should you ever make changes to the document that lead to (i) changes in page numbers of existing sectioning headers or (ii) new or deleted sectioning headers, you would have to spend nontrivial amounts of your own time editing the .toc file to keep its contents in sync with the main body of the document.

If you don't like the look of the table of contents that's created by LaTeX's default mechanism, do consider seriously using a package such as tocloft to change the look and layout of the ToC.

share|improve this answer
    
I think he really wants to make a separate ToC document and edit the headings in it. I assume this is then to be used somewhere separate from the main document. –  Raphael Aug 15 '12 at 12:01
    
Thanks for the hint with \input Main.toc. That's exactly what I want. But it gives me several error messages, the first one beeing that there is no "\select" command. The .toc says \select@language{german}, also it shows the @language{german} as "text" in the pdf output. There are more error messages about missing items... –  Jonas Jermann Aug 15 '12 at 12:02
    
I updated the description with a MNWE... –  Jonas Jermann Aug 15 '12 at 12:14
2  
@JonasJermann -- thanks for posting this clarification. Do see the comment I left below your question. The presence of the \select@language command appears to be what's messing up the process: The @ character is not considered a "letter" (unless you precede it with \makeatletter), and thus LaTeX tries to parse the command as \select @language and throws out an error message. The purpose of providing the \select@language instruction isn't clear to me, to be honest. Try compiling your document without it. –  Mico Aug 15 '12 at 13:27
add comment

I don't know which documentclass you use. But a general way to get the table of contents as an extra *.tex-file seems to be to create a fake document:

Take the *.toc-file and "restore" the structure of your document (if you can handle regexp it may take only some minutes):

\chapter{name}
\section{name}
...

Insert the first pagenumber (depends on the class) at the first chapter and insert all pagenumbers for LaTeX for all sections, subsections, and so on. Now you can change your sections, without all the text.

Two remarks:

  • You have to find out how to change the counter of the pagenumber of your class.

  • Probably it would be much easier if you tell us, to what end you would like to change your toc. There are many usual ways to do that, even whole packages!

share|improve this answer
add comment

I spent the last 2 hours trying to do something similar. I am making a summary of a dissertation with the table of contents from the original file. I use

\input Thesis.toc 

to dump the original table of contents into my other file (Summary.tex). However, since I am using the babel package to handle multiple character sets, it dumps a macro command (\select@language {english}) into the .toc file. Badness ensues.

I found a solution in this post: Automatically produce outline? and a clarification here: What do \makeatletter and \makeatother do?

Here's the solution. Use \makeatletter to get around the @ and then switch back to text mode immediately after with \makeatother:

\makeatletter
\input Thesis.toc
\makeatother

If you do not need to modify the table of contents from the original document, you can just \input $jobname$.toc. If you need to edit it, however, then I suggest copying the original and modifying it by hand.

Instead of using \input you may also consider using \anothertableofcontents from the shorttoc package, which may give you more control over the formatting of the table of contents.

(For the benefit of anyone else who tries this, don't try to dump a .toc file from a book into an article class document. More badness will ensue when it hits part or chapter.)

share|improve this answer
add comment

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.