编辑:@michal.h21 我尝试在我的 tex 文件中包含一个cfg
文件(名为,正如您所建议的) 。我运行命令:但它并没有改变任何东西。cfg)
alt.tex
make4ht -ul alt.tex "cfg.cfg"
因此我改变了我的alt.tex
添加
\ifx\HCode\undefined \else
\Css{body{background-color:green;}}
\Css{.list3 *, .list4 *, .list5 *, .list6 *{display:inline;}}
\ConfigureEnv{quote}{\Tg<quote>}{\Tg</quote>}{}{}
\fi
请添加包含正常物品的个人清单
\vspace{1cm}
\textbf{THIS IS WHAT i WANT IN PDF AND HTML:}
PERSONAL LIST THROUGH THE GENERIC LIST ENV. \quad [the alignment fails in the HTML version]
\begin{personallist2}
\item personal list with normal item \begin{personallist2}
\item personal list with normal item\begin{personallist2}\setcounter{list3}{33}
\item string of text
\end{personallist2}
\end{personallist2}
\end{personallist2}
输出
http://i.imgur.com/lTiZwI3.png
这意味着即使包含普通项目的个人列表也会显示在一行上。
=========================== 编辑结束 ===========================
编辑:我希望enumitem
尽可能避免使用该包和其他列表包,因为我的代码必须兼容没有互联网或最花哨的包的各种计算机。
该列表enumerate
具有一个非常好的特性,即当项目是后续列表本身时,嵌套的枚举列表将显示在一行上,而不是一些通常的字符串。
我想创建一个个人列表 [深度为三] 以便控制标签和间距,就像任何个人列表一样,但环境\begin{list}
不提供良好的属性enumerate
。
我\personallist
复制粘贴了 的定义并进行了定义enumerate
,但我们注意到 的left margin
行为与\personallist
不同。left margin
enumerate
问题
如何enumerate
在递归中实现一行上的嵌套,定义personallist2
具有我喜欢的所有间距?
我使用xelatex
或 进行编译,但是没有这些引擎的其他包也lualatex
存在问题。fontspec
如果你想使用 进行编译lualatex
,请helpersht
从https://github.com/michal-h21/helpers4ht
@michal.h21安装
\documentclass[oneside,a4paper, 12pt]{article}
\usepackage{alternative4ht}
\altusepackage{polyglossia}
\altusepackage{fontspec}
%recursion
\newcounter{listlvl}
\setcounter{listlvl}{-1}
%counter by level
\newcounter{list1}
\setcounter{list1}{0}
\newcounter{list2}
\setcounter{list2}{0}
\newcounter{list3}
\setcounter{list3}{0}
\newenvironment{personallist2}
{
%add one level
\addtocounter{listlvl}{1}
%test the level
\ifcase\value{listlvl}
% level = 0
\begin{list}
{
{\alph{list1}}
}
{
\setlength{\leftmargin}{\leftmargini}
\setlength{\labelsep}{0ex}
\setlength{\itemindent}{1\parindent}
\setlength{\listparindent}{1\parindent}
\setlength{\parsep}{1\parskip}
\setlength{\itemsep}{0\parskip plus 0.25\parskip minus 0.25\parskip}
\setlength{\topsep}{0\parskip plus 0.25\parskip minus 0.25\parskip}
\setlength{\partopsep}{0\parskip plus 0.25\parskip minus 0.25\parskip}
\usecounter{list1}
}
% level = 1
\or
\begin{list}
{\textbf{\alph{list2}}\large)\normalsize}
{
\setlength{\leftmargin}{\leftmarginii}
\addtolength{\leftmargin}{-0.5\leftmargini}
\setlength{\labelsep}{0.5ex}
\setlength{\itemindent}{1\parindent}
\setlength{\listparindent}{1\parindent}
\setlength{\parsep}{1\parskip}
\setlength{\itemsep}{0\parskip plus 0.25\parskip minus 0.25\parskip}
\setlength{\topsep}{0\parskip plus 0.25\parskip minus 0.25\parskip}
\setlength{\partopsep}{0\parskip plus 0.25\parskip minus 0.25\parskip}
\usecounter{list2}
}
% level = 2
\or
\begin{list}
{\textit{\roman{list3}}\large)\normalsize}
{
\setlength{\leftmargin}{\leftmarginiii}
\addtolength{\leftmargin}{-0.5\leftmarginii}
\setlength{\labelsep}{0.5ex}
\setlength{\itemindent}{1\parindent}
\setlength{\listparindent}{1\parindent}
\setlength{\parsep}{1\parskip}
\setlength{\itemsep}{0\parskip plus 0.25\parskip minus 0.25\parskip}
\setlength{\topsep}{0\parskip plus 0.25\parskip minus 0.25\parskip}
\setlength{\partopsep}{0\parskip plus 0.25\parskip minus 0.25\parskip}
\usecounter{list3}
}
\else
% \begin{list}
% {***
% }
% {
% }
\fi
}
{\end{list}
%down of level
\addtocounter{listlvl}{-1}
}
\makeatletter
\def\personallist{%
\ifnum \@enumdepth >3 \@toodeep\else
\advance\@enumdepth \@ne
\edef\@enumctr{enum\romannumeral\the\@enumdepth}\fi
\@ifnextchar[{\@@enum@}{\@enum@}}
\def\@@enum@[#1]{%
\@enLab{}\let\@enThe\@enQmark
\@enloop#1\@enum@
\ifx\@enThe\@enQmark\@warning{The counter will not be printed.%
^^J\space\@spaces\@spaces\@spaces The label is: \the\@enLab}\fi
\expandafter\edef\csname label\@enumctr\endcsname{\the\@enLab}%
\expandafter\let\csname the\@enumctr\endcsname\@enThe
\csname c@\@enumctr\endcsname7
\expandafter\settowidth
\csname leftmargin\romannumeral\@enumdepth\endcsname
{\the\@enLab\hspace{\labelsep}}%
\@enum@}
\def\@enum@{\list{\csname label\@enumctr\endcsname}%
{\usecounter{\@enumctr}\def\makelabel##1{\hss\llap{##1}}}}
\makeatother
\begin{document}
COMPLETELY GENERIC LIST \quad [the alignment fails in the HTML version]
\begin{list}{label1}{spacing}
\item \begin{list}{label2}{spacing}
\item \begin{list}{label3}{spacing}
\item string of text
\end{list}
\end{list}
\end{list}
\vspace{1cm}
ENUMERATE \quad [the alignment succeeds in the HTML version]
\begin{enumerate}
\item \begin{enumerate}
\item \begin{enumerate}\setcounter{enumiii}{33}
\item string of text
\end{enumerate}
\end{enumerate}
\end{enumerate}
\vspace{1cm}
PERSONAL LIST THROUGH ENUMERATE \quad [the alignment succeeds in the HTML version, but there is no creation of a new line !]
\begin{personallist}
\item \begin{personallist}
\item \begin{personallist}\setcounter{enumiii}{33}
\item string of text
\end{personallist}
\end{personallist}
\end{personallist}
\vspace{1cm}
\textbf{THIS IS WHAT i WANT IN PDF AND HTML:}
PERSONAL LIST THROUGH THE GENERIC LIST ENV. \quad [the alignment fails in the HTML version]
\begin{personallist2}
\item \begin{personallist2}
\item \begin{personallist2}\setcounter{list3}{33}
\item string of text
\end{personallist2}
\end{personallist2}
\end{personallist2}
\end{document}
编译
make4ht -ul filename.tex