{calculations} is about calculations in (La)TeX documents. A popular package is calc although may other also exist (fp, pgf, and LaTeX3 packages).

learn more… | top users | synonyms

30
votes
7answers
4k views

How to use \pageref{foo} as a number?

What I want to do is to show a "progress bar" in the header to show how far you are in the document, by making a rule with width pagenumber divided by total pages times the paper width. This is what ...
3
votes
1answer
52 views

Parse numerical value from glossaries variable

Can I parse the text returned from \gls*{...} and get latex to recognize it as a numerical variable so that I can use it in a calculation? This calculation could be done using calculator, fp, calc or ...
2
votes
1answer
57 views

Tikz 3d trimetric view coordinate calculation bug

I'm trying to draw a line in the x-y-plane and circles in the y-z-plane at constant x position. Problem is, that the circle is far out of position (x-coordinate of center point of the circle is ...
1
vote
1answer
28 views

How to print a past value of a counter [duplicate]

I have this counter which I have defined using \newcounter{myCounter}. Printing the value of myCounter can be easily done via \arabic{myCounter}. How can I print the value of (myCounter - 2)?
5
votes
1answer
101 views

Does anyone have an explanation of the algorithm for calculating weeknumber by Taco Hoekwater?

Taco Hoekwater wrote an algorithm in 2006 calculating the weeknumber. The algorithm mostly computes the weeknumber correctly, but apparantly misses out for the first 4 days of 2015. Without an ...
4
votes
1answer
63 views

Is it possible to use the width of one TikZ node to calculate the width of another?

Question Is it possible to store the variable width of a node and use that width to calculate the text width of another node in TikZ? Example I have a list of similar nodes side-by-side (inline, ...
8
votes
4answers
760 views

ConTeXt / e-TeX Real Numbers?

I've been using LaTeX for about 6 years and the calc package for a long time. Therefore, not being able to use real / floating point numbers was never really a problem. I've been pouring over the ...
8
votes
3answers
509 views

What is the best way to do math inside LaTeX macros?

I'm interested in writing a little personal package (or sharing it if it's actually useful) to speed up typesetting Trigonometry. I'd like commands like ...
4
votes
1answer
74 views

How can I calculate the distance added between a title and a titlerule?

Question How can I calculate the distance after a title such that I can place a node where the title rule would go? Example I would like a bar to drop from the top righthand corner of the page down ...
8
votes
3answers
3k views

Multiply the value by decimal number in latex?

I used the following construct quite often: \includegraphics[width=\textwidth/2]{pic.png} But when I try to adjust the size a small bit, like this: \includegraphics[width=\textwidth*0.45]{pic.png} ...
4
votes
3answers
302 views

How to round number to two digits after the decimal place and have a comma separator?

I have the following function: % Formats inputed number with 2 digits after the decimal place \newcommand*{\formatNumber}[1]{\FPround{\cost}{#1}{2}\cost} % \cost goes through some calculations ...
5
votes
1answer
1k views

Insert relative date and time specifications?

How can I specify a relative date and let LaTeX insert the resulting absolute one? For example like this: \somedatecommand{next thursday} Which should result in: Thursday, 20.10.2011 Or: ...
10
votes
2answers
5k views

simple arithmetic on index of foreach statement in tikz

Is foreach really a tikz statement or is derived from some other package? I would like to draw a horizontal axis with 7 ticks spaced 1 cm apart. I'd like to place a label under each tick that is the ...
0
votes
0answers
49 views

Perpendicular line to a line on a 3D plane

\documentclass{standalone} \usepackage{pgfplots} \usetikzlibrary{calc} \pgfplotsset{compat=1.10} \begin{document} \begin{tikzpicture} \begin{axis}[ view={125}{35}, axis lines=center, ...
3
votes
2answers
174 views

TikZ decorated paths and fixedpointarithmetic library

Background: I am trying to apply multiple decorations to a path in a TikZ picture. In this particular case, my attempts fail as the maximum dimension PGF can calculate with is exceeded. This is not ...
18
votes
9answers
2k views

fibonacci numbers

Hi I am trying to do Fibonacci below is the code but I am getting some error \newcount\n \newcount\np \newcount\npp \newcount\m \newcount\f \def\fibonacci#1{{\ifnum #1<3 1\else \np=1\npp=1\m=3 ...
2
votes
1answer
113 views

How to solve the Arithmetic overflow problem?

I was making an article and everything was going alright, when suddenly I got an error: The error: Arithmetic overflow. \calc@Acount l.78 ...qwe dqweqwrwf qewrfrQ aRF EFCas drfFR}{62} My article ...
4
votes
1answer
219 views

How to divide two lengths and get a result as an integer?

I have a problem dividing two lenghts and getting a result as an integer. I was trying to use this package: \usepackage[nomessages]{fp} It didn't really work for me. I tried it multiple ways, but it ...
21
votes
2answers
488 views

Sum of finite series using LaTeX 3

Is it possible to calculate the value of a finite series, say, using LaTeX 3?
8
votes
2answers
466 views

Rounding up decimal number using LaTeX 3

I would like to use LaTeX 3 to round up decimal numbers; I want something like the following: If I type \RoundingUpFunction{2.7} it should return 3 as output. Unfortunately, I haven't taken the ...
13
votes
5answers
531 views

Calculations in TikZ for iterative procedure

In many \foreach iterative procedures in TikZ I would like to relate the generic node called n\x -- where x is a natural number -- to another node the name of which is obtained by applying basic ...
2
votes
1answer
105 views

How can I put a minipage that fits to the actual line width inside of a TikZ Node?

Question I would like to put a minipage environment inside of a tikz node. I know this is done already with the align=left command, but if you set a minimum width of the node to \linewidth, then the ...
6
votes
3answers
543 views

Tikz: drawing in perspective

I am working on drawing a beam in perspective. I have my point I want to use as the perspective point (10, 3). What would be the way to draw along this line? For instance, consider ...
3
votes
1answer
77 views

calculating polar coordinates with tikz

Random polar coordinates has an example of the general sort of syntax I'm aiming to follow. For some reason the result is not working as intended. In the MWE, I've commented out the line where I ...
16
votes
7answers
1k views

Calculating right angle triangle side inside LaTeX

I'd like compute the width of a screen from it's diagonal and its aspect ratio inside a LaTeX document. The formula is easy to get from the Pythagorean theorem, but needs square roots. I currently ...
22
votes
5answers
4k views

Floating point calculations in LaTeX?

I am looking for a method to do minimal floating point / integer calculations in LaTeX, not for the purpose of package writing, but for the production of actual text. Here is an example to ...
17
votes
3answers
838 views

square root of number in counter

I would like to get the square root of a number which I have stored into a counter. I have been using the calc package for summation and multiplication operations, but I cannot find anything like ...
3
votes
1answer
115 views

Why can't I use a variable from a \foreach loop inside a calc library macro?

Question Why can't I use the \foreach variable as a percentage in my calculations with the calc library of TikZ? Sample Code In the following, I could replace the variable \mypercentage with an ...
3
votes
0answers
30 views

Formatting numbers the Indian way [duplicate]

This is a follow-up question to Handling numbers and calculations. The numbers printed by \num[group-separator={,},group-minimum-digits=4]{\the\numexpr(5000)\relax} will produce comma separated ...
2
votes
2answers
45 views

Handling numbers and calculations [duplicate]

I have to deal with a lot of numbers in my latex documents. So far, I have been using a rudimentary \newcommand{\VarOne}{1000} to define \VarOne and then use it as it is using \VarOne{} in the ...
5
votes
1answer
138 views

Adding a number to every element

I have a table, whose entries are a list of one or more numbers. Now, I need that all numbers in the table are to be incremented by 1. For example, say, I have the table: \documentclass{article} ...
3
votes
1answer
48 views

global variables and/or array of variables

I'm looking for a way to obtain (in tex/latex - still difficult for me to determine the difference - I guess it should state latex) run-time defineable global variables to be used with the fp package. ...
3
votes
2answers
136 views

Compute the difference between two time points on different dates

This is a follow-up question to How to compute the difference between two time points (e.g., 11:30 am and 01:20 pm => 110 min)?. Consider the code from David's excellent answer here: ...
13
votes
2answers
798 views

How to compute the difference between two time points (e.g., 11:30 am and 01:20 pm => 110 min)?

Is there a simple way to compute the difference between two times (same day), so 11:30 am and 01:20 pm should lead to 110 min (or 1h 50min), for example? I saw the datenumber package but it only seems ...
1
vote
1answer
43 views

How to reuse a term in calc macro of latexcalc?

Although latexcalc seems to be no longer in active development, I'd like to know whether it is possible to reuse a term which I want to both display and calculate, but only maintain once, e.g ...
1
vote
1answer
26 views

interactive tooltipp improvement

according to this article, especially to AlexGs tooltipp code [1], it seems to me, that if the text inside the tooltipp will exceed more than one line, it disappears outside the page. It would be ...
0
votes
0answers
43 views

Command-scopes in a tabular-environment

I'm trying to use a command which aggregates some values. When using it with normal text, it is properly working but if I call the command in a table it seems that there is a problem with scopes or ...
4
votes
1answer
51 views

how do I multiply a command argument with a constant?

I'm writing a novel and I defined a set of commands for starting a new chapter: %A \newcommand{\AKapitel}[1]{\lettrine[lines=3, lraise=-0.2,findent=-22pt, nindent=14pt, ...
8
votes
2answers
262 views

How to do simple calculation in latex tables

Here I wish to do three things: 1) I want my table to be like this one below whereas mine is 2) I want numbers to appear in the same format as their heading p (in bold) 3) I want latex to ...
3
votes
1answer
43 views

spacing from calculator package

I'm trying to include images and overlay them with their width and height info in mm. I save the image to a box and then use the calculator package to calculate the mm width and height of that box. ...
6
votes
2answers
144 views

Trying to convert Hrs:Mins to Mins

I am having a bit of trouble trying to convert a time format from Hours:Minutes for instance 12:05 into 12*60+5 = 725, ie I would like to use 725 as a number of minutes. I am already using the number ...
4
votes
2answers
127 views

Calculator and calculus package: result [.] dot instead [,] comma

My codes, \documentclass{article} \usepackage{calculator} \usepackage{calculus} \newcommand\teo{3} \newcommand\job{,5} \begin{document} \MULTIPLY{\teo}{340}\W \MULTIPLY{\job}{5605}\WW ...
6
votes
2answers
247 views

Use input inside a spreadtab environment with calculations

My aim is to create a command for inserting tables, which will format the table, and add calculations on its values, given a file containing the raw data of the rows only. ...
6
votes
2answers
148 views

the calc package doesn't compute the correct value

I get an unexpected result using the calc package. I simply try to multiply the real value '10.01' by the entire value '10000' and to store the result in a counter. But the returned value is not the ...
5
votes
5answers
991 views

How can I multiply two numbers?

I use pgffor package and I have \foreach \n in {1,...,10}{**something I want**} How can I print n*(n+1) for each n? When I write just \n*(\n+1) instead of **something I want**, ...
0
votes
2answers
65 views

LateX code for 1+2+3+4+5 = 15 [duplicate]

Can anyone help please? I need to know how to make the sum of value S(n) = 0+1+2+3+4...+(n-1)+n (example: 0+1+2+3 = 6 , 0+1+2+3+4+5+6+7 = 28 and so on) on Latex I am new in this language. \batchmode ...
15
votes
6answers
2k views

Sum of (example: 0+1+2+3 = 6 , 0+1+2+3+4+5+6+7 = 28 and so on)

Can anyone help please? I need to know how to make the sum of value S(n) = 0+1+2+3+4...+(n-1)+n (example: 0+1+2+3 = 6 , 0+1+2+3+4+5+6+7 = 28 and so on) on Latex
10
votes
2answers
816 views

Page number in Fibonacci style

How to display the page number in Fibonacci. Example: Normal page number 1, 2, 3, 4, 5, 6, 7, 8,... Fibonnacci page number style: 1, 1, 2, 3, 5, 8, 13, ...
3
votes
2answers
140 views

How to calculate and use the ratio of two lengths?

I want to calculate the ratio of two lengths in Latex, so that I can then stretch an en dash by that ratio. For example, in the code below, I'd like to replace the "0.7" value of FakeStretch with the ...
7
votes
5answers
2k views

How to find the ratio of a length command (e.g., \textwidth) to a reference value (e.g., 6cm) ?

How to find the ratio of a length command (e.g., \textwidth) to a reference value (e.g., 6cm) ? Actually I want to use the ratio for the \scalebox argument, e.g., \scalebox{<ratio>}. ...