编辑:

编辑:

我怎样才能用白线分隔列和单元格?我在 Google 上搜索后发现我们可以在表格定义中放入\hline和,|但这会产生黑线。

 \documentclass{article}
 \usepackage{array,multirow}
 \begin{document}
 \begin{tabular}{|c|cc|}\hline
 \multirow{4}{*}{Foo} & 1 & 2 \\
   & 1 & 2 \\\cline{2-3}
   & 1 & 2 \\
   & 1 & 2 \\\hline
  \multirow{4}{*}{Bar} & 1 & 2 \\
     & 1 & 2 \\\cline{2-3}
     & 1 & 2 \\
     & 1 & 2 \\\hline
   \end{tabular}
\end{document}

我怎样才能将它们改为白线?

答案1

使用colortbl。我使用蓝色只是为了演示,因为这里的背景是白色的。您可以根据实际情况更改bluewhite( )。\arrayrulecolor{white}

 \documentclass{article}
 \usepackage{array,multirow,colortbl}
 \begin{document}
 \arrayrulecolor{blue}         %% change blue to white in your case
 \begin{tabular}{|c|cc|}\hline
 \multirow{4}{*}{Foo} & 1 & 2 \\
   & 1 & 2 \\\cline{2-3}
   & 1 & 2 \\
   & 1 & 2 \\\hline
  \multirow{4}{*}{Bar} & 1 & 2 \\
     & 1 & 2 \\\cline{2-3}
     & 1 & 2 \\
     & 1 & 2 \\\hline
   \end{tabular}
\end{document}

在此处输入图片描述

有关详细信息,请参阅colortble第 5 页和第 6 节第 7 和第 8 节的文档。要获取文档,请texdoc colortbl从命令提示符运行或访问texdoc.net

另一个选择是使用xcolor带有选项的包[table]

\documentclass{article}
 \usepackage{array,multirow}
 \usepackage[table]{xcolor}
 \begin{document}
 \pagecolor{blue!40} %% just to demonstrate - remove in your file
 \arrayrulecolor{white}
 \begin{tabular}{|c|cc|}\hline
 \multirow{4}{*}{Foo} & 1 & 2 \\
   & 1 & 2 \\\cline{2-3}
   & 1 & 2 \\
   & 1 & 2 \\\hline
  \multirow{4}{*}{Bar} & 1 & 2 \\
     & 1 & 2 \\\cline{2-3}
     & 1 & 2 \\
     & 1 & 2 \\\hline
   \end{tabular}
\end{document}

在此处输入图片描述

编辑:

它也适用于长表:

\documentclass{article}
 \usepackage{array,multirow,longtable}
 % \usepackage{colortbl}
 \usepackage[table]{xcolor}
 \usepackage[textheight=10cm]{geometry} %% onlly for testing
 \begin{document}
 \pagecolor{blue} %% just to demonstrate - remove in your file
 \arrayrulecolor{white}
 \begin{tabular}{|c|cc|}\hline
 \multirow{4}{*}{Foo} & 1 & 2 \\
   & 1 & 2 \\\cline{2-3}
   & 1 & 2 \\
   & 1 & 2 \\\hline
  \multirow{4}{*}{Bar} & 1 & 2 \\
     & 1 & 2 \\\cline{2-3}
     & 1 & 2 \\
     & 1 & 2 \\\hline
   \end{tabular}
   
  
\begin{longtable}{|>{\bf\centering\arraybackslash}p{1in}| p{2in}|}
\hline
\large{Name} & \large{\textbf{Definition}}\\ \hline
\endfirsthead
\hline
\large{Name} & \large{\textbf{Definition}}\\ \hline
\endhead
\hline
\multicolumn{2}{r}{continued \ldots}
\endfoot
\hline
\endlastfoot

  Newton's first law & An object will \\ \hline
  Newton's second law & The net force \\\hline
  Newton's third law & When two bodies \\ \hline
  Linear momentum & The product of an object's \\ \hline
  Net force on a body & Is said to be equal \\ \hline
  Impulse of a force & The product of \\\hline
  Principle of conservation of momentum & In a closed system, \\
    \hline
  Perfectly elastic collision & A collision is \\ \hline
  Inelastic collision & A collision is \\ \hline
  Radian & $\pi$ radians = $180^\circ$\\ \hline
  Gravitational field strength & The gravitational force
    \\\hline
  Newton's law of gravitation & Any two point masses\\\hline
\end{longtable}
\end{document}

在此处输入图片描述

编辑:

对于以下评论中的疑问:

你可以使用类似

\newcolumntype{M}[1]{>{\centering\arraybackslash}p{#1}} %% this needs array package
\begin{longtable}{|M{1.4cm}|M{1cm}|M{1cm}|M{3.7cm}|M{1.8cm}|M{1.8cm}|}

相关内容