<div dir="ltr">Michal,<div><br></div><div>I've come back to your suggestions, and am implementing them.  Maybe this will suggest I should switch to newer software, b/c ...</div><div><br></div><div>(1) when I compiled your sample in isolation (first bit of text below), I got an error from epubcheck.  The generated epub looked fine, and the internal references worked, but this error worries me, because epubcheck is the only tool I know of to verify that an epub is well-formatted.</div><div><br></div><div>(2) I then transferred your suggestions to my actual book, and ..... the references didn't work.  I'm in the process of boiling this down to an MWE, but figured I'd report this, just in case the answer is "you need to update your software".</div><div><br></div><div>Thanks,</div><div>--che--</div><div><br></div><div>== 1 ==</div><div>$ ls<br>config.cfg  Makefile  sample.tex<br>$ make sample.FULL<br>tex4ebook -c config.cfg sample.tex<br>[STATUS]  tex4ebook: Conversion started<br>[STATUS]  tex4ebook: Input file: sample.tex<br>HTML Tidy for Linux version 5.6.0<br>[STATUS]  tex4ebook: Conversion finished<br>make[1]: Leaving directory '/home/chet/Hack/jcfilliatre/sample'<br>epubcheck sample.epub<br>/usr/bin/epubcheck: 1: PK  : not found<br>/usr/bin/epubcheck: 2: Syntax error: word unexpected (expecting ")")<br>make: *** [Makefile:9: sample.FULL] Error 2<br>$ </div></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Thu, Feb 20, 2025 at 5:14 AM Michal Hoftich <<a href="mailto:michal.h21@gmail.com">michal.h21@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div>Hi Chet,</div></div><div><br></div><div class="gmail_quote"><div dir="ltr" class="gmail_attr"><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><br><div>I've been fighting a perplexing problem with internal refs when generating an ebook.  I've boiled it down to an MWE, but really don't know how to proceed.  It seems that people attach MWE as MIME attachments, and that's what I'll do.  </div><div><br></div><div>I'm not a real expert in TeX, so perhaps I've left a few things in this MWE that I could/should have left out. I hope it's small enough.  Also, I should ask if there are any good tutorials or references for how to get \label/\ref to work well with tex4ebook/tex4ht, esp. in the presence of figure, minipage, listinputlisting environments.  I left in the chapters, so that the generated EPUB would have multiple pages (so I could verify that the links were broken by testing them in ebook-viewer, as well as by epubcheck).</div><div><br></div><div>Environment:</div><div><br></div><div> I'm using:</div><div>Ubuntu 24.04 LTS</div><div>texlive 2023.20240207-1</div><div><br></div><div>and the tex4ht and tex4ebook that come with the packages texlive-extra-utils and texlive-binaries.</div></div></div></blockquote><div><br></div><div><div dir="ltr"><div><br></div><div>it seems there are multiple problems:</div><div><br></div><div>1. you are probably using too old version of TeX4ht and TeX4ebook, you shouldn't get epubcheck errors about colons in id with the up-to-date version.</div><div>2. I would change your TeX code. First of all, I would use a custom environment that would replace the minipage, update the program counter, and print the program title.</div><div><br></div><div>The declaration can look like this:</div><div><br></div><div>\newcounter{program}<br>\renewcommand{\theprogram}{\arabic{program}}<br>\newcommand\printprogram[1]{\theprogram\space #1\par}<br>\newenvironment{program}[1]{\refstepcounter{program}\minipage{\textwidth}\printprogram{#1}}{\endminipage}<br></div><div><br></div><div>You can then simplify your listings:</div><div><br></div><div>\begin{figure}[tp]<br>\begin{program}{Title}<br>\label{fig:label}<br>\lstinputlisting{/usr/share/texlive/README}%<br>\end{program}<br>\caption{Caption}<br>\end{figure}<br></div><div><br></div><div>Note that you need to use \label directly after \begin{program}, because \lstinputlisting internally updates reference counters so that the link would be wrong.</div><div><br></div><div>For TeX4ht, you will need to use a config file:</div><div><br></div><div>%%%%%%%%%%%%</div><div>\Preamble{xhtml}<br>\ConfigureEnv{program}<br>{\ifvmode\IgnorePar\fi\EndP\HCode{<div class="program">}\Configure{minipage}{}{}{}{}}<br>{\ifvmode\IgnorePar\fi\EndP\HCode{</div>}}{}{}<br>\renewcommand\printprogram[1]{\ifvmode\IgnorePar\fi\EndP</div><div>\HCode{<div class="programname">}\AnchorLabel\theprogram\quad#1\HCode{</div>}\par}<br><br>\begin{document}<br>\EndPreamble<br></div><div>%%%%%%%%%%%%</div></div><div><br></div><div>It adds some HTML tags for the program and program title, to enable CSS styling. For example, if you want to make the title bold, you could add something like:</div><div><br></div><div>\Css{.programname{text-weight: bold;}} <br></div><div><br></div><div>to the config file. Also, note the \AnchorLabel command. It will insert a destination link for the current label. This will ensure that \ref and \pageref will point to the right place. <br></div><div><br></div><div>The full example is attached. Compile using:</div><div><br></div><div>$ tex4ebook -c config.cfg sample.tex</div><div><br></div><div>Best regards,</div><div>Michal</div><div><br></div> </div></div></div>
</blockquote></div>