52
votes
11answers
2k views

How can I define a mathematical function as a LaTeX macro?

I am attempting to create a usable function within LaTeX such that its inputs are transformed mathematically. However, I cannot find any documentation that can perform such mathematical function ...
6
votes
4answers
239 views

Is there a better way to check divisibility in LaTeX?

I want to draw a trimmed ruler, for example, from 2.3cm to 3.9cm where the distance between two consecutive marks is 1mm. I have difficulty to efficiently check whether or not the counter is a ...
7
votes
2answers
105 views

Numerical calculations using PSTricks

Assume I have defined a constant \valueA as \def\valueA{25 2 sqrt sqrt mul } I would like to devide this value by the square root of 2, so I tried \pstFPdiv\valueB{\valueA}{2 sqrt} but this is ...
2
votes
1answer
181 views

Calculating coordinates with postscript [duplicate]

I want to calculate coordinates for some lines using pstricks. How can I do this? Example: I want something like (0.5*cos(45) + 8, 0.5*sin(45) + 8) and use coordinate pairs like this one to ...
2
votes
4answers
662 views

Is there a simpler way to do arithmetic in PSTricks?

I want to animate PSTricks diagram, so looping is intensively used. I have 3 global variables \START, \STOP, \DELTA that should be declared in the preamble. The remaining variables in the body will ...
3
votes
4answers
271 views

What is the TeX equivalent for the following C# nested loop?

I need a nested loop to animate PSTricks diagrams. In C# or C or C++, I usually write as follows. int N=6; for(int x=0; x<N; x++) for(int y=x+1; y<N; y++) Console.WriteLine("({0}, ...
6
votes
1answer
529 views

How to divide a length-valued macro by a dimensionless-valued macro?

I have attempted to do as follows, but it does not work. \documentclass{minimal} \usepackage{pstricks-add} \psset { xunit=\dimexpr1cm/\psPi\relax, yunit=1cm } \begin{document} ...
2
votes
1answer
398 views

How to improve accuracy when working with PSTricks?

I have tried this with TikZ that produces the same issue, you can try Leo's solution here. In other words, this issue is NOT specific to PSTricks. The hidden idea is to avoid cropping with pdfcrop ...