7

I have some macros in my document, and I want to create my own HTML for there. I follow this blog entry but I can't to make it work.

I put this code before my \begin{document}:

    \def\one#1#2#3{#1space#2space#3}

    \NewConfigure{one}[4]%
         {\def\a@one{#1}\def\b@one{#2}%
          \def\c@one{#3}\def\d@one{#4}}

    % I can't understand this things too much - I'm not familiar with TeX
    \def\@temp#1#2#3{\a@one#1\c@one#2\d@one#3\b@one}  
       \let\one\@temp

    \Configure{one}
       {\Tg<span class="one">\Tg<code>}{\Tg</b>\Tg</span>}
       {\Tg</code>\Tg<em>}{\Tg</em>\Tg<b>} 

    \one{verbatim}{emphasize}{boldface}

And compile with: htlatex mylatexfile.tex "xhtml"

And I get this error message:

    ! Use of \one doesn't match its definition.
    l.19         \one{
                      verbatim}{emphasize}{boldface}

My problem is, for example, I have a macro like:

    \newcommand{\myfunction}[2]{The title is: #1 an the body is \textit{#2} }

and I want to translate this in some like:

    <div class="container">
       <div class="title"><!-- #1 goes here --></div>
       <div class="content"><!-- #2 goes here --></div>
    </div>

How I can do that?

9

tex4ht works best when your macros are saved in a .sty file and tex4ht configurations for these macros are saved in file named as the .sty file, only with .4ht suffix. In your situation, you may put your macro \myfunction to mystyle.sty:

\newcommand{\myfunction}[2]{The title is: #1 an the body is \textit{#2} }

now what to put to mystyle.4ht? You need to declare configurations for inserted html tags, redefine \myfunction to insert these tags and provide default values for configurations:

\NewConfigure{myfunction}{3}

\renewcommand\myfunction[2]{\a:myfunction#1\b:myfunction#2\c:myfunction}

\Configure{myfunction}{\HCode{<div class="container">\Hnewline
   <div class="title">}}{\HCode{</div>
   <div class="content">}}{\HCode{</div>
</div>}}

simplified form of \NewConfigure is used here, with number in {} brackets you declare commands \a:name, \b:name, ... We need to declare three insertions, before and after parameters and between them.

For more information see my tex4ht tutorial. You may also need to modify the provided configurations for \Configure{myfunction} because of paragraphs handling see Control the <p> tags

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.