0

I use Excel2latex to generate tables, and for some reason I keep getting the wrong outside borders.

This is my code:

\begin{table}[htbp]
  \centering
  \caption{Add caption}
    \begin{tabular}{|rcc|r|r|r|}
    \toprule
          &       & \multicolumn{3}{l}{\textbf{Coal Resources Summary (Mt)}} &  \\
    \midrule
    \multicolumn{1}{|l|}{Seam} & \multicolumn{1}{c|}{Depth(m)} & \multicolumn{1}{l|}{Thickness (m)} & \multicolumn{1}{l|}{Measured} & \multicolumn{1}{c|}{Indicated} & \multicolumn{1}{l|}{Inferred} \\
    \midrule
    \multicolumn{1}{|l|}{No. 1} & \multicolumn{1}{r|}{} & \multicolumn{1}{r|}{4} & 14.5  & 0.7   & 7 \\
\cmidrule{1-1}\cmidrule{3-6}    \multicolumn{1}{|l|}{No. 2} & \multicolumn{1}{c|}{<400} & \multicolumn{1}{r|}{10} & 41    & 2.6   & 24 \\
\cmidrule{1-1}\cmidrule{3-6}    \multicolumn{1}{|l|}{No. 3} & \multicolumn{1}{r|}{} & \multicolumn{1}{r|}{8} & 32.8  & \multicolumn{1}{c|}{-} & 21 \\
    \midrule
          & Total &       & 88.3  & 3.3   & 52 \\
    \midrule
          & \multicolumn{2}{c|}{\textbf{Total (rounded)}} & \textbf{90} & \textbf{3} & \textbf{50} \\
    \bottomrule
    \end{tabular}%
  \label{tab:crs}%
\end{table}%

enter image description here

Any help?

Juan Castaño
  • 28,426

2 Answers2

3

The booktabs package is explicitly incompatible with vertical lines. I like booktabs, so here is how I would do it with that package:

  1. Remove the vertical lines.
  2. Move the "Coal Resources Summary" to the caption.
  3. Move the "Depth" column to the caption (if you wanted to keep it, using a multirow would be a much better way than all those multicolumns).
  4. The units Mt only apply to three of the columns, not all of them.
  5. Remove the midrules between the seems.
  6. I'm not sure what "- Mt" means. I feel like "?" is a better way to indicate "unknown". Or do you mean "0"?
  7. \usepackage{siunitx} allows you to align your numbers on the decimal point. The only downside is text entries need to be surrounded by {}. (You also can't have bold entries unless you follow https://tex.stackexchange.com/a/66256/107497, but I feel like the last line of a table doesn't need to be bold.)
  8. Consider removing the rounded row. It adds a lot of clutter for not much more information.
\documentclass{article}
\usepackage{booktabs}
\usepackage{siunitx}
\begin{document}
\begin{table}[htbp]
  \centering
  \caption{Coal Resources Summary for depths greater than 400m}
    \begin{tabular}{c S[table-format=2.0] S[table-format=2.1] S[table-format=1.1] S[table-format=2.0]}
    \toprule
    Seam \# & {Thickness (m)} & {Measured (Mt)} & {Indicated (Mt)} & {Inferred (Mt)} \\
    \midrule
    1 & 4 & 14.5  & 0.7   & 7 \\
    2 & 10 & 41    & 2.6   & 24 \\
    3 & 8 & 32.8  & ? & 21 \\
    \midrule
    \multicolumn{2}{c}{Total} & 88.3  & 3.3   & 52 \\
    \midrule
    \multicolumn{2}{c}{Total (rounded)} & 90 & 3 & 50 \\
    \bottomrule
    \end{tabular}%
  \label{tab:crs}%
\end{table}%[![enter image description here][1]][1]
\end{document}

output

Teepeemm
  • 6,708
2

do not use booktabs

\begin{table}[htbp]
  \centering
  \caption{Add caption}
    \begin{tabular}{|rcc|r|r|r|}
    \hline
          &       & \multicolumn{3}{l}{\textbf{Coal Resources Summary (Mt)}} &  \\
    \hline
    \multicolumn{1}{|l|}{Seam} & \multicolumn{1}{c|}{Depth(m)} & \multicolumn{1}{l|}{Thickness (m)} & \multicolumn{1}{l|}{Measured} & \multicolumn{1}{c|}{Indicated} & \multicolumn{1}{l|}{Inferred} \\
    \hline
    \multicolumn{1}{|l|}{No. 1} & \multicolumn{1}{r|}{} & \multicolumn{1}{r|}{4} & 14.5  & 0.7   & 7 \\
\cline{1-1}\cline{3-6}    \multicolumn{1}{|l|}{No. 2} & \multicolumn{1}{c|}{<400} & \multicolumn{1}{r|}{10} & 41    & 2.6   & 24 \\
\cline{1-1}\cline{3-6}    \multicolumn{1}{|l|}{No. 3} & \multicolumn{1}{r|}{} & \multicolumn{1}{r|}{8} & 32.8  & \multicolumn{1}{c|}{-} & 21 \\
    \hline
          & Total &       & 88.3  & 3.3   & 52 \\
    \hline
          & \multicolumn{2}{c|}{\textbf{Total (rounded)}} & \textbf{90} & \textbf{3} & \textbf{50} \\
    \hline
    \end{tabular}%
  \label{tab:crs}%
\end{table}%

tableau

leandriis
  • 62,593
gigiair
  • 1,812