I use the package called "lstaddons" (creator, initial question) to get colored line backgrounds on listings.
I want to color the whole line to the frame. What I miss there is a dynamic calculation of the linewidth.
You can adjust the linebackgroundsep, which moves the colorbox to the left. And through linebackgroundwidth you can set the width of the box.
My question is: Is there any opportunity to calculate the linewidth dynamic through a macro? I tried this one, but i think its a bit crappy...
\newdimen\lstwidth
\newdimen\lstxleftmargin
\lstxleftmargin = 15pt
\lstwidth = 0pt
\advance\lstwidth by \linewidth
\advance\lstwidth by -\lstxleftmargin % Minus xleftmargin
\advance\lstwidth by 1pt % Minus Rand rechts
and in the listing settings:
\lstset{
linebackgroundcolor={\ifodd\value{lstnumber}\color{codegray}\fi},
linebackgroundsep=3pt, % lstaddons: fills the line from the left frame
linebackgroundwidth={\lstwidth}, % lstaddons: ... to the right
frame=lr,
numbersep=10pt,
xleftmargin=\lstxleftmargin,
xrightmargin=5pt
}

linebackgroundwidth=\dimexpr\linewidth-15pt+1pt\relax. Not sure whether1ptis appropriate here, since frame borders are "usually".4pt. Without a proper MWE it's hard to tell. – Werner Sep 09 '12 at 14:06