[texhax] remove `pt' from end of string

Alexander Grahn A.Grahn at fz-rossendorf.de
Wed Oct 5 13:16:11 CEST 2005


Dear TeX-Friends,

I'm trying to write a macro that removes the `pt' unit from a string.
While the macro \removept works on a hardcoded string, case (1)
of attached example, it fails on a string which itself is a macro,
although it is an \edef'ed one, case (2).

Would you please help me to adjust the macro so that it works in case
(2) as well?

Thanks,
Alexander

\documentclass{article}

\def\removept#1pt{%
  #1%
}

\def\bufa{ 1.31415pt}

\newdimen\mylength
\mylength=1.31415pt
\edef\bufb{ \the\mylength}
  
\begin{document}
  (1) works:\expandafter\removept\bufa
  
  \typeout{bufb: \bufb} %indeed, it's 1.31415pt

  (2) doesn't:\expandafter\removept\bufb
\end{document}



More information about the texhax mailing list