# [Tex/LaTex] Table with multirow vertical arrow and text

arrowsmultirowtablestikz-arrows

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}