# Tag Info

4

You have to use the fpu library, if you plan to do “exact” computations. Otherwise PGF uses TeX's arithmetic which is not accurate enough. \documentclass[a4paper,11pt]{scrartcl} \usepackage{array} \usepackage{pgf} \usepgflibrary{fpu} \pgfkeys{pgf/fpu} \begin{document} \begin{tabular}{*{4}{r@{\enspace}>{$}l<{$}}} a) & ...

2

Following Christian's comment, I wrote the following code: \documentclass{article} \usepackage{pgfplotstable} \begin{document} \newcommand{\filtercode}{% \pgfmathparse{int(less(\cellvalue, 0.01))}% \ifnum\pgfmathresult=1 % \edef\cellvalue{x}% \else \pgfmathparse{int(less(\cellvalue, .1))}% ...

9

I'm not sure that the algorithm in the question is correct, nevertheless it is certainly implemented in a sub-optimal manner. Although Jake's (now deleted) answer is readable it also has a huge overhead in calling the parser inside a function. It is quite simple to use the lower level pgfmath macros (although I probably would be expected to say that). ...

10

In general it might be hard but here you are only using pgfmath for an inequality test which is a sledgehammer you can avoid: \documentclass{article} \usepackage{pgfplotstable} \begin{document} \pgfplotstableset{symbol column/.style={column type=c, postproc cell content/.style={ /pgfplots/table/@cell content={}{% \ifdim##1pt <0.01pt ...

1

Here's a workaround using the fact that \sqrt[3]{x} is the inverse function to x^3: A little dirty but works like a charm. Note the domain is actually the range because I've switched the x and y values. \begin{tikzpicture}[xscale=.2,yscale=.5] \draw[xstep=1, ystep=1, gray, very thin, dotted] (-30,-4) grid (30,4); \draw[<->] (0,-4) -- (0,4) ...

16

After getting these two answers I'd like to publish my solution also. After seeing jfbu's answer I was a bit intimidated and I went the luatex way. The code is probably not efficient, but it can produce an animated PDF – unfortunately this feature only works in Adobe Reader – or pages with the different evolution phases. Also this code only works with n×n ...

19

Just for fun (but perhaps it can be useful to anyone), there is my Lua solution: Main TeX file \documentclass{article} \usepackage{pgffor} \usepackage{xcolor} \usepackage{courier} % Courier has bold series, while cm doesnt \usepackage[active,tightpage]{preview}\PreviewEnvironment{tabular} % Load lua program, and define macros for accessing its functions ...

26

I ran your code but it appeared to be very slow, I suspect from all the \pgfmathtruncatemacro. But here we can do all calculations with \numexpr easily. This code is based on the TeX primitives \ifnum, \ifcase and \csname..\endcsname. I have used \foreach loops in the first two code samples as I wanted to stay close to your original framework. In the third ...

10

If you use pdflatex or LuaLaTeX, then \documentclass{article} \usepackage{pgf} \pgfmathsetseed{\number\pdfrandomseed} \begin{document} \pgfmathsetmacro{\test}{rand}\test \end{document} will pick a random seed each time. With XeLaTeX there's nothing similar. The value of \pdfrandomseed doesn't change during a run, though.

Top 50 recent answers are included