I am trying to get the below xml structure through the TeX4ht

the first list should be tagged as

<list1 type=""><item1><p><label>1.</label>....</p></item1>

and the second list should be

<list2 type=""><item2><p><label>a.</label>....</p></item2>

see the complete structure mentioned below:

  <list1 type="numbered">
   <item1><p><label>1.</label>First level item 1st entry</p></item1>
   <item1><p><label>2.</label> First level item 2nd item entry</p>
     <list2 type="alpha">
      <item2><p><label>a.</label> First level item 1st entry</p></item2>
      <item2><p><label>b.</label> First level 2nd item entry</p></item2>
    <item1><p><label>3.</label> First level item 2nd item entry</p></item1>

the value of the "type" in the <list type=" "> should be based on the the \labelenumi

I am using the below tex coding

\item First level item 1st entry
\item First level item 2nd item entry
\item second level item 1st entry
\item second level item 2nd entry
\item First level item 3rd item entry

and I used the below coding in the cfg file


            \HCode{<list\thecountlist\space type="numbered">}}

But I cant able to get the correct structure, Please suggest How to solve the problem

1 Answer 1


The fifth argument of \ConfigureList is inserted after item label, not at item end. You need to use a little trick to correctly close the items:


 \HCode{<list\thecountlist\space type="numbered">}%


In this example, helper macro, \finishitem, which holds the closing tags for </item[number]> is used. It is used at the item start and at the environment end, where you want to insert the closing tags. When the list starts, it is empty, as you don't want to close any item at that moment. It is defined to insert the closing tags in the item configuration.

Another change which I introduced is to use tex4ht \par instead of explicit <p> tags. You can handle multiple paragraphs in one item in this way, which would be impossible with explicit tags.

The result:

  <list1 type="numbered"><item1>
     <!--l. 4--><p class="noindent" ><label>
  1. </label>First level item 1st entry
     <!--l. 5--><p class="noindent" ><label>
  2. </label>First level item 2nd item entry
         </p><list2 type="numbered"><item2>
         <!--l. 7--><p class="noindent" ><label>
      (a) </label>second level item 1st entry
         <!--l. 8--><p class="noindent" ><label>
     (b) </label>second level item 2nd entry</p></item2></list2>
     <!--l. 10--><p class="noindent" ><label>
  3. </label>First level item 3rd item entry</p></item1></list1>

You must log in to answer this question.

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