There is no standard way to do it in tex4ht
, but it is possible to do it using some hacks. Try the following configuration file:
\Preamble{xhtml}
% \TocAt{likechapter,chapter,likesection,section,likesubsubsection,subsection}
\makeatletter
\def\getsection#1{
\expandafter\def\csname toc#1\endcsname##1##2##3{
\edef\@tempa{##1}
\edef\@tempb{\csname the#1\endcsname}
\ifx\@tempb\@tempa \textgreater ##1\ ##2\fi}
}
\makeatother
\def\resetsections{%
\def\doTocEntry{\ifx\tempa\@empty\fi}
\def\tocpart{}
\def\toclikepart{}
\def\tocchapter{}
\def\toclikechapter{}
\def\tocsection{}
\def\toclikesection{}
\def\tocsubsection{}
\def\toclikesection{}
}
\def\breadcrumbs{%
\bgroup\resetsections\getsection{chapter}\getsection{part}\getsection{section}\getsection{subsection}%
\HCode{<a href="\jobname.html">Main</a>}\IfFileExists{\jobname.4ct}{\input{\jobname.4ct}}{}
\egroup%
}
\Configure{crosslinks*}{}
\Configure{crosslinks+}{\ifvmode\IgnorePar\fi\EndP\HCode{<div class="breadcrumbs">}\breadcrumbs\IgnorePar\HCode{</div>}}{}{}{}
\begin{document}
\EndPreamble
we erase default crosslinks
definition using \Configure{crosslinks*}{}
, then we request call to \breadcrumbs
macro in crosslinks+
configuration.
\breadcrumbs
macro is little bit hacky. We exploit the TOC file generated by tex4ht
, which is named \jobname.4ct
. It looks like this:
\expandafter\ifx\csname doTocEntry\endcsname\relax \expandafter\endinput\fi
\doTocEntry\tocchapter{1}{\csname a:TocLink\endcsname{2}{x2-10001}{QQ2-2-1}{Overview}}{3}\relax
\doTocEntry\tocsection{1.1}{\csname a:TocLink\endcsname{3}{x3-20001.1}{QQ2-3-2}{Introduction}}{3}\relax
\doTocEntry\tocchapter{2}{\csname a:TocLink\endcsname{4}{x4-30002}{QQ2-4-3}{Software}}{7}\relax
\doTocEntry\tocsection{2.1}{\csname a:TocLink\endcsname{5}{x5-40002.1}{QQ2-5-4}{Drivers}}{7}\relax
\doTocEntry\tocsubsection{2.1.1}{\csname a:TocLink\endcsname{6}{x6-50002.1.1}{QQ2-6-5}{Ethernet driver}}{7}\relax
\doTocEntry\tocsubsection{2.1.2}{\csname a:TocLink\endcsname{7}{x7-60002.1.2}{QQ2-7-6}{USB driver}}{8}\relax
\par
we call macro \resetsections
, in which we declare macros which may be containted in the .4ct
file to do nothing, then using \getsection
, we request testing if the included chapter
, section
and subsection
equals to the current sectioning numbers. If they do, then they are printed.
A sample file:
\documentclass{book}
\begin{document}
\part{Documentation}
\chapter{Overview}
\section{Introduction}
\chapter{Software}
\section{Drivers}
\subsection{Ethernet driver}
\subsection{USB driver}
hello world
\end{document}
The result: