3

I was trying https://ctan.org/pkg/transparent package. I get an error when using it with tex4ht. Same code works OK in lualatex and pdf.

Is there a way to make it work with tex4ht? Here is MWE

\documentclass[12pt]{book}
\usepackage{graphicx}
\usepackage{transparent}
\begin{document} 

some text here

More text here

\transparent{1}\includegraphics[width=0.5\textwidth]{example-image-a}

More text here

More text here
\end{document}

Compiled using

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

gives

/usr/local/texlive/2023/texmf-dist/tex/latex/l3backend/l3backend-dvips.def)
(./foo2.aux) (/usr/local/texlive/2023/texmf-dist/tex/latex/base/ts1cmr.fd)
! Undefined control sequence.
l.12 \transparent
               {1}\includegraphics[width=0.5\textwidth]{example-image-a}
? 

TL 2023 on Linux.

tex4ht tracking

2 Answers 2

3

Try this configuration file, transparent.4ht:

\providecommand\transparent[1]{}
\NewConfigure{texttransparent}{2}
\providecommand\texttransparent[2]{\def\transparent:opacity{#1}\a:texttransparent#2\b:texttransparent}
\Configure{texttransparent}{\HCode{<span class="texttransparent" style="opacity:\transparent:opacity;">}}{\HCode{</span>}}
\Hinput{transparent}
\endinput

It defines dummy \transparent command, but the \texttransparent actually can be used for transparency in HTML.

Here is a sample:

\documentclass[12pt]{article}

\usepackage{color}
\usepackage{transparent}

\begin{document}
\colorbox{yellow}{%
\bfseries
 \color{blue}%
 Blue and %
 \transparent{0.6}%
 transparent blue%
 }

 \bigskip
 Hello World
 \texttransparent{0.5}{Hello World}
 Hello World
 \end{document}

This is the result:

enter image description here

As you can see, both \color and \transparency don't have any effect, as I cannot find a way how to support them reliably for the HTML output.

3

The original transparent package doesn't support dvi-modes, it only works with lualatex and pdflatex.

If you load the new pdfmanagement and the extended backend code

\DocumentMetadata{}
\documentclass{article}

it will no longer error (as long as tex4ht doesn't disable \DocumentMetadata), but I don't know if tex4ht will do something sensible in html with it.

As an alternative you could provide a fallback definition:

\documentclass[12pt]{book}
\usepackage{graphicx}
\usepackage{transparent}
\providecommand\transparent[1]{}
\begin{document} 

some text here

More text here

\transparent{1}\includegraphics[width=0.5\textwidth]{example-image-a}

More text here

More text here
\end{document}

You must log in to answer this question.

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