How can i multiple variable by decimal number? I have this code:

   \tempArgument = #1
   \multiply\tempArgument by 0.75
   \defcolor\tmp\mainColor{\tempArgument} \tmp

I want to have in \tempArgument first argument multiplied by some constant. I want to use only plain TeX, not LaTeX.

  • 2
    do you want \tempArgument to be a count register (so will have to round to nearest integer to multiply by .75) or do you want the answer in a macro (which can hold the decimal digits). Why plain rather than latex, most people use a rather more complete format for documents than plain. latex or context or something. – David Carlisle Feb 27 '15 at 20:45
  • I want to have in \tempArgument numbers like 1.5, 1.2 and so on. There will no be number larger then 5, most of time there will be from interval 0-2. Latex is too complicated if you have specific needs and do not want to read documentation with hundred of pages. I want to have everything under my control and well explained. – OrdinaryNick Feb 27 '15 at 20:50
  • What does \defcolor do? – egreg Feb 27 '15 at 21:07
  • 2
    @Novros How does it operate? TeX has no floating point registers, they can only be emulated, to a certain extent, with \dimen registers. However, the fp package can work also with Plain TeX, IIRC. – egreg Feb 27 '15 at 21:23
  • 1
    @Novros so \tempArgumnent can not be defined by \newcount if you want it to have values like 1.5. "under your control and well explained" comes to "not existing and having to do it all your self". color mixing and integrating colour into tex's box mode is available in well tested macro sets for any format this is intended to be used for document production rather than educational examples. – David Carlisle Feb 27 '15 at 21:32

This shows the calculation 5 * .75

> \tempArgument=macro:
\headerColor ...the \dimen 0 }\show \tempArgument 

l.15 \headerColor{5}



   \dimen0 = #1pt
   \edef\tempArgument{\expandafter\strippt\the\dimen0 }%



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.