1

I am trying to convert an existing book from plain PDF output to ebook format for online publishing (and doing some reformatting in the process, but that's another question).

I have images in the \part page (thanks to @PeterWilson for that). Problem is those images do not appear in tex4ebook output, without any error/warning.

Full (current) header of my book follows:

\documentclass[10pt,ebook,italian,onecolumn,oneside,titlepage,extrafontsizes]{memoir}
\usepackage[italian]{babel}
\usepackage{graphicx}
\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{ucs}
\usepackage{makeidx}
\usepackage{quotmark}
\newcommand{\gqt}[1]{\tqt{\scshape #1}}
\newcommand{\stars}{\begin{center} * * *\\ \end{center}}
%
\makeatletter
\def\@partimage{}
\newcommand{\partimage}[2][]{\gdef\@partimage{\includegraphics[#1]{#2}}}
\renewcommand{\printparttitle}[1]{\parttitlefont #1\vfil\@partimage\vfil\gdef\@partimage{}}
\makeatother
%
\setlength\cftpartnumwidth{2em}
%
\author{Mauro Condarelli}
\title{Cronache della Nuova Terra}
\begin{document}
%
\frontmatter
\maketitle
%
\mainmatter
\chapterstyle{companion}
%\book{Cronache della Nuova Terra}
\tableofcontents
%
\partimage[width=210pt]{old_mage.jpg}
\part{In cerca di un Mondo Nuovo}
%
%
\chapter{La Missione}
%
%scene: 'Prologo I'

La Pianta non era certo imponente, somigliava a una verza troppo cresciuta, alta quasi un metro e mezzo e larga altrettanto, grandi foglie verde pallido sormontavano un tronco corto e tozzo dal quale partiva un robusto peduncolo che portava a una grossa zucca adagiata sulla sabbia pulita.\par
...
%end scene
%
%end chapter
%

\backmatter
\appendix
%
%
\end{document}

Problem, as said, is image (old-mage.jpg, in this case) simply vanishes leaving no visible trace.

I'm using a plain: tex4ebook -c tex4book.cfg Cronache_della_Nuova_Terra.tex to compile; contents of tex4book.cfg follows:

\Preamble{xhtml}   
\CoverMetadata{thano.jpg}
\Configure{AddCss}{blitz-lite.css}
\DeclareGraphicsExtensions{.svg,.png,.jpg,.pdf}
\begin{document}
\EndPreamble

Any hint welcome

2
  • Does the .cfg file need to declare the graphics extensions BEFORE it sets the CoverMeta? Apr 22, 2019 at 21:24
  • @JeffreyJWeimer: changing the order in .cfg and/or converting all images to .png (default format, AFAIK) does not change anything. Cover image is processed and present, images in \partimage are not.
    – ZioByte
    Apr 22, 2019 at 21:38

1 Answer 1

3

tex4ht redefines all sectioning commands, in order to provide a uniform configurable interface for all LaTeX classes. So the \printparttitle command is not used in tex4ht. Instead, the image can be printed in configuration for \part. Try the following configuration file:

\Preamble{xhtml}
\CoverMetadata{thano.jpg}
\Configure{AddCss}{blitz-lite.css}
\makeatletter
\Configure{part}
{}{}
{\ifvmode\IgnorePar\fi\EndP\HCode{<h1 class="partHead"><span class="titlemark">}\partname \ \thepart \HCode{</span>}}
{\HCode{</h1>\Hnewline<aside class="partimage">}\@partimage\HCode{</aside>}\IgnoreIndent\par\OpfRegisterFile}
\makeatother
\Css{.partimage{margin:0 auto;text-align:center;}}
\Css{.partimage img{max-width:100\%;}}
\Css{.partHead .titlemark{display:block;}}
\DeclareGraphicsExtensions{.svg,.png,.jpg,.pdf}
\begin{document}
\EndPreamble

The most important part is in \Configure{part} from the manual:

\Configure{unit} {top} {bottom} {before-title} {after-title}

This command determines the content to be inserted at the mentioned locations of the specified units.

\Configure{chapter}
{\HCode{<div class="chapter">}}  {\HCode{</div>}}
{\HCode{<h2 class="chapterHead">}\chaptername
    ~\thechapter\HCode{<br />}}
{\HCode{</h2>}}

So we insert the image in the top insertion:

 \ifvmode\IgnorePar\fi\EndP\HCode{<aside class="partimage">}\@partimage\HCode{</aside>}

The \ifvmode\IgnorePar\fi\EndP is necessary to get the paragraphs right, \HCode{<aside class="partimage">}\@partimage\HCode{</aside>} then prints the image inside <aside class="partimage"> element. This enables us to style it using CSS styles, as can be seen in the \Css commands.

The \OpfRegisterFile command is necessary for a correct page sequence. This command is provided by tex4ebook and registers current HTML file to a page sequence. The page with part title would be displayed at the end of file otherwise.

This is the result:

enter image description here

4
  • Thanks; just a small issue: I would like to have image below title. Playing with top/bottom/before/after I managed to place image between "Parte I" and Title, but if I try to put it after Title strange things happen (i.e.: I get image for "Parte II" after "Parte I" or I don't get "Parte I" where it belongs, but it directly goes where "Parte II" should be... and "Parte II" is where I expect "Parte III"). Any hint?
    – ZioByte
    Apr 23, 2019 at 10:50
  • 1
    @ZioByte I would insert it after </h1> then. See the updated answer.
    – michal.h21
    Apr 23, 2019 at 11:01
  • Thanks; tex4ebook seems very capable, unfortunately I was not able to find extensive documentation (just the very terse 'tex4ebook-doc.pdf') so I keep bumping into problems next one has a separate Question.
    – ZioByte
    Apr 23, 2019 at 12:39
  • @ZioByte most of the issues are shared with tex4ht, but it hasn't much better documentation. I am working on a new documentation for tex4ht: github.com/michal-h21/tex4ht-doc it already contains lot of info about configuration
    – michal.h21
    Apr 23, 2019 at 12:43

You must log in to answer this question.

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