TeX4ht Supports Lettrine

Raphaël Pinson has kindly contributed the code that enables TeX4ht to support lettrine package. (lettrine.sty helps to typeset dropped capitals in a LaTeX document.) This probably will solve the long standing problem of drop capital support in TeX4ht, even if all the options of lettrine package are not supported at this time. Hope, Raphaël will continue support to enhance TeX4ht by adding all the missing options of lettrine.

Only ante option is supported now apart from basic command lettrine with two arguments, the first being the character for dropped capital and second, rest of characters in that string or chosen to form what is usually called lettrine line.

Seven TeX4ht hooks have been provided to configure lettrine as given hereunder:

  1. Before lettrine
  2. After lettrine
  3. Before lettrine initial character
  4. Between lettrine initial character and lettrine line
  5. After lettrine line
  6. Before lettrine ante
  7. After lettrine ante

Further hooks, namely, HlettrineChar and HlettrineString have been defined to access initial character and lettrine line respectively, in case, we want to further re-configure lettrine. The default configuration is provided below:

Configure{lettrine}
   {\HCode{<span class="lettrine lettrine-HlettrineChar">}}
   {\HCode{</span>}}
   {\HCode{<span class="lettrine-letter">}}
   {\HCode{</span><span class="lettrine-line">}}
   {\HCode{</span>}}
   {\HCode{<span class="lettrine-ante">}}
   {\HCode{</span>}}

Users shall write their own custom \Css declarations to format the dropcapital and lettrine line to suit their taste. The default \Css declarations are:

\Css{.lettrine{float: left;
    line-height: 0.7; margin-left: -0.1em;
    margin-bottom: -.5em; margin-right: 0.2em;}}
\Css{.lettrine-ante{vertical-align: top;}}
\Css{.lettrine-letter{font-family: InitialsFont; font-style: normal;
    font-size: 4em; color: gray;}}
\Css{.lettrine-A{margin-right: 0.3em;}}
\Css{.lettrine-A + .lettrine-line{margin-left: -0.4em;}}
\Css{.lettrine-{margin-right: 0.3em;}}
\Css{.lettrine- + .lettrine-line{margin-left: -0.4em;}}
\Css{.lettrine-J{line-height: 1; margin-right: 0;}}
\Css{.lettrine-H, .lettrine-I, .lettrine-N, .lettrine-U{margin-right: 0;}}
\Css{.lettrine-V{margin-right: -0.3em;}}
\Css{.lettrine-V + .lettrine-line{margin-left: 0.3em;}}
\Css{.lettrine-Q{padding-bottom: 1em;margin-top: -0.6em;}}
\Css{.lettrine-line{font-variant: small-caps;}}

A typical html page generated with the help of this newly created lettrine.4ht can be seen here.

6 Responses to “TeX4ht Supports Lettrine”


  • There is (probably) an error in lines

    Css{.lettrine-À{margin-right: 0.3em;}}
    Css{.lettrine-À + .lettrine-line{margin-left: -0.4em;}}
    

    Non-ASCII characters generate weired CSS file containing

     .lettrine-protect let prOteCt relax Protect csname acp:cendcsname {2}A{margin-right: 0.3em;}
    .lettrine-protect let prOteCt relax Protect csname acp:cendcsname {2}A + 
    
    • If you wrap the accented characters with unexpanded{...}, as given below:

        Css{.lettrine-unexpanded{À}{margin-right: 0.3em;}}

      the problem disappears. TeXLive has the modified version of lettrine.4ht.

  • Could you please provide some instructions on how to add this into an existing tex4ht installation? Does the .4ht file just need to be copied to the right place? Thanks.

  • You have generated a beautiful page here:
    http://download.river-valley.com/tex4ht/lettrine/ltrn-test.html
    It would be very educational for new users of tex4ht (which I find to be quite intimidating to use, unfortunately) such as myself, if you could please post the original tex file and perhaps a few comments on implementation.
    Thanks & Regards

    • As you will agree, the presentation of an HTML page is controlled by the *.css.  Usually, I do follow a minimalist approach to presentation with almost no colors and other frills. Here, the role of TeX4ht is only passive, i.e., TeX4ht does not do any formatting by its own except that it helps to write out the *.css declarations which you want to have in the jobname.css. Indeed, I am only happy to publish an annotated version of the source TeX file. But, I thought that people might be hundred times more imaginative or might have much better design sense than my minimalist ones. Anyway, I shall publish an annotated version of the source as soon as possible.

Leave a Reply