在表格中制作一条粗垂直线

在表格中制作一条粗垂直线

我有一张需要编辑的表格。首先,我想用一条粗竖线将第一列与其余四列分开。其次,我想将“生物体 DNA 中碱基的百分比”排版在两行上。第三,“生物体”应位于三行中间 - 两行用于“生物体 DNA 中碱基的百分比”,一行用于包含“腺嘌呤”、“鸟嘌呤”、“胞嘧啶”和“胸腺嘧啶”的行。

为什么表格的左边缘有三个垂直条?为什么右边缘第二行缺少“||”?如果我想让第一列中的数据(不包括单词“Organism”)在左边缘对齐,我该如何修改代码?

\documentclass[10pt]{amsart}


\usepackage{makecell}
\usepackage{boldline}
\setcellgapes{3pt}


\setlength{\oddsidemargin}{0.0in}
\setlength{\evensidemargin}{0.0in} \setlength{\textwidth}{6.1in}
\setlength{\topmargin}{0.0in} \setlength{\textheight}{9in}



\begin{document}

\makegapedcells
\begin{tabular}{||!{\vrule width0.8pt}c | c | c | c | c||} \hline
\multicolumn{5}{|| c ||}{\textbf{Base Composition of DNA}} \\ \hline
Organism        &\multicolumn{4}{|| c ||}{Percentage of base in organism's DNA} \\ \hline
                &   adenine     &   guanine &   cytosine    &   thymine \\ \hline
Maize           &   26.8\%      &   22.8\%  &   23.2\%      &   27.2\% \\ \hline
Octopus         &   33.2\%      &   17.6\%  &   17.6\%      &   31.6\% \\ \hline
Chicken         &   28.0\%      &   22.0\%  &   21.6\%      &   28.4\% \\ \hline
Rat             &   28.6\%      &   21.4\%  &   20.5\%      &   28.4\% \\ \hline
Human           &   29.3\%      &   20.7\%  &   20.0\%      &   30.0\% \\ \hline
Grasshopper     &   29.3\%      &   20.5\%  &   20.7\%      &   29.3\% \\ \hline
Sea urchin      &   32.8\%      &   17.7\%  &   17.3\%      &   32.1\% \\ \hline
Wheat           &   27.3\%      &   22.7\%  &   22.8\%      &   27.1\% \\ \hline
Yeast           &   31.3\%      &   18.7\%  &   17.1\%      &   32.9\% \\ \hline
{\em E. coli}   &   24.7\%      &   26.0\%  &   25.7\%      &   23.6\% \\ \hline
\end{tabular}

\end{document}

答案1

您可以使用V{...}更粗的垂直线。

\documentclass[10pt]{amsart}

\usepackage{makecell}
\usepackage{boldline}
\setcellgapes{3pt}

\setlength{\textwidth}{6.1in}
\setlength{\textheight}{9in}
\calclayout

\begin{document}

\makegapedcells
\begin{tabular}{|| c V{3} c | c | c | c||} \hline
\multicolumn{5}{|| c ||}{\textbf{Base Composition of DNA}} \\ \hline
Organism        &\multicolumn{4}{ c ||}{Percentage of base in organism's DNA} \\ \hline
                &   adenine     &   guanine &   cytosine    &   thymine \\ \hline
Maize           &   26.8\%      &   22.8\%  &   23.2\%      &   27.2\% \\ \hline
Octopus         &   33.2\%      &   17.6\%  &   17.6\%      &   31.6\% \\ \hline
Chicken         &   28.0\%      &   22.0\%  &   21.6\%      &   28.4\% \\ \hline
Rat             &   28.6\%      &   21.4\%  &   20.5\%      &   28.4\% \\ \hline
Human           &   29.3\%      &   20.7\%  &   20.0\%      &   30.0\% \\ \hline
Grasshopper     &   29.3\%      &   20.5\%  &   20.7\%      &   29.3\% \\ \hline
Sea urchin      &   32.8\%      &   17.7\%  &   17.3\%      &   32.1\% \\ \hline
Wheat           &   27.3\%      &   22.7\%  &   22.8\%      &   27.1\% \\ \hline
Yeast           &   31.3\%      &   18.7\%  &   17.1\%      &   32.9\% \\ \hline
{\em E. coli}   &   24.7\%      &   26.0\%  &   25.7\%      &   23.6\% \\ \hline
\end{tabular}

\end{document}

在此处输入图片描述

设置\oddsidemargin\evensidemargin\topmargin;使用\calclayout,与 AMS 类。

将长标题分成两行并删除“Organism”下方规则的替代代码。

\begin{tabular}{|| c V{3} c | c | c | c||} \hline
\multicolumn{5}{|| c ||}{\textbf{Base Composition of DNA}} \\ \hline
Organism        & \multicolumn{4}{ c ||}{%
                    \begin{tabular}{@{}c@{}}
                    Percentage of base\\
                    in organism's DNA
                    \end{tabular}%
                  } \\ \cline{2-5}
                &   adenine     &   guanine &   cytosine    &   thymine \\ \hline
Maize           &   26.8\%      &   22.8\%  &   23.2\%      &   27.2\% \\ \hline
Octopus         &   33.2\%      &   17.6\%  &   17.6\%      &   31.6\% \\ \hline
Chicken         &   28.0\%      &   22.0\%  &   21.6\%      &   28.4\% \\ \hline
Rat             &   28.6\%      &   21.4\%  &   20.5\%      &   28.4\% \\ \hline
Human           &   29.3\%      &   20.7\%  &   20.0\%      &   30.0\% \\ \hline
Grasshopper     &   29.3\%      &   20.5\%  &   20.7\%      &   29.3\% \\ \hline
Sea urchin      &   32.8\%      &   17.7\%  &   17.3\%      &   32.1\% \\ \hline
Wheat           &   27.3\%      &   22.7\%  &   22.8\%      &   27.1\% \\ \hline
Yeast           &   31.3\%      &   18.7\%  &   17.1\%      &   32.9\% \\ \hline
{\em E. coli}   &   24.7\%      &   26.0\%  &   25.7\%      &   23.6\% \\ \hline
\end{tabular}

在此处输入图片描述


您可以通过省略所有垂直线来轻松制作更好的表格;双重线和较粗的线毫无用处。此外,%在每个单元格中重复也是一种浪费,因为列已经声明包含百分比。

\documentclass[10pt]{amsart}

\usepackage{booktabs,siunitx}

\setlength{\textwidth}{6.1in}
\setlength{\textheight}{9in}
\calclayout

\begin{document}

\begin{tabular}{
 @{}
 l
 *{4}{S[table-format=2.1]}
 @{}
}
\toprule
\multicolumn{5}{c}{\textbf{Base Composition of DNA}} \\
\midrule
Organism        &\multicolumn{4}{c}{Percentage of base in organism's DNA} \\
\cmidrule(l){2-5}
                &   {adenine} &   {guanine} &   {cytosine}    &   {thymine} \\
\midrule
Maize           &   26.8      &   22.8  &   23.2      &   27.2 \\
Octopus         &   33.2      &   17.6  &   17.6      &   31.6 \\
Chicken         &   28.0      &   22.0  &   21.6      &   28.4 \\
Rat             &   28.6      &   21.4  &   20.5      &   28.4 \\
Human           &   29.3      &   20.7  &   20.0      &   30.0 \\
Grasshopper     &   29.3      &   20.5  &   20.7      &   29.3 \\
Sea urchin      &   32.8      &   17.7  &   17.3      &   32.1 \\
Wheat           &   27.3      &   22.7  &   22.8      &   27.1 \\
Yeast           &   31.3      &   18.7  &   17.1      &   32.9 \\
{\em E. coli}   &   24.7      &   26.0  &   25.7      &   23.6 \\
\bottomrule
\end{tabular}

\end{document}

在此处输入图片描述

相关内容