0

On compiling a tex file into a pdf by pdflatex sample.tex, which contains \tableofcontents command, file sample.toc is generated as expected. However it is empty (0 bytes).

Here are the files:

sample.tex

\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}

\begin{document}

\tableofcontents

\section{First Section} some math here \begin{align} &n + \sum_{i=1}^{\lfloor \lg n \rfloor} 2^i \ &= n + \frac{2(1-2^{\lfloor \lg n \rfloor})}{1-2} \end{align*}

\section*{second section} plain text here

\end{document}

sample.toc

sample.aux

\relax 
\gdef \@abspage@last{1}

sample.log

This is pdfTeX, Version 3.141592653-2.6-1.40.24 (TeX Live 2022/Arch Linux) (preloaded format=pdflatex 2022.5.18)  18 MAY 2022 15:33
entering extended mode
 restricted \write18 enabled.
 %&-line parsing enabled.
**sample.tex
(./sample.tex
LaTeX2e <2021-11-15> patch level 1
L3 programming layer <2022-04-10>
(/usr/share/texmf-dist/tex/latex/base/article.cls
Document Class: article 2021/10/04 v1.4n Standard LaTeX document class
(/usr/share/texmf-dist/tex/latex/base/size12.clo
File: size12.clo 2021/10/04 v1.4n Standard LaTeX file (size option)
)
\c@part=\count185
\c@section=\count186
\c@subsection=\count187
\c@subsubsection=\count188
\c@paragraph=\count189
\c@subparagraph=\count190
\c@figure=\count191
\c@table=\count192
\abovecaptionskip=\skip47
\belowcaptionskip=\skip48
\bibindent=\dimen138
)
(/usr/share/texmf-dist/tex/latex/base/inputenc.sty
Package: inputenc 2021/02/14 v1.3d Input encoding file
\inpenc@prehook=\toks16
\inpenc@posthook=\toks17
)
(/usr/share/texmf-dist/tex/latex/amsmath/amsmath.sty
Package: amsmath 2021/10/15 v2.17l AMS math features
\@mathmargin=\skip49

For additional information on amsmath, use the `?' option. (/usr/share/texmf-dist/tex/latex/amsmath/amstext.sty Package: amstext 2021/08/26 v2.01 AMS text

(/usr/share/texmf-dist/tex/latex/amsmath/amsgen.sty File: amsgen.sty 1999/11/30 v2.0 generic functions @emptytoks=\toks18 \ex@=\dimen139 )) (/usr/share/texmf-dist/tex/latex/amsmath/amsbsy.sty Package: amsbsy 1999/11/29 v1.2d Bold Symbols \pmbraise@=\dimen140 ) (/usr/share/texmf-dist/tex/latex/amsmath/amsopn.sty Package: amsopn 2021/08/26 v2.02 operator names ) \inf@bad=\count193 LaTeX Info: Redefining \frac on input line 234. \uproot@=\count194 \leftroot@=\count195 LaTeX Info: Redefining \overline on input line 399. \classnum@=\count196 \DOTSCASE@=\count197 LaTeX Info: Redefining \ldots on input line 496. LaTeX Info: Redefining \dots on input line 499. LaTeX Info: Redefining \cdots on input line 620. \Mathstrutbox@=\box50 \strutbox@=\box51 \big@size=\dimen141 LaTeX Font Info: Redeclaring font encoding OML on input line 743. LaTeX Font Info: Redeclaring font encoding OMS on input line 744. \macc@depth=\count198 \c@MaxMatrixCols=\count199 \dotsspace@=\muskip16 \c@parentequation=\count266 \dspbrk@lvl=\count267 \tag@help=\toks19 \row@=\count268 \column@=\count269 \maxfields@=\count270 \andhelp@=\toks20 \eqnshift@=\dimen142 \alignsep@=\dimen143 \tagshift@=\dimen144 \tagwidth@=\dimen145 \totwidth@=\dimen146 \lineht@=\dimen147 @envbody=\toks21 \multlinegap=\skip50 \multlinetaggap=\skip51 \mathdisplay@stack=\toks22 LaTeX Info: Redefining [ on input line 2938. LaTeX Info: Redefining ] on input line 2939. ) (/usr/share/texmf-dist/tex/latex/l3backend/l3backend-pdftex.def File: l3backend-pdftex.def 2022-04-14 L3 backend support: PDF output (pdfTeX) \l__color_backend_stack_int=\count271 \l__pdf_internal_box=\box52 ) (./sample.aux) \openout1 = `sample.aux'.

LaTeX Font Info: Checking defaults for OML/cmm/m/it on input line 5. LaTeX Font Info: ... okay on input line 5. LaTeX Font Info: Checking defaults for OMS/cmsy/m/n on input line 5. LaTeX Font Info: ... okay on input line 5. LaTeX Font Info: Checking defaults for OT1/cmr/m/n on input line 5. LaTeX Font Info: ... okay on input line 5. LaTeX Font Info: Checking defaults for T1/cmr/m/n on input line 5. LaTeX Font Info: ... okay on input line 5. LaTeX Font Info: Checking defaults for TS1/cmr/m/n on input line 5. LaTeX Font Info: ... okay on input line 5. LaTeX Font Info: Checking defaults for OMX/cmex/m/n on input line 5. LaTeX Font Info: ... okay on input line 5. LaTeX Font Info: Checking defaults for U/cmr/m/n on input line 5. LaTeX Font Info: ... okay on input line 5. (./sample.toc) \tf@toc=\write3 \openout3 = `sample.toc'.

[1

{/var/lib/texmf/fonts/map/pdftex/updmap/pdftex.map}] (./sample.aux) ) Here is how much of TeX's memory you used: 1183 strings out of 478238 18440 string characters out of 5850456 311201 words of memory out of 5000000 19469 multiletter control sequences out of 15000+600000 473275 words of font info for 42 fonts, out of 8000000 for 9000 1141 hyphenation exceptions out of 8191 54i,10n,62p,202b,121s stack positions out of 5000i,500n,10000p,200000b,80000s </usr/share/texmf-dist/fonts/type1/public/amsfonts/cm/cmbx12.pf b></usr/share/texmf-dist/fonts/type1/public/amsfonts/cm/cmex10.pfb></usr/share/ texmf-dist/fonts/type1/public/amsfonts/cm/cmmi12.pfb></usr/share/texmf-dist/fon ts/type1/public/amsfonts/cm/cmmi8.pfb></usr/share/texmf-dist/fonts/type1/public /amsfonts/cm/cmr12.pfb></usr/share/texmf-dist/fonts/type1/public/amsfonts/cm/cm r8.pfb></usr/share/texmf-dist/fonts/type1/public/amsfonts/cm/cmsy10.pfb></usr/s hare/texmf-dist/fonts/type1/public/amsfonts/cm/cmsy8.pfb> Output written on sample.pdf (1 page, 71619 bytes). PDF statistics: 48 PDF objects out of 1000 (max. 8388607) 28 compressed objects within 1 object stream 0 named destinations out of 1000 (max. 500000) 1 words of extra memory for PDF output out of 10000 (max. 10000000)

How can I fix, so sample.toc is correctly generated, and hence render table of contents in the pdf file by a second compilation of pdflatex sample.tex?

1 Answers1

0

The \section* command is, in fact, for sections that won't appear in the table of content. Replace them with \section and it'll work.

Just removing the two spurrious starts gives the output below. result

Miyase
  • 2,544
  • 2
  • 12
  • 26
  • sample.toc is generated, but table of contents isn't renderd – Mostafa Touny May 18 '22 at 13:52
  • I just tried it with your code, just removing two * and it works after two compilations. Did you change anything else? – Miyase May 18 '22 at 13:52
  • I did two compilations by pdflatex sample.tex after replacing \section* by \section, Yet no table of contents is rendered in the pdf file – Mostafa Touny May 18 '22 at 13:55
  • That was a typo; Updated the comment. I use \section not \section*. Doesn't work – Mostafa Touny May 18 '22 at 13:56
  • Then it's really not normal. \section is a basic LaTeX command, and it does add the section to the table of contents, unless you have other specific commands in your file, or an external problem (corrupted installation, permission problems in the current folder...) – Miyase May 18 '22 at 13:57
  • I installed Tex Live from Manjaro's official distribution manager pacman. I don't have any special configuration. That's even a fresh installation. – Mostafa Touny May 18 '22 at 13:59
  • Assuming that your installation is working, try starting fresh. Remove any temporary file, keeping only the TeX file. Correct the two section commands without changing anything else, and compile twice with PDFLaTeX (making sure that your editor isn't deleting anything, as some do). You should get the result I added in my answer above. – Miyase May 18 '22 at 14:01
  • It worked now; Thanks – Mostafa Touny May 18 '22 at 14:04