[tex4ht] Is it possible to fix tex4ht links so so it ends at top of page?

Nasser M. Abbasi nma at 12000.org
Wed Sep 25 11:17:01 CEST 2024


On 9/20/2024 2:59 AM, Michal Hoftich wrote:
> 
> Toc links always point directly to the section titles. As there are
> usually  multiple sections on each page, you couldn't link to individual
> sections otherwise.
> 
> If you have TOC that links only to chapters that are alway on a separate
> page, you can try this configuration:
> 
> %%%%%%%%%%%%%%%%%%%%%%%%%
> \Preamble{xhtml}
> 
> \Configure{TocLink}{\Link[\LikeRef{cutfile \LikeRef{fileidcut #1}(L
> }]{}{#3} #4\EndLink}
> 
> \begin{document}
> \EndPreamble
> %%%%%%%%%%%%%%%%%%%%%%%%%
> 

Hello Michal;

Is there a way to turn this \configure command On and Off
in Latex?

I'd like to use it, but the problem is that I do have TOC's
on a page which is not split, and now the links do not work.

I am thinking if there is a way to turn this ON and OFF
from inside Latex, then it can work for me.

If I put your command in .cfg then it will not work for me
as it affects the whole document and some local TOC's where
the split is not large enough will no longer work.

Here is an example to illustrate. This is 2 chapters web page
with split=2.  So each chapter will be on separate web page.

But on chapter one, I have few sections and a local TOC for
the chapter that links to them, i.e. on same page.

------ example -----------
\documentclass[12pt]{book}%

\usepackage{lipsum}

\begin{document}
	
\ifdefined\HCode
\Configure{TocLink}{\Link[\LikeRef{cutfile \LikeRef{fileidcut #1}(L }]{}{#3} #4\EndLink}
\Configure{tableofcontents*}{chapter}
\else
\setcounter{tocdepth}{0} %for toc
\tableofcontents
\fi

\ifdefined\HCode
\TocAt{chapter,section}%this tells tex4ht to make TOC on chapter also
\fi

	
\chapter{chapter 1}
%tex4ht will now automatically generate local TOC here
%but the TOC no longer have links that work
%is it possible to TURN OFF the \Configure{TocLink} here
%if so, how? i.e. make it go back to default
\section{s1}
\lipsum[2-4]
\section{s2}
\lipsum[2-4]

%Now I can turn the \Configure{TocLink} back ON here
\ifdefined\HCode
\Configure{TocLink}{\Link[\LikeRef{cutfile \LikeRef{fileidcut #1}(L }]{}{#3} #4\EndLink}
\fi
\chapter{chapter 2}
more important text

etc....	
\end{document}
------------------------------

Now I compile the above using

make4ht -ulm default -a debug A.tex "mathjax,2,htm"

You will see that the main TOC works, but the TOC
on first chapter, the links do not work.  I can fix this
by making split=3, but I do not want to do that.

Is there a way to turn this on/off inside the Latex itself?
If so, then this will work for me.

Thank you,
--Nasser



More information about the tex4ht mailing list.