How to enable use of minus and plus in tex documents?
To perform simple arithmetic operations with lengths you can use the e-TeX primitive \dimexpr
:
\documentclass{article}
\newlength{\lengtha}
\setlength{\lengtha}{.5\textwidth}
\newlength{\lengthb}
\setlength{\lengthb}{.5\textwidth}
\begin{document}
\noindent\begin{tabular*}{\dimexpr\lengtha+\lengthb\relax}{cc}
\hline
a & b \\
\hline
\end{tabular*}
\end{document}
For further details, please refer to the e-TeX manual.
Something different is the use of plus
and minus
to specify glue in TeX:
<dimen>plus<dimen>minus<dimen>
where the plus<dimen>
and minus<dimen>
are optional and set to zero if not present; plus
introduces stretchability, minus
introduces shrinkability.
Use the calc package. Package description:
Adds infix expressions to perform arithmetic on the arguments of the LaTeX commands
\setcounter
,\addtocounter
,\setlength
, and\addtolength
.
\documentclass{article}
\usepackage{calc}
\newlength{\lengtha}
\setlength{\lengtha}{.5\textwidth}
\newlength{\lengthb}
\setlength{\lengthb}{.5\textwidth}
\begin{document}
\begin{tabular*}{\lengtha + \lengthb}{cc}
\hline
a & b \\
\hline
\end{tabular*}
\end{document}