关于下面显示的 MWE,我不知道合并的列和行之间行颜色不一致的原因。虽然我使用了命令 (\rowcolor{gray!25}),但在合并的列和合并的行的区域中,行被部分着色。我注意到
主要是多列+多行命令中的第二个单元格与 \rowcolor 命令不匹配,导致格式明显不合适。
此外,当同时使用多行和多列命令时,通常(但并非总是)会出现此问题,如果单独/单独使用其中任何一个命令,则行颜色没有问题,但在同一组单元格上使用它们时,就会出现这样的问题。即:
\multicolumn{1}{|>{\centering\arraybackslash}m{8cm}|}
{\multirow[c]{-2}{=}[0.5cm]{text}}
- 另外,从下面的 MWE 可以看出,一些合并(行 + 列)正常出现,如表格后半部分中的前 2 个合并(行 + 列)所示。
以下是 MWE:
\documentclass[a4paper,12pt,twoside]{book}
\usepackage[a4paper,top=2.5cm,bottom=2.5cm,margin=2.5cm,bindingoffset=0.5cm]{geometry}
\makeatletter
\def\ifGm@preamble#1{%
\ifGm@newgm
%\Gm@warning{`#1': not available in `\string\newgeometry'; skipped}%
\expandafter\@firstofone
\else
\expandafter\@firstofone
\fi}%
\makeatother
\usepackage[bidi=basic,layout=lists.tabular]{babel}
\babelprovide[import=ar,mapdigits,main]{arabic}
\babelprovide[import=en,language=Default]{english}
\babelfont{rm}{Latin Modern Roman}
\babelfont[arabic]{rm}{amiri}
\babelfont[english]{rm}{Times New Roman}
\usepackage{pdflscape}
\usepackage{rotating}
\usepackage[hidelinks,colorlinks=true,breaklinks,allcolors=blue]{hyperref}
\usepackage{fancyhdr}
\usepackage{fancybox, graphicx}
\usepackage[table]{xcolor}
\usepackage{tabu,multirow}
\usepackage[framemethod=tikz]{mdframed}
\usetikzlibrary{shadows}
\usepackage{longtable}
\usepackage{array}
\newcolumntype{?}[1]{!{\vrule width #1}}
\usepackage{booktabs}
\setlength{\belowrulesep}{0pt}
\setlength{\belowbottomsep}{0pt}
\setlength{\aboverulesep}{0pt}
\setlength{\belowrulesep}{0pt}
\setlength{\abovetopsep}{0pt}
\usepackage{makecell}
\usepackage{boldline}
\usepackage[skins,xparse,breakable]{tcolorbox}
\begin{document}
\newgeometry{landscape,margin=2.5cm}
\pagewidth = \paperwidth
\pageheight = \paperheight
\fancyheadoffset[lh]{0pt}%
\begin{table}[htbp]
\setlength\arrayrulewidth{1pt} % so that lines apear since they get overried by rowcolors command
\begin{center}
\begin{tabular}
{
?{1mm}c
?{0.5mm}>{\centering\arraybackslash}m{2cm}
|>{\centering\arraybackslash}c
|>{\centering\arraybackslash}m{3cm}
|>{\centering\arraybackslash}m{3cm}
|>{\centering\arraybackslash}m{3cm}
|>{\centering\arraybackslash}m{2cm}?{1mm}
}
%\rowcolor{white} %Color for first row
\toprule[1mm] %may be used to draw a horizontal line at the top of the table.
%\hline % Not needed here as top rule is used
\textbf{dfdfdfdf}
&
\textbf{الحالة
dffds sdfds
}
&
\multicolumn{2}{|c|}{\textbf{tttt t ttt ttt}}
&
\textbf{rrrrr rrrrrr rrrr rrr}
&
\textbf{ttttttttttttt}
&
\textbf{ttttttt}
\\
\midrule[1mm]
\rowcolor{gray!25}
\cellcolor{white}
&
&
mm
&
&
mm
&
mm
&
mmmm
\\
\cmidrule[0.5pt]{3-3}
\cmidrule[0.5pt]{5-7}
\rowcolor{gray!25}
\cellcolor{white}
&
&
&
\multicolumn{1}{|>{\centering\arraybackslash}m{8cm}|}{}
&
mm
&
mm
&
mmmm
\\
\cmidrule[0.5pt]{5-7}
\rowcolor{gray!25}
\cellcolor{white}
&
&
\multirow[c]{-2}{0cm}[0cm]
{mm}
&
\multicolumn{1}{|>{\centering\arraybackslash}m{8cm}|}
{
\multirow[c]{-2}{=}[0.5cm]
{
mm
}}
&
mm
&
mm
&
mmmm
\\
\cmidrule[0.5pt]{3-7}
\cellcolor{white}
&
\cellcolor{gray!25}
&
\foreignlanguage{coptic}{ⲩ}
&
\multicolumn{1}{|>{\centering\arraybackslash}m{8cm}|}
{
mmmmmm mmmmmm mmm mmm mmm mmmmmmmm mmm mmmm mmmmmmmmm mm
}
&
mm
&
mm
&
mmmm
\\
\cmidrule[0.5pt]{3-7}
\rowcolor{gray!25}
\cellcolor{white}
&
&
&
\multicolumn{1}{|>{\centering\arraybackslash}m{8cm}|}{ }
&
mm
&
mm
&
mmmm
\\
\cmidrule[0.5pt]{5-7}
\rowcolor{gray!25}
\cellcolor{white}
&
&
\multirow[c]{-2}{*}[0cm]{mm}
&
\multicolumn{1}{|>{\centering\arraybackslash}m{8cm}|}
{
\multirow[c]{-2}{=}[0cm]
{
في بعض الأحيان لتعبر عن النطق الواضح
}}
&
mm
&
mm
&
mmmm
\\
\cmidrule[0.5pt]{3-7}
\cellcolor{white}
&
\cellcolor{gray!25}
\multirow[c]{-6}{2cm}[0.5cm]
{
mmmmmm mmmmmm mmm mmm mmm mmmmmmmm
}
&
\multicolumn{2}{|>{\centering\arraybackslash}m{10cm}|}
{
mm
}
&
mm
&
mm
&
mmmm
\\
\cmidrule[1pt]{2-7}
\rowcolor{gray!25}
\cellcolor{white}
&
\cellcolor{white}
&
\multicolumn{2}{|>{\centering\arraybackslash}m{10cm}|}{ }
&
mm
&
mm
&
mmmm
\\
\cmidrule[0.5pt]{5-7}
\rowcolor{gray!25}
\cellcolor{white}
&
\cellcolor{white}
&
\multicolumn{2}{|>{\centering\arraybackslash}m{10cm}|}
{\multirow[c]{-2}{=}[0cm]{\centering mm}}
&
mm
&
mm
&
mmmm
\\
\cmidrule[0.5pt]{3-7}
\cellcolor{white}
&
&
\multicolumn{2}{|>{\centering\arraybackslash}m{10cm}|}
{mm}
&
&
mm
&
\\
\cmidrule[0.5pt]{3-4}
\cmidrule[0.5pt]{6-6}
\cellcolor{white}
&
&
\multicolumn{2}{|>{\centering\arraybackslash}m{10cm}|}{}
&
\multirow[c]{-2}{*}[0cm]{mm}
&
mm
&
\multirow[c]{-2}{*}[0cm]{mmmm}
\\
\cmidrule[0.5pt]{5-7}
\cellcolor{white}
&
&
\multicolumn{2}{|>{\centering\arraybackslash}m{10cm}|}
{\multirow[c]{-2}{=}[0cm]{\centering mm}
}
&
mm
&
mm
&
mmmm
\\
\cmidrule[0.5pt]{3-7}
\rowcolor{gray!25}
\cellcolor{white}
\multirow[c]{-13}{*}[0.5cm]{mm}
&
\cellcolor{white}
\multirow[c]{-6}{2cm}[0.5cm]
{
mmmm mmmmm mmm mmmmmmm
}
&
\multicolumn{2}{|>{\centering\arraybackslash}m{10cm}|}
{
mmmmmm mmmmmm mmm mmm mmm mmmmmmmm mmm
}
&
mm
&
mm
&
mmmm
\\
\bottomrule[1mm] %draws a horizontal line to finish off a table
\end{tabular}
\end{center}
\end{table}
\clearpage
\restoregeometry
\pagewidth = \paperwidth
\pageheight = \paperheight
\fancyheadoffset[lh]{0pt}%
\end{document}
答案1
好吧,经过多次尝试,您无法忽略序言中定义的列宽(如果您是第一次修改此列)和“多列命令”中定义的宽度,与用于修改所考虑列的其他“多列”命令相比(如果此列以前被修改过)。如果您将它们匹配,使得新列宽略微超过非突出显示列的最大定义宽度,则不会出现任何问题,否则您将遇到上面显示的问题。简而言之,您会看到非突出显示列使用的最大宽度,并将新宽度设置为略微超过它。因此,为了避免混淆,请参阅以下解释:
- 在序言中,第四列定义为
"|>{\centering\arraybackslash}m{3cm}"
列宽为3cm,在多列中多次修改,非高亮列的最大定义宽度为8cm:
\multicolumn{1}{|>{\centering\arraybackslash}m{8cm}|}
{mmmmmm mmmmmm mmm mmm mmm mmmmmmmm mmm mmmm mmmmmmmmm mm}
列宽为 8 厘米,因此非高亮列的最大定义宽度为 8 厘米。将高亮行的新列宽至少设置为 9 厘米。
\multicolumn{1}{|>{\centering\arraybackslash}m{9cm}|}{ }
```````````````````````````````````````````
````````````````````````````````````````
\multicolumn{1}{|>{\centering\arraybackslash}m{9cm}|}{\multirow[c]{-2}{=}[0cm]{في بعض الأحيان لتعبر عن النطق الواضح}}
最终的MWE如下所示:
\documentclass[a4paper,12pt,twoside]{book}
\usepackage[a4paper,top=2.5cm,bottom=2.5cm,margin=2.5cm,bindingoffset=0.5cm]{geometry}
\makeatletter
\def\ifGm@preamble#1{%
\ifGm@newgm
%\Gm@warning{`#1': not available in `\string\newgeometry'; skipped}%
\expandafter\@firstofone
\else
\expandafter\@firstofone
\fi}%
\makeatother
\usepackage[bidi=basic,layout=lists.tabular]{babel}
\babelprovide[import=ar,mapdigits,main]{arabic}
\babelprovide[import=en,language=Default]{english}
\babelfont{rm}{Latin Modern Roman}
\babelfont[arabic]{rm}{amiri}
\babelfont[english]{rm}{Times New Roman}
\usepackage{pdflscape}
\usepackage{rotating}
\usepackage[hidelinks,colorlinks=true,breaklinks,allcolors=blue]{hyperref}
\usepackage{fancyhdr}
\usepackage{fancybox, graphicx}
\usepackage[table]{xcolor}
\usepackage{tabu,multirow}
\usepackage[framemethod=tikz]{mdframed}
\usetikzlibrary{shadows}
\usepackage{longtable}
\usepackage{array}
\newcolumntype{?}[1]{!{\vrule width #1}}
\usepackage{booktabs}
\setlength{\belowrulesep}{0pt}
\setlength{\belowbottomsep}{0pt}
\setlength{\aboverulesep}{0pt}
\setlength{\belowrulesep}{0pt}
\setlength{\abovetopsep}{0pt}
\usepackage{makecell}
\usepackage{boldline}
\usepackage[skins,xparse,breakable]{tcolorbox}
\begin{document}
\newgeometry{landscape,margin=2.5cm}
\pagewidth = \paperwidth
\pageheight = \paperheight
\fancyheadoffset[lh]{0pt}%
\begin{table}[htbp]
\setlength\arrayrulewidth{1pt} % so that lines apear since they get overried by rowcolors command
\begin{center}
\begin{tabular}
{
?{1mm}c
?{0.5mm}>{\centering\arraybackslash}m{2cm}
|>{\centering\arraybackslash}c
|>{\centering\arraybackslash}m{3cm}
|>{\centering\arraybackslash}m{3cm}
|>{\centering\arraybackslash}m{3cm}
|>{\centering\arraybackslash}m{2cm}?{1mm}
}
%\rowcolor{white} %Color for first row
\toprule[1mm] %may be used to draw a horizontal line at the top of the table.
%\hline % Not needed here as top rule is used
\textbf{dfdfdfdf}
&
\textbf{الحالة
dffds sdfds
}
&
\multicolumn{2}{|c|}{\textbf{tttt t ttt ttt}}
&
\textbf{rrrrr rrrrrr rrrr rrr}
&
\textbf{ttttttttttttt}
&
\textbf{ttttttt}
\\
\midrule[1mm]
\rowcolor{gray!25}
\cellcolor{white}
&
&
mm
&
\multicolumn{1}{|>{\centering\arraybackslash}m{9cm}|}{}
&
mm
&
mm
&
mmmm
\\
\cmidrule[0.5pt]{3-3}
\cmidrule[0.5pt]{5-7}
\rowcolor{gray!25}
\cellcolor{white}
&
&
&
\multicolumn{1}{|>{\centering\arraybackslash}m{9cm}|}{}
&
mm
&
mm
&
mmmm
\\
\cmidrule[0.5pt]{5-7}
\rowcolor{gray!25}
\cellcolor{white}
&
&
\multirow[c]{-2}{0cm}[0cm]
{mm}
&
\multicolumn{1}{|>{\centering\arraybackslash}m{9cm}|}
{
\multirow[c]{-2}{=}[0.5cm]
{
mm
}}
&
mm
&
mm
&
mmmm
\\
\cmidrule[0.5pt]{3-7}
\cellcolor{white}
&
\cellcolor{gray!25}
&
\foreignlanguage{coptic}{ⲩ}
&
\multicolumn{1}{|>{\centering\arraybackslash}m{8cm}|}
{
mmmmmm mmmmmm mmm mmm mmm mmmmmmmm mmm mmmm mmmmmmmmm mm
}
&
mm
&
mm
&
mmmm
\\
\cmidrule[0.5pt]{3-7}
\rowcolor{gray!25}
\cellcolor{white}
&
&
&
\multicolumn{1}{|>{\centering\arraybackslash}m{9cm}|}{ }
&
mm
&
mm
&
mmmm
\\
\cmidrule[0.5pt]{5-7}
\rowcolor{gray!25}
\cellcolor{white}
&
&
\multirow[c]{-2}{*}[0cm]{mm}
&
\multicolumn{1}{|>{\centering\arraybackslash}m{9cm}|}
{
\multirow[c]{-2}{=}[0cm]
{
في بعض الأحيان لتعبر عن النطق الواضح
}}
&
mm
&
mm
&
mmmm
\\
\cmidrule[0.5pt]{3-7}
\cellcolor{white}
&
\cellcolor{gray!25}
\multirow[c]{-6}{2cm}[0.5cm]
{
mmmmmm mmmmmm mmm mmm mmm mmmmmmmm
}
&
\multicolumn{2}{|>{\centering\arraybackslash}m{10cm}|}
{
mm
}
&
mm
&
mm
&
mmmm
\\
\cmidrule[1pt]{2-7}
\rowcolor{gray!25}
\cellcolor{white}
&
\cellcolor{white}
&
\multicolumn{2}{|>{\centering\arraybackslash}m{10cm}|}{ }
&
mm
&
mm
&
mmmm
\\
\cmidrule[0.5pt]{5-7}
\rowcolor{gray!25}
\cellcolor{white}
&
\cellcolor{white}
&
\multicolumn{2}{|>{\centering\arraybackslash}m{10cm}|}
{\multirow[c]{-2}{=}[0cm]{\centering mm}}
&
mm
&
mm
&
mmmm
\\
\cmidrule[0.5pt]{3-7}
\cellcolor{white}
&
&
\multicolumn{2}{|>{\centering\arraybackslash}m{10cm}|}
{mm}
&
&
mm
&
\\
\cmidrule[0.5pt]{3-4}
\cmidrule[0.5pt]{6-6}
\cellcolor{white}
&
&
\multicolumn{2}{|>{\centering\arraybackslash}m{10cm}|}{}
&
\multirow[c]{-2}{*}[0cm]{mm}
&
mm
&
\multirow[c]{-2}{*}[0cm]{mmmm}
\\
\cmidrule[0.5pt]{5-7}
\cellcolor{white}
&
&
\multicolumn{2}{|>{\centering\arraybackslash}m{10cm}|}
{\multirow[c]{-2}{=}[0cm]{\centering mm}
}
&
mm
&
mm
&
mmmm
\\
\cmidrule[0.5pt]{3-7}
\rowcolor{gray!25}
\cellcolor{white}
\multirow[c]{-13}{*}[0.5cm]{mm}
&
\cellcolor{white}
\multirow[c]{-6}{2cm}[0.5cm]
{
mmmm mmmmm mmm mmmmmmm
}
&
\multicolumn{2}{|>{\centering\arraybackslash}m{10cm}|}
{
mmmmmm mmmmmm mmm mmm mmm mmmmmmmm mmm
}
&
mm
&
mm
&
mmmm
\\
\bottomrule[1mm] %draws a horizontal line to finish off a table
\end{tabular}
\end{center}
\end{table}
\clearpage
\restoregeometry
\pagewidth = \paperwidth
\pageheight = \paperheight
\fancyheadoffset[lh]{0pt}%
\end{document}