2

I needed to add some symbols in between two columns in tabular. The figure below is the output needed. I do not know how to achieve this.

Output image

Googling gave me this question where the OP wanted something similar. However, the solution there was too narrow for my use as I wanted to automate this in some rows and not in all. Is there some other way of doing this?

L__
  • 209

2 Answers2

3

With no extra columns and preserving the original spacings:

\documentclass{article}
\usepackage{array}

\begin{document}

\noindent\begin{tabular}{|ccc|cc|}
\hline
\multicolumn{1}{|c@{\hspace*{\tabcolsep}\makebox[0pt]{-}}}{a}
  & b & c & d & e \\
\hline
a & \multicolumn{1}{c@{\hspace*{\tabcolsep}\makebox[0pt]{-}}}{b}
 & c & d & e \\
\hline
\end{tabular}

\noindent\begin{tabular}{|ccc|cc|}
\hline
a & b & c & d & e \\
\hline
a & b & c & d & e \\
\hline
\end{tabular}

\end{document}

enter image description here

The idea is to se \multicolumn and the @{...} syntax to insert the symbol using a box of zero width.

Gonzalo Medina
  • 505,128
2

This solution incorporates Steven's suggestion, and refines the spacing by adding extra columns:

\documentclass[a4paper]{article}

\begin{document}

\setlength{\tabcolsep}{2pt}

\begin{table}[h]
\begin{tabular}{|ccccccc|ccccc|}
\hline
 & a & - & b &   & c & & & d & & e &\\
\hline
 & p &   & q & - & r & & & s & & t &\\
\hline
\end{tabular}
\end{table}

\end{document}

enter image description here

commonhare
  • 2,630