{"id":607,"date":"2012-10-23T14:57:58","date_gmt":"2012-10-23T09:27:58","guid":{"rendered":"http:\/\/www.cvr.cc\/?p=607"},"modified":"2012-10-23T14:57:58","modified_gmt":"2012-10-23T09:27:58","slug":"an-annotated-tex-source","status":"publish","type":"post","link":"https:\/\/cvr.cc\/?p=607","title":{"rendered":"An Annotated TeX Source"},"content":{"rendered":"<p>Mahesh wanted to see the annotated source of the T<span style=\"position: relative; top: 0.5ex; margin-left: -0.1667em; margin-right: -0.125em; text-transform: uppercase;\">e<\/span>X document that generated the output <a href=\"http:\/\/download.river-valley.com\/tex4ht\/lettrine\/ltrn-test.html\">shown here<\/a>. There are two components in the source:\u00a0 (1) document source, let us call it as <code>test.tex<\/code>, (2) a custom configuration for T<span style=\"position: relative; top: 0.5ex; margin-left: -0.1667em; margin-right: -0.125em; text-transform: uppercase;\">e<\/span>X4ht, let us call it as <code>my.cfg<\/code>.<br \/>\n<!--more--><\/p>\n<h4 style=\"color: #27d; font-size: 1.25em;\">Document Source<\/h4>\n<pre>documentclass[a4paper]{article}\n\n\\usepackage{lettrine}\n\\usepackage{lipsum,shortvrb}\n\\usepackage[utf8]{inputenc}\n\n\\MakeShortVerb{|}\n\\def\\hlink#1#2{\\Tg&lt;a href=\"#1\"&gt;#2\\Tg&lt;\/a&gt;}\n\n\\begin{document}\n\n\\title{Taming TeX4ht to Support Lettrine Package}\n\n\\author{\\hlink{http:\/\/www.cvr.cc}{\\textsc{cv radhakrishnan}},\n        \\Tg&lt;small&gt;\\hlink{http:\/\/www.river-valley.com}{River Valley},\n        Trivandrum, \\textsc{india}\\Tg&lt;\/small&gt;}\n\n\\maketitle\n\n\\lettrine{T}{his code} has kindly been contributed by\n\\hlink{http:\/\/www.raphink.info\/}{Rapha\"el Pinson} and is\n\\hlink{https:\/\/github.com\/cc-translators\/sagesse\/blob\/master\/lettrine.4ht}\n{available here}. The original code was slightly modified to fit\ninto the scheme of TeX4ht.  Rapha\"el had provided eight hooks to\nre\\Configure |lettrine| which I'd reduced to seven. All the hooks are\nprovided below:\n\n\\begin{enumerate}\n \\item Before |lettrine|\n \\item After  |lettrine|\n \\item Before lettrine initial character\n \\item Between lettrine initial character and lettrine line\n \\item After lettrine line\n \\item Before lettrine ante\n \\item After lettrine ante\n\\end{enumerate}\n\n\\lettrine{F}{urther} hooks have been defined to access initial\ncharacter and lettrine line in case we want to \\Configure\n|lettrine|. |HlettrineChar| and |HlettrineString| can be used to\naccess the character and line respectively. The screenshot of this\npages as rendered in Firefox is \\hlink{lettrine.png}{available here}.\n\nHere is a bit of dummy text to fill in the page. lipsum[5-9]\n\n\\end{document}<\/pre>\n<p>There is nothing special to explain in the above part. <code>\\hlink<\/code> is a<br \/>\ncustom macro with two arguments to cross-link something to a <small>URL<\/small>. The<br \/>\npackages are popular ones and need no introduction.<\/p>\n<h4 style=\"color: #27d; font-size: 1.25em;\">Custom Configuration<\/h4>\n<p>The custom configuration, <code>my.cfg<\/code> has two parts &#8212; a preamble part and a post preamble part. Preamble area shall consist of three important commands:<\/p>\n<ol>\n<li><code>\\Preamble<\/code> &#8212; beginning of preamble area.<\/li>\n<li><code>\\begin{document}<\/code> &#8212; do not confuse with the <code>begin{document}<\/code> in your document source.<\/li>\n<li><code>\\EndPreamble<\/code> &#8212; end of preamble area.<\/li>\n<\/ol>\n<p><code>\\Preamble<\/code> command shall contain all the options that are to be passed on to T<span style=\"position: relative; top: 0.5ex; margin-left: -0.1667em; margin-right: -0.125em; text-transform: uppercase;\">e<\/span>X4ht. Options can be provided as comma separated strings. All needed T<span style=\"position: relative; top: 0.5ex; margin-left: -0.1667em; margin-right: -0.125em; text-transform: uppercase;\">e<\/span>X packages shall be loaded before <code>Preamble<\/code> command as shown below, where we have loaded <code>xspace<\/code> package.<\/p>\n<pre>\\RequirePackage{xspace}\n\\Preamble{xhtml,NoFonts,ext=html,charset=\"utf-8\"}<\/pre>\n<p>For more details about options, please see <a href=\"http:\/\/www.cvr.cc\/tex4ht-options\/\">this post<\/a>.<\/p>\n<pre>\\Configure{PROLOG}{DOCTYPE}\n\\Configure{VERSION}{}\n\\Configure{DOCTYPE}{\\HCode{&lt;!DOCTYPE html&gt;\\Hnewline}}\n\\Configure{HTML}{\\HCode{&lt;html&gt;\\Hnewline}}{\\HCode{\\Hnewline&lt;\/html&gt;}}\n\\Configure{@HEAD}{}\n\\Configure{@HEAD}{\\HCode{&lt;meta\n         \\expandafter\\csname a:charset\\endcsname\/&gt;\\Hnewline}}\n\\Configure{@HEAD}{\\HCode{&lt;meta name=\"generator\" content=\"TeX4ht\n         http:\/\/www.tug.org\/tex4ht\/\" \/&gt;\\Hnewline}}\n\\Configure{@HEAD}{\\HCode{&lt;link\n         rel=\"stylesheet\" type=\"text\/\\Css\"\n         href=\"\\expandafter\\csname aa:\\CssFile\\endcsname\" \/&gt;\\Hnewline\n    }\n}\n\\Configure{BODY}{\\Tg&lt;body&gt;}{\\Tg&lt;\/body&gt;}\n\\begin{document}\n\\def\\hlink#1#2{\\Tg&lt;a href=\"#1\"&gt;#2\\Tg&lt;\/a&gt;\\xspace}\n\\EndPreamble<\/pre>\n<p>All the configuration items that are processed by T<span style=\"position: relative; top: 0.5ex; margin-left: -0.1667em; margin-right: -0.125em; text-transform: uppercase;\">e<\/span>X4ht at the top of the document source shall be provided before the <code>begin{document}<\/code> command that appears in the preamble area. All the elements that form part of prolog and <code>&lt;head&gt;<\/code> element of <small>HTML<\/small> are the ideal candidates. Thus, <code>PROLOG<\/code>, <code>VERSION<\/code>, <code>DOCTYPE<\/code>, <code>HTML<\/code>, <code>@HEAD<\/code> and <code>BODY<\/code> are re-\\Configured as we want them in a different manner. In <small>HTML<\/small> 5, we do not need <small>DTD<\/small>, <small>XML<\/small> version and further several meta part are more simplified, we re\\Configure these items in this part of the configuration. You might note that <code>@HEAD<\/code> is additive, each <code>\\Configure{@HEAD}<\/code> has one argument which will be added to the <code>&lt;head&gt;...&lt;\/head&gt;<\/code> part of the <small>HTML<\/small>. We have inserted character set, link information for <code>.\\Css<\/code> file, meta information relating to generator which is T<span style=\"position: relative; top: 0.5ex; margin-left: -0.1667em; margin-right: -0.125em; text-transform: uppercase;\">e<\/span>X4ht, by re-configuring <code>@HEAD<\/code>.<\/p>\n<pre>\\Configure{\\textsc}{\\Tg&lt;span class=\"sc\"&gt;}{\\Tg&lt;\/span&gt;}\n\\Configure{texttt}{\\Tg&lt;span class=\"tt\"&gt;}{\\Tg&lt;\/span&gt;}\n\\Configure{textbf}{\\Tg&lt;span class=\"bf\"&gt;}{\\Tg&lt;\/span&gt;}\n\\Css{.sc{font-variant: small-caps;}}\n\\Css{.bf{font-weight: bold;}}\n\\Css{small{font-size: .8em;}}\n\\Css{.tt,.verb{font-family: monospace; white-space: nowrap;\n    color: #222; font-size: 85%;}}<\/pre>\n<p>The above lines show a few font attributes where we have re\\Configured commands like <code>\\textsc<\/code>, <code>textbf<\/code>, and <code>texttt<\/code>. The related <code>.\\Css<\/code> declarations have been provided following the font attributes.<\/p>\n<pre>\\Css{body{margin-top: 2em; margin-bottom: 1em; width: 60%;\n    margin-left: auto; margin-right: auto; padding: 3em;\n    color: #444; box-shadow: 2px 2px 20px -5px #bfbfbf;\n    -webkit-box-shadow: 2px 2px 20px -8px #bfbfbf;\n    -moz-box-shadow: 2px 2px 20px -5px #bfbfbf;\n    font-family: \"EB Garamond\";\n    font-style: normal;\n    font-size: 1em; line-height: 1.3em;\n    border: 1px solid #fefeef; }}\n\\Css{p.indent{ text-indent: 0em }}<\/pre>\n<p>The above provides <code>.\\Css<\/code> declarations for <code>&lt;body&gt;<\/code> element with a soft gray shadow, 60% width of the window, slightly grayed text color, slightly increased line height, 3em padding on all sides, etc. Not a big deal. The text indent has been suppressed through another <code>.\\Css<\/code> declaration, as the indent can interfere with lettrine spacing.<\/p>\n<p>Our custom configuation ends here if you do not want to make use of the free web font, namely, EB Garamond created by <a href=\"http:\/\/www.georgduffner.at\/ebgaramond\/impressum.html\">Georg Duffner<\/a> and distributed under <a href=\"http:\/\/scripts.sil.org\/cms\/scripts\/page.php?site_id=nrsi&amp;id=OFL\"><small>OFL<\/small> <\/a>font licence. The font can be had from Google or from <a href=\"http:\/\/www.georgduffner.at\/ebgaramond\/\">here<\/a>. The succeeding lines are <code>.\\Css<\/code> declarations to make use of Garamond and CheshireInitials fonts in your document.<\/p>\n<pre>\\Css{@font-face{font-family: InitialsFont; font-style: normal;\n    src: url\/fonts\/CheshireInitials.ttf;}}\n\\Css{@font-face{font-family: \"EB Garamond SC\"; font-variant: small-caps;\n    src: url\/fonts\/EBGaramond12-SC.ttf;}}\n\\Css{@font-face{font-family: \"EB Garamond\"; font-style: normal;\n    font-weight: normal; font-variant: normal;\n    src: url\/fonts\/EBGaramond12-Regular.ttf;}}\n\\Css{@font-face{font-family: \"EB Garamond Italic\"; font-style: italic;\n    font-weight: normal;font-variant: normal;\n    src: url\/fonts\/EBGaramond12-Italic.ttf;}}\n\\Css{@font-face{font-family: \"EB Garamond Bold\"; font-style: normal;\n    font-weight: bold; font-variant: normal;\n    src: url\/fonts\/EBGaramond12-Bold.ttf;}}\n\\Css{em, i, .ecti, .ecti1, .thanks, .signature, .dvquote-text,\n.dvprayer-text{font-family: \"EB Garamond Italic\", serif;}}\n%\n\\Css{strong, b, .partToc a, .partToc, .likepartToc a, .likepartToc,\n.chapterToc a, .chapterToc, .likechapterToc a, .likechapterToc,\n.appendixToc a, .appendixToc, .addchapToc,\n.paragraphHead, .likeparagraphHead,\n.subparagraphHead, .likesubparagraphHead,\n.caption td.id{font-family: \"EB Garamond Bold\", serif;}}\n%\n\\Css{.small-caps, .booksubtitle, .dvday, .sectionHead,\n.dvquote-ref, .dvbox .lettrine-line{font-family: \"EB Garamond SC\", serif;}}\n%\n% CheshireInitials for Lettrine character\n%\n\\Css{.lettrine{float: left; font-family: InitialsFont;\n    line-height: 1.15; margin-left: -0.1em; padding-bottom: -0.6em;\n    margin-bottom: -1em; margin-right: 0.2em;}}<\/pre>\n<h4 style=\"color: #27d; font-size: 1.25em;\">How to run T<span style=\"position: relative; top: 0.5ex; margin-left: -0.1667em; margin-right: -0.125em; text-transform: uppercase;\">e<\/span>X4ht<\/h4>\n<p>Save the above sources as <code>test.tex<\/code> and <code>my.cfg<\/code> respectively. Following command can be invoked from terminal:<\/p>\n<pre>  mzlatex test my ' -cunihtf'<\/pre>\n<p>The synatax is<\/p>\n<pre>  script &lt;tex-file&gt; &lt;conf-file&gt; '&lt;options-for-t4ht&gt;'<\/pre>\n<p>Please note the space between the opening single quote character and <code>-cunihtf<\/code> which is very important. The sources and latest <code>lettrine.4ht<\/code> package are available <a title=\"lettrine archive\" href=\"http:\/\/download.river-valley.com\/tex4ht\/lettrine\/lettrine.zip\">here as a zip archive<\/a>.<\/p>\n<p>Enjoy the magic!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Mahesh wanted to see the annotated source of the TeX document that generated the output shown here. There are two components in the source:\u00a0 (1) document source, let us call it as test.tex, (2) a custom configuration for TeX4ht, let us call it as my.cfg.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20,26,15,16],"tags":[],"class_list":["post-607","post","type-post","status-publish","format-standard","hentry","category-annotated-source","category-lettrine","category-tex","category-tex4ht"],"_links":{"self":[{"href":"https:\/\/cvr.cc\/index.php?rest_route=\/wp\/v2\/posts\/607","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cvr.cc\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cvr.cc\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cvr.cc\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cvr.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=607"}],"version-history":[{"count":0,"href":"https:\/\/cvr.cc\/index.php?rest_route=\/wp\/v2\/posts\/607\/revisions"}],"wp:attachment":[{"href":"https:\/\/cvr.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=607"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cvr.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=607"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cvr.cc\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=607"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}