Graphics, Figures & TablesRemoving superfluous vertical Table Rules

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
zdegraf
Posts: 1
Joined: Tue Jul 30, 2013 2:42 pm

Removing superfluous vertical Table Rules

Post by zdegraf »

Is there a way to get rid of the vertical rule in the upper left hand corner in this table?

Code: Select all

\begin{table}
  \caption{Fancy table.} 
  \label{tab:ListeningDist}
  \centering
  \begin{tabular}{|l|c|c||c|c|}  \cline{2-3} \cline{4-5}
    & \multicolumn{2}{ c|| }{x} & \multicolumn{2}{ |c| }{y} \\ \hline
    A  & 1 & 4 & 7 & 10 \\  
    B  & 2 & 5 & 8 & 11 \\  
    C  & 3 & 6 & 9 & 12 \\ \hline
 \end{tabular}
\end{table}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Removing superfluous vertical Table Rules

Post by Johannes_B »

Not exactly the answer to your question, but: Lines, especially vertical ones, should be avoided in tabular material.

Here is an approach using the booktabs package. Have a look at it and give it a try. Tabular material looks much cleaner this way.

You can directly click on "OPEN IN WRITELATEX" below to see the output.

Code: Select all

\documentclass[a4paper]{article}
\usepackage{booktabs}

\begin{document}
  \begin{table}
    \caption{Fancy table.}
    \label{tab:ListeningDist}
    \centering
    \begin{tabular}{lcccc} \toprule
      & \multicolumn{2}{c}{x} & \multicolumn{2}{c}{y} \\ \cmidrule(rl){2-3} \cmidrule(rl){4-5}
      A & 1 & 4 & 7 & 10 \\
      B & 2 & 5 & 8 & 11 \\
      C & 3 & 6 & 9 & 12 \\ \bottomrule
    \end{tabular}
  \end{table}

  Your original table with the solution, but as I said, I do not recommend this layout.

  \begin{table}
    \caption{Fancy table.}
    \label{tab:ListeningDist}
    \centering
    \begin{tabular}{l|c|c||c|c|} \cline{2-3} \cline{4-5}
      & \multicolumn{2}{ c|| }{x} & \multicolumn{2}{ |c| }{y} \\ \hline
      \multicolumn{1}{|c|}{A} & 1 & 4 & 7 & 10 \\
      \multicolumn{1}{|c|}{B} & 2 & 5 & 8 & 11 \\
      \multicolumn{1}{|c|}{C} & 3 & 6 & 9 & 12 \\ \hline
    \end{tabular}
  \end{table}
\end{document}
Please also read about Minimal Working Examples. It is much easier this way to test a solution.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Post Reply