TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

(This post bases on: lstaddons: Dynamic linewidth calculation)

Hey everyone, is there a way to do this with a multiplication instead of two additions?


Thank you in advance :)

share|improve this question
up vote 16 down vote accepted

If \lst@linebgrdsep is a register then:

\dimexpr\linewidth + 2\lst@linebgrdsep \relax

Hint: Real numbers are also possible.


\dimexpr\linewidth + (\lst@linebgrdsep)*2 \relax

Note, the first factor is the length value, the integer factors follows afterwards in the product. This is limited to integer numbers.

Real numbers can be supported by wrapping the macro \lst@linebgrdsep in \dimexpr.

\dimexpr\linewidth + 1.5\dimexpr\lst@linebgrdsep\relax \relax
share|improve this answer
thanks! the second one works fine for me ;) – tollo Sep 9 '12 at 15:42

I don't know the definition of \lst@linebgrdsep, so I define it here.

share|improve this answer
thanks also for the effort – tollo Sep 9 '12 at 15:44

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.