[Tex/LaTex] Setting \textwidth seems to break textblock* command from textpos package

marginspositioningtextpos

I would like to position text absolutely using the textblock* command from the textpos package. Minimal working example:

\documentclass{article}
\usepackage[absolute]{textpos}
% \renewcommand{\textwidth}{17cm} % (*)
\begin{document}
  \begin{textblock*}{3cm}(1cm,0.98\paperheight)
    XXXXXXXXXXXXXXX
  \end{textblock*}
\end{document}

This breaks as soon as I redefine the textwidth as done by the line marked (*) above. Why is this and, more importantly, how can I fix this? ("It breaks" here means I get "! Missing number, treated as zero. ! Illegal unit of measure (pt inserted)." in the line with the text (placeholder "X…X" above).)

Bonus question: How can I specify something like \paperheight - 1cm?

Best Answer

You have to use \setlength instead of \renewcommand and also \dimexpr\paperheight-1cm\relax for the second question :

\documentclass{article}
\usepackage[absolute]{textpos}
\setlength{\textwidth}{17cm} % (*)
\begin{document}
  \begin{textblock*}{3cm}(1cm,\dimexpr\paperheight-1cm\relax)
    XXXXXXXXXXXXXXX
  \end{textblock*}
\end{document}

enter image description here

Related Question