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?

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

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

3
  • What is supposed to be wrong with using booktabs?
    – Gaussler
    Jul 23 at 14:21
  • booktabs says that it is incompatible with vertical lines and that they should never be used.
    – Teepeemm
    Jul 23 at 14:53
  • @Teepeemm Well, booktabs is right. Vertical lines are considered bad style nowadays.
    – Gaussler
    Jul 23 at 15:00

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.