4

Is this possible to generate the .css file based on the customized .cls file not from config file (i.e. \Css {}). e.g., environment quote was defined in my class file as:

\newenvironment{quote}%
               {\list{}{\topsep9\p@\leftmargin\z@\rightmargin\z@}%
                \small\fontseries{b}\selectfont%
                \item\relax\}%
               {\endlist}%

and I am using the command htlatex test "xhtml,fn-in" "-cunihft" "-cvalidate -p" for HTML conversion and the converted HTML output came is:

                    <p class="indent" >
                    <span 
class="ptmr8t-x-x-90">Collusion  is  when  firms  use  history-dependent  strategies  to  sustain</span></p>

and CSS output is:

.quote {margin-bottom:0.25em; margin-top:0.25em; margin-left:1em; margin-right:1em; text-align:justify;}

means the css output actually not generated from the class (.cls) file instead it is from config file (.cfg which is used for tex4ht)

Now the expected output in CSS (for "quote") is:

.quote {font-size:80%; font-weight: bold;}

How can I achieve this? Please suggest...

2

You can create .4ht file for your class. Say, if you have class myclass.cls:

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{myclass}[2017/07/11 Example LaTeX class]
\LoadClass[]{article}
\renewenvironment{quote}%
               {\list{}{\topsep9\p@\leftmargin\z@\rightmargin\z@}%
                \small\fontseries{b}\selectfont%
                \item\relax}%
               {\endlist}% 

\endinput

the configuring .4ht file will be myclass.4ht:

\ConfigureEnv{quote}{\NoFonts}{\EndNoFonts}{}{}
\Css{.quote{font-size:80\%; font-weight: bold;}}

\endinput

The configuration for quote environment only disables font heuristics inside the environment, to get rid of these <span class="ptmr8t-x-x-90"> elements. The default configuration for quote in tex4ht will add <div class="quote"> around the environment automatically, so you don't need to do that by hand. In the \Css command, you must escape the % character using \%.

The following sample file:

\documentclass{myclass}

\begin{document}
\section{Do common commands work?}

Yes, \textbf{they} \textit{do}\footnote{even footnotes?}.
\begin{quote}
  Collusion  is  when  firms  use  history-dependent  strategies  to  sustain
\end{quote}
\end{document}

produces this result:

enter image description here

<div class="quote">
<!--l. 8--><p class="noindent" >Collusion is when firms use history-dependent strategies to sustain</p></div>
  • Thanks Michal for your response. Now the thing is converting the tex command to css commands. We do have test on the sample, whatever we specified in \Css {} will be generated in .css file. But we expect the properties needs to pickup from what we specified in our class file. – MadyYuvi Jul 11 '17 at 12:02
  • @MadyYuvi do you have some complete example? I think I've created some code which can get current font properties and save them to the CSS, but haven't tested it for two years: github.com/michal-h21/helpers4ht/blob/master/textstyle4ht.sty – michal.h21 Jul 11 '17 at 13:41
  • @MadyYuvi ah, here is a tutorial: michal-h21.github.io/samples/helpers4ht/textstyle.html – michal.h21 Jul 11 '17 at 13:41
  • Shall I send the complete example (customized cls and TeX application file) to your mail? – MadyYuvi Jul 12 '17 at 4:37
  • @MadyYuvi yes you can. I am little bit busy recently, but I should be able to take a look at it in few days – michal.h21 Jul 12 '17 at 6:18
0

I saw Andrew's reply which is similar to the requirement what I asked, and the link is Can we simplify the \Configure coding in CFG file in tex4ht Thanks for everyone who tried...

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.