# Make4ht with \ref and \index in the Caption

The below file compile fine with pdflatex and showing error in make4ht. How to rectify this?

\documentclass{book}
\usepackage{lipsum,hyperref}
\begin{document}
\chapter{Chapter Title}

\section{Introduction}\label{sec:1}

Nominal data are usually used with count and frequencies, such as to find out the total number of left-handed participants in a study. Figure~\hyperref[fig-001]{1.1} illustrates an excerpt from a questionnaire that collected nominal data.

\subsection{Background}\label{subsec:1-1}

\lipsum[3]

\begin{figure*}
\caption{Excerpt 95\% from a questionnaire used in an actual user study of Section~\ref{sec:1} and Subsection~\ref{subsec:1-1} to collect nominal \index{demographics} data [\protect\hyperlink{ch2-ref48}{Shang et\,\,al. 2020}].\label{fig-001}}
\end{figure*}

With this approach, the lowest, the middle, and the highest points of the actual scale are anchored to the lowest, the middle, and the highest points of the target scale, respectively, then the intervening scale points are inserted at equal numerical intervals.

The European Union-wide framework known as the General Data Protection Regulation \footnote{{\href{https://ec.europa.eu/commission/priorities/justice-and-fundamental-rights/data-protection/2018-reform-eu-data-protection-rules_en}{https://ec.europa.eu/commission/priorities/justice-and-fundamental-rights/data-protection/2018-reform-eu-data-protection-rules{\_}en}.}} EU approach data privacy.

\end{document}


UPDATE1:

UPDATE2:

Figure 1.1 questionnaire should be Figure <a href='#fig1.1'>1.1</a> questionnaire. It means caption cross-links are missing.

• Thanks for posting the new question. What is the error message that you get with make4ht? If you can, please paste the error as text in a code block and not an an image. Aug 5 at 12:16
• LaTeX1 Compile Error is: [ERROR] htlatex: ./test1.tex 862 File ended while scanning use of \newlabel. LaTeX2 Compile Error is: [ERROR] htlatex: ./test1.tex 862 File ended while scanning use of \n:wlbl. [ERROR] htlatex: ./test1.tex 3 File ended while scanning use of \:testdef. Aug 5 at 12:21
• @JohnKormylo: I have needed the figure caption in the \listoffigures also. How to avoid this error using duplicate. could you please provide the command? Aug 5 at 12:30
• Your code works fine for me. Try deleting the aux file and try again. Aug 5 at 12:37
• @JohnKormylo: Yes, It's working fine after deleting aux file. But when using make4ht without -m draft option it's running 3 times and showing error. But the output HTML is having cross link is working fine. Aug 5 at 12:41

It seems that there was no configuration for the figure* environment in TeX4ht, so you don't get correct HTML tags in this case. I've fixed this issue in TeX4ht sources. Until this change comes to TeX Live, you can use the following configuration file:

\Preamble{xhtml}
\ConfigureEnv{figure*}
{\IgnorePar\EndP\HCode{<figure class="figure">\Hnewline}%
\bgroup \Configure{float}{\ShowPar}{}{}%
}
{\egroup
\IgnorePar\EndP\HCode{</figure>}\ShowPar
\par}
{}{}

\begin{document}
\EndPreamble


This is the resulting HTML code for your figure:

   <figure class='figure' id='-excerpt-from-a-questionnaire-used-in-an-actual-user-study-of-section-ref-sec-and-subsection-ref-subsec-to-collect-nominal-data-chrefshang-etal-'>
<a id='x1-30011'></a>
<figcaption class='caption'><span class='id'>Figure 1.1: </span><span class='content'>Excerpt 95% from a questionnaire used in an actual user study of
Section 1.1  and Subsection 1.1.1  to collect nominal  data [<a href='#ch2-ref48'>Shang et al. 2020</a>].</span></figcaption><!-- tex4ht:label?: x1-30011  -->
</figure>