從 .cls 檔案產生 .css,而不是從 .cfg 檔案生成

從 .cls 檔案產生 .css,而不是從 .cfg 檔案生成

是否可以基於自訂的 .cls 檔案而不是設定檔(即 \Css {})來產生 .css 檔案。例如,環境引用在我的類別文件中定義為:

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

我正在使用 HTML 轉換命令htlatex test "xhtml,fn-in" "-cunihft" "-cvalidate -p",轉換後的 HTML 輸出是:

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

CSS 輸出為:

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

意味著 css 輸出實際上不是從類別 (.cls) 檔案產生的,而是從設定檔(用於 tex4ht 的 .cfg)產生的

現在 CSS 中的預期輸出(「quote」)是:

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

我怎樣才能實現這個目標?請建議...

答案1

您可以.4ht為您的班級建立文件。比如說,如果你有課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

設定.4ht檔將是myclass.4ht

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

\endinput

環境配置quote僅停用環境內的字體啟發式,以消除這些<span class="ptmr8t-x-x-90">元素。quotein的預設配置tex4ht<div class="quote">自動新增到環境中,因此您無需手動執行此操作。在\Css命令中,您必須%使用 轉義字元\%

以下範例文件:

\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}

產生這個結果:

在此輸入影像描述

<div class="quote">
<!--l. 8--><p class="noindent" >Collusion is when firms use history-dependent strategies to sustain</p></div>

答案2

我看到Andrew的回覆和我問的要求類似,連結是我們可以簡化 tex4ht 中 CFG 檔案中的 \Configure 編碼嗎感謝所有嘗試過的人...

相關內容