2

I am using tex4ht to convert a html document.

I configure the list based new environment like nomenclature for latex to pdf output. The pdf output and label alignment is good for nomenclature environment.

MWE:

\documentclass{article}

\makeatletter
\def\nomnoteslabel#1{\hspace\labelsep #1}%
\newenvironment{nomenclature}[1]{\list{}{%
        \setlength{\labelwidth}{#1\p@}%
         \setlength{\labelsep}{12\p@}%
          \let\leftmargin\labelwidth%
           \let\makelabel\nomnoteslabel
            \setlength{\itemsep}{\z@}%
             \rmfamily\fontsize{8\p@}{10\p@}\selectfont\raggedright}}%
             {\endlist}%
\makeatother

\begin{document}

\begin{nomenclature}{30.5}
\item[\textit{x}*] Dimensional coordinates along the channel  
\item[\(k_{\lambda}{_{1w}}\)] Radiation absorption coefficient at the wall 
\item[\(e_{b{\lambda}_{1}}\)]  Plank's function  
\end{nomenclature}

\end{document}

I also try to configure the my.cfg file to get some customized coding for the nomenclature environment.

my.cfg

\Preamble{xhtml,mathml,NLM,-xtpipes,NoFonts,refcaption,DocBook}

\NewConfigure{nomenclature}{2}
\ConfigureEnv{nomenclature}
   {\ifvmode\IgnorePar\fi\EndP\HCode{<def-list>}\ShowPar%
%     \Configure{listings}
%        {\Hcode{<def-item>}}
%        {\Hcode{</def-item>}}
%        {\Hcode{<term>}}
%        {\Hcode{</term>}}
    \bgroup 
    \Configure{HtmlPar}
        {\EndP\HCode{<def><p>}}
        {\EndP\HCode{<def><p>}}
        {\HCode{</p></def>\Hnewline}} 
        {\HCode{</p></def>\Hnewline}}
   }
   {\egroup%
    \ifvmode\IgnorePar\fi\EndP\HCode{</def-list>}\ShowPar%
\par}{}{}%

\begin{document}
\EndPreamble

But I am not get the required customized html tags. I am struggle to configure the list based environment.

My Current Output:

<def-list>
&#x00A0;    <italic>x</italic>*
      Dimensional
      coordinates
      along
      the
      channel
&#x00A0;    k*
      Radiation
      absorption
      coefficient
      at
      the
      wall
&#x00A0;    e*
      Plank&#8217;s
      function
   </def-list>

My Required Output:

Each whole item (For ex: \item[\textit{x}*] Dimensional coordinates along the channel) should be captured <def-item></def-item>

Each item label (For ex: [\textit{x}*]) should be captured <term><italic>x*</italic></term>

Each item content (For ex: Dimensional coordinates along the channel) should be captured <def><p>Dimensional coordinates along the channel</def></p>

The Whole required coding looks like this:

<def-list>
<def-item><term>&#x00A0;    <italic>x</italic>*</term>
      <def><p>Dimensional
      coordinates
      along
      the
      channel</p></def></def-item>
<def-item><term>&#x00A0;    k*</term>
      <def><p>Radiation
      absorption
      coefficient
      at
      the
      wall</p></def></def-item>
<def-item><term>&#x00A0;    e*</term>
      <def><p>
      Plank&#8217;s
      function</p></def></def-item>
   </def-list>

How to customize configure the list labels and its contents. Kindly advice.

2

You can use \ConfigureList instead of \ConfigureEnv for list environments. From tex4ht info:

Lists  -----    
\ConfigureList.....................5

#1   type of list (e.g., itemize, description, enumerate,
                       list, trivlist)
#2   before list
#3   after  list
#4   before label
#5   after label

\DeleteMark   removes latex’s label; to be placed at the end of #4
\AnchorLabel  defines an anchor for \label in current item; to
              be placed in #5

So we can just modify your \ConfigureEnv a little bit to configure the items:

\Preamble{xhtml,mathml,NLM,-xtpipes,NoFonts,refcaption,DocBook}

\Configure{textit}{\HCode{<italic>}}{\HCode{</italic>}}
\Configure{textbf}{\HCode{<bold>}}{\HCode{</bold>}}
\ConfigureList{nomenclature}
   {\ifvmode\IgnorePar\fi\EndP\HCode{<def-list>}\ShowPar%
    \bgroup 
    \Configure{HtmlPar}
        {\EndP\HCode{<def><p>}}
        {\EndP\HCode{<def><p>}}
        {\HCode{</p></def>\Hnewline}} 
        {\HCode{</p></def>\Hnewline}}
    \def\EndDefItem{}
   }
   {\EndDefItem\egroup%
    \ifvmode\IgnorePar\fi\EndP\HCode{</def-list>}\ShowPar%
    \par}{\EndDefItem\HCode{<def-item><term>}\def\EndDefItem{\HCode{</def-item>}}}{\HCode{</term>}}%

\begin{document}
\EndPreamble

Only interesting construct is \EndDefItem which is defined as empty at beginning of nomenclature and it is defined to close <def-item> element after first \item is used. Note that you also need to use \EndDefItem before closing the environment, in order to close the last item. Also note that you don't need \NewConfigure{nomenclature}, as you don't use it anywhere.

The result:

      <def-list>
      <def-item><term>
     <italic>x</italic>*   </term>
      Dimensional
      coordinates
      along
      the
      channel
      </def-item><def-item><term>
     <!--l. 19--><math 
 xmlns="http://www.w3.org/1998/Math/MathML"  
display="inline" ><mrow 
><msub><mrow 
><mi 
>k</mi><msub><mrow 
></mrow><mrow 
><mi 
>λ</mi></mrow></msub 
></mrow><mrow 
><mn>1</mn><mi 
>w</mi></mrow></msub 
></mrow></math>  </term>
      Radiation
      absorption
      coefficient
      at
      the
      wall
      </def-item><def-item><term>
     <!--l. 20--><math 
 xmlns="http://www.w3.org/1998/Math/MathML"  
display="inline" ><mrow 
><msub><mrow 
><mi 
>e</mi></mrow><mrow 
><mi 
>b</mi><msub><mrow 
><mi 
>λ</mi></mrow><mrow 
><mn>1</mn></mrow></msub 
></mrow></msub 
></mrow></math>  </term>
      Plank&#x2019;s
      function</def-item></def-list>

</body></html> 
  • Your solution is awesome. Your solution is working excellent. – Vetri Oct 22 '15 at 15:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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