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`).

Filter by
Sorted by
Tagged with
0
votes
0answers
42 views

what does calc.sty missing from the foler mean

This error suddenly appeared in my file! It was not before what should I do? File `calc.sty' not found. \RequirePackage
2
votes
1answer
31 views

Latex long calculation error: “Missing number, treated as zero”

Why do I get the error "Missing number, treated as zero." for case A, while other cases are working? And how to avoid it? \documentclass{report} \begin{document} \newlength\newLen % Case A (...
1
vote
0answers
34 views

Tikz plots. I need to draw the intersection coordinates [duplicate]

I have this plot with the intersections of the functions f(x) & g(x) marked as P1, P2 and P3. How can I write its coordinates instead of the texts "P1", "P2" and "P3" ...
0
votes
0answers
55 views

Precision Tikzmath

I have the implementation of Bissection method in tikzmath environment below: \documentclass[tikz,border=5mm]{standalone} \usepackage{etoolbox} \usepackage{tikz} \usepackage{fp} \usepackage{xfp} \...
0
votes
0answers
47 views

Matrix operations on tikz math

Is possible I define a matrix A a vector x and compute the product b = A*x using tikzmath environment? Many thanks.
0
votes
0answers
38 views

Problem with Tikz - Math (Looping)

I have the following code in TikzMath to generate approximations for a initial problem of system of differential equations (rule of medium point). The algorithm is given below: \documentclass[tikz,...
1
vote
0answers
29 views

exam/geometry: First footer is shifted below when setting geometry using \AtBeginDocument

This answer does the job for placing the header right. However, the first footer is unknowingly shifted way much down. So, why does \AtBeginDocument{\settototalheight\headerTotalHeight{\headerContents}...
4
votes
1answer
97 views

tcolorbox: error with \settototalheight when calculating the header height before passing it to the geometry package

Following up this answer, I would like to know why the following doesn't compile and gives this error ! Undefined control sequence. \tcb@startbox ...x }{\tcb@w@upper }\tcb@lua@color {tcbcolupper}\...
2
votes
2answers
35 views

Replacing length registers in expressions

I have some understanding on how to use length registers for calculations. However, I always end up requiring way too many length registers for tasks which could probably be solved better by ...
0
votes
1answer
55 views

Calculating recursive terms of a sequence

I want to calculate resursive terms of a sequence. The following code do this task with fibonacci sequence (sure, could be other sequence). \documentclass[varwidth,border=5]{standalone} \usepackage{...
0
votes
1answer
81 views

Using Tikz package to extracting length, coordinates and assigning them to variables

The code below is extracted from: "\internalforces" command in stanli package (code exam1b - The second coding set in this example) and Using reference points in "Stanli" Is there ...
0
votes
0answers
45 views

Variable declaration, substitution and automated calculations with luatex in math environment [duplicate]

I am trying to perform automated calculations with latex using lualatex. I need to be able to printout calculations like "M = a+b" while maintaining all functionalities and options wihtin ...
2
votes
1answer
80 views

Rounding a value from a function

Is possible I define a mathematical function f(x), for example, f(x) = sqrt(x), evaluate this function in a given point p=2 and round the result with 4 decimal places? I prefer use this code inside a ...
4
votes
3answers
358 views

Calculation summations in Latex

Anyone can help me please? I need to calculate the sum 1+1/2+1/3+...1/n (n given) by using only Latex commands. I have no idea how can I do this. Many thanks.
2
votes
2answers
100 views

Inaccuracy in floating number computation with fpu library

So I am trying to do some a bit involved computations with LaTeX, and it kept spitting out a nonsense answer. I am trying to compute number of layers you could cover a ball with, given some conditions,...
8
votes
2answers
570 views

Tikz wrong calculation draw exponential function

Thanks for your help in advance:) I have a problem with tikz calculating/printing the values of my function wrong. The function is f(x) = (ax³+bx²+cx)*e^(dx) with a=-3.01718 b=11.8804 c=0.753323 d=-0....
1
vote
1answer
49 views

Add days to a specific date in datetime2 in a for loop / foreach loop

I want to calculate the beginning and ending date of a week (first day is Monday, last is Sunday). This is working fine for a single date. Now I want to calculate the start and end of multiple weeks ...
1
vote
1answer
55 views

Dynamic table : setting the column number after the table

I would like to create a dynamic table with \N columns at the beginning of the page, in which \N is the number of sections in the whole document, so the value of \N is set after the table. When I set ...
-1
votes
1answer
32 views

How to set horizontal alignment inside a custom environment, based on one of the parameters

So with this code using xparse : \NewDocumentEnvironment{figwcommentary}{O{0.45} m m} { \adjustbox{valign=t} {\begin{minipage}{#1\textwidth} #2 \end{minipage} } } { \adjustbox{valign=t,right=0.5\...
6
votes
2answers
338 views

How to divide in LaTeX without it rounding or truncating?

I'm working on a diagram and I'm pretty new to LaTeX, so I've decided to try to do it using math instead of statically assigned values. I have come up with the following: \newcommand\qoffset{14} \...
2
votes
2answers
32 views

Latex3 sum of array terms

I have used expl3 to sum the terms of a given array, however as you can see the procedure is quite cumbersome. Is there a more elegant way to do the same thing? \documentclass{article} \usepackage{...
1
vote
1answer
26 views

Cutting text to a given length

I want to put text on the header of my document (I'm using fancyhdr), but if the text surpass certain length it overlaps with other elements. For example, if I want to put "A very long text to ...
4
votes
2answers
171 views

Why is there an arithmetic overflow in the progress bar with more than 44 frames?

I am trying to implement a progress bar into my beamer theme, but as soon as I hit 45 frames, I get the error message ! Arithmetic overflow. \progressbar@progressbar ...progressbar@tmpcounta \divide \...
1
vote
0answers
35 views

TikZ - “Calculate” the numeric suffix of the name of a node

Relaxing answer Symbol gives the answer in his comment below. Change \def\secondnode{T22} \coordinate (M) at ($(T2#1)!.5!(\secondnode)$); to \coordinate (M) at ($(T2#1)!.5!(T2\the\numexpr#1+1\relax)$...
6
votes
2answers
538 views

How to make text appear in the middle of a phantom in math mode?

I want to make a part of an equation to appear in the center of a (horizontal) phantom. This would be awesome for example for making bra-kets that are all of the same width and still look natural. ...
5
votes
2answers
173 views

How to round numbers to hundreds, i.e., to the nearest multiple of 100

I want to round numbers to hundreds. I note Rounding a number to its hundred. However, the question asks about rounding 2,386.0 down to 2,300.0 -- and I would want it to be rounded up to 2,400.0, and ...
3
votes
2answers
62 views

Convert \input to number

I'm reading several txt-files from disk and I want to do some simple calculations on them and be able to print them on the page. Basically I have: \newcommand\getinput[2]{ \immediate\write18{do-...
2
votes
0answers
55 views

A mask for conversion degrees to radians and viceversa for my students of an high school

Starting from this code: \documentclass[a4paper,12pt]{article} \usepackage{calculator} \usepackage{amsmath,amssymb} \begin{document} \DEGtoRAD{60}{\sola} Result in radian without the use $\pi$: \sola ...
0
votes
1answer
147 views

How to write a math parser in TeX?

TeX is not really good in calculating, so some packages and LuaTeX were developed. But none of these solutions offers symbolic/exact mathematics, so I have tried something like this: % Plain TeX \...
3
votes
1answer
78 views

Approximation of module gsl or Asymptote own calculation is the best?

Example: import graph; import gsl; size(12cm,false); defaultpen(linewidth(.7bp)); real f(real x){return x^2;} real g(real x){return 2^x;} draw(graph(f,-1.5,5),red); draw(graph(g,-1.5,5),blue); draw(...
0
votes
1answer
61 views

Multiplication and division with counters while also formatting

See the code that follows. The user gives some pairs of numbers. Each time they happen also to be displayed. Finally they are added up in a specific way. \documentclass{article} %\def\Result... \...
1
vote
1answer
40 views

Not able to draw arrows parallel to line

I am trying to draw a region. I am not able to draw arrows parallel to line connecting inner region to outer region. This is what I have and this is what I want The code I have so far is below. ...
7
votes
2answers
246 views

Modeling randomly generated inscribed triangles

The problem I am modeling: Three points are randomly chosen on a circle. What is the probability that the triangle formed by these three points contains the center of the circle? Conceptual ...
2
votes
1answer
76 views

xsim: How to calculate points of the sections

Is there a simple way to calculate the points a section includes? \documentclass{scrartcl} \usepackage[no-files]{xsim} \xsimsetup{ exercise/the-counter = \thesection.\arabic{exercise}, exercise/...
0
votes
1answer
44 views

use \IfEqCase output as a numeric value

How can i use the output as a number \documentclass{article} \usepackage{xstring} \newcommand{\CableType}{N2XSY} \newcommand{\Ksc}{ \IfEqCase{\CableType}{ ...
2
votes
2answers
99 views

tikz rectangle that fits exacly into linewidth including boundary

I had this code: \documentclass{article} \usepackage{tikz} \usetikzlibrary{positioning} \begin{document} \newcommand{\mywidth}{\linewidth} \begin{figure}[p] \begin{tikzpicture} \draw[ultra thick]...
14
votes
4answers
825 views

How to get the sum, difference, product, and quotient from a macro in ConTeXt or Plain TeX?

I want to create a set of macros like this: \addnumbers{2}{5} \subtractnumbers{3}{5} \multiplynumbers{2}{-2} \dividenumbers{2}{8} The first will display the number 7, adding #1 and #2. The ...
0
votes
0answers
86 views

LaTeX set and add durations as in primary school

I'm looking for a package, or even a macro that allows me to simply write duration calculations for young students. Like for example this (Lebossé-Hemery 1957 classe de sixième): Please note that ...
1
vote
1answer
115 views

Why does pgf calculate arc sine incorrectly (by a lot)?

Reasonable imprecision is OK, but diverging from a calculator by entire 10 degrees is unacceptable. \documentclass[border=5mm]{standalone} \usepackage{tikz} \usetikzlibrary{math} \tikzmath { \angle=...
2
votes
1answer
152 views

Avoid “Illegal unit of measure (pt inserted)” when dealing with LaTeX lengths

My goal is to link to external video files in beamer presentations rather then embedding them directly into the PDF (e.g., with media9 package) to keep the size as small as possible. I use the ...
0
votes
0answers
61 views

Total and subtotal calculations

I am writing a series of tests in LaTeX, and I was wondering if LaTeX could calculate the total marks and the number of questions. Ideally I would like it to do the following: Let's say Question 1 ...
2
votes
1answer
201 views

Can I write once, publish in HTML(blog) and PDF?

I'm going to write an article. It will have math equations, images, and tables. My article frequently contains repeated content with slight modifications. For instance my article may have If the ...
9
votes
1answer
288 views

Calculating with \directlua in Plain LuaTeX

I have never used Lua before, so I have some questions about the calculations: How can avoid appending .0 if the result is an integer? How can I achieve that the right number of zeros is appended ...
0
votes
0answers
53 views

Open source tool to compute/calculate numeric latex equations?

Scenario Currently, when I substitute values in an equation written in latex, I copy paste that into wolfram alpha, which has difficulties handling the \cdot and longer equations. Which leads to ...
0
votes
1answer
77 views

How to make calculations with counters?

I have three counters counterBoat, counterThink and counterWork. I want to print the integer "round"(100*counterBoat/(counterBoat+ counterThink+ counterWork)) in my document. I use the package ...
1
vote
1answer
89 views

Doing math with \pageref (finding the last page number and adding 3) [duplicate]

So I'm writing an exam. It will have some as-yet-unknown number of pages P, and an additional 3 pages of a formula sheet. So the total length is N = P +3. I need to write "This exam has $P$ pages, ...
8
votes
1answer
409 views

How can I show radius of this circle exactly?

I want to show radius of this circle. The correct result of radius is 7/sqrt(3). My code. \documentclass[border = 1mm]{standalone} \usepackage{tikz} \usepackage{tikz-3dplot} \usetikzlibrary{...
0
votes
1answer
181 views

Filling the latex table dynamically

I have generated an exercise problem for a function table as \documentclass{article} \usepackage[top=1in, bottom=1in, left=1in, right=1in]{geometry} \usepackage{fancyhdr} \usepackage{multicol} \...
6
votes
3answers
204 views

Basic calculations in PGF/TikZ for loop

I've seen a bunch of similar questions and answers relating to the same kind of problem, but they either weren't particularly well explained or something got lost in translation somewhere. So I ...
1
vote
0answers
50 views

calculate the title height and if the title height is above some number then add some space

calculate the title height and if the title height is above some number then add some space. when I use the code get the title, but when I use code like this \settoheight{\heightoftitle}{\vbox{\...

1
2 3 4 5
11