{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
2answers
118 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
820 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
86 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
56 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
75 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
275 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
100 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
75 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
78 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
225 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
48 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
45 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
70 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
48 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
192 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
127 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
96 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
602 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
46 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
81 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
94 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
123 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
102 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
110 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
728 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
180 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
346 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: ...
4
votes
1answer
92 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
88 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 ...
6
votes
1answer
84 views

Dynamic calculation within regular expression quantifier in LaTeX3's l3regex package

I am trying to do some simple calculations to be applied to a regular expression quantifier used in l3regex's \regex_replace_all:nnN function. I've built my code around what I found here: Defining a ...
1
vote
1answer
91 views

Effect of adding plus and minus to \includegraphics

I have a document with a lot of pictures. The exact scale of the pictures isn't all that important. Is it possible to allow the pictures a little bit of "stretch" to help squeeze everything together? ...
3
votes
2answers
131 views

Perform simple calculations on user-defined variables

In my document, I have a user-defined variable like: \newcommand{\MyNumber}{30} Suppose, if I want to use a derivative of \MyNumber, it could be \MyNumber+10, 100-\MyNumber, 5*\MyNumber of ...
2
votes
1answer
80 views

Apply shift to (current axis.left of origin)

I was trying to improve the solution at Drawing lines in a plot and give them a label? by using Jake's answer at How to access \xmin, \xmax, \ymin, \ymax from within PGFplots axis environment. So, ...
5
votes
2answers
146 views

Is it possible to extrapolate data for a 3d-plot in pgfplots?

I am having several measurements to plot and would like to use something like a 3d surface from pgfplots. I am having a frame as outer border and a grid as measurement raster. The measured values are ...
13
votes
5answers
397 views

Transform big number into scientific format

I want to convert my big integer number into a shorter form; for example \convert{123456789} = 1.23 x 10^9 Is there any package which allows me to do so?
2
votes
3answers
148 views

Efficient way to indicate steps in a derivation

Imagine you're writing up a long derivation, and sometimes, the step to go from one equality to the next is nonobvious (for example, maybe it requires application of a theorem). In such cases, you ...
4
votes
1answer
111 views

Calculating averages and more

I am translating a Word document into LaTeX as a learning experience. Now there is this table, that already has hard-coded values. However, I would like to have it generic, so that changing a single ...
11
votes
2answers
274 views

Factorial (or, even better, binomial coefficient) function

Is there a function in l3fp for calculating factorials or, even better, binomial coefficients directly?
11
votes
4answers
295 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 ...
3
votes
2answers
90 views

How to calculate number of symbols in chapter heading?

Is there a simple way to calculate number of symbols in headings? I'm planning to change color and size of every even to red 16pt and every odd to blue 10pt. Like this one made in word: Or maybe ...
3
votes
2answers
61 views

identify pieces of text automatically generated from input and new command

I have a document where many of its values are defined in a separate file via \newcommand, and added to the main document using \input in the preamble. The file being included is the output of a ...
0
votes
0answers
71 views

Software/Programm: latex-based math trainer

I need some help, because I searched the internet for quite a long time, but I wasn't successfull in getting a solution: I'm looking for a program/software, which helps me to practice math, which is ...
1
vote
1answer
75 views

How do I store the x or y value of a named node in tikz \draw?

A big part of the question above has already been answered: "Use the calc tikzlibrary and the let syntax". \begin{tikzpicture} \draw [help lines] (0,0) grid (4,4); \node (A) at (2,1) {A}; ...
3
votes
1answer
189 views

fp calculation variable

I want to do some calculations in a LaTeX document; the result of the first is used in the next calculation. I figured out that the fp package should do the job. Here is an example: ...
4
votes
2answers
134 views

How to calculate a new length?

What I want to do is calculate the actual size between the edge of the paper, and my header. \evenmarginsize and \oddmarginsize do not do this. \settowidth{\msize}{((\paperwidth - \textwidth)/2)} ...
3
votes
1answer
144 views

A problem with underfull \hbox in alignment (tabular*) and/or perhaps the calc package

I am getting an underfull \hbox in alignment (badness 10000) with tabular*. The warning goes away if I adjust the table width by 0.00002pt (as per the MWE below). The difference seems to arise ...
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 ...
2
votes
1answer
169 views

How to calculate intersections of a line defined by a segment and an ellipse in tikz

EDIT Here's what I intended to ask, but didn't clearly formulate initially. The Tikz package intersections allows one to calculate and manipulate the intersection point of two non-parallel lines ...
17
votes
4answers
351 views

How can I convert units in LaTeX environment?

Example: \usepackage{siunitx} \newcommand{\temperature}[1]{\SI{#1}{\celsius}} \temperature{100} output: 100°C I would like something like: \newcommand{\temperature}[1]{\SI{#1+273}{\kelvin} ...