1

In this minimal example:

\documentclass[11pt]{book}
\usepackage[utf8]{inputenc}
\usepackage[]{hyperref}

\begin{document}
Hahaha \hyperref[other]{2}
\end{document}

Compiling with pdflatex, it ends up fine:

pdf

However when I compile it with

make4ht minimal.tex "mathml"

The html version does not show the number correctly.

enter image description here

I would like to know, how can I adjust htlatex so that it correctly produces documents with \hyperref?

Thanks

1
  • 1
    There's no anchor for that link: no \label{other} command anywhere. Once you add that, it works for me.
    – frabjous
    Commented Jun 30, 2022 at 23:34

1 Answer 1

0

It seems like a bug in TeX4ht support for the \hyperref command. It uses the \ref command internally, so when the linked label is not found, it will print ?? to signalize the missing reference. As you don't have any other label in your document, you get this missing reference sign.

You can use the following config file to mimic the \hyperref behavior, which prints the text even when reference is missing:

\Preamble{xhtml}
\makeatletter
\def\label@hyperref[#1]{%
  \expandafter\label@@hyperref\csname r@#1\endcsname{#1}%
}%
\def\label@@hyperref#1#2#3{%
  \ifx#1\relax
    \protect\G@refundefinedtrue
    \@latex@warning{%
      Hyper reference `#2' on page \thepage \space undefined%
    }%
    \begingroup
      \hyperrefundefinedlink{#3}%
    \endgroup
  \else%
    \def\hyperrefLabel{#3}%
    \Configure{ref}%
      {\Link}{\EndLink}{\Configure{ref}{}{}{}#3}\ref{#2}%
  \fi
}
\makeatother
\begin{document}
\EndPreamble

compile using:

 make4ht -c config.cfg minimal.tex "mathml"

This is the result:

enter image description here

1
  • Thank you very much for your answer!
    – Socrates
    Commented Jul 8, 2022 at 19:15

You must log in to answer this question.

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