添加背景颜色后,第一列第二行的文本被隐藏了。不知道如何修复它

添加背景颜色后,第一列第二行的文本被隐藏了。不知道如何修复它
\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage[scaled]{helvet}
\usepackage{amsmath,amsfonts,amssymb}
\usepackage{mathpazo}

\usepackage{helvet}
\renewcommand{\familydefault}{\sfdefault}

%size of paper
\usepackage{geometry}
\geometry{
 a4paper,
 total={170mm,257mm},
 left=20mm,
 top=20mm,
 }

\title{Trial}
\author{ble}
\date{March 2021}

%tables
\usepackage{tabularx}
\usepackage{threeparttable}
\setlength{\tabcolsep}{20pt}
\renewcommand{\arraystretch}{1.5}
\setlength{\arrayrulewidth}{0.5mm}
\setlength{\tabcolsep}{18pt}
\usepackage{xcolor,colortbl}
\usepackage{multirow}

\usepackage{array}
\newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}}
\newcolumntype{M}[1]{>{\centering\arraybackslash}m{#1}}
\usepackage{chngpage}
\usepackage{adjustbox}



\begin {document} 


\definecolor{Gray}{gray}{0.85}
\newcolumntype{a}{>{\columncolor{Gray}}M{1cm}}
\begin{table}
\begin{adjustwidth}{-0.1in}{-1in}
    \begin{tabular}{|a|M{3.5cm}|M{9cm}|}
    \hline
       \rowcolor{lightgray} Type  & Item & Discharge Method \\
       \hline
        \multirow{4}{*}{Paper} & Newspapers & 
                While disposing it should not be wet, one should spread it out evenly or should be tied into a single pile.
                Advertisements coated with vinyl, vinyl, and other dirt should not be mixed \\
             \cline{2-3}
            {} & Brochures, Notebooks, Paper Shopping Bags, Calendar, Wrappers & 
                  Remove the vinyl-coated cover and spring from the notebook. Discharge separately. Plastic wrapping paper is excluded
             \\
             \cline{2-3}
            {} & Paper Cups, Paper Packs & 
                Empty the contents, rinse it with water, squeeze it, dispose in a bag or bundle it together.\\
            \cline{2-3}
            {} & Boxes (Snacks, Package Boxes, Corrugated Boxes, etc.) & Remove the vinyl coating, tape attached to the box and staples, crush or fold for easier transportation \\
            \hline
            \multirow{2}{*}{Cans} & Iron Cans, Aluminum Cans (Drinks and Foods) &  Empty contents, rinse with water and squeeze if possible. \\
            \cline{2-3}
            {} & Other Cans (Butane Gas, Pesticide Containers) & Empty content by drilling a hole, remove plastic cap if present and dispose. Dispose in a bag (vinyl bag is permitted).
            \\
            \hline
    \multirow{2}{*}{Bottles} &  Beverage Bottles and Other Bottles & Remove the bottle cap, empty the contents, rinse it with water and discharge it separately. 
    Do not put foreign substances such as cigarette butts
* For beer bottles, etc., the empty container and deposit system is used at retail stores, etc. \\
\cline{2-3}
{} & Pesticide Bottles & Rinse it with water and discharge it separately do not mix with beverage bottles. \\
\hline
\multirow{2}{*}{Metals}
{} & Scrap Metals (Tools, Steel Wires, Nails, Iron Plates, Electric Wires, etc.) &
Prevent mixing with foreign substances, place in a transparent bag or tie it with a string to dispose. \\

\cline{2-3}
{} & Non-ferrous Metals (Nickel Silvers, Aluminums, Stainless Steels) & Prevent mixing with foreign substances, place in a transparent bag or tie it with a string to dispose.\\
\hline
\multirow{3}{*}{Plastics} & PET bottles, Synthetic resin containers. 

& Remove lid, empty contents, rinse with water and squeeze it to reduce the volume, as much as possible
* Excluding waste oil containers. \\
\cline{2-3}
{} & Household goods & Remove foreign substances, attached trademarks, etc. completely and place in a transparent vinyl or bundle them to dispose them.
Empty the residue of fruits and fish boxes completely and rinse thoroughly with water to dispose. \\
\cline{2-3}
{} & Waste Styrofoam & Excluding disposable cup noodle containers, lunch boxes and waste Styrofoam coated with foreign substances or other materials (PE, PP, etc.) \\
\hline

Textiles & Pure Wool, Mixed Wool, Innerwear, Outwear, etc. &
Except wet clothes, nylon, disposable diapers, quilted blankets, etc. Tie it using a string or dispose in a box or transparent vinyl. \\
\hline 
Batteries & MR, SR & Dispose in a transparent vinyl or box. \\

\hline 

Vinyl & Snack Bags, Ramen Bags, Household Rubber Gloves, Disposable Plastic Bags, etc. & Only plastic bags are collected separately and discharged. If foreign substances such as food are smeared, wash them thoroughly and dispose. \\
\hline
    \end{tabular}
    \end{adjustwidth}
    \caption{Recyclables}
    \label{tab:my_label}
\end{table}

答案1

您可以使用具有多种优点的表格{NiceTabular}来制作该表格nicematrix

  • 在 中{NiceTabular},您可以使用命令\Block来垂直和水平合并单元格。垂直合并时,您可以指定逻辑行数而不是身体的行与 一样\multirow
  • 您可以为行和列着色,而无须使用负数参数\multirow
  • 您可以使用钥匙绘制所有规则hvlines
  • 您不会看到 Zarko 的答案中出现的细白线。

但是,中没有x列类型{NiceTabular}(可能在未来版本中)。在我的示例中,我进行了计算,以便获得这样的行为{tabularx}(我采用了 Zarko 答案的值)。

\documentclass{article}
\usepackage[a4paper,margin=2cm]{geometry}
\usepackage[english]{babel}
\usepackage{xcolor}
\renewcommand{\familydefault}{\sfdefault}
\usepackage{mathpazo}
\usepackage{amsmath,amssymb}
\usepackage[scaled]{helvet}

\usepackage{nicematrix}
\NiceMatrixOptions{cell-space-limits=5pt}

\title{Trial}
\author{ble}
\date{March 2021}

\begin{document}
\begin{table}
\setlength{\arrayrulewidth}{0.5mm}      % thicker arrayrules
\setlength\tabcolsep{3pt}               % reduced separation between column content from their borders
\begin{NiceTabular}[hvlines]
              {m{4em}
               >{\centering\arraybackslash}m{\dimexpr (\textwidth -4em -6\tabcolsep -4\arrayrulewidth)/10*3}
               >{\centering\arraybackslash}m{\dimexpr (\textwidth -4em -6\tabcolsep -4\arrayrulewidth)/10*7}}
\CodeBefore
    \columncolor{gray!85}{1}
    \rowcolor{lightgray}{1}
\Body
 Type  & Item & Discharge Method \\
\Block{3-1}{Paper}
    & Newspapers 
        & While disposing it should not be wet, one should spread it out evenly or should be tied into a single pile. Advertisements coated with vinyl, vinyl, and other dirt should not be mixed
        \\  
    & Brochures, Notebooks, Paper Shopping Bags, Calendar, Wrappers 
        &   Remove the vinyl-coated cover and spring from the notebook. Discharge separately. Plastic wrapping paper is excluded
        \\  
    & Paper Cups, Paper Packs 
        & Empty the contents, rinse it with water, squeeze it, dispose in a bag or bundle it together.
        \\  
\Block{2-1}{Cans}
    & Boxes (Snacks, Package Boxes, Corrugated Boxes, etc.) 
        & Remove the vinyl coating, tape attached to the box and staples, crush or fold for easier transportation 
        \\  
    & Iron Cans, Aluminum Cans (Drinks and Foods) 
        &  Empty contents, rinse with water and squeeze if possible. 
        \\  
\Block{2-1}{Bottles}
    & Other Cans (Butane Gas, Pesticide Containers) 
        & Empty content by drilling a hole, remove plastic cap if present and dispose. Dispose in a bag (vinyl bag is permitted).
        \\  
    &  Beverage Bottles and Other Bottles 
        & Remove the bottle cap, empty the contents, rinse it with water and discharge it separately. Do not put foreign substances such as cigarette butts 
        * For beer bottles, etc., the empty container and deposit system is used at retail stores, etc. 
        \\  
    & Pesticide Bottles 
        & Rinse it with water and discharge it separately do not mix with beverage bottles. 
        \\  
\Block{2-1}{Metals}
    & Scrap Metals (Tools, Steel Wires, Nails, Iron Plates, Electric Wires, etc.) 
        & Prevent mixing with foreign substances, place in a transparent bag or tie it with a string to dispose. 
        \\  
    & Non-ferrous Metals (Nickel Silvers, Aluminums, Stainless Steels) 
        & Prevent mixing with foreign substances, place in a transparent bag or tie it with a string to dispose.
        \\  
\Block{3-1}{Plastics}
    & PET bottles, Synthetic resin containers.
        & Remove lid, empty contents, rinse with water and squeeze it to reduce the volume, as much as possible
        * Excluding waste oil containers. 
        \\  
    & Household goods 
        & Remove foreign substances, attached trademarks, etc. completely and place in a transparent vinyl or bundle them to dispose them.
        Empty the residue of fruits and fish boxes completely and rinse thoroughly with water to dispose. 
        \\  
    & Waste Styrofoam 
        & Excluding disposable cup noodle containers, lunch boxes and waste Styrofoam coated with foreign substances or other materials (PE, PP, etc.) \\
Textiles 
    & Pure Wool, Mixed Wool, Innerwear, Outwear, etc. 
        & Except wet clothes, nylon, disposable diapers, quilted blankets, etc. Tie it using a string or dispose in a box or transparent vinyl. \\
Batteries 
    & MR, SR 
        & Dispose in a transparent vinyl or box. 
        \\  
Vinyl 
    & Snack Bags, Ramen Bags, Household Rubber Gloves, Disposable Plastic Bags, etc. 
        & Only plastic bags are collected separately and discharged. If foreign substances such as food are smeared, wash them thoroughly and dispose. 
        \\  
\end{NiceTabular}
\caption{Recyclables}
\label{tab:my_label}
\end{table}
\end{document}

上述代码的输出

答案2

也许你应该扩展或者澄清你的问题。

我把你的表格整理如下

\documentclass[10pt,a4paper]{article}
\usepackage[left=2.00cm, right=2.00cm, top=2.00cm, bottom=2.00cm]{geometry}

<your MWE>

\end{document}

并且没有发现任何缺失的行。或者是您添加了另一种背景颜色?

不相关:删除表格环境中的空行。

二十

答案3

如果您有彩色(多行)单元格,则需要在着色后在其中添加文本。 在您的例子中,这意味着\multirow必须将其插入到它跨越的最后一行,并且它跨越的行数为负数,如下面 MWE 中所做的那样。

无关

  • 请始终在您遗漏的代码行中提供可编译的 MWE(最小工作示例)\end{document}
  • 请仅加载每个包
  • 根据用途对它们进行分组(字体、数学、表格……)
  • 而不是拉伸数组,而是通过使用在单元格内容之前和之后插入垂直间隙cellspace(如下面的 MWE 中所做的那样)
  • 相反,tabular我认为最好使用宏tabularx并省略使用宏adjustidthchangepage
  • 对于列中单元格内容的垂直居中,列单元格C类型已更新,请参阅下面的 MWEX\renewcommand\tabularxcolumn[1]{m{#1}}
  • 不要使用旧的chngpage,因为它已被弃用,最好使用带有选项的新版本strict,即:它应该被加载为:\usepackage[strict]{changepage}
  • 跨越线的负数\multirow计算为<行数 - 添加的垂直间隙和水平规则的大小>其中增加的垂直大小以文本行数估算。例如,第一个“多行单元格”跨越 11 个文本行,插入了 8 个间隙

梅威瑟:

\documentclass{article}
\usepackage[a4paper,
            margin=2cm]{geometry}
% fonts
\usepackage[english]{babel}
\usepackage[table]{xcolor}
\renewcommand{\familydefault}{\sfdefault}
\usepackage{mathpazo}
% math
\usepackage{amsmath,amssymb}% amsfonts is loaded by amssymb
%tables
\usepackage[scaled]{helvet}
\usepackage[column=O]{cellspace}% better, than {} aren't necessary
    \setlength\cellspacetoplimit{5pt}
    \setlength\cellspacebottomlimit{5pt}
\usepackage{multirow, tabularx, threeparttable}
    \newcolumntype{C}[1]{>{\centering\arraybackslash
                           \hsize=#1\hsize}X }
    \addparagraphcolumntypes{C}
% miscellaneous
\usepackage[strict]{changepage}  
\usepackage{adjustbox}   


\title{Trial}
\author{ble}
\date{March 2021}

\begin{document}
\begin{table}
    \renewcommand\tabularxcolumn[1]{m{#1}}  % vertical centered X cells contents
    \setlength{\arrayrulewidth}{0.5mm}      % thicker arrayrules
    \setlength\tabcolsep{3pt}               % reduced separation between column content from their borders
    \begin{tabularx}{\linewidth}{|>{\columncolor{gray!85}}p{4em}|
                                    O{C{0.3}}|
                                    O{C{0.7}}|}
    \hline
\rowcolor{lightgray} Type  & Item & Discharge Method \\
    \hline
    & Newspapers 
        & While disposing it should not be wet, one should spread it out evenly or should be tied into a single pile. Advertisements coated with vinyl, vinyl, and other dirt should not be mixed
        \\  \cline{2-3}
    & Brochures, Notebooks, Paper Shopping Bags, Calendar, Wrappers 
        &   Remove the vinyl-coated cover and spring from the notebook. Discharge separately. Plastic wrapping paper is excluded
        \\  \cline{2-3}
    & Paper Cups, Paper Packs 
        & Empty the contents, rinse it with water, squeeze it, dispose in a bag or bundle it together.
        \\  \cline{2-3}
\multirow{-9}{=}{Paper}
    & Boxes (Snacks, Package Boxes, Corrugated Boxes, etc.) 
        & Remove the vinyl coating, tape attached to the box and staples, crush or fold for easier transportation 
        \\  \hline
    & Iron Cans, Aluminum Cans (Drinks and Foods) 
        &  Empty contents, rinse with water and squeeze if possible. 
        \\  \cline{2-3}
\multirow{-3}{=}{Cans}
    & Other Cans (Butane Gas, Pesticide Containers) 
        & Empty content by drilling a hole, remove plastic cap if present and dispose. Dispose in a bag (vinyl bag is permitted).
        \\  \hline
    &  Beverage Bottles and Other Bottles 
        & Remove the bottle cap, empty the contents, rinse it with water and discharge it separately. Do not put foreign substances such as cigarette butts 
        * For beer bottles, etc., the empty container and deposit system is used at retail stores, etc. 
        \\  \cline{2-3}
\multirow{-4}{=}{Bottles}
    & Pesticide Bottles 
        & Rinse it with water and discharge it separately do not mix with beverage bottles. 
        \\  \hline
    & Scrap Metals (Tools, Steel Wires, Nails, Iron Plates, Electric Wires, etc.) 
        & Prevent mixing with foreign substances, place in a transparent bag or tie it with a string to dispose. 
        \\  \cline{2-3}
\multirow{-4}{=}{Metals}
    & Non-ferrous Metals (Nickel Silvers, Aluminums, Stainless Steels) 
        & Prevent mixing with foreign substances, place in a transparent bag or tie it with a string to dispose.
        \\  \hline
    & PET bottles, Synthetic resin containers.
        & Remove lid, empty contents, rinse with water and squeeze it to reduce the volume, as much as possible
        * Excluding waste oil containers. 
        \\  \cline{2-3}
    & Household goods 
        & Remove foreign substances, attached trademarks, etc. completely and place in a transparent vinyl or bundle them to dispose them.
        Empty the residue of fruits and fish boxes completely and rinse thoroughly with water to dispose. 
        \\  \cline{2-3}
\multirow{-9}{=}{Plastics}
    & Waste Styrofoam 
        & Excluding disposable cup noodle containers, lunch boxes and waste Styrofoam coated with foreign substances or other materials (PE, PP, etc.) \\
    \hline
Textiles 
    & Pure Wool, Mixed Wool, Innerwear, Outwear, etc. 
        & Except wet clothes, nylon, disposable diapers, quilted blankets, etc. Tie it using a string or dispose in a box or transparent vinyl. \\
    \hline
Batteries 
    & MR, SR 
        & Dispose in a transparent vinyl or box. 
        \\  \hline
Vinyl 
    & Snack Bags, Ramen Bags, Household Rubber Gloves, Disposable Plastic Bags, etc. 
        & Only plastic bags are collected separately and discharged. If foreign substances such as food are smeared, wash them thoroughly and dispose. 
        \\  \hline
    \end{tabularx}
    \caption{Recyclables}
    \label{tab:my_label}
\end{table}
\end{document}

在此处输入图片描述

相关内容