Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [calculations]

{calculations} is about calculations in (La)TeX documents. A popular package is calc, although others also exist (fp, pgf, and LaTeX3 packages, e.g `xfp`).

5
votes
2answers
134 views

Inaccurate Calculations By pgfplots

In graphing a certain function using pgfplots (link here) I noticed a distortion in the curve that at first I assumed must have been a point of inflexion - but on investigating the maths, found that ...
0
votes
1answer
29 views

how to get the monday of a years first week?

I would like to get the date of the monday of the first week of a year from only the year The purpose is a week planner where I put one week on each page and as most of the years first weeks monday is ...
5
votes
2answers
203 views

How to do calculations with a LaTeX counter in a newtcolorbox environment?

I created a course summary box. In order to distinguish the summaries by school year, I have put an optional argument that displays the latter in the upper left corner (highlighted in yellow on the ...
3
votes
1answer
74 views

Using the minipage enviroment inside \newcommand

i want to put the minipage enviroment inside a newcommand to avoid typing. \documentclass[aspectratio=169]{beamer} \usepackage[T1]{fontenc} \usepackage{lmodern} \usepackage[nomessages]{fp} \...
0
votes
2answers
31 views

Aligned TOC with titletoc

I'm trying to get my toc build with the titletoc package as I'm using it to do other content tables with it. I get it to work almost like i want it to, but i have some issues: First of all i have do ...
1
vote
2answers
57 views

Reference variables from package calculator in TiKZ

I have this code: \documentclass[letterpaper,12pt]{report} \usepackage[letterpaper, landscape, margin=0in]{geometry} \usepackage{graphicx} \usepackage[spanish]{babel} \usepackage{tikz} \usepackage{...
2
votes
2answers
55 views

using division to calculate column size

I am converting from another format and creating tables with varying numbers of columns. I would like the column to be approximately layed out. If there are two columns, I want each column to get ...
12
votes
4answers
958 views

Calculating the value of a formula without duplication, using LuaTeX or similar

If I have a numerical equation (i.e. no unknowns) in LaTeX, is it possible to have the equation typeset and evaluated in one go? I know calculations can be done relatively easily by embedding Lua ...
2
votes
3answers
84 views

Adding width of text to node coordinate?

I am currently trying to position some text in the center of a square drawn in a tikzpicture, like so: However, I am having a bit of trouble. Take the following example: \documentclass{article} \...
4
votes
3answers
144 views

Calculations on variables using LaTeX

I'm trying to do some basic calculations using values stored on a command, but it doesn't do the calculation: \newcommand{\lenghtHeatExchanger}{0.820} \newcommand{\heightHeatExchanger}{1.081} \...
0
votes
0answers
26 views

Automatically determine the height of header and footer in the presence of the `calc` package

I am trying to automatically correct the \headheight and \footskip using the fancyhdr package. This has already been asked in this question. The accepted answer proposes the following solution \...
0
votes
1answer
33 views

Plotting a sequence of points defined by a simple formula

This shouldn't be difficult, but I cannot make it work. I expected this code to generate the plot a certain sequence of blue points on a black circle: \begin{tikzpicture}[scale=3] \def\n{7} \def\...
2
votes
3answers
118 views

Using calc library with background package

Im trying to place a page border on every page using ornaments and the background package. I'd like to place this frame 0.6cm away from the border of the page and therefore I'm using the calc library ...
5
votes
1answer
47 views

Why is binomial probability calculation wrong in pgfplots?

During my investigation of this nice question by @Sentient, I found a rather bizarre problem: Given the binomial parameters n=15 and p=0.7, @Sentient’s code produces some probability ...
2
votes
1answer
47 views

Is there a problem rounding numbers with the calculator package?

I am using the calculator package to round a number and am having trouble in some cases. Is there an issue with what I am doing? I have included a MWE, uncommenting the line which rounds 0.0 will ...
0
votes
0answers
26 views

Copy value from one spreadtab to another

I have two tables. The first only does calculations with spreadtab and has some final result that I tag (with spreadtab's ommand tab). Later, I want to reuse the value in another spreadtab, but I do ...
1
vote
2answers
102 views

Scale images in proportion to textwidth

[I rewrite this post to address the questions posed in the comments.] First I formulate what I want to accomplish as clearly as I can. After that, I explain why I want to do that. My question: How ...
2
votes
1answer
96 views

How TeX does its scale factor calculation? [duplicate]

With the following example \documentclass{article} \begin{document} \dimen0=1sp \dimen1=0.5\dimen0 \dimen2=0.99999\dimen0 \dimen3=0.999992\dimen0 \dimen4=0.999993\dimen0 \count255=\dimen0 \the\...
5
votes
2answers
126 views

xcolor wrong conversion to cmyk color model

This is a MWE: \documentclass{article} \usepackage{xcolor} \begin{document} \definecolor{mycolor}{HTML}{4CAF50} \extractcolorspecs{mycolor}{\tmpmodel}{\tmpcolorspec} My color model: \...
5
votes
2answers
315 views

Evaluate calculations on label

I would like to display the evaluation of data on node instead display the values. What I mean is instead \x + 3*\y evaluate to 0 + 3*0 it should display 0, the result of calculation. How to do that? ...
8
votes
5answers
1k views

How to make table less cramped

I have a table which is defined using etoolbox but I'm not sure how to make it look less cramped. \documentclass{article} \usepackage{calculator} \usepackage{pgffor,etoolbox} \begin{document} \...
9
votes
3answers
398 views

Rewrite a postscript macro in LaTeX

I wrote a macro in PSTricks with which the number pi is calculated approximately with the so-called "Monte-Carlo-Method". A table will be setup with two randomly chosen numbers x and y (each of ...
1
vote
1answer
55 views

How to perform calculations(Not just display) [closed]

I have almost zero knowledge of TEX. I want an easy way to take common algorithms and use them to calculate values. This would ideally be done in the browser, but if not appropriate I could run on a ...
5
votes
4answers
276 views

Support for “tables of functions”

Prior to that arrival of calculators, we were cursed (or blessed) with "log tables", tables of functions to a fixed number of significant figures Is there any (La)TeX support for such tables? Or ...
1
vote
1answer
183 views

Addition & Multiplication of parameter and constant with unit

I want to substract and multiply with an optional parameter and a constant with cm as unit. Like this: \documentclass{article} \usepackage{changepage, xintexpr} \newcommand{\test}[2][1]{ \begin{...
1
vote
0answers
66 views

Feasibility of a Latex “Computation Verifier”

This may be more appropriate on stackoverflow, but as it pertains specifically to the existence of a utility for LaTeX, I thought I should ask it here. In my experience as an undergraduate, it's very ...
2
votes
1answer
111 views

Cumulative binomal distribution using pgfplots

This is a follow-up question to Declaring a function to be used by pgfplots. The MWE \documentclass{article} \usepackage{pgfplots} \usetikzlibrary{arrows.meta} \pgfplotsset{compat=1.15} \begin{...
0
votes
2answers
92 views

making a function to calculate average [closed]

How I can make to create a \newcommand to calculate an average between three numbers (can be numbers or numeric variables)? Usage would be \numberavg{<A>}{<B>}{<C>} Should be ...
6
votes
1answer
162 views

Is there a sane way to visualize a division in “german style”

I need to visualize divisions in "german style". I managed to do it with TikZ, but it's a hard job! \documentclass[parskip=half]{scrreprt} \usepackage{tikz} \usetikzlibrary{chains} \begin{document} \...
7
votes
4answers
877 views

How can I calculate geometric sequence in LaTeX?

I am trying to make my own command to calculate geometric sequence in LaTeX example: 10*4^(n+1) I've tried couple of things similar to this but non of them seemed to work: \newcommand{\...
1
vote
2answers
84 views

Beamer: uncover frame number based on variable/counter

Current Situation: \begin{frame} % Part one of frame (including several \pause commands) % I am working on this % Part two (finished) \begin{itemize} \item<7-> Text \visible<8>{more ...
0
votes
1answer
25 views

Treat content of a column as numbers, not a boxes

I'm making documentation for data communication protocol and trying to make a table column which shows an offset of the message fields, calculated for each field (table row) and takes field width ...
3
votes
1answer
72 views

Show logical calculations

For my students, I'd like a macro to show logical calculations bit by bit ( AND, OR, XOR ) between two numbers in base b ( b integer from 2 to 36) . Parameters would be number1, number2 and b; ...
1
vote
0answers
109 views

Show calculations in base b

For showing to my students, I'd like a macro who shows how add, and substract numbers in base b , with b =2 or b=16. Parameters would be : number1, number2 , et base b in wich number1 and number2 are ...
1
vote
1answer
207 views

How can I illustrate point decimal number to binary conversion

I'd like to convert point decimal number to binary as made by the command \baseexpansion in the jfbu's answer to the question: How can I illustrate decimal to binary conversion? For example, I'd ...
0
votes
1answer
177 views

Calculation with Latex

I am currently trying to create an exam template for my institute. What I want to receive is like this: Task 1 [8 Points] (text text text) Subtask 1.1 [3 Points] (text text text) Subask 1.2 [5 ...
1
vote
1answer
45 views

Add Rows to Table With Macro (calc fields result the same for each row)

I use as template macro from this articale: Add Rows to Table With Macro. All work fine if values in cells not to calculate. But othewise results of calculation is the same for each row. How to avoid ...
3
votes
3answers
369 views

Tikz: Calculate and store the Euclidian distance between two coordinates

Is there an easy way to store the Euclidian distance between two coordinates? I want to store the value 4 in a macro, so that I can use it to specify the width of a node. The easiest way I could ...
3
votes
1answer
60 views

How to specify a date and make calculations with it in datetime2?

I want to specify a date (and give it a name) in a master header TEX-file, then refer to that date in several independent daughter files. As this doesn't even work within a single file, this ...
9
votes
1answer
220 views

Accumulators in TikZ

I wanted to calculate something in TikZ. But, my TikZ code doesn't accumulate values to a variable. The following code is expected to output 1+2+...+10 = 55. However, it just shows 0. What should I ...
0
votes
1answer
53 views

Automation and variables

For school and exams, time is at a premium. Copying expressions and pasting them in a third party calculator is too time consuming. Not to mention if you discover that you have made a mistake, and ...
0
votes
1answer
114 views

How to add numbers with character?

how to add numbers which will automatically ignore non-numbers, file should be read from .csv file Eg.when A=10, B=20, C=NA --> here content of C contains some characters which is not a number so ...
2
votes
2answers
206 views

Math operations on lengths

I have a table with three columns and I want the table to be distributed on \textwidth of the page. I tried: \documentclass{article} \usepackage{tabularx} \begin{document} \begin{tabularx}{\...
3
votes
2answers
185 views

Problems with numerical stability [closed]

In a macro that is supposed to calculate the value of the third derivative, I used the following formula: (f (x + 3 * delta) -3 * f (x + 2 * delta) + 3 * f (x + delta) -f (x)) / (delta) ^ 3 Because ...
3
votes
1answer
224 views

pgfplots: drawing multiple vectors with corresponding unit vectors

Suppose you have a couple of 3D-vectors given by their start and endpoints. Now you want to define a command that draws one of these vectors together with its respective unit vector from the same ...
0
votes
0answers
36 views

Evaluate combinations of page dimensions [duplicate]

For any given class and its specified page layout, I'd like to be able to combine (sum or subtract) a subset of the page dimensions, to obtain a length to work with, without specifying absolute values....
4
votes
1answer
85 views

Is there a preferred way to switch between units?

I'm working on a recipe book. Some of my recipes are in British Imperial units, some in American, some in metric. I want to avoid manual conversion as that can produce errors, but I want the book to ...
0
votes
1answer
134 views

Strange behaviour of \FPeval

I have a piece of code, which sometimes compiled correctly, other times it gives an error. Is it possible that the package fp is unstable? Or might another package conflict with fp? How could I fix ...
0
votes
1answer
66 views

How to cumulate computed durations?

My current code generates a result as shown in the image below. My problem is: how to cumulate the "Car" durations?. When the line 95 % \global\let\routeCarTotalDuration\tempd% is uncommented, ...
0
votes
1answer
251 views

subtract leftskip from textwidth inside a expression

If I do: \includegraphics[width=\textwidth-\leftskip]{image.png} I don't get the same picture size as if I subtract its values of 483pt-60pt = 423pt. But if i do: \includegraphics[width=\textwidth-...