Update:
As I mentioned in the comment below, the Table of contents should be the same regardless of the splitting done. So the solution should produce the same toc in HTML from the following commands
htlatex foo.tex
htlatex foo.tex "htm,2"
Original question below
When setting \setcounter{tocdepth}{0}
in report class, then the PDF file shows only the chapters as expected in toc, but the HTML shows both chapter and sections in toc.
When setting \setcounter{tocdepth}{1}
in artice class, then the PDF file shows only the sections as expected in toc, and now the HTML shows only the sections in toc as expected as well.
So, the question is: Why tex4ht agrees with pdf toc for article and not for report?
The following diagram illustrates this. I am not using any options or configuration files other than standard commands to build these. MWE and commands used is below.
Article
\documentclass{article}%
\setcounter{tocdepth}{1}
\begin{document}
\tableofcontents
\clearpage
\section{This is section 1}
some text in section 1
\subsection{1}
some text in section, subsection
\section{This is section 2}
some text in section 2
\subsection{1}
some text in section, subsection
\section{This is section 3}
some text in section 3
\subsection{1}
some text in section, subsection
\end{document}
commands used
pdflatex foo.tex
htlatex foo.tex
Report
\documentclass{report}%
\setcounter{tocdepth}{0}
\begin{document}
\tableofcontents
\clearpage
\chapter{This is chapter 1}
some text in chapter 1
\section{1}
some text in chapter, section
\chapter{This is chapter 2}
some text in chapter 2
\section{1}
some text in chapter, section
\chapter{This is chapter 3}
some text in chapter 3
\section{1}
some text in chapter, section
\end{document}
Appendix
I know of a work around for the report case. But the question is really not to find a workaround, but why it happens in first place. Here is the work around for those interested.
\documentclass{report}%
\setcounter{tocdepth}{0}
\begin{document}
\ifdefined\HCode
\Configure{tableofcontents*}{chapter} %force htlatex to only show chapters
\else
\tableofcontents
\fi
\clearpage
\chapter{This is chapter 1}
some text in chapter 1
\section{1}
some text in chapter, section
\chapter{This is chapter 2}
some text in chapter 2
\section{1}
some text in chapter, section
\chapter{This is chapter 3}
some text in chapter 3
\section{1}
some text in chapter, section
\end{document}
HTML result now is as expected
Here is the full output of the htlatex output for the report case. It is not too large, but posting it since the comment below said this can't be produced on a different machine. I am using texlive 2014 as can be seen from the log:
>htlatex foo.tex
This is pdfTeX, Version 3.14159265-2.6-1.40.15 (TeX Live 2014) (preloaded format=latex)
restricted \write18 enabled.
entering extended mode
LaTeX2e <2014/05/01>
Babel <3.9k> and hyphenation patterns for 78 languages loaded.
(./foo.tex (/usr/local/texlive/2014/texmf-dist/tex/latex/base/report.cls
Document Class: report 2007/10/19 v1.4h Standard LaTeX document class
(/usr/local/texlive/2014/texmf-dist/tex/latex/base/size10.clo))
(/usr/local/texlive/2014/texmf-dist/tex/generic/tex4ht/tex4ht.sty)
(/usr/local/texlive/2014/texmf-dist/tex/generic/tex4ht/tex4ht.4ht
::::::::::::::::::::::::::::::::::::::::::
TeX4ht info is available in the log file
::::::::::::::::::::::::::::::::::::::::::
) (/usr/local/texlive/2014/texmf-dist/tex/generic/tex4ht/tex4ht.sty
--- needs --- tex4ht foo ---
(./foo.tmp) (./foo.xref)
(/usr/local/texlive/2014/texmf-dist/tex/generic/tex4ht/html4.4ht)
(/usr/local/texlive/2014/texmf-dist/tex/generic/tex4ht/html4-math.4ht)
(/usr/local/texlive/2014/texmf-dist/tex/generic/tex4ht/html4.4ht)
(/usr/local/texlive/2014/texmf-dist/tex/generic/tex4ht/html4-math.4ht)
(/usr/local/texlive/2014/texmf-dist/tex/generic/tex4ht/html4.4ht)
(/usr/local/texlive/2014/texmf-dist/tex/generic/tex4ht/html4-math.4ht)
(/usr/local/texlive/2014/texmf-dist/tex/generic/tex4ht/latex.4ht
(/usr/local/texlive/2014/texmf-dist/tex/generic/tex4ht/html4.4ht)
(/usr/local/texlive/2014/texmf-dist/tex/generic/tex4ht/html4-math.4ht))
(/usr/local/texlive/2014/texmf-dist/tex/generic/tex4ht/fontmath.4ht
(/usr/local/texlive/2014/texmf-dist/tex/generic/tex4ht/html4.4ht)
(/usr/local/texlive/2014/texmf-dist/tex/generic/tex4ht/html4-math.4ht))
(/usr/local/texlive/2014/texmf-dist/tex/generic/tex4ht/report.4ht
(/usr/local/texlive/2014/texmf-dist/tex/generic/tex4ht/html4.4ht)
(/usr/local/texlive/2014/texmf-dist/tex/generic/tex4ht/html4-math.4ht))
(/usr/local/texlive/2014/texmf-dist/tex/generic/tex4ht/html4.4ht)
(/usr/local/texlive/2014/texmf-dist/tex/generic/tex4ht/html4-math.4ht))
(./foo.aux) [1] (./foo.4ct) [2] [3]
Chapter 1.
[4]
Chapter 2.
[5]
Chapter 3.
[6] (./foo.aux) )
Output written on foo.dvi (6 pages, 12504 bytes).
Transcript written on foo.log.
This is pdfTeX, Version 3.14159265-2.6-1.40.15 (TeX Live 2014) (preloaded format=latex)
restricted \write18 enabled.
entering extended mode
LaTeX2e <2014/05/01>
Babel <3.9k> and hyphenation patterns for 78 languages loaded.
(./foo.tex (/usr/local/texlive/2014/texmf-dist/tex/latex/base/report.cls
Document Class: report 2007/10/19 v1.4h Standard LaTeX document class
(/usr/local/texlive/2014/texmf-dist/tex/latex/base/size10.clo))
(/usr/local/texlive/2014/texmf-dist/tex/generic/tex4ht/tex4ht.sty)
(/usr/local/texlive/2014/texmf-dist/tex/generic/tex4ht/tex4ht.4ht
::::::::::::::::::::::::::::::::::::::::::
TeX4ht info is available in the log file
::::::::::::::::::::::::::::::::::::::::::
) (/usr/local/texlive/2014/texmf-dist/tex/generic/tex4ht/tex4ht.sty
--- needs --- tex4ht foo ---
(./foo.tmp) (./foo.xref)
(/usr/local/texlive/2014/texmf-dist/tex/generic/tex4ht/html4.4ht)
(/usr/local/texlive/2014/texmf-dist/tex/generic/tex4ht/html4-math.4ht)
(/usr/local/texlive/2014/texmf-dist/tex/generic/tex4ht/html4.4ht)
(/usr/local/texlive/2014/texmf-dist/tex/generic/tex4ht/html4-math.4ht)
(/usr/local/texlive/2014/texmf-dist/tex/generic/tex4ht/html4.4ht)
(/usr/local/texlive/2014/texmf-dist/tex/generic/tex4ht/html4-math.4ht)
(/usr/local/texlive/2014/texmf-dist/tex/generic/tex4ht/latex.4ht
(/usr/local/texlive/2014/texmf-dist/tex/generic/tex4ht/html4.4ht)
(/usr/local/texlive/2014/texmf-dist/tex/generic/tex4ht/html4-math.4ht))
(/usr/local/texlive/2014/texmf-dist/tex/generic/tex4ht/fontmath.4ht
(/usr/local/texlive/2014/texmf-dist/tex/generic/tex4ht/html4.4ht)
(/usr/local/texlive/2014/texmf-dist/tex/generic/tex4ht/html4-math.4ht))
(/usr/local/texlive/2014/texmf-dist/tex/generic/tex4ht/report.4ht
(/usr/local/texlive/2014/texmf-dist/tex/generic/tex4ht/html4.4ht)
(/usr/local/texlive/2014/texmf-dist/tex/generic/tex4ht/html4-math.4ht))
(/usr/local/texlive/2014/texmf-dist/tex/generic/tex4ht/html4.4ht)
(/usr/local/texlive/2014/texmf-dist/tex/generic/tex4ht/html4-math.4ht))
(./foo.aux) [1] (./foo.4ct) [2] [3]
Chapter 1.
[4]
Chapter 2.
[5]
Chapter 3.
[6] (./foo.aux) )
Output written on foo.dvi (6 pages, 12504 bytes).
Transcript written on foo.log.
This is pdfTeX, Version 3.14159265-2.6-1.40.15 (TeX Live 2014) (preloaded format=latex)
restricted \write18 enabled.
entering extended mode
LaTeX2e <2014/05/01>
Babel <3.9k> and hyphenation patterns for 78 languages loaded.
(./foo.tex (/usr/local/texlive/2014/texmf-dist/tex/latex/base/report.cls
Document Class: report 2007/10/19 v1.4h Standard LaTeX document class
(/usr/local/texlive/2014/texmf-dist/tex/latex/base/size10.clo))
(/usr/local/texlive/2014/texmf-dist/tex/generic/tex4ht/tex4ht.sty)
(/usr/local/texlive/2014/texmf-dist/tex/generic/tex4ht/tex4ht.4ht
::::::::::::::::::::::::::::::::::::::::::
TeX4ht info is available in the log file
::::::::::::::::::::::::::::::::::::::::::
) (/usr/local/texlive/2014/texmf-dist/tex/generic/tex4ht/tex4ht.sty
--- needs --- tex4ht foo ---
(./foo.tmp) (./foo.xref)
(/usr/local/texlive/2014/texmf-dist/tex/generic/tex4ht/html4.4ht)
(/usr/local/texlive/2014/texmf-dist/tex/generic/tex4ht/html4-math.4ht)
(/usr/local/texlive/2014/texmf-dist/tex/generic/tex4ht/html4.4ht)
(/usr/local/texlive/2014/texmf-dist/tex/generic/tex4ht/html4-math.4ht)
(/usr/local/texlive/2014/texmf-dist/tex/generic/tex4ht/html4.4ht)
(/usr/local/texlive/2014/texmf-dist/tex/generic/tex4ht/html4-math.4ht)
(/usr/local/texlive/2014/texmf-dist/tex/generic/tex4ht/latex.4ht
(/usr/local/texlive/2014/texmf-dist/tex/generic/tex4ht/html4.4ht)
(/usr/local/texlive/2014/texmf-dist/tex/generic/tex4ht/html4-math.4ht))
(/usr/local/texlive/2014/texmf-dist/tex/generic/tex4ht/fontmath.4ht
(/usr/local/texlive/2014/texmf-dist/tex/generic/tex4ht/html4.4ht)
(/usr/local/texlive/2014/texmf-dist/tex/generic/tex4ht/html4-math.4ht))
(/usr/local/texlive/2014/texmf-dist/tex/generic/tex4ht/report.4ht
(/usr/local/texlive/2014/texmf-dist/tex/generic/tex4ht/html4.4ht)
(/usr/local/texlive/2014/texmf-dist/tex/generic/tex4ht/html4-math.4ht))
(/usr/local/texlive/2014/texmf-dist/tex/generic/tex4ht/html4.4ht)
(/usr/local/texlive/2014/texmf-dist/tex/generic/tex4ht/html4-math.4ht))
(./foo.aux) [1] (./foo.4ct) [2] [3]
Chapter 1.
[4]
Chapter 2.
[5]
Chapter 3.
[6] (./foo.aux) )
Output written on foo.dvi (6 pages, 12504 bytes).
Transcript written on foo.log.
----------------------------
tex4ht.c (2012-07-25-19:36 kpathsea)
tex4ht -f/foo.tex
-i~/tex4ht.dir/texmf/tex4ht/ht-fonts/
(/usr/local/texlive/2014/texmf-dist/tex4ht/base/unix/tex4ht.env)
(/usr/local/texlive/2014/texmf-dist/tex4ht/ht-fonts/iso8859/1/charset/unicode.4hf)
(/usr/local/texlive/2014/texmf-dist/fonts/tfm/public/cm/cmr10.tfm)
(/usr/local/texlive/2014/texmf-dist/tex4ht/ht-fonts/alias/lm/lm-rep-cmrm/cmr.htf)
Searching `lm-rep-cmrm.htf' for `cmr10.htf'
(/usr/local/texlive/2014/texmf-dist/tex4ht/ht-fonts/unicode/lm/lm-rep-cmrm.htf)
[1 file foo.html
file foo.css
file foo.tmp
] [2] [3] [4] [5] [6]
Execute script `foo.lg'
----------------------------
t4ht.c (2012-07-25-19:28 kpathsea)
t4ht -f/foo.tex
(/usr/local/texlive/2014/texmf-dist/tex4ht/base/unix/tex4ht.env)
Entering foo.lg
Entering foo.css
Entering foo.tmp
>
Here is the actual HTML produces as well. (not too large also)
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html >
<head><title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="generator" content="TeX4ht (http://www.tug.org/tex4ht/)">
<meta name="originator" content="TeX4ht (http://www.tug.org/tex4ht/)">
<!-- html -->
<meta name="src" content="foo.tex">
<meta name="date" content="2014-08-09 11:55:00">
<link rel="stylesheet" type="text/css" href="foo.css">
</head><body
>
<h2 class="likechapterHead"><a
id="x1-1000"></a>Contents</h2> <div class="tableofcontents">
<span class="chapterToc" >1 <a
href="#x1-20001" id="QQ2-1-2">This is chapter 1</a></span>
<br />  <span class="sectionToc" >1.1 <a
href="#x1-30001.1" id="QQ2-1-3">1</a></span>
<br /> <span class="chapterToc" >2 <a
href="#x1-40002" id="QQ2-1-4">This is chapter 2</a></span>
<br />  <span class="sectionToc" >2.1 <a
href="#x1-50002.1" id="QQ2-1-5">1</a></span>
<br /> <span class="chapterToc" >3 <a
href="#x1-60003" id="QQ2-1-6">This is chapter 3</a></span>
<br />  <span class="sectionToc" >3.1 <a
href="#x1-70003.1" id="QQ2-1-7">1</a></span>
</div>
<h2 class="chapterHead"><span class="titlemark">Chapter 1</span><br /><a
id="x1-20001"></a>This is chapter 1</h2>
<!--l. 10--><p class="noindent" >some text in chapter 1
<h3 class="sectionHead"><span class="titlemark">1.1 </span> <a
id="x1-30001.1"></a>1</h3>
<!--l. 12--><p class="noindent" >some text in chapter, section
<h2 class="chapterHead"><span class="titlemark">Chapter 2</span><br /><a
id="x1-40002"></a>This is chapter 2</h2>
<!--l. 15--><p class="noindent" >some text in chapter 2
<h3 class="sectionHead"><span class="titlemark">2.1 </span> <a
id="x1-50002.1"></a>1</h3>
<!--l. 17--><p class="noindent" >some text in chapter, section
<h2 class="chapterHead"><span class="titlemark">Chapter 3</span><br /><a
id="x1-60003"></a>This is chapter 3</h2>
<!--l. 21--><p class="noindent" >some text in chapter 3
<h3 class="sectionHead"><span class="titlemark">3.1 </span> <a
id="x1-70003.1"></a>1</h3>
<!--l. 23--><p class="noindent" >some text in chapter, section
</body></html>
report
on my machine, only chapters, not sectionstex4ht
handlestocdepth
, afaik