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?

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.

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

  • Adding \setlength{\tabcolsep}{2pt} before your tabular will allow you to change the intercolumn spacing, you might mention. – Steven B. Segletes Mar 17 '14 at 19:34
  • And I think you need an \hline between your two rows. – Steven B. Segletes Mar 17 '14 at 19:35
  • Thanks Steven. I was about to delete my answer in favour of yours. Very gracious of you. Gonzalo's is elegant. – commonhare Mar 17 '14 at 19:47

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.