3

Turning a book I just finished into an ebook, I ran into two (I thought unrelated) problems. The more vexing one was that the open-double-quote was being turned into a backslash after a point very early on. The second was that at some point the font went wonky and I was getting character-level <span>s for the bulk of the book, which I was able to work around using the excellent answer here related to \Configure{htf}. Coming up with an MWE for this post, I discovered that they are related.

\documentclass[10pt]{book}

\usepackage{hyperref}

\begin{document}
``This renders correctly''

{\sc Do small caps break it?} ``No"

\hyperlink{a}{How about hyperlinks?} ``No"

\hyperlink{a}{\sc But... small caps inside hyperlinks} make everything afterwards render as
small caps, and break the ``double quotes,'' though not the `single quotes.'

\end{document}

This renders just fine in LaTeX... "But... small caps inside hyperlinks" is rendered in small caps, and the text afterwards is normal, with normal double quotes. However, compiling it with htlatex test.tex "xhtml" gives HTML with character-level spans that persist after the hyperlink, and the opening double quote is rendered as backslash.

I discovered that I could work around this by putting a \normalfont at the end of the hyperlink text. It still renders the small caps with character-level spans but I should post that as another question, I suppose.

So I will mark this as "answered," but I wanted to post it to point out what looks to be a bug in tex4ht, and in case anyone has a similar problem

2 Answers 2

4

Use \textsc and not the deprecated command \sc:

\documentclass[10pt]{book}

\usepackage{hyperref}

\begin{document}
``This renders correctly''

\textsc{Do small caps break it?} ``No''

\hyperlink{a}{How about hyperlinks?} ``No''

\hyperlink{a}{\textsc{But... small caps inside hyperlinks}} make everything afterwards render as
small caps, and break the ``double quotes,'' though not the `single quotes.'

\end{document}

This is the output after htlatex test.tex "xhtml"

<?xml version="1.0" encoding="iso-8859-1" ?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
<!--http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd-->  
<html xmlns="http://www.w3.org/1999/xhtml"  
> 
<head><title></title> 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> 
<meta name="generator" content="TeX4ht (http://www.tug.org/tex4ht/)" /> 
<meta name="originator" content="TeX4ht (http://www.tug.org/tex4ht/)" /> 
<!-- xhtml,html --> 
<meta name="src" content="kuhn.tex" /> 
<meta name="date" content="2014-08-31 19:32:00" /> 
<link rel="stylesheet" type="text/css" href="kuhn.css" /> 
</head><body 
>
<!--l. 6--><p class="noindent" >&#8220;This renders correctly&#8221;
</p><!--l. 8--><p class="indent" >   <span 
class="cmcsc-10">D<span 
class="small-caps">o</span> <span 
class="small-caps">s</span><span 
class="small-caps">m</span><span 
class="small-caps">a</span><span 
class="small-caps">l</span><span 
class="small-caps">l</span> <span 
class="small-caps">c</span><span 
class="small-caps">a</span><span 
class="small-caps">p</span><span 
class="small-caps">s</span> <span 
class="small-caps">b</span><span 
class="small-caps">r</span><span 
class="small-caps">e</span><span 
class="small-caps">a</span><span 
class="small-caps">k</span> <span 
class="small-caps">i</span><span 
class="small-caps">t</span>? </span>&#8220;No&#8221;
</p><!--l. 10--><p class="indent" >   <a 
href="#a">How about hyperlinks?</a> &#8220;No&#8221;
</p><!--l. 12--><p class="indent" >   <a 
href="#a"><span 
class="cmcsc-10">B<span 
class="small-caps">u</span><span 
class="small-caps">t</span>... <span 
class="small-caps">s</span><span 
class="small-caps">m</span><span 
class="small-caps">a</span><span 
class="small-caps">l</span><span 
class="small-caps">l</span> <span 
class="small-caps">c</span><span 
class="small-caps">a</span><span 
class="small-caps">p</span><span 
class="small-caps">s</span> <span 
class="small-caps">i</span><span 
class="small-caps">n</span><span 
class="small-caps">s</span><span 
class="small-caps">i</span><span 
class="small-caps">d</span><span 
class="small-caps">e</span> <span 
class="small-caps">h</span><span 
class="small-caps">y</span><span 
class="small-caps">p</span><span 
class="small-caps">e</span><span 
class="small-caps">r</span><span 
class="small-caps">l</span><span 
class="small-caps">i</span><span 
class="small-caps">n</span><span 
class="small-caps">k</span><span 
class="small-caps">s</span></span></a> make everything afterwards
render as small caps, and break the &#8220;double quotes,&#8221; though not the &#8216;single
quotes.&#8217;
</p>

</body></html> 

and you see that the small caps are properly segregated.

2
  • Thanks, I see that works too... Would love to know how to solve the per-character <span>s (I see that I didn't do the right markdown for <span> above, I'll edit that.
    – Nat Kuhn
    Commented Aug 31, 2014 at 19:19
  • @NatKuhn That's much beyond my almost inexistent knowledge of tex4ht.
    – egreg
    Commented Aug 31, 2014 at 19:20
0

As I point out in the text above, inserting a \normalfont at the end of the hyperlink text works around this bug.

I would welcome other answers.

You must log in to answer this question.

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