Tag Info

New answers tagged

6

You can use the Mod(<num>,<base>) function to get the modulus, but I didn't understand if you want it in the for each loop or not so here is for the loop \documentclass{article} \usepackage{tikz} \begin{document} \begin{tikzpicture} \coordinate (Origin) at (0,0); \coordinate (XAxisMin) at (0,0); \coordinate (XAxisMax) at (11,0); ...


1

I didn't quite get what your intention is but here is a quick example for coming up with PGF solutions. \documentclass[]{article} \usepackage{pgf} \usepgflibrary{fpu} \pgfmathdeclarefunction{m2in}{1}{% \begingroup \pgfkeys{/pgf/fpu} \pgfmathfloatparsenumber{#1} \pgfmathfloatifflags{\pgfmathresult}{3}{%True Not a number \def\pgfmathresult{3Y0.0e0]}% ...


5

You can also use \IfDecimal from the xstring package: Code: \documentclass{article} \usepackage{xstring} \newcommand*{\CheckIfNumerical}[1]{% \IfDecimal{#1}{% ``#1" is a number.% }{% ``#1" is NOT a number.% }% }% \begin{document} \par\CheckIfNumerical{7} \par\CheckIfNumerical{3.14} \par\CheckIfNumerical{NaN} ...


3

datatool provides conditionals for testing whether an argument is numerical or not: \documentclass{article} \usepackage{datatool}% http://ctan.org/pkg/datatool \newcommand{\testreal}[1]{\ifthenelse{\DTLisnumerical{#1}}{T}{F}} \begin{document} \testreal{just} \testreal{123John} \testreal{324.56} \testreal{.} \testreal{23.4.56} \testreal{346} ...


2

UPDATED to handle negatives. A call to \testreal sets up a recursive loop that checks every byte in the string. First, it strips off a leading negative, if it exists, since that will not affect if the remainder of the string is or is not a valid real number. With what remains, here is how it proceeds. It notes that no digit nor decimal point has yet ...


6

unbounded coords key works only you get a precise inf as a coordinate. However if the coordinate gets too big but not inf it tries to process that number and you get this error. In order to avoid such problems use restrict <x,y> to domain key \documentclass{article} \usepackage{pgfplots} \pgfplotsset{compat=1.10} \begin{document} ...


6

I don't know with pgfmath; with expl3 you can compile your table like this: \documentclass{article} \usepackage[margin=1cm]{geometry} \usepackage{array,siunitx} \sisetup{ add-decimal-zero, round-precision=5, round-mode=places, round-integer-to-decimal, group-digits=false, detect-all, } \usepackage{xparse} \ExplSyntaxOn ...


2

With the standard TeX arithmetic, precision is very limited.If you need more accurate results, you may need to use some external program or any extension of TeX, such as luatex. Using my package calculator I get results similar to what you get with Tikz: \documentclass{article} \usepackage{calculator} \usepackage{ifthen} \begin{document} ...


3

Extend your options with fixed zerofill. \documentclass{article} \pagestyle{empty} \usepackage{tikz} \usetikzlibrary{calc,fixedpointarithmetic} \def\mynum{0} \def\myvoffset{0pt} \usepackage[margin=0.5in]{geometry} \begin{document} %Using \texttt{TikZ} \begin{tikzpicture}[/pgf/number format/.cd,fixed,precision=4,verbatim, fixed zerofill] \coordinate(UL) ...



Top 50 recent answers are included