2

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} 
cgnieder
  • 66,645
b degnan
  • 255
  • 3
    You can use \strip@pt only in a \makeatletter context. Can you show an example of what you're trying to do? – egreg Jun 17 '16 at 14:56
  • 2
    Related: http://tex.stackexchange.com/questions/8351/what-do-makeatletter-and-makeatother-do Even more related: http://tex.stackexchange.com/questions/109522/how-to-use-textwidth-or-any-variable-in-a-picture-environment/109526#109526 – yo' Jun 17 '16 at 14:56
  • @yo' I read those before I posted, but the \def\strippt{\strip@pt} still doesn't work because the \strip@pt is undefined for me. The crux is where/how \strip@pt is defined. – b degnan Jun 17 '16 at 15:06
  • 2
    @bdegnan You have to copy the line before and the line after as well (that's what egreg was explaining and what you'd find in the first link of me). If it still doesn't work, then we need a complete minimal example – yo' Jun 17 '16 at 15:09
  • and don't use \the\bitcolumnwidth it's \bitcolumnwidth – touhami Jun 17 '16 at 15:30
  • @yo' I created a minimum example and updated the question. I included a table just to check the values that were being passed. I test things by commenting out the \FPeval line and the last line of the table. – b degnan Jun 17 '16 at 16:48
  • @campa Got it. I didn't understand the makeatletter part until I read more on those. I had never heard of them before. Can someone formally answer this so I can accept it? – b degnan Jun 17 '16 at 16:55
  • @campa seemed to work on the shoulders of giants to provide the comment which helped in the end. Would that be the best person to answer? – cfr Jun 17 '16 at 23:01
  • 1
    @cfr yes, campa would be the best. In retrospect, egreg had the right idea but I was too ignorant of the whole thing until campa, so it should go to campa. – b degnan Jun 17 '16 at 23:23

1 Answers1

3

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

egreg
  • 1,121,712