# Table with multirow vertical arrow and text

I would like to annotate a table with an arrow along the right side representing (in this case) decreasing operator precedence for a computer language. I am familiar with the other solution listed here, which involves placing the entire table in math mode, but I'd like to have a bit more control over the formatting of the text and arrow, as well as perhaps have a nice colored tikz arrow with the text inside of it.

My current example uses math mode inside of a /rotatebox, but the arrow is not column height, as I would like.

\documentclass[10pt]{article}
\usepackage[portrait, margin=0.25in]{geometry}
\usepackage{inconsolata}
\usepackage[T1]{fontenc}
\renewcommand*\familydefault{\ttdefault}
\usepackage[fleqn]{amsmath}
\usepackage{booktabs}
\usepackage{multirow}

\begin{document}
\begin{tabular}{@{}l|llllllll@{}}
Unary & +  & -  & \textasciicircum &&&&&\multirow{6}*{\rotatebox[origin=c]{270}{$\underrightarrow{precedence}$}}\\
Multiplication & * & / & \% & << & >> & \& & \&\textasciicircum&\\
Addition & + & - & | & \textasciicircum &&&&\\
Comparison & == & != & < & <= & > & >= &&\\
Logical & \&\& &&&&&&&\\
& ||   &&&&&&&
\end{tabular}
\end{document}


Currently looks like this:

Interested in something like this:

This is very easy to get with pst-node (a member of the pstricks family): put the table in a postscript environment, define empty nodes at the end of the first and last row, and connect them with an arrow. Furthermore the text over the arrow is noted in math mode, but as a real text:

\documentclass[10pt]{article}
\usepackage[portrait, margin=0.25in]{geometry}
\usepackage{inconsolata}
\usepackage[T1]{fontenc}
\renewcommand*\familydefault{\ttdefault}
\usepackage[fleqn]{amsmath}
\usepackage{booktabs}
\usepackage{multirow, rotating}
\usepackage{pst-node, auto-pst-pdf}

\begin{document}

\renewcommand\arraystretch{1.25}
\begin{postscript}
\begin{tabular}{@{}l|llllllll@{}}
Unary & + & - & \textasciicircum &&&&&\pnode{B}\\%
Multiplication & * & / & \% & << & >> & \& & \&\textasciicircum&\\
Addition & + & - & | & \textasciicircum &&&&\\
Comparison & == & != & < & <= & > & >= &&\\
Logical & \&\& &&&&&&&\\
& || &&&&&&&\pnode{E}
\end{tabular}
\psset{arrowinset=0.12, arrows=->, nrot=:U, shortput=nab, labelsep=2pt}
\ncline[linecolor=red, nodesepA=-10.5pt, nodesepB=-4.8pt]{B}{E}^{\colorbox{Pink3!60}{precedence}}
\ncline[offset=30pt, linecolor=blue ]{B}{E}\ncput*{\colorbox{LightSteelBlue1}{precedence}}
\end{postscript}

\end{document}


Added: This other code gives an automatic sizing of the arrow. it puts the tabular in a box node, to which are associated 12 secondary nodes,and two of the rightmost associated nodes are connected by an arrow:

\begin{postscript}
\psDefBoxNodes{T}{
\begin{tabular}{@{}l|llllllll@{}}
Unary & + & - & \textasciicircum &&&&& \\%
Multiplication & * & / & \% & << & >> & \& & \&\textasciicircum&\\
Addition & + & - & | & \textasciicircum &&&&\\
Comparison & == & != & < & <= & > & >= &&\\
Logical & \&\& &&&&&&&\\
& || &&&&&&&
\end{tabular}}
\psset{arrowinset=0.12, arrows=->, nrot=:U, labelsep=2pt}
\pcline[linecolor=red](T:tr)(T:br)
\naput[nrot=:U]{\colorbox{Pink3!30}{precedence}}%{T:Cr}
\end{postscript}


• Very nice! Still not quite as tall as the table, though. How can I get it to extend to as close to the length of the vertical divider as I can? Jan 26, 2016 at 2:09
• Yes, the nodes are set on the base line of the row. I'll update my answer in a moment. Jan 26, 2016 at 2:21
• Also, is there a way to specify the background color for \ncput* ? Currently it is white, and the full example is on a colored background. I understand that, from the way the additive rendering works, there's no such thing as a "transparent" background, so specifying the color directly seems as if it should suffice. Jan 26, 2016 at 2:25
• Aha, never mind on the background color. 'fillcolor=<color>' inside of \psset has done the trick nicely! Jan 26, 2016 at 2:35
• I've updated my answer. The adjustment of the arrows length has to be done by hand. Is that what you want? Jan 26, 2016 at 3:22