{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

3
votes
1answer
82 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
26 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
34 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
25 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
108 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: ...
1
vote
1answer
36 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
25 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
40 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 ...
8
votes
2answers
192 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
37 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
140 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
81 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
137 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
911 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**, ...
13
votes
2answers
729 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 ...
10
votes
2answers
788 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, ...
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
0
votes
2answers
50 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 ...
4
votes
1answer
42 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, ...
3
votes
2answers
131 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 ...
3
votes
0answers
26 views

Use data from other multiple data files with calculations [duplicate]

This answer shows nicely how to use data from another file while plotting data using \addplot table. However, when trying to access the create on use column using \thisrow{}, an error occurs. For ...
17
votes
6answers
838 views

Rounding a number to its hundred

Does anybody know how I could have LaTeX round a number like 2,386 so that I finally get only written 2,300? I tried with siunitx and its option [round-mode=places,round-precision=-2] but it didn't ...
2
votes
2answers
133 views

Relative node positioning with calc library

Hi I'm trying to place same nodes relative to each other. I'm trying to place a node in the middle between two other nodes, but also half a cm to the right. \usepackage{tikz} \usetikzlibrary{calc} ...
1
vote
0answers
65 views

Is there a counter or variable that can be used to store numbers with decimals?

I'm working on an invoice document which has a "Grand Total" at the end of the document after some rows of invoice items. As such, I need to keep a running count of the total for each row. Using the ...
1
vote
0answers
89 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 ...
7
votes
4answers
306 views

Debugging Advice: Dimension too large (Need stack trace)

Background: I am stuck on a "Dimension too large" problem which is occurring during index generation. This is a large index of links to files (along with other related information), and am sure the ...
5
votes
1answer
153 views

Numeric variable in LaTeX

I have been given the task of creating a LaTeX template for producing marking reports for student research proposals. We need an easy way to assign marks (numeric values) to particular qualities of ...
4
votes
1answer
94 views

Calculation of an absolute position

My question is about calculating with the package textpos. By saving the vertical position of a block of text with zsavepos and calculating the middle of it, I want to position a block of text at the ...
2
votes
1answer
91 views

Time calculations

Based on a given starting time, I'd like to automatically calculate a time table. Based on https://groups.google.com/forum/#!topic/de.comp.text.tex/BQrRUYmDrHw I put the following MWE together: ...
5
votes
2answers
242 views

Do multiplication rules differ in TikZ compared to standard TeX?

I'd like to scale a line according to \figscale. Here it is said that the below syntax should work in general, but in this graphic it does not. As the picture shows, the numbers are just concatenated ...
2
votes
1answer
59 views

Building evaluated arrays

I'm trying to build an array dynamically in latex then use it in tikz. I'm a little confused about how to create an array and add evaluated mathematical expressions to it (I'm trying arrayjob). ...
2
votes
1answer
61 views

\widthof text in a def'd subroutine inside a tikzpicture? [duplicate]

I have already seen \widthof within tikzpicture, but this is slightly different. I have a rather complex Tikz image, which I'd like to eventually include in a Latex document; as such, I'd like this ...
2
votes
2answers
77 views

Automate a running counter through a document

The following minimal example demonstrates my situation: \documentclass{article} \usepackage{calculator} \newcommand{\pts}{0} \begin{document} \ADD{\pts}{3}{\pts}\pts \ADD{\pts}{3}{\pts}\pts ...
2
votes
1answer
60 views

Using a fp variable in a longtabu header

So, I am using the tabu package (which I need to use over tabular others for several reasons) to make a long table spanning several pages. This table contains currency amounts in a column, and I'd ...
3
votes
3answers
202 views

Summation of a list of numbers

The next code gives : 1 1.2 3 But 1 2.2 5.2 is expected. What is wrong ? \documentclass[tikz]{standalone} \begin{document} \xdef\Sum{0} \foreach \i in {1,1.2,3} { \pgfmathsetmacro\Sum{\Sum+\i} ...
4
votes
1answer
141 views

How to use margins in calculations?

I'd like to have a rule that has for example the width of \paperwidth-\leftmargin-\rightmargin. I tried to use \dimexpr, but apparently I do something wrong, because it does not work. ...
2
votes
4answers
107 views

Define variables holding a percentage

I would like to define some variables in a tex document. For example, I write in .tex something similar as: Our tool succeeds to validate x samples out of all the y samples, thus its success ratio is ...
15
votes
5answers
618 views

command for floor

I need something that corresponds to floor() to use it in a macro (I don't mean the notation, I really mean the function that rounds downwards). Something like this: \floor{34.75} produces 34 ...
1
vote
1answer
52 views

longtabu: put running total of some columns under the header on each page

so, I have a longtabu table spanning several pages. The table has a header, that needs to be repeated on each page. Some of the columns are numerical amounts, and I would like to put a row presenting ...
5
votes
1answer
96 views

Stretching an \fbox horizontally to fit the page

I have a frame box next to some text (Komentar:), and I would like to stretch it so it fills up the page. I've done this using the calc package by subtracting \widthof{Komentar: } from \hsize (or ...
1
vote
1answer
120 views

Tikz: How to combine orthogonal edge syntax with coordinate calculation? [duplicate]

I'm trying to combine the syntax for orthogonal edges (p |- q) with the syntax for calculation relative coordinates ($ (a) + (1,0) $). Example: \draw ($ (node1.south) + (1,0) $) to ( ($ (node1.south) ...
6
votes
1answer
150 views

Add (n) working days to a specific date

My g-brief will contain something like "I have noted a deadline for your answer of ten working days until...". Is there a package or way to add n working-days (ie. mon-fri, let's not over complicate ...
2
votes
1answer
117 views

How to get float numbers as parameter of \newcommand

I have defined a \newcommand function like into this code: \documentclass{scrartcl} \usepackage{pbox,calc} \newcounter{pointsExo} \setcounter{pointsExo}{4} \newcounter{pointsSousTotal} ...
5
votes
1answer
124 views

Resize tikzfigure in tcolorbox depending on height of tcolorbox

in my book I got many different type of boxes so I made some macros placing the boxes automatically according to their arguments. That's one of them. So far I made some boxes that have big "+" and ...
10
votes
3answers
745 views

TikZ coding style

I've got a piece of TikZ code here and since I am only starting to learn how to use it, I wanted to ask whether this code would be regarded to be ok or rather completely unreadable and what I can do ...
10
votes
1answer
193 views

Floating point and fixed point arithmetic in LaTeX3: Where documented? Safe to use?

Since about twenty years, I use a private fixed point arithmetic package which I would like to replace by something newer and better. There is the equally old (but good) fp package, but LaTeX3 is ...
12
votes
3answers
364 views

Formatting numbers while printing

Is there a way to format number strings while printing? Suppose I have the following declaration: \newcommand{\MyNumberA}{40} \newcommand{\MyNumberB}{60} The following in the text: ...
5
votes
1answer
110 views

How do I do currency calculations in text?

I am writing a long document, which has a lot of money references in Indian rupees (easily typeset using package tfrupee). Some definitions peculiar to Indian money before we proceed: Its grouped ...
2
votes
0answers
118 views

Perform spreadsheet-like calculations and display formula and result

Currently I am performing calculations using excel and manually formatting them for printing using an online LaTeX equation editor. The end result looks something like this: As you may imagine this ...