12

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

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

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

Thank you in advance :)

17

If \lst@linebgrdsep is a register then:

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

Hint: Real numbers are also possible.

Otherwise:

\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
| improve this answer | |
7

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

\newdimen\lst@linebgrdsep
\lst@linebgrdsep.5\textwidth
\edef\x{\the\dimexpr\linewidth+\lst@linebgrdsep*2\relax}
\show\x
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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