Tex4ht:多列列表

Tex4ht:多列列表

我使用 multicol 包生成“2x2”列表(两行,两列),这在 pdflatex 中运行良好,但在 tex4ht 中却不行。虽然 multicol 通常可以与 tex4ht 配合使用,但包含列表环境似乎会导致奇怪的换行行为(在 tex4ht 中)。

我还为列表使用了特殊标签,之所以包含这些标签,是因为任何解决方案(如果有的话)都必须与这些特殊标签配合使用,这一点很重要(对于使用这些标签的问题,我实际上只需要“2x2”列表)。然而,正如 mwe 所示,问题并不是由这些特殊标签引起的。

这是 pdf 输出:

pdf 文件

HTML 输出:

html 输出

虽然使用表格环境就可以实现正确的格式,但我更愿意使用列表。

这是 mwe:

\documentclass[12pt]{article}
\usepackage[T1]{fontenc} %necessary for MathJax?
\usepackage{multicol}
\usepackage[inline]{enumitem} % for customized lists; note INLINE option
\usepackage[dvipsnames]{xcolor}

\ifdefined\HCode

\definecolor{mcyellow}{rgb}{247,244,58}
\definecolor{mcblue}{rgb}{123,104,238}
\definecolor{mcpink}{rgb}{247,58,241}
\definecolor{mcgreen}{rgb}{118,247,58}
\definecolor{mcorange}{rgb}{247,165,58}

\newcommand{\mcY}{\hspace{0pt}\colorbox{mcyellow}{\sffamily Y}}
\newcommand{\mcB}{\hspace{0pt}\colorbox{mcblue}{\sffamily \textcolor{White}{B}}}
\newcommand{\mcP}{\hspace{0pt}\colorbox{mcpink}{\sffamily \textcolor{White}{P}}}
\newcommand{\mcG}{\hspace{0pt}\colorbox{mcgreen}{\sffamily G}}
\newcommand{\mcO}{\hspace{0pt}\colorbox{mcorange}{O}}

\else

\newcommand{\mcY}{\setlength{\fboxsep}{8pt}\colorbox[RGB]{247,244,58}{\sffamily\textbf{Y}}\quad\setlength{\fboxsep}{2pt}}
\newcommand{\mcB}{\setlength{\fboxsep}{8pt}\colorbox[RGB]{123,104,238}{\sffamily\textcolor{white}{\textbf{B}}}\quad\setlength{\fboxsep}{2pt}}
\newcommand{\mcP}{\setlength{\fboxsep}{8pt}\colorbox[RGB]{247,58,241}{\sffamily\textcolor{white}{\textbf{P}}}\quad\setlength{\fboxsep}{2pt}}
\newcommand{\mcG}{\setlength{\fboxsep}{8pt}\colorbox[RGB]{118,247,58}{\sffamily\textbf{G}}\quad\setlength{\fboxsep}{2pt}}
\newcommand{\mcO}{\setlength{\fboxsep}{8pt}\colorbox[RGB]{247,165,58}{\sffamily\textcolor{white}{\textbf{O}}}\quad\setlength{\fboxsep}{2pt}}

\fi

\begin{document}

This list looks good in pdf and html:
  \begin{enumerate}
    \item Item 1
    \item Item 2
  \end{enumerate}

  I need two-column lists, such as this, which looks perfect in pdf but poor in html:
  \begin{multicols}{2}
  \begin{enumerate}
    \item[\mcY] Item
    \item[\mcB] Item
    \item[\mcP] Item
    \item[\mcG] Item
  \end{enumerate}
  \end{multicols}

  The issue is not caused by my special labels, as the next list shows:
  \begin{multicols}{2}
  \begin{enumerate}
    \item Item
    \item Item
    \item Item
    \item Item
  \end{enumerate}
  \end{multicols}

\end{document}

配置如下:

\Preamble{html}

\Configure{VERSION}{}
\Configure{DOCTYPE}{\HCode{<!DOCTYPE html>\Hnewline}}
\Configure{HTML}{\HCode{<html>\Hnewline}}{\HCode{\Hnewline</html>}}
\Configure{@HEAD}{\HCode{<link href="\FileName.css" rel="stylesheet" type="text/css" />\Hnewline}} 

\Configure{fbox}
{\HCode{<span class="fbox">}\bgroup \fboxrule=0pt}
{\egroup\HCode{</span>}}
\Css{span.fbox {border: 1pt solid black;}}

\Css{.colorbox {
  margin-left: 0em;
  margin-right: 1em;
  margin-top: 0.8em;
  margin-bottom: 0.4em;
  padding:0.2em;
} 
}

\Configure{HColor}{mcyellow}{rgb(247,244,58)}
\Configure{HColor}{mcblue}{rgb(123,104,238)}
\Configure{HColor}{mcpink}{rgb(247,58,241)}
\Configure{HColor}{mcgreen}{rgb(118,247,58)}
\Configure{HColor}{mcorange}{rgb(247,165,58)}

\begin{document}


\EndPreamble

相关内容