# Show variable name, measurement unit and value in a single command invocation

I am using the fp package to write a coursework in mechanics and calculate the numerical values on the fly. Here is some example code:

\documentclass{article}
\usepackage[nomessages]{fp}  % http://ctan.org/pkg/fp
\begin{document}

\section{Requirements}
\FPset{P_output_kW}{11}
\FPset{n_output_max_rpm}{5000}

P_output_kW = \FPprint{P_output_kW} kW
n_output_max_rpm = \FPprint{n_output_max_rpm} rpm
\end{document}


As is evident, I am attempting to print every assigned variable by name, value and measurement unit. First of all, the above code does not compile with the error:


\begin{document}
\FPset{power}{5}
\FPunit{power}{\si{\kilo\watt}}% predefined from sciunitx
\FPprint{power}

\FPset{time}{2}
\FPunit{time}{\si{\hour}}
\FPprint{time}\par

\FPmacro{power}{\x}
\FPmacro{time}{\t}
\pgfmathparse{\x*\t}
\FPset{energy}{\pgfmathresult}
\FPunit{energy}{\si{\kilo\watt\hour}}
\FPprint{energy}
\end{document}


• Hey, it appears both answers work fine, I just picked the first one. Thanks for the work and for letting me know about sciunitx`. +1 – Vorac Sep 25 '15 at 10:45