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}
Best Answer
This is very easy to get with
pst-node
(a member of thepstricks
family): put the table in apostscript
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: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: