Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

When htlatex converts a document, emphasis and bold-face are converted to spans of a certain style which is defined in the accompanying CSS file.

Input:

\documentclass{scrartcl}

\begin{document}
  Normal text

  \em{Emphasized text}

  \textbf{Bold-faced text}
\end{document}

Output (header and footer stripped):

<!--l. 4--><p class="noindent" >Normal text
<!--l. 6--><p class="indent" >  <span 
class="cmti-10x-x-109">Emphasized text</span>
<!--l. 8--><p class="indent" >  <span 
class="cmbxti-10x-x-109">Bold-faced text </span> 

Is it possible to generate "plain" HTML that does not use an external CSS file? Something along these lines:

<!--l. 4--><p class="noindent" >Normal text
<!--l. 6--><p class="indent" >  <em>Emphasized text</em>
<!--l. 8--><p class="indent" >  <b>Bold-faced text </b>

This is for pasting references into another website that already has a CSS.

share|improve this question
    
You can also include the css-code inside the html file. Would that be acceptable too? –  canaaerus Sep 4 '12 at 10:09
add comment

1 Answer

up vote 11 down vote accepted

You have to do two things:

you can disable generation of css and ugly elements like

<span 
class="cmti-10x-x-109">Emphasized text</span>

with some command line options:

htlatex filename "xhtml, NoFonts, -css" 

You will then have to provide configurations for em and textit, as they are by default dealed only by css.

This should be done with custom config file, like myfonts.cfg

\Preamble{xhtml}
\Configure{emph}{\ifvmode\ShowPar\fi\HCode{<em>}}{\HCode{</em>}}
\Configure{textbf}{\ifvmode\ShowPar\fi\HCode{<b>}}{\HCode{</b>}}
\begin{document}
\EndPreamble

Now your htlatex call will be

htlatex filename "myfonts, -css, NoFonts"

Resulting html

<body 
>
<!--l. 4--><p class="noindent" >Normal text
</p><!--l. 6--><p class="indent" >  <em>Emphasized text</em>
</p><!--l. 8--><p class="indent" >  <b>Bold-faced text</b> </p> 
</body></html> 

All command line options of tex4ht are described in this article. There are also other interesting articles about configuring of this system.

For getting rid of <p class="indent">, you can put following to the config file:

\Configure{HtmlPar}
{\EndP\Tg<p>}
{\EndP\Tg<p>}
{\HCode{</p>\Hnewline}}
{\HCode{</p>\Hnewline}}
share|improve this answer
    
Works for me. But I have two questions: 1. Where did you find the documentation on the -css option? 2. Is there a way to get rid of the class="indent"? –  krlmlr Sep 4 '12 at 12:37
    
@user946850 see edit –  michal.h21 Sep 4 '12 at 12:59
    
The described code works for me too. But how to get rid off class="likesectionHead" and <a id="x1-1000"></a> from the < h3> tag (similarly from the < h4> tag), of the resulting html: <h3 class="likesectionHead"><a id="x1-1000"></a>2013</h3> <p> </p> <h4 class="likesubsectionHead"><a id="x1-2000"></a>Journal papers</h4> <p> </p> –  rasha Jan 1 '13 at 20:08
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.