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

Nasser M. Abbasi nma at 12000.org
Fri Sep 20 10:23:58 CEST 2024


On 9/20/2024 2:59 AM, Michal Hoftich wrote:
> Hi Nasser,
> 

> 
> 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
> %%%%%%%%%%%%%%%%%%%%%%%%%
> 
> Best regards,
> Michal

Thanks Michal. Yes this works as long as my split level matches
the table of content I am generating.

For example, if I have this latex

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

\usepackage{lipsum}
	
\begin{document}
\ifdefined\HCode
\Configure{tableofcontents*}{chapter}
\else
\setcounter{tocdepth}{0} %for toc
\tableofcontents
\fi

\ifdefined\HCode
\TocAt{chapter,section}%this says to make TOC for each chapter page
\fi

\tableofcontents	

\chapter{chapter 1}
\lipsum[2-4]

\section{section one in chapter 1}
\lipsum[2-4]

\section{section two in chapter 1}
\lipsum[2-4]


\chapter{chapter 2}
more important text
  	
\end{document}
----------------------

And compile using split level 2

make4ht -ulm default -a debug -c A.cfg A.tex 'mathjax,htm,2'

Then the links on the table of content on the chapter page
do _not_ work, since the sections inside the page are on same
page and not separate (as you said).

But this, now using 3 split level instead of 2, makes it work

make4ht -ulm default -a debug -c A.cfg A.tex 'mathjax,htm,3'

Now links in TOC in the chapter work and do not have
the shift problem.

So I think your new .cfg could work for me, I just need
to make sure the split level I am using matches correctly
with my use of these generated table of contents.

The problem is that the web pages are too complicated and
some have different split levels and TOC's all over the place,
so I need to change things.

I will see if I can use your .cfg.  It would be nice if the
software figures this all itself automatically, but this
may be just too complicated to do for all possible cases.

Regards
--Nasser




> 



More information about the tex4ht mailing list.