# Tag Info

5

Thanks to Manuel's comment, mtpro2 apparently also defines \SQRT. Then calculator overwrites that definition since it is loaded later. Hence, when you try to use \SQRT, it is calculator's definition which is active. So, the error you get is the same as that with the following code: \documentclass{article} \usepackage{calculator} \begin{document} \$ ...

7

Another comparison, with pstricks, and its module pst-eucl: Euler's nine-point circle (adapted from pst-eucl documentation): \documentclass[12pt, pdf, x11names]{article}% \usepackage{pstricks-add} \usepackage{pst-eucl} \usepackage{auto-pst-pdf} \begin{document} \psset{unit=2,dotsize = 2pt} \begin{pspicture}(-3,-1.5)(3,2.5) ...

16

This is, indeed, due to some inaccuracies in PGF, and can actually been seen in the manual in the section on coordinate calculations. More specifically it appears to be down to the the \pgfpointnormalised command which has been around for years (i.e., prior to the math engine) but has never been updated. Armed with an alternative definition, the altitudes ...

8

For comparison, here's one way to construct and draw altitudes in Metapost; the orthocenter looks correct even when zoomed in. prologues := 3; outputtemplate := "%j%c.eps"; beginfig(1); u = 2cm; z1 = origin; z2 = (1u,2.5u); z3 = (4u,0); z4 = whatever[z2,z3]; z4-z1 = whatever * (z3-z2) rotated 90; z5 = whatever[z3,z1]; z5-z2 = whatever * (z1-z3) ...

1

As suggested by @cfr in the comment you can use tikzmath to achieve this: \documentclass[preview, border=7mm]{standalone} \usepackage{tikz} \usetikzlibrary{math} \begin{document} \newlength{\SmallLength} \setlength{\SmallLength}{1.2 pt} \tikzmath{ if 4.5/2.3 < \SmallLength then { {divided smaller}; } else { {divided higher or equal}; }; ...

2

The problem is that \total{cost} does not mean anything to the \taxes and \addtaxes commands, which is why they give the error. If, instead, you use \taxes{\arabic{cost}} then everything is fine. That is, if you pass them numbers, rather than a macro, it works -- although the formatting is not quite as you would like it. Having said this, your class file ...

4

Apparently, listing options is evaluated before before=\getnumlen{#1} is used and numlen set. This means that numlen is 0pt --> the \getnumlen{#1} must be called in this special option block (too). A dirty trial --> Use \getnumlen{#1} in basicstyle option --> it's an effective code macro and no typesetting/font macro, so it should not harm there. ...

17

An expl3 implementation: \nonstopmode \input expl3-generic \relax \ExplSyntaxOn % -*- expl3 -*- \cs_new:Nn \svend_gcd:nn { \int_compare:nNnTF {#2} = { 0 } {#1} { \svend_gcd:ff {#2} { \int_mod:nn {#1} {#2} } } } \cs_generate_variant:Nn \svend_gcd:nn { ff } \int_new:N \l__svend_tmp_int \cs_new:Nn \svend_reduced:nn { \int_set:Nn ...

9

Here is a solution using R for the computations and the R-package knitr to link back to the LaTeX file. \documentclass{article} \begin{document} Using R with the package 'knitr' to reduce the fraction and then get both the reduced fraction but also the components of the fraction. Note: This is a quick demo of linking R and LaTeX using the 'knitr' ...

22

An option using Lua+LaTeX. Made small improvement. Made a Lua function to be called as a LaTeX command, with the numerator and denominator passed as arguments, instead of hardcoding the values in as before. The command is \simplify{a}{b}: \documentclass{article} \usepackage{luacode} \usepackage{amsmath} %------------------------ \begin{luacode} ...

24

Here is a flat latex2e implementation. \documentclass{article} \usepackage{amsmath} \newcount{\numerator} \newcount{\denominator} \newcount{\gcd} % compute \gcd and returns reduced \numerator and \denominator \newcommand{\reduce}[2]% #1=numerator, #2=denominator {\numerator=#1\relax \denominator=#2\relax \loop \ifnum\numerator<\denominator ...

22

If you are not bound to expl3 (in which case you “just” need to implement the algorithm): \documentclass{scrartcl} \usepackage{xintgcd,xintfrac} \newcommand*\reducedfrac[2] {\begingroup \edef\gcd{\xintGCD{#1}{#2}}% \frac{\xintNum{\xintDiv{#1}{\gcd}}}{\xintNum{\xintDiv{#2}{\gcd}}}% \endgroup} \begin{document} \[ \frac{278922}{74088} = ...

Top 50 recent answers are included