In LaTeX2e,how can I sum two values and assign them to other variable?

I want to compute something like:

```
var=\textwidth - 1cm
```

And if both were constants:

```
var=1+1
```

Skip to content
# [Tex/LaTex] How to sum two values and store the result in other variable

###### Related Question

calculationsdimension-expressions

In LaTeX2e,how can I sum two values and assign them to other variable?

I want to compute something like:

```
var=\textwidth - 1cm
```

And if both were constants:

```
var=1+1
```

## Best Answer

In regular LaTeX, the

`calc`

package allows for easy manipulation of length arithmetic:The above deals with lengths. For basic arithmetic using numbers, the

`fp`

package. Here is an example using infix notation (Reverse Polish Notation/RPN is also possible via`\FPupn`

):