I don't get this error with the current TeX Live 2020. It is probably some package clash that had been fixed in the past.
Anyway, there is no awesomebox
support in TeX4ht, so this needs some work. I've came with the following solution. Save this as awesomebox.4ht
:
\NewConfigure{awesomebox}{3}
\newcounter{awesomebox@cnt}
\RenewDocumentCommand \awesomebox { O{abvrulecolor} O{} o m m m +m }{%
\stepcounter{awesomebox@cnt}
\def\awesomebox@id{awesomebox-\arabic{awesomebox@cnt}}
\extractcolorspec{#1}{\tsf@color}%
\expandafter\convertcolorspec\tsf@color{HTML}\tsf@color%
\a:awesomebox
\IfValueTF {#3}
{ #3 \\ #2 \textcolor{#6}{\Huge#5}\b:awesomebox #7 #2}
{ #2 \textcolor{#6}{\Huge#5}\b:awesomebox #7 #2}
\c:awesomebox
}
\Configure{awesomebox}{%
\Css{\#\awesomebox@id\space .icon{border-right:4px solid \#\tsf@color;}}
\ifvmode\IgnorePar\fi\EndP%
\HCode{<div class="awesomebox" id="\awesomebox@id"><div class="icon">}%
\Picture+{}%
}{\EndPicture%
\HCode{</div><div class="boxcontent">}%
\par%
}{%
\ifvmode\IgnorePar\fi\EndP%
\HCode{</div></div>}%
}
\Css{.awesomebox{display:grid; grid-template-columns: 90px auto;margin-top:1rem;margin-bottom:1rem;}}
\Css{.awesomebox .icon{padding-right:0.5rem;margin-right:0.5rem;text-align:center;}}
\Css{.awesomebox .boxcontent{vertical-align:top;}}
It redefines the \awesomebox
command to insert HTML tags instead of the default code. The redefinition also generates unique ID for each box - we need this in order to be able to apply color rule to each box. The rule color is converted to RGB value usable in CSS and saved in \tsf@color
macro. \a:awesomebox
, \b:awesomebox
and \c:awesomebox
are macros used to insert the HTML code. They are declared using \Configure{awesomebox}
.
\Css{\#\awesomebox@id\space .icon{border-right:4px solid \#\tsf@color;}}
This declares the colored bar.
\HCode{<div class="awesomebox" id="\awesomebox@id"><div class="icon">}%
This inserts the <div>
element that contain the whole box. Icon and the text are both contained in another <div>
elements, with icon
and boxcontent
classes.
\Picture+{} ... \EndPicture
This will convert all code that is contained to images. It will convert icons to images.
\Css{.awesomebox{display:grid; grid-template-columns: 90px auto;margin-top:1rem;margin-bottom:1rem;}}
\Css{.awesomebox .icon{padding-right:0.5rem;margin-right:0.5rem;text-align:center;}}
\Css{.awesomebox .boxcontent{vertical-align:top;}}
This styles the box. We use the CSS grid to display box as table. Icon is 90px wide, the text content is resized as necessary.
There is another small issue. There are no support files for Fontawesome fonts in TeX4ht. We need to provide some dummy files to suppress the error message. Save the following content to both fa5free1solid.htf
and fa5free1solid.htf
:
.lm-ec
This is an example where I've added some more sample boxes:
\documentclass[a4paper,twoside,openright]{book}
\usepackage[greek,british]{babel}
\usepackage{xcolor}
\usepackage{awesomebox}
\setlength{\aweboxleftmargin}{9mm}
\setlength{\aweboxsignraise}{-5mm}
\usepackage{lipsum}
\makeatletter
\begin{document}
\textcolor{green}{hi}
\notebox{test} % Comment out this line and it works just fine, but with it you get an error for textcolor
\tipbox{\lipsum[1-2]}
\warningbox{\lipsum[3]}
\end{document}
And this is the result:

htlatex file
(tested in a current texlive).xcolor
clashes. I will try to come with a solution for the icons.