# Multiple source document with htlatex and tex4ebook

How should I compile a document with chapters on different tex files using tex4ebook? The output of 'tex4ebook main.tex' has valid title page, index, empty chapters and valid bibliography.

Structure of the main file is this:

% ......
\includeonly{%
Miscellaneus/Abstract,%
Linux_chapters/Chap1,%
Linux_chapters/Chap2,%
Linux_chapters/Chap3,%
Linux_chapters/Chap4,%
Linux_chapters/Chap5,%
Linux_chapters/Chap6,%
Linux_chapters/Chap7,%
Linux_chapters/Chap9,%
Linux_chapters/Chap8,%
Windows_chapters/Chap1,%
Windows_chapters/Chap2,%
Windows_chapters/Chap3,%
Windows_chapters/Chap4,%
Windows_chapters/Chap8,%
All_chapters/Final,%
Miscellaneus/References%
}

\newcounter{Item}
\newcounter{Hfootnote}
\newcounter{bookmark@seq@number}
\newcounter{ttl@toc@chapters}

\begin{document}

\begin{titlingpage}

\fontsize{18pt}{20pt}\selectfont

%titling page

\end{titlingpage}

\newpage

\include{Miscellaneus/Abstract}

\begin{KeepFromToc}
\tableofcontents
\end{KeepFromToc}

\chapter*{}
\thispagestyle{empty}
\null
\vfill
\begin{center}
\HUGE{\textbf{LINUX}}
\end{center}
\vfill

\phantomsection

\include{Linux_chapters/Chap1}
\include{Linux_chapters/Chap2}
\include{Linux_chapters/Chap3}
\include{Linux_chapters/Chap4}
\include{Linux_chapters/Chap5}
\include{Linux_chapters/Chap6}
\include{Linux_chapters/Chap7}
\include{Linux_chapters/Chap9}
\include{Linux_chapters/Chap8}

\chapter*{}
\thispagestyle{empty}
\null
\vfill
\begin{center}
\HUGE{\textbf{WINDOWS}}
\end{center}
\vfill

\phantomsection

\include{Windows_chapters/Chap1}
\include{Windows_chapters/Chap2}
\include{Windows_chapters/Chap3}
\include{Windows_chapters/Chap4}
\include{Windows_chapters/Chap8}

\phantomsection

%\appendix
\include{All_chapters/Final}
\include{Miscellaneus/References}
\printindex
\end{document}


htlatex gives no errors but only produces html for the title page

• tex4ebook put all sections and chapters to standalone pages, because of memory and performance limitations of ebook readers. so you may get title page and other stuff that doesn't produce sections on the first page and sections are accessible only from the table of contents. if you get just empty sections, the problem may be with some clashing packages, could you post a complete mwe? – michal.h21 Mar 3 '15 at 15:43
• What you mean by "a complete mwe"? Sorry but I'm a noon on tex. Anyway, also htlatex produces a single page with just titles of chapters. Links in the index refers to these empty sections into the same page – gtatr Mar 4 '15 at 11:35
• @user2682991 this looks like problem with some package you use, by mwe I mean minimal compilale example which shows the problem, you may upload it as a zip file somewhere – michal.h21 Mar 7 '15 at 14:22
• I don't know what to remove to make it 'minimal', since in the main file there is just the title page and the reference to every chap. Anyway here is the source: tempsend.com/969229BA75 – gtatr Mar 8 '15 at 15:49

OP has following \includeonly command in his project

\includeonly{%
Miscellaneus/Abstract,%
Linux_chapters/Chap1,%
Linux_chapters/Chap2,%
Linux_chapters/Chap3,%
Linux_chapters/Chap4,%
Linux_chapters/Chap5,%
Linux_chapters/Chap6,%
Linux_chapters/Chap7,%
Linux_chapters/Chap9,%
Linux_chapters/Chap8,%
Windows_chapters/Chap1,%
Windows_chapters/Chap2,%
Windows_chapters/Chap3,%
Windows_chapters/Chap4,%
Windows_chapters/Chap8,%
All_chapters/Final,%
Miscellaneus/References%
}


from these chapters, only Miscellaneus/Abstract and Miscellaneus/References are really included, others aren't. It is obviously because of the _ character in directory name, which is together with ^ infamous for causing various problems with tex4ht. in this case, it is an obvious bug. easy fix for this problem is to redefine _ catcode:

\catcode\_=12
\includeonly{%
Miscellaneus/Abstract,%
Linux_chapters/Chap1,%
Linux_chapters/Chap2,%
Linux_chapters/Chap3,%
Linux_chapters/Chap4,%
Linux_chapters/Chap5,%
Linux_chapters/Chap6,%
Linux_chapters/Chap7,%
Linux_chapters/Chap9,%
Linux_chapters/Chap8,%
Windows_chapters/Chap1,%
Windows_chapters/Chap2,%
Windows_chapters/Chap3,%
Windows_chapters/Chap4,%
Windows_chapters/Chap8,%
All_chapters/Final,%
Miscellaneus/References%
}
\catcode\_=8 % set catcode of _ to previous value


the chapters should be included correctly now