[Tex/LaTex] \strip@pt\textwidth gives “undefined control sequence”

macros

I'm sure that this is something silly, but I've been beating my head against the statement \strip@pt\textwidth giving "undefined control sequence". I'm trying to modify some drawings in TikZ widths dynamically, and there's a lot of math involved due to the fact I need to support 3 page widths. It also gives me the opportunity to learn tikz and the fp package, but I need to strip the "pt" from the \textwidth statement.

I'm using this document definition: \documentclass[journal,letterpaper]{IEEEtran}

If \strip@pt is not defined, how do I define it?

edit

My minimal example:

\documentclass[journal,letterpaper]{IEEEtran}
\usepackage{fp}     

\begin{document}
\newcommand\bitfieldwidth{32}  
\newcommand\bitfielddivision{8}
\FPeval{\bitcolumnwidth}{(\strip@pt\textwidth) / \bitfieldwidth}
% the issue is here        ^^^^^^^^^
\begin{tabular}{|c|c|}
\hline
variable & value \\
\hline
textwidth &\the\textwidth \\
\hline
columnwidth &\the\columnwidth \\
\hline
bitcolumnwidth &$\bitcolumnwidth$ \\
\hline
\end{tabular}

\end{document} 

Best Answer

The macro \strip@pt has @ in its name, so it can only be used in a context where @ is a letter, see What do \makeatletter and \makeatother do?

\documentclass[journal,letterpaper]{IEEEtran}
\usepackage{fp}

\begin{document}

\newcommand\bitfieldwidth{32}
\newcommand\bitfielddivision{8}
\makeatletter
\FPeval{\bitcolumnwidth}{(\strip@pt\textwidth) / \bitfieldwidth}
\makeatother

\begin{tabular}{|c|c|}
\hline
variable & value \\
\hline
textwidth &\the\textwidth \\
\hline
columnwidth &\the\columnwidth \\
\hline
bitcolumnwidth &$\bitcolumnwidth$ \\
\hline
\end{tabular}

\end{document}

You can define a “user level” macro:

\documentclass[journal,letterpaper]{IEEEtran}
\usepackage{fp}

\makeatletter
\let\strippt\strip@pt
\makeatother

\begin{document}

\newcommand\bitfieldwidth{32}
\newcommand\bitfielddivision{8}
\FPeval{\bitcolumnwidth}{(\strippt\textwidth) / \bitfieldwidth}

\begin{tabular}{|c|c|}
\hline
variable & value \\
\hline
textwidth &\the\textwidth \\
\hline
columnwidth &\the\columnwidth \\
\hline
bitcolumnwidth &$\bitcolumnwidth$ \\
\hline
\end{tabular}

\end{document}

enter image description here

However, you don't need fp to do this, provided you just divide by an integer:

\edef\bitcolumnwidth{\the\dimexpr\textwidth/\bitfieldwidth\relax}

will define \bitcolumnwidth as something that can be used in the context of a dimension:

\documentclass[journal,letterpaper]{IEEEtran}

\begin{document}

\newcommand\bitfieldwidth{32}
\newcommand\bitfielddivision{8}
\edef\bitcolumnwidth{\the\dimexpr\textwidth/\bitfieldwidth\relax}

\begin{tabular}{|c|c|}
\hline
variable & value \\
\hline
textwidth &\the\textwidth \\
\hline
columnwidth &\the\columnwidth \\
\hline
bitcolumnwidth &\bitcolumnwidth \\
\hline
\end{tabular}

\end{document}

enter image description here