2

@michal.h21 EDIT2: I updates all the repositories from https://github.com/michal-h21. It works . I edited the code which does not work

this is what I do. I copy your cfg.cfg, I create the myfile.tex and run

tex4ebook   -l -f epub -m -t myfile.tex

this is the simple code

    \documentclass{article} 

\makeatletter
\def\subsubsubsection{%
\penalty-9999
\@startsection{paragraph}{4}{0em}{0.1\parskip}{1em}{%
\small\rmfamily\mdseries\itshape}
}
\makeatother


\setcounter{secnumdepth}{5}
\setcounter{tocdepth}{5}

    \begin{document}
    \tableofcontents
    \section{first seciton}
    \subsection{first subsection}
    \subsubsection{first subSUBsection}
    \subsubsubsection{first subSUBsubsection}

    my subsubsubsection here

    \paragraph{first para}

    werfj

    \section{second section}
    \section{third seciton}
    \end{document}

it works well now.

4

It is quite a lot of requirements, I hope I didn't forget about anything. I've moved your code from the TeX file to the .cfg file, which is more flexible. You also need the development version of tex4ebook, because the version in distributions has fixed level of sections which go to the NCX file (it is used in the side menu).

\Preamble{xhtml,sections+}

\NewSection\subsubsubsection{\theparagraph}

\Configure{subsubsubsection}
{\ifvmode\IgnorePar\fi\EndP\IgnorePar\Tg<subsubsubsection id="subsubsubsection.\theparagraph">}
{\ifvmode\IgnorePar\fi\EndP\IgnorePar\Tg</subsubsubsection>}
{\addtocounter{paragraph}{1}
 \HCode{<font size="+0">}%
 \NoFonts\HCode{<span class="it">}%
 \TitleMark%
 \HCode{\Hnewline}}%
{\HCode{</span>}\EndNoFonts%
 \HCode{</font>}%
 \HCode{\Hnewline}%
 \par\IgnoreIndent\ShowPar%
}

\Css{span.it{font-style:italic;}}
\ConfigureMark{subsubsubsection}{\theparagraph~@@@~}
\Configure{toToc}{subsubsubsection}{paragraph}


\ConfigureToc{paragraph}
{~~~\HCode{<span class="paragraphToc" >}}{~@@@~}{}{\HCode{</span>}\HCode{<br />\Hnewline}}

% \ConfigureToc{subsubsubsection}
% {~~~\HCode{<span class="subsubsubsectionToc" >}}{~@@@~}{}{\HCode{</span>}\HCode{<br />\Hnewline}}

\def\newncxtox#1#2{%
  \ConfigureToc{#1}%
  {\closelevels{#2}%
  \csname a:NavSection\endcsname\csname Ncx:Mark\endcsname}
  {\csname c:NavSection\endcsname~@@@~}
  {}
  {\csname b:NavSection\endcsname%
    \finishtoclevel{#1}%
  }
}

\begin{document}
\expandafter\def\csname ncx:title\endcsname{%
  \HCode{<docTitle>\Hnewline<text>}\Title\HCode{</text>\Hnewline</docTitle>\Hnewline}
  \newncxtox{paragraph}{paragraph}
}
\EndPreamble

Let's dive into the code a little bit:

\Preamble{xhtml,sections+}

You will get section links thanks to sections+ option.

\ConfigureMark{subsubsubsection}{\theparagraph~@@@~}
\Configure{toToc}{subsubsubsection}{paragraph}

First configuration will add the @@@ after the subsubsubsection counter, the second will include it in the TOC, using configuration for \paragraph. So \ConfigureToc{paragraph} will work for both commands.

\def\newncxtox#1#2{%
  \ConfigureToc{#1}%
  {\closelevels{#2}%
  \typeout{konfigurujeme nxc title #1, - #2}
  \csname a:NavSection\endcsname\csname Ncx:Mark\endcsname}
  {\csname c:NavSection\endcsname~@@@~}
  {}
  {\csname b:NavSection\endcsname%
    \finishtoclevel{#1}%
  }
}

\begin{document}
\expandafter\def\csname ncx:title\endcsname{%
  \HCode{<docTitle>\Hnewline<text>}\Title\HCode{</text>\Hnewline</docTitle>\Hnewline}
  \newncxtox{paragraph}{paragraph}
}

This is a dirty hack to get your @@@ into the NCX file, this isn't normally configurable. The \newnctox command is modeled after internal tex4ebook command, which takes care of correct hierarchy of entries in the NCX file. It is a list of entries at the same on lower level than the current sectioning. Because \subsubsubsection is configured as \paragraph and because it is lowest part of the hierarchy, the only element in the closing list is the paragraph itself.

Here are some results:

enter image description here

and the document:

enter image description here

Finally, the ebook viewer:

enter image description here

  • It works, but is there a way to put the flag sections+ in the .tex file, instead of relying on a .cfg file ? – HarryLotter Dec 22 '16 at 15:16
  • I have found a bug related to your hack for the yellow TOC. If I add * a second section*, then the bug appears and I have the message HTML Tidy for Windows version 5.3.9 Ligne: 40 Col: 1 - Error:unexpected </navMap> in <navPoint> Ligne: 41 Col: 1 - Error:unexpected </ncx> in <navPoint> Tidy ncx 2 Tidy opf 0. is it possible for the solution to work with custom sections, entered via \sectionABC and \sectionDEF and so on ? – HarryLotter Dec 22 '16 at 16:53
  • @HarryLotter could you please update your question with code that causes the error? – michal.h21 Dec 22 '16 at 17:22
  • @HarryLotter it should work now. – michal.h21 Dec 22 '16 at 23:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.