1

I have code for a table to be drawn. It is almost what I want. I am requesting three modifications to be made to it.

I would like vertical lines, forming the left and right edges of the table, to be drawn. These lines together with the horizontal line above the title and the horizontal line after the last row of the table should make a rectangle.

There are two vertical lines separating the three columns. I would like the vertical line separating the first column from the other two columns to be either 1.5 times thicker than the vertical line separating the second and third column and the vertical lines forming the left and right edges of the table. (In the code provided, two parallel lines drawn close to each other separate the first and second columns.)

The data - certain percentages - should be horizontally centered in their rows.

\documentclass{amsart}

\usepackage{array}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}

\begin{document}


\begin{center}
\begin{tabular}{l||r|r}
\hline
\multicolumn{3}{c}{\textbf{---Title is Lengthy --- Here is First Line}}\\
\multicolumn{3}{c}{\textbf{Here is Second Line}} \\ \hline\hline
\textbf{Class}&\multicolumn{1}{C{1.5in}|}{\textbf{Percent Present in Habitat A}}&\multicolumn{1}{C{1.75in}}{\textbf{Percent Present in Habitat B}}\\\hline

\textbf{Mammals}                        &                   &               \\
\hspace*{1em}Dog                        &   20\%            &   5\%         \\
\hspace*{1em}Cow                        &   10\%            &   7\%         \\ \hline
\textbf{Bird}                           &                   &               \\
\hspace*{1em}Peacock                    &   15\%            &   25\%        \\ \hline
\hspace*{1em}Turkey                     &   25\%            &   40\%        \\ \hline
\textbf{Animals}                        &   \textbf{3\%}    &   \textbf{5\%}    \\
\hline
\end{tabular}
\end{center}

\end{document}
3

For the thicker vertical line, you have the boldline package which does exactly what you want, with syntax V{num} in the table preamble to obtain a vertical rule with thickness num times \arrayrulewidth.

Other than that, I simplified a bit your code, and propose two variants,– the second with the \thead command, from makecell, which allows for line breaks within standard columns and a common formatting. Furthermore, the content of \thead is centred by default, both vertically and horizontally.

\documentclass{amsart}

\usepackage{array}
\usepackage{boldline}\usepackage{makecell}
\renewcommand{\theadfont} {\normalsize\bfseries}


\newcolumntype{C}[1]{>{\centering\arraybackslash}m{#1}}
\setlength{\extrarowheight}{3pt}

\begin{document}


\begin{center}
\begin{tabular}{|lV{1.5}c|c|}
\hline
\multicolumn{3}{|c|}{\textbf{---Title is Lengthy --- Here is First Line}}\\
\multicolumn{3}{|c|}{\textbf{Here is Second Line}} \\ \hline\hline
\textbf{Class}&\multicolumn{1}{C{1.5in}|}{\textbf{Percent Present in Habitat A}}&\multicolumn{1}{C{1.75in}|}{\textbf{Percent Present in Habitat B}}\\\hline

\textbf{Mammals} & & \\
\quad Dog & 20\% & 5\% \\
\quad Cow & 10\% & 7\% \\ \hline
\textbf{Bird} & & \\
\quad Peacock & 15\% & 25\% \\ \hline
\quad Turkey & 25\% & 40\% \\ \hline
\textbf{Animals} & \textbf{3\%} & \textbf{5\%} \\
\hline
\end{tabular}
\end{center}
\vskip 1cm

\begin{center}
\begin{tabular}{|lV{1.5}c|c|}
\hline
\multicolumn{3}{|c|}{\thead{---Title is Lengthy --- Here is First Line\\ Here is Second Line}} \\ \hline\hline
\textbf{Class}&\thead{Percent Present in \\ Habitat A} &\thead{Percent Present in \\ Habitat B}\\\hline

\textbf{Mammals} & & \\
\quad Dog & 20\% & 5\% \\
\quad Cow & 10\% & 7\% \\ \hline
\textbf{Bird} & & \\
\quad Peacock & 15\% & 25\% \\ \hline
\quad Turkey & 25\% & 40\% \\ \hline
\textbf{Animals} & \textbf{3\%} & \textbf{5\%} \\
\hline
\end{tabular}
\end{center}

\end{document} 

enter image description here

To have an unboxed title, and a bigger vertical spacing between the title and the first horizontal line, you can use this code:

    \begin{tabular}{|lV{1.5}c|c|}
    \multicolumn{3}{c}{\thead{---Title is Lengthy --- Here is First Line\\ Here is Second Line}} \\
    \noalign{\vspace{2ex}}\hline
    \textbf{Class}&\thead{Percent Present in \\ Habitat A} & \thead{Percent Present in \\ Habitat B}\\ \hline
    \textbf{Mammals} & & \\
    \quad Dog & 20\% & 5\% \\
    \quad Cow & 10\% & 7\% \\ \hline
    \textbf{Bird} & & \\
    \quad Peacock & 15\% & 25\% \\ \hline
    \quad Turkey & 25\% & 40\% \\ \hline
    \textbf{Animals} & \textbf{3\%} & \textbf{5\%} \\
    \hline
    \end{tabular}

enter image description here

  • That is the display that I want. – A gal named Desire Jan 15 at 22:55
  • Which one, out of curiosity? – Bernard Jan 15 at 22:56
  • 1
    Wait a moment, I'll post an example. – Bernard Jan 15 at 23:06
  • 1
    I've posted an example. Is it more or less like you want? – Bernard Jan 15 at 23:22
  • 1
    It is used to insert things between two rows, which do not have to be aligned within a column. – Bernard Jan 16 at 0:04

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.