I'm using listings package (http://ctan.org/pkg/listings) to show pseudocode, and want to add comments to the right side of my listing, where there's a lot of white space now.
I need to use flexible column width (it seems to work better). I set language=TeX. I need comments left-justified, but the whole block of comments to be on the right side (so the box enclosing all comments should be right-justified).
If I make columns fixed, I can usually align comments with spaces, but fixed doesn't look good and I figured there must be less hacky solution to this.
Here's what my listing looks like now:
Code: Select all
Code, edit and compile here:
\lstset{language=TeX,emph={foreach},emphstyle=\emph,morecomment=[l][\tiny]{//},commentstyle=\itshape,columns=flexible}\begin{lstlisting}[float,caption={Basic SAT Algorithm.},label=Migdalskiy-BruteForceSATMTD, numbers=right, stepnumber=1,mathescape=true,columns=flexible,lineskip=2pt,basicstyle=\small,keywords={for,each,do,and,or,if,then,return,procedure,function}]$(\vec s_{min},d_{min}) \leftarrow (\vec 0, -\infty)$for each $face_A \in F(A)$ docheckDirection( $-\vec n( face_A )$ )for each $face_B \in F(B)$ docheckDirection( $\vec n( face_B )$ )... blah , blah , blah ...function support($Shape$, $\vec s$)return $min\{\vec s \cdot \vec v : \forall \vec v \in V(Shape)\}$\end{lstlisting}