5

I would like to force the column width in a table to be zero even if there is text in the column.

I'm after something like this:

Zero width collumn

So I try the code

\begin{tabular}{|c|>{\centering}p{0.cm}|c|}
\hline  1 &  &  \tabularnewline
\hline   & 2 &  \tabularnewline
\hline   &  & 3 \tabularnewline
\hline  \end{tabular} 

which produces

non-zero width collumn

I can use the @{} trick from Removing or changing table border spacing to remove the padding before the 2, but that does not help me that much.

Any ideas?

I'm guessing it's possible to play the game using negative spaces, or maybe draw it with tikz... but it feels a bit cumbersome.

PS: In reality, I just want to be able to put symbols on the borders of the table, so if anyone knows how to do that instead, I'm equally happy.

8

You have to use a box of 0pt width for this cell with 2. Also, you need to add @{\hspace{-.5\arrayrulewidth}} and @{\hspace{-.5\arrayrulewidth}} around this column specification. The reason for the negative space is to shift the second pipe | to the position of the first one, so that they become a single pipe, and the text will be centered around the pipe.

\documentclass[12pt]{article}   
\usepackage{array} 
\begin{document}

\begin{tabular}{|c|@{\hspace{-.5\arrayrulewidth}}c@{\hspace{-.5\arrayrulewidth}}|c|}
\hline 1 &                  &   \tabularnewline
\hline   & \makebox[0pt]{2} &   \tabularnewline
\hline   &                  & 3 \tabularnewline
\hline  \end{tabular} 

\end{document}

enter image description here

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.