hi guys,
i need some little math operation in my tex code, i wana do some operation as follows:
\newcommand \NumAA{aa}
\newcommand \NumAA{ab}
\newcommand \NumAA{ba}
\newcommand \NumAA{bb}
%where aa,ab,ba,bb some numerical values
\newcommand \z {\NumAA + \NumAB}
\newcommand \n {\NumBA + \NumBB}
\newcommand \q{\z / \n}
The Problem is, that latex just replaces the macros and calculates instead of
(aa + ab) / (ba + bb) -> aa + ab / ba + bb
which is common knowledge not the same... is there a possibility to use some kind of "()" or is there some kind of float register available. Thanks for ur help..
Looking forward to hearing from you.. sry, my english is not very well...
General ⇒ problem division with macros
NEW: TikZ book now 40% off at Amazon.com for a short time.

problem division with macros
Just to complete gmedina's answer, I provide an example:
The fp package is divided into sub-packages. You only need one of them to get sums and divisions.
Code: Select all
\documentclass{article}
\usepackage{fp-basic}
\begin{document}
\newcommand{\MyOp}[4]{%
\FPadd\Numerator{#1}{#2}%
\FPadd\Denominator{#3}{#4}%
\FPdiv\Result\Numerator\Denominator}
\MyOp{1.2}{22.3}{45.2}{36.21}
\FPprint\Result
\FPset\NumAA{11.21} \FPset\NumAB{23.4}
\FPset\NumBA{2.45} \FPset\NumBB{3.43}
\MyOp{\NumAA}{\NumAB}{\NumBA}{\NumBB}
\FPprint\Result
\end{document}
The CTAN lion is an artwork by Duane Bibby. Courtesy of www.ctan.org.
-
- Posts: 2
- Joined: Sat Jan 16, 2010 5:49 pm
Re: problem division with macros
hi,
that is exactly what im looking for! Thank u guys!!
that is exactly what im looking for! Thank u guys!!