在以下情况下,Tex4ht
如果包含某个包,即使未使用该包,也会生成一个矩阵的列之间没有空格的 HTML 文件。
移除包装后,柱子之间的空隙又显现出来。
这只会影响 tex4ht,而不会影响 pdflatex。
表格型
\documentclass[12pt,notitlepage]{article}%
\usepackage{tabularx} %commenting this off restores the spaces
\begin{document}
\begin{tabular}{p{6in}}
\[
\left[ \begin {array}{cc}
0 & 1 \\
-25 & -4
\end {array}
\right]
\]
\end{tabular}
\end{document}
数组包
\documentclass[12pt,notitlepage]{article}%
\usepackage{array}% http://ctan.org/pkg/array
\begin{document}
\begin{tabular}{p{6in}}
\[
\left[ \begin {array}{cc}
0 & 1 \\
-25 & -4
\end {array}
\right]
\]
\end{tabular}
\end{document}
下列软件包也会导致同样的问题,但这是由于它们array
在内部加载了该包: siunitx
,ltxtable
并且任何其他加载该array
包的软件包都会出现上述问题。
如果 Latex 代码在环境之外,则不会出现这些问题tabular
。正如我在下面的评论中所说,这是一个来自大型文档的小示例。我使用tabular
2 列来帮助我排列文档的布局。左侧是命令,右侧是输出。两者都可以是乳胶代码,如上所示。
答案1
我再次发现了这个问题,我认为你可以用这个版本修复这个问题array.4ht
:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% array.4ht 2023-11-06-15:09 %
% Copyright (C) 1997-2009 Eitan M. Gurari %
% Copyright 2009-2023 TeX Users Group
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either
% version 1.3c of this license or (at your option) any
% later version. The latest version of this license is in
% http://www.latex-project.org/lppl.txt
% and version 1.3c or later is part of all distributions
% of LaTeX version 2005/12/01 or later.
%
% This work has the LPPL maintenance status "maintained".
%
% The Current Maintainer of this work
% is the TeX4ht Project <http://tug.org/tex4ht>.
%
% If you modify this program, changing the
% version identification would be appreciated.
\def\@tabular{\leavevmode
\hbox \bgroup \:@tabular:
$\col@sep\tabcolsep \let\d@llarbegin\begingroup
\let\d@llarend\endgroup
\@tabarray}
\pend:def\@tabular{\let\@array:a\a:tabular \let\@array:b\b:tabular
\let\@array:c\c:tabular \let\@array:d\d:tabular
\let\@array:e\e:tabular \let\@array:f\f:tabular
}
\def\:temp[#1]#2{%
\def\Clr{#2}\a:VBorder
\HAssign\ar:cnt0
\let\HAlign\empty
%
\@tempdima \ht \strutbox
\advance \@tempdima by\extrarowheight
\setbox \@arstrutbox \hbox{}%
\begingroup
\@mkpream{#2}%
\xdef\@preamble{%
\everycr{}\tabskip\z@skip\noexpand\MkHalign\noexpand\@sharp
{\@arstrut \@preamble \tabskip\z@skip}%
}%
\xdef\:temp{%
\def\noexpand\HAlign{\HAlign}%
\def\noexpand\ar:cnt{\ar:cnt}}\aftergroup\:temp
%
\endgroup
\@arrayleft
\if #1t\vtop \else \if#1b\vbox \else \vcenter \fi \fi
\bgroup
\def\v:TBL{#1}%
\let \protect \relax \lineskip \z@
\baselineskip \z@ \m@th
\let\\\@arraycr \let\tabularnewline\\\let\par\@empty
\ifx \EndPicture\:UnDef
\SaveMkHalignConfig %%%%%%%%% \let\sv:ALIGN\HAlign
\ifx \recall:ar\:UnDef
\pend:def\@array{\recall:ar}%
\edef\recall:ar{%
\noexpand\ifx \noexpand\EndPicture\noexpand\:UnDef \noexpand\else
\arrayrulewidth\the\arrayrulewidth
\doublerulesep\the\doublerulesep
\arraycolsep\the\arraycolsep
\tabcolsep\the\tabcolsep
\noexpand\fi }%
\fi
% why did we set these variables to zero? it leads to wrong spacing
% in pictures.
% https://puszcza.gnu.org.ua/bugs/?229
% \arrayrulewidth\z@ \doublerulesep\z@
% \arraycolsep\z@ \tabcolsep\z@
\Configure{MkHalign}
{\@array:a}%
{\@array:b\ProperTrTrue}%
{\a:putHBorder\InitHBorder
\gHAdvance\cline:cnt by 1
\expandafter\ifx \csname cw:cline-\cline:cnt\endcsname \relax \else
\Tag{Cline-\cline:cnt}{}%
\fi
\expandafter\ifx \csname cw:Cline-\cline:cnt\endcsname \relax \else
\ht:special{t4ht@[}%
\fi
%
\ifProperTr{\@array:c}}%
{\ifProperTr{\@array:d}%
\ifomit: \Tag{cline-\cline:cnt}{}\fi
\expandafter\ifx \csname cw:Cline-\cline:cnt\endcsname \relax \else
\ht:special{t4ht@]}%
\fi
\global \omit:false
%
\a:putHBorder\InitHBorder}%
{\ifProperTr{\@array:e}\RecallMkHalignConfig\recall:ar}%
{\ifProperTr{\@array:f}}
%
\Configure{MkHalign}%
{\@array:a}%
{\@array:b\ProperTrTrue}%
{\a:putHBorder\InitHBorder \ifProperTr{\@array:c}}%
{\ifProperTr{\@array:d}\a:putHBorder\InitHBorder}%
{\ifProperTr{\@array:e}%%%%%%%%%%\global \let\HAlign\sv:ALIGN
\RecallMkHalignConfig\recall:ar}%
{\ifProperTr{\@array:f}}
%
\else \let\@sharp##\fi
\@preamble}
\HLet\@array\:temp
\HLet\@@array\@array
\let\:tempc\@startpbox
\append:defI\:tempc{\expandafter\everypar
\expandafter{\the\everypar\everypar{\HtmlPar}\HtmlPar}}
\HLet\@startpbox\:tempc
\def\:tempc{\relax \ifnum\HCol=1 \a:endarray\fi
\enda:rray}
\HLet\endarray\:tempc
\def\:tempc{\relax \ifnum\HCol=1 \a:endtabular\fi
\enda:rray $\egroup}
\HLet\endtabular\:tempc
\def\enda:rray{\crcr\ifx \EndPicture\:UnDef \EndMkHalign
\else \egroup\fi \egroup \@arrayright \gdef\@preamble{}}
\expandafter \let \csname endtabular*\endcsname\endtabular
\def\:tempc{\@classx
\@tempcnta \count@
\prepnext@tok
\@addtopreamble{\ifcase \@chnum
\hfil
\d@llarbegin
\insert@column
\d@llarend \hfil \or
\hskip1sp\d@llarbegin \insert@column \d@llarend \hfil \or
\hfil\hskip1sp\d@llarbegin \insert@column \d@llarend \or
%
\vtop \@startpbox{\@nextchar}\insert@column \@endpbox \or
\vtop \@startpbox{\@nextchar}\insert@column \@endpbox \or
\vbox \@startpbox{\@nextchar}\insert@column \@endpbox
\fi}\prepnext@tok}
\HLet\@classz\:tempc
\def\:tempc{\@chclass
\ifnum \@lastchclass=6 \@ne \@chnum \@ne \else
\ifnum \@lastchclass=7 5 \else
\ifnum \@lastchclass=8 \tw@ \else
\ifnum \@lastchclass=9 \thr@@
\else \z@
\ifnum \@lastchclass = 10
\global \expandafter\let \csname @testpach \ar:cnt\endcsname\@nextchar
%
\else
\edef\@nextchar{\expandafter\string\@nextchar}%
\@chnum
\if \@nextchar c\z@ \add:ar-\else
\if \@nextchar l\@ne \add:ar<\else
\if \@nextchar r\tw@ \add:ar>\else
\z@ \@chclass
\if\@nextchar |\@ne \b:VBorder\else
\if \@nextchar !6 \else
\if \@nextchar @7 \d:VBorder\else
\if \@nextchar <8 \else
\if \@nextchar >9 \else
10
\@chnum
\if \@nextchar m\thr@@ \add:ar m\else
\if \@nextchar p4 \add:ar p\else
\if \@nextchar b5 \add:ar b\else
\z@ \@chclass \z@ \@preamerr \z@ \fi \fi \fi \fi
\fi \fi \fi \fi \fi \fi \fi \fi \fi \fi \fi \fi}
\HLet\@testpach\:tempc
\def\add:ar#1{\HAdvance\ar:cnt by 1
\def\ch:class{#1}%
\c:VBorder
\edef\HAlign{\HAlign 0 \ar:cnt\space #1 }}
\def\HColAlign{\expandafter \ifx\csname
\expandafter\string\ch:class :T:D\endcsname\relax \else \csname
\expandafter\string\ch:class :T:D\endcsname\fi}
%
\long\def\:temp#1#2#3{%
\multispan{#1}\a:multicolumn \begingroup
\def\@addamp{\if@firstamp \@firstampfalse \else
\@preamerr 5\fi}%
\def\Clr{#2}\a:VBorder
\HAssign\ar:cnt0
\let\HAlign\empty
%
\@mkpream{#2}%
\ifx \EndPicture\:UnDef
\def\:temp##1 ##2 ##3 {##3}%
\xdef\new:span{\new:span\HRow.\HCol\expandafter\:temp\HAlign;}%
\fi
\@addtopreamble\@empty
\global\let\ch:class\ch:class
\xdef\:temp{%
\def\noexpand\HAlign{\HAlign}%
\def\noexpand\ar:cnt{\ar:cnt}}\aftergroup\:temp
%
\endgroup
\def\@sharp{\c:multicolumn#3\d:multicolumn}%
\@arstrut \@preamble
\null
\b:multicolumn
\ignorespaces}
\HLet\multicolumn\:temp
\def\save@decl{%
\toks \count@ = \expandafter\expandafter\expandafter {%
\csname a:array\ifnum\@lastchclass=9
>\else <\fi \expandafter\expandafter\expandafter\endcsname
\expandafter\@nextchar\the\toks
\expandafter\count@\csname b:array\ifnum\@lastchclass=9
>\else <\fi\endcsname
}}
\NewConfigure{array>}{2}
\NewConfigure{array<}{2}
\Hinput{array}
\endinput
变化在于我们不将数组空间设置为零:
% why did we set these variables to zero? it leads to wrong spacing
% in pictures.
% https://puszcza.gnu.org.ua/bugs/?229
% \arrayrulewidth\z@ \doublerulesep\z@
% \arraycolsep\z@ \tabcolsep\z@
结果如下: