1

Tex4ebook is producing strange page numbers in the toc on a kindle.

MWE:

 \documentclass[ebook,12pt,oneside,openany]{memoir}

 \begin{filecontents}{\jobname.bib}
 @book{Hiemenz,
 author={Hiemenz},
 title={Polymer Chemistry}
 }
 \end{filecontents}

 \usepackage{pgffor}

 \usepackage{lipsum}

 \usepackage[backend=biber,hyperref=auto,backref=true]{biblatex}
 \addbibresource{\jobname.bib}

 \usepackage{imakeidx}

 \makeindex[intoc=true,columns=1,noautomatic]

 \usepackage[hyperindex=true]{hyperref}

 \title{Book}
 \author{Author}
 \date{}

 \begin{document}

 \maketitle

 \frontmatter

 \tableofcontents

 \mainmatter

 \foreach \n in {1,...,100}{%
 \chapter{Chapter}
 Here comes a quotation \cite{Hiemenz}.

 aword\index{aword}

 \lipsum
 }

 \printbibliography
 \printindex

 \end{document}

Running tex4ebook and producing a mobi version gives a toc without page numbers when viewed in Calibre:

mobi version in Calibre

If I transfer the mobi to a Kindle reader, I get strange page numbers:

Kindle version

The numbers increase but then stop at 224 for the rest of the book.

Where are these numbers coming from and why are they wrong? Is it possible to delete them or stop Tex4ebook from producing them?

Thank you.

Update for Michal.h21:

Thanks for your additional comments on page numbers with tex4ebook. It gave me a clue to look at the conversion of the epub to mobi.

I originally used the kindlegen program to convert the epub to mobi. Using the Calibre conversion program doesn't give the page number problem so it looks like a bug in kindlegen.

However the Calibre conversion doesn't handle the bibliography properly and there is an incorrect line break after the reference number:

Bibliography from Calibre conversion

Is there any way to change the way the bibliography items are coded in html using css commands to avoid this? If not I will resort to manually trying to typeset the bibliography items.

If tex4ebook doesn't produce page numbers, what do the numbers from biblatex/backref shown in the picture mean and how are they produced?

As always thanks for all your help and patience with my questions.

Update 2:

Thanks for the extra explanations and suggestions. I tried your css suggestions. The result for the epub is:

epub output

The mobi conversion with kindlegen and Calibre now produce the same result as the epub look. There is the large gap after the reference number and no hanging indent but otherwise it's ok. I presume from your comments that it's not possible to get the normal style for the reference that is produced with pdf output.

Update 3:

What I wrote about the reference layout is wrong for multiple references. The epub output with the new css is:

new epub output

The two references are overlapping.

Thanks again for all your help.

Another update for Michal.h21:

I have looked at this page issue again. When I check the epub with epubcheck, it gives a lot of errrors, such as

ERROR(RSC-005): sample.epub/OEBPS/samplech90.html(-1,-1): Error while parsing file 'Attribute name "X0-Hiemenz" associated with an element type "a" must be followed by the ' = ' character.'.
FATAL(RSC-016): sample.epub/OEBPS/samplech91.html(17,11): Fatal Error while parsing file 'Attribute name "X0-Hiemenz" associated with an element type "a" must be followed by the ' = ' character.'.

and

ERROR(RSC-012): sample.epub/OEBPS/sampleli3.html(24,33): Fragment identifier is not defined.
ERROR(RSC-012): sample.epub/OEBPS/sampleli3.html(26,33): Fragment identifier is not defined.

Could this be the reason why kindlegen gives bad page numbers?

Thanks again.

1 Answer 1

3

tex4ebook doesn't produce any page numbers at all. It is even not possible at the moment even if you want to do it. I would like to produce package which could insert page break marks in the ebook at places where the page break occurred in the PDF version. I think that it should be possible to use LuaTeX callbacks to do that, but I wasn't successful yet.

Anyway, if you see any page numbers, they were either added by Calibre, if you used it for the conversion to Kindle, or by the Kindle reader itself. I have no idea why it stops at page 224.

edit:

While tex4ht doesn't preserve page numbers, they are still available to macros. So biblatex backref feature can use them for linking back to citations.

Regarding your second question, I think that it is caused by paragraph which is started inside the reference entry, it is displayed on the new line.

Try the following configuration:

\Preamble{xhtml}

\begin{document}

% \Css{dt.thebibliography { display@inline;}}
\Css{dd.thebibliography p{display@inline;}}
% \Css{dd.thebibliography {display@inline;}}
\makeatletter
\def\bibConfigure{
  \ConfigureList{thebibliography}
  {\ifvmode \IgnorePar \fi \EndP \EndP
    \HCode {<dl class="thebibliography">}%
    \PushMacro \end@itm \global \let \end@itm =\empty}%
  {\ifvmode \IgnorePar \fi \EndP
    \PopMacro \end@itm \global \let \end@itm \end@itm \EndP
    \HCode {</dd></dl>}\HtmlParOn\ShowPar}%
  {\ifvmode \IgnorePar \fi \EndP \gHAdvance \bibN by 1
    \end@itm \global \def \end@itm {\EndP \Tg </dd>\HtmlParOn}%
    \HCode {<dt id="X\therefsection-\abx@field@entrykey"
      class="thebibliography">}\bgroup \bf}%
  {\ifvmode \IgnorePar \fi \EndP
    \egroup
    \HCode {</dt><dd\Hnewline id="bib-\bibN"
      class="thebibliography">}%
    \HtmlParOff}%
}
\makeatother
\EndPreamble

it disables paragraphs inside bibliography items

6
  • Thanks for the clarification. I have provided additional information in the question.
    – user41974
    Feb 13, 2017 at 0:53
  • I made another update to the question and tried your suggestion. Thanks again.
    – user41974
    Feb 13, 2017 at 9:55
  • @user41974 it might be enough to make inline just the paragraph. please see the update
    – michal.h21
    Feb 13, 2017 at 11:53
  • The revised css code works better. Unfortunately, Calibre still converts this incorrectly as I showed above. Thanks again for your help.
    – user41974
    Feb 15, 2017 at 3:14
  • @user41974 then we need a little bit more difficult configuration, we need to disable paragraphs inside bibliography completely.
    – michal.h21
    Feb 15, 2017 at 11:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .