% tkz-tool-print.tex
% Copyright 2022 Alain Matthes
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
% This work has the LPPL maintenance status “maintained”.
% The Current Maintainer of this work is Alain Matthes.

\def\fileversion{4.2c}
\def\filedate{2022/07/14} 
\typeout{2022/07/14 4.2c  tkz-tools-print}  
\makeatletter
%<------------- tkzPrintFrac ---------------------------------->
\def\tkzPrintFrac#1#2{% 
\begingroup
\tkzReducFrac{#1}{#2}
\xdef\tkzprintfrac{$     \frac{\tkzMathFirstResult}{\tkzMathSecondResult}$}%
 \ifnum\tkzMathFirstResult=0%
    \xdef\tkzprintfrac{$0$}%
 \else
 \ifnum\tkzMathSecondResult=1 %
    \ifnum\tkzMathFirstResult=1 %
         \xdef\tkzprintfrac{$1$}%
      \else
       \ifnum\tkzMathFirstResult=-1%
          \xdef\tkzprintfrac{$-1$}%
        \else
          \xdef\tkzprintfrac{$\tkzMathFirstResult$}%
       \fi\fi
 \else 
   \ifnum\tkzMathFirstResult=1 %
          \xdef\tkzprintfrac{$\tkzmathstyle\frac{1}{\tkzMathSecondResult}$}%
     \else
       \ifnum\tkzMathFirstResult=-1 %
      \xdef\tkzprintfrac{$\tkzmathstyle\frac{-1}{\tkzMathSecondResult}$}%
        \else
     \xdef\tkzprintfrac{$\tkzmathstyle\frac{\tkzMathFirstResult}{%
                             \tkzMathSecondResult}$}%
 \fi\fi\fi\fi   
\endgroup}
%<------------- tkzPrintFracWithPi ---------------------------------->
\def\tkzPrintFracWithPi#1#2{%
\begingroup
\tkzReducFrac{#1}{#2}
\xdef\tkzprintfrac{%
           $\tkzmathstyle\frac{\tkzMathFirstResult\pi}{\tkzMathSecondResult}$}%
\ifnum\tkzMathFirstResult=0%
    \xdef\tkzprintfrac{$0$}%
\else
	\ifnum\tkzMathSecondResult=1 %
    	\ifnum\tkzMathFirstResult=1 %
        	\xdef\tkzprintfrac{$\pi$}%
      	\else
       		\ifnum\tkzMathFirstResult=-1%
          		\xdef\tkzprintfrac{$-\pi$}%
        	\else
          		\xdef\tkzprintfrac{$\tkzMathFirstResult\pi$}%
       		\fi
		\fi
	\else 
   		\ifnum\tkzMathFirstResult=1 %
    		\xdef\tkzprintfrac{%
								$\tkzmathstyle\frac{\pi}{\tkzMathSecondResult}$
									}%
     	\else
       		\ifnum\tkzMathFirstResult=-1 %
        		\xdef\tkzprintfrac{$\tkzmathstyle\frac{-\pi}{%
	        	 			\tkzMathSecondResult}$}%
        	\else
         		\xdef\tkzprintfrac{$\tkzmathstyle\frac{%
					  					   \tkzMathFirstResult\pi}{%
                             			   \tkzMathSecondResult}$
										   }%
     		\fi
	  	\fi
	\fi
\fi   
\endgroup
}%

\makeatother
\endinput