LaTeX: separate columns in a table with a character instead of a line

Is it practically possible to use a character to separate the columns of a table instead of a vertical line?

Specifically consider a two column table, with col1 and col2. As long as col1 is a single line there is no problem. The problem occurs when col1 is a long line and word wraps into multiple lines (still one row, of course). The character ( a close parens, ) in this case) appears between the columns on the first displayed line as it should but not on the subsequent lines.

I need it to appear on all the displayed lines.

My suspicion is the normal vertical line is drawn graphically and is not a repeated character so the answer is no and the long line must be manually broken into multiple rows but it would certainly be useful if there were a reasonable way (without rewriting the system, of course) to have LaTeX do it automatically.

\documentclass{book}
\usepackage{array}

\begin{document}
\begin{tabular}{!{(}p{1cm}!{)}!{(}p{1cm}!{)}}
col1 & col2 \\
long text 1 & long text 2 \\
\end{tabular}
\end{document}


• Since your question is very interesting, I took the liberty to add a MWE, please rollback if you don't like it. – CarLaTeX May 26 '18 at 6:15
• it is rather hard to define what you mean by "line" here (and latex doesn't try) the table row is larger than the ) but that doesn's necessarily relate to lines of text in a p column, you would see the same if the cell had a large image, or \\[1cm] was used for the end of row, or the table was expanded with \arraystretch or \extrarowheight – David Carlisle May 26 '18 at 6:47
• Line refers to lines of display. For example assume a text line of 'one two three four' is word wrapped between the two and three, it would appear as two display lines although it is only one line. A text line of 'one two\\ three four' would also appear on two display lines but would in fact be two lines and would be treated as such. – mrbb May 26 '18 at 6:56
• To address another user you have to type @ followed by the nickname, in your case @DavidCarlisle. Otherwise he could not see your comment. – CarLaTeX May 26 '18 at 8:41
• It might be possible to do it with strechable math parentheses, so that the parentheses don't just span one row and are repeated, but span two or three rows in case a cell is broken over several rows. This way, the parentheses would also indicate the height of the cell. Not like I would be able to implement that, it's just an idea, but if someone with the skillz reads this, I guess: knock yourself out. – thymaro May 26 '18 at 10:37

I have some doubts regarding a pure latex solution. But with lualatex you could do this:

%needs lualatex
\documentclass{book}
\usepackage{array}

\begin{document}

\begin{tabular}{>{\localleftbox{%
\llap{\makebox[2\tabcolsep]{(}}%
\rlap{\hspace{1cm}\makebox[1\tabcolsep]{)}}}}p{1cm}
>{\localleftbox{%
\llap{\makebox[2\tabcolsep]{(}}%
\rlap{\hspace{1cm}\makebox[1\tabcolsep]{)}}}}p{1cm}
}
col1 & col2 \\
long text 1 & long text 2 \\
\end{tabular}

\end{document}


• Thank you for this. I can't evaluate at the moment because of problems with installation. I am reinstalling texlive and will check back when new installation is up and running correctly. – mrbb May 26 '18 at 17:57

This is the best I can do:

\documentclass{article}
\usepackage{array}
\usepackage{tikz}
\usetikzlibrary{matrix}
\tikzset{
mynode/.style={
left delimiter=(,
right delimiter=),
text width=1cm,
text height=1ex
}
}

\begin{document}
\begin{tikzpicture}
\matrix{
\node[mynode] {col 1};&
\node[mynode] {col 2};\\
\node[mynode] {long text 1};&
\node[mynode] {long text 2};\\
};
\end{tikzpicture}
\end{document}


But there is a better solution, see Kpym's answer here: Different behavior of matrix with node defined explicitly with delimeters versus matrix of nodes.