1

I found great solution here which allows one to use verbatim as second argument for href. It is the only solution I found after trying many, where I can use verbatim as second argument of href. (No, I do not want to use \url, I need to use href as I want to use specific shorter target names, as the URL can be very long to use)

It worked in pdf. When I tried it in tex4ht I get a compile error. Here is MWE

\documentclass[12pt,notitlepage]{article}
\usepackage{hyperref}
\usepackage{verbatimbox}

\begin{document} 

\begin{myverbbox}{\myTarget}https://some_url_with_^many_%*?_strange_characters/report.htm\end{myverbbox}

\href{https://some_url_with_^many_%*?_strange_characters/report.htm}{\myTarget}

\end{document}

This compiles in lualatex to pdf with no problem

enter image description here

But in tex4ht it gives error

make4ht -ulm default -a debug main.tex "mathjax,htm,nostyle"

...
(/usr/local/texlive/2023/texmf-dist/tex/latex/l3backend/l3backend-dvips.def)
(./main.aux) (/usr/local/texlive/2023/texmf-dist/tex/latex/base/ts1cmr.fd)
(/usr/local/texlive/2023/texmf-dist/tex/latex/lm/t1lmtt.fd)
! Missing \endcsname inserted.
<to be read again> 
\hbox 
l.59 ...strange_characters/report.htm\end{myverbbox}

Does tex4ht not support verbatimbox? How to make it work in tex4ht also?

TL 2023

tex4ht tracking

1 Answer 1

2

This issue seems to be caused by the redefinition of the \sbox command by TeX4ht. The following config file should fix this issue:

\Preamble{xhtml}
\catcode`\:=11
\let\sbox\:sbox
\DeclareRobustCommand\:xbox[2]{\o:sbox:{#1}{{#2}}}
\HLet\sbox\:xbox
\catcode`\:=12
\begin{document}
\EndPreamble

With this change, it compiles:

enter image description here

<!-- l. 11 --><p class='noindent'><a href='https://some_url_with_^many_%*?_strange_characters/report.htm'><span class='cmtt-12'>https://some_url_with_^many_%*?_strange_characters/report.htm</span>   </a>
</p>
1
  • Thanks Michal. Will test it later today on a large document I have.
    – Nasser
    Oct 2 at 10:11

You must log in to answer this question.

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