2

I have a table that needs some edits. First, I would like a thick vertical line separating the first column from the remaining four columns. Second, I want "Percentage of base in organism's DNA" typeset on two lines. Third, "Organism" should be centered among three rows - two for "Percentage of base in organism's DNA" and one for the row containing "adenine," "guanine," "cytosine," and "thymine."

Why are there three vertical bars on the left edge of the table? Why is the "||" missing in the second row along the right edge? If I wanted the data in the first column, excluding the word "Organism," to be aligned on the left edge, how would I modify the code?

\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}
4

You can use V{...} for thicker vertical rules.

\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}

enter image description here

Don't set \oddsidemargin, \evensidemargin and \topmargin; use \calclayout, with AMS classes.

Alternative code for breaking the long header into two lines and for removing the rule below “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}

enter image description here


You can easily make a better table by omitting all vertical rules; double rules and thicker ones serve no purpose whatsoever. Also repeating % in every cell is a waste, because the columns are already stated to contain percentages.

\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}

enter image description here

  • How thick is the line drawn with V{3}? I see that you removed || in \multicolumn{4} command. I don't want the vertical bar under "Organism," leaving an empty box. Do you know how I can get "Percentage of base in organism's DNA" on two rows? – Adelyn May 6 '16 at 15:50
  • I made an edit to my comment to you. I apologize if you were trying to reply to a vague question that I had asked. – Adelyn May 6 '16 at 15:56
  • @Adelyn I don't know the unit of measure for the thickness; just experiment. The rules generally belong to the preceding column, except for the leading ones that of course belong to the first column. – egreg May 6 '16 at 15:57
  • Yes, that is a nicely displayed table. – Adelyn May 6 '16 at 16:14
  • 1
    @Thruston Yes, @{} suppresses the space at either end; the *{4}{<cols>} means “repeat four times the columns specifier <cols>”, in this case a numeric column with numbers having two digits in the integral part and one digit in the fractional part. – egreg May 6 '16 at 16:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.