# tex4ht: getting accented letters in small capitals through \selectfont

I try to get small capitals in my html document, but the tex4ht code that I found works only for the command \textsc. however, I enter all my change of font through \rmfamily\mdseries\scshape\selectfont and so the accented letters are not turned into small capitals.

i compile with make4ht -ul hello.tex

I use an extension of tex4ht by @michal.h21,

https://github.com/michal-h21/helpers4ht

\documentclass[oneside,a4paper, 12pt]{article}

\usepackage{alternative4ht}
\altusepackage{fontspec}
\setmainfont{TeX Gyre Termes}
\altusepackage{polyglossia}
\setmainlanguage{czech}

\ifx\HCode\undefined \else
\AtBeginDocument{
\Configure{textsc}{\ifvmode\ShowPar\fi\NoFonts\HCode{<span class="sc">}}{\HCode{</span>}\EndNoFonts}
\Css{.sc{ font-variant: small-caps;}}
}\fi
\begin{document}

\section{LlAaLALALA}

small with selectfont: \rmfamily\mdseries\scshape\selectfont{Příliš žluťoučký kůň úpěl ďábelské ódy}\normalfont\\
small: \textsc{Příliš žluťoučký kůň úpěl ďábelské ódy}\\
capital: \textsc{PŘÍLIŠ ŽLUŤOUČKÝ KŮŇ ÚPĚL ĎÁBELSKÉ ÓDY}\\

\end{document}


You would get the same result also with default setup with fontenc and inputenc:

\documentclass[oneside,a4paper, 12pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\ifx\HCode\undefined \else
\AtBeginDocument{
\Configure{textsc}{\ifvmode\ShowPar\fi\NoFonts\HCode{<span class="sc">}}{\HCode{</span>}\EndNoFonts}
\Css{.sc{ font-variant: small-caps;}}
}\fi
\begin{document}

\section{LlAaLALALA}

small with selectfont: \rmfamily\mdseries\scshape\selectfont{Příliš žluťoučký kůň úpěl ďábelské ódy}\normalfont\\
small: \textsc{Příliš žluťoučký kůň úpěl ďábelské ódy}\\
capital: \textsc{PŘÍLIŠ ŽLUŤOUČKÝ KŮŇ ÚPĚL ĎÁBELSKÉ ÓDY}\\

\end{document}


when you take a look at the HTML:

<span
class="eccc1200-"><span
class="small-caps">P</span></span><span
class="eccc1200-">ř</span><span
class="eccc1200-">í<span
class="small-caps">l</span><span
class="small-caps">i</span></span><span
class="eccc1200-">š </span><span


span elements with two different classes are used for accented and unaccented letters. In the dvi file, it is recorded as following:

 fnt: eccc1200 at 12pt
set: 'P'
xxx: 't4ht@+&{35}x0159{59}'
set: 'x'
xxx: 't4ht@+&{35}x00ED{59}'
set: 'xli'
xxx: 't4ht@+&{35}x0161{59}'
set: 'x'
w: 4.360046pt


As you can see, font eccc1200 is selected for the whole text, so class=eccc1200- should have been used. But small caps are obviously redefined somewhere to produce class small-caps, which isn't applied to accented letters. It is a bug in tex4ht dvi processor, which is unlikely to get fixed, as there is nobody who understand it. So as a fix, you can configure class eccc1200- to produce small caps through CSS:

\ifx\HCode\undefined \else
\AtBeginDocument{
\Configure{textsc}{\ifvmode\ShowPar\fi\NoFonts\HCode{<span class="sc">}}{\HCode{</span>}\EndNoFonts}
\Css{.sc,.eccc1200-{ font-variant: small-caps;}}
}\fi

• it is odd: if I compile your mwe [with inputenc] with make4ht -ul hello.tex I have no problem with the accented small caps from \selectefont, whether I use \Css{.sc,.eccc1200-{ font-variant: small-caps;}} or the original \Css{.sc{ font-variant: small-caps;}}. The odd thing is that, If I compile your mwe without any css{...}, then I have no problem with sc from \selectefont, but I loose the non-capital sc from \textsc{...}. Your trick \Css{.sc,.eccc1200-{ font-variant: small-caps;}} does not work when I use my mwe with  \usepackage{alternative4ht}. – Koala Jan 8 '16 at 12:53
• in fact, my original mwe leads to class="cmcsc-10x-x-120">ó<span  and not eccc1200-. even if I try \Css{.sc,.cmcsc-10x-x-120-{ font-variant: small-caps;}} with my mwe, it does not work – Koala Jan 8 '16 at 12:58
• @Koala you are right, different font name is used with original mwe. \Css{.sc,.cmcsc-10x-x-120{ font-variant: small-caps;}} works for me (note that in this case there should be no - at the end of class name, it should be the same as in the class attribute only with dot at the beginning – michal.h21 Jan 8 '16 at 13:14