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
1 answer
93 views

Validity of \def in tikz

The following code does not resolve the defines inside tikzpicture and thus does not print the labels. \documentclass[tikz]{article} \usepackage{keycommand} \usepackage{ifthen} \usepackage{tikz} \...
RootRaven's user avatar
  • 249
0 votes
1 answer
20 views

rounding error in simple assignment

I have a simple assignment in LuaTex: \dimen1 = 210mm Now I print the value \the\dimen1 The result is: 597.50787pt Calculating back with 1pt = 0.351mm is: 209.725...mm. This is an error of more than a ...
coonlight's user avatar
4 votes
1 answer
268 views

Why is calculated value not recognized as a number?

In the code below I want to proceed with a calculated result (from Lualatex). But the calculated value (rounded) is not recognized as a number. Who knows a solution for this? \documentclass{article} \...
PaulJGD's user avatar
  • 253
0 votes
0 answers
52 views

How to handle calculations in tabularx?

I try to create an invoice letter with automatic calculations of the invoice sum. Using tabular everything works. With tabularx the counters do work correctly but the calculations do not. I understand ...
mrCarnivore's user avatar
  • 1,367
6 votes
2 answers
283 views

Finding syntax for performing calculations in latex [duplicate]

I'm wanting to perform some calculations in latex for the purpose of building a diagram that can be re-used for different inputs. Specifically its related to drawing lines connecting two points and ...
Phenomniverse's user avatar
3 votes
2 answers
100 views

How to expand \fpeval{} results numerically?

I' m trying to use xfp to create some automated homework solutions. For short documents it works like a charm, but for longer one the compiling time grows exponentially. For example: \def\GDUbeta{30} %...
Guanyang Xue's user avatar
0 votes
0 answers
91 views

FP calculation bug within tabularray

Strange results had been reported here when using the fp package inside a table using tabu package. A solution had been proposed to manage the fact that computations are done twice by performing a ...
Tobard's user avatar
  • 1,180
0 votes
1 answer
64 views

Simple calculations within tabularx-environment

I want to perform simple arithmetic operations for a document in a table in the tabularx environment. There is a column for the quantity, a column for the unit price and a column for the total price, ...
Mr_Nofreeze's user avatar
1 vote
0 answers
19 views

doing calculations with textfield inputs [duplicate]

I want to make a PDF form with various text fields. I want to take the input from one textfield (where a number is typed in) and sustract it from another number. In the PDF, the substracted number ...
Tobias R.'s user avatar
2 votes
2 answers
353 views

How to annotate calculations?

I am writing a basic mathematics book and I would like to annotate some calculations, using arrows, underlines, horizontal, vertical and diagonal lines, boxes, circles, etc., with different colors, to ...
Adriano Steffler's user avatar
0 votes
1 answer
82 views

Multiply LaTeX counter with real

Suppose, I want to create an invoice in LaTeX. Therefore, I list via macro some items. The macro will trigger an item specific counter. At the end, I would love to multiply the actual value of that ...
Jan's user avatar
  • 5,224
1 vote
1 answer
58 views

Define a tikz variable only inside the current tikzpicture

I want to "define" a variable inside my tikzpicture. This answer gives a solution for how to do that, using the math library. The thing I am concerned with is that when I assign \x1 the ...
tush's user avatar
  • 1,093
2 votes
1 answer
71 views

Avoid axes distortion when drawing on image in tikz

I want to draw 10 circles in a circular shape, inside a rectangle. The problem is that the 10 circles are positioned as an ellipse, and not around the circumference of a circle. I want to place the 10 ...
tush's user avatar
  • 1,093
1 vote
1 answer
72 views

Putting a non-integer number as a radius of a circle

I recently embarked the journey of learning LaTeX and there are some caveats to overcome. I tried to draw circles with radius 2, 3, 4 cm but the code does not generate when I try with an irrational ...
abdul's user avatar
  • 113
2 votes
1 answer
65 views

ConTeXt: How do I do calculations with /nextpage?

This works great \definelayout[\nextpage][new] to set the layout for the next page. How can I set the layout for the \nextpage+2 ? This didn't work \definelayout[\nextpage+2][new] I tried a \numexpr ...
Stanley's user avatar
  • 351
0 votes
0 answers
18 views

Omit page reference if target is on the same or the facing page

I'm working on a two-side scrbook in which references are made to other sections, figures, etc. If the target is on the very same page, I want to omit a page reference in the text (i.e., if we're on ...
hschmauder's user avatar
0 votes
0 answers
40 views

spreadtab how to add every third row

I want to add many cases so the spreadtab, but the changes I want to do it manually. For example the have here two cases, so I have to add the sum up Case A and Case B so I have to write in the \...
IH Pro's user avatar
  • 141
1 vote
1 answer
104 views

Change Units in Calculation

Quick question. I'm looking for a way to change the units of a length while performing a calculation. I'm currently using the ragged2e package and trying to adjust \setlength{\RaggedRightRightskip}{...
User23456234's user avatar
  • 1,475
11 votes
4 answers
976 views

How to calculate numbers bigger than 16383 in tikz? [duplicate]

I was trying to output the positive integer powers of 2 starting from 2^10=1024. I was met with a Dimension too large error. When I force compiled, every number from 2^14=16384 was output as 16383. My ...
ded4943's user avatar
  • 111
1 vote
3 answers
283 views

Calculate the value of definite integrals?

I am trying to create a package for LaTeX, in this package I will need, if possible, to calculate the value of definite integrals. Is there a possibility to do this in LaTeX? Using for example the pgf ...
fsbmat's user avatar
  • 487
5 votes
2 answers
109 views

Determine the length of the rest of a math display line for multlined

\documentclass{article} \pagestyle{empty} \usepackage{mathtools} \usepackage{lipsum} \begin{document} \lipsum[1] \[ \text{beginning}\land \begin{multlined}[t][\linewidth] (\text{extremely long ...
user avatar
0 votes
1 answer
88 views

Multiply length using \expr

I have a length that I wish to scale, however I am not sure of how to do it, and none of the answers i have found online have been helpful. The function I attempted to derive this from is: % #1 is the ...
cdickstein's user avatar
0 votes
1 answer
75 views

Tikz does not always calculate equations

The attached code attempts to print the first letter of the English alphabet using the alphalph package and f_1 by simple arithmetic. \documentclass{article} \usepackage[utf8]{inputenc} \usepackage{...
oppe3782's user avatar
0 votes
3 answers
70 views

a macro for mskip with half stretch and shrink?

We often find ourselves using nonzero stretch and shrink parts in \hskip and \mskip, typically 50% of the natural space value, e.g., \hskip.1em plus.05em minus.05em or \mskip1mu plus.5mu minus.5mu. ...
user avatar
3 votes
3 answers
44 views

How to "teach" a custom command to set rules whilst also using linebreak?

So I am sadly still not as versed with TeX as I wish I would be. I am looking for guidance on creating a custom command. I have been doing this manually so far but would want to take a step ahaed. ...
curies's user avatar
  • 199
4 votes
3 answers
54 views

Custom footer text on every sixteenth absolute page

For a book, an Indian publisher wants me to include what they call "forma numbers" (not sure what the standard term is, if there is one) with the book name abbreviation on every sixteenth ...
user22209's user avatar
  • 921
2 votes
1 answer
102 views

\dimeval for pdflatex?

I'm using pdfTeX 3.141592653-2.6-1.40.22 (TeX Live 2022/dev/Debian). In a recent question, I have been provided with two excellent answers that unfortunately both make use of \dimeval. This command is ...
vwegert's user avatar
  • 2,855
3 votes
1 answer
495 views

How to calculate a mean in LaTeX?

I'd like to set up a LaTeX template for grading, which would contain several categories that are graded individually using A-F by the user of the template. Out of these, the final grade has to be ...
krab1k's user avatar
  • 105
0 votes
1 answer
48 views

Changing the color of the block using the calculator package

I'm trying to plot blocks with different colors. but it looks like all of them are getting the same color and only the last block is changing its color. What went wrong in this code \documentclass[...
Diana's user avatar
  • 1,191
1 vote
2 answers
97 views

Calculate a floating point value to scale a length

As background, I was trying to write a macro that divides a page into columns given just a decimal scale factor. For example, given an input of .7 it should create columns of width .7*\textwidth and ....
Kenneth Hanson's user avatar
0 votes
2 answers
67 views

How to enlarge figure by animate

Objective: First, I put a picture (named test.png) in a circle (made by TikZ). Then, I want to get an animated effect to enlarge the whole figure by controlling the value of the option scale. The ...
lyl's user avatar
  • 2,677
2 votes
1 answer
159 views

Latex3 floating point calculations in longtblr (tabularray)

I'm learning LaTeX3 and trying to do simple calculations on floats in a longtblr environment. Trouble is that I cannot manage to dynamically compute sub-totals per row. The global total is working ...
Wabylete's user avatar
3 votes
1 answer
139 views

Changing the default length unit in tikz

Is there a way to change the default length unit in tikz to the ex unit? I have trouble while calculating complicated coordinates in tikz when I'm using the ex unit (I always get an error or a wrong ...
Master.AKA's user avatar
15 votes
1 answer
1k views

Animate mass-spring-damper TikZ

I've create a TikZ of a mass-spring-damper system that is described by the following ODEs dx1/dt = x2 dx2/dt = -w0^2*x1 -2*zeta*w0*x2 + u y = K*w0*x1 + 2*zeta*w0*x2 wherein u is the input and y is ...
Pascal's user avatar
  • 307
5 votes
2 answers
861 views

tikz Math Library: Why does this operation "755 / 100" produce 7.54999 and not 7.55?

Here is a code example. \tikzmath{ \x = 755; \x = \x / 100; } Output: \x I expect my value stored in \x to be 7.55, but it is instead 7.54999. Is there some setting to make the result be ...
Jon's user avatar
  • 133
0 votes
1 answer
86 views

Placing symbols into spreadtab

I am quite new for the spreadtab package. I have prepared a MWE for my issues as: \documentclass[handout]{beamer} \usepackage{spreadtab} %\input{diagrams} \newcommand\dollarsign{\$} \begin{document} \...
ozturkib's user avatar
  • 160
2 votes
1 answer
68 views

Floating point calculations LaTeX without printing result in pdf

I'm writing a package and I need LaTeX to perform calculations involving floats and fractional parts without them appearing on the pdf, like how you would define a variable in Python without having it ...
Trait of the Union's user avatar
0 votes
2 answers
90 views

How can I convert automatically a calculated angle in degrees minutes and seconds [duplicate]

I want to make a batterie of exercises for a part of geometry. In this document I can change the length of the triangle. It calculates the angle. But I want the angle in Degrees minutes and seconds. ...
Arne Timperman's user avatar
3 votes
1 answer
202 views

Use command argument in foreach

When I define a new command to draw an axis I want to use one argument to calculate the step size of the tick numbers. I tried this but it didn't work: \newcommand{\axistest}[2]{ \draw[->,color=...
elementzero23's user avatar
3 votes
2 answers
446 views

How to write Pascal's Triangle modulo 2

I am writing a document and would love to write Pascal's triangle modulo 2. That is each binomial coefficient modulo 2, "the remainder" when dividing by 2. I found these links (Pascal) of ...
MathematicalMoose's user avatar
4 votes
0 answers
146 views

What are the available macros for algebra and calculus?

The polynom package can provide all the steps of a long division of polynomials if I just provide the polynomials: \documentclass{article} \usepackage{polynom} \begin{document} \polylongdiv{x^4-3x^3-...
Chilote's user avatar
  • 189
3 votes
3 answers
300 views

pgfplots: Dimension too large with no obvious large numbers

The following MWE results in the error Dimension too large. Changing the upper limit of the domain to a smaller value like 120 gets makes this error disappear. \documentclass{article} \usepackage{...
schtandard's user avatar
  • 14.5k
0 votes
1 answer
45 views

How to use decimal computations inside parentheses to compute the height of an image?

I have the following LaTeX file which does not compile: \documentclass{report} \usepackage{calc} \usepackage{graphicx} \newcommand\AFiveHeight{210mm} \newcommand\BodyToLayoutRatio{0.7} \newcommand\...
Liisi's user avatar
  • 137
3 votes
1 answer
138 views

Automatic calculation of check number for ISBN-13

Here is a simple example. If I have the first 12 digits of ISBN-13 number. \documentclass[12pt]{report} \parskip=12pt \def\ISBNnumber{978-618-5645-08} \pagestyle{empty} \begin{document} ...
Zeljko Hrcek's user avatar
4 votes
3 answers
326 views

Adding to number

I want to check if the value of the parameter is negative. If the parameter is negative, I want to substract 0.5 and if it is positive, I want to add 0.5. The best I could do is define new variable ...
Pygmalion's user avatar
  • 6,155
0 votes
0 answers
42 views

One to one function, how to draw in LaTeX? [duplicate]

Here are both set of one to one function. How to make LaTeX coding in figure type: (x)=0,2,3 (y)=a,b,c
Muhammad WASEEM FAROOQ's user avatar
3 votes
8 answers
856 views

How do I print an increasing value with iteration in LaTeX?

For example, I want to print all values x + 1 with n repetition In Python it would be: def arithmetic_add_1_(n,x): for k in range(n): print(x) x = x+1 print(x) with n -> repetitions ...
Debush's user avatar
  • 49
3 votes
1 answer
67 views

StrGobble doesn't work with \numexpr

I made the following function which strips left, right or both (if present) brackets and it seems to work as intended when used in the document, i.e. \stripp{1}, \strip{(1)}, \strip{1)} and \strip{(1)}...
Tomasz23's user avatar
  • 570
2 votes
1 answer
142 views

Rounding up to decimal pgfmath

I need to define a Roundup function that is "defined as the smallest number, specified to one decimal place, that is equal to or higher than its input." For example, Round up (4.02) is 4.1; ...
3isenHeim's user avatar
  • 2,097
2 votes
1 answer
180 views

How to draw \hrule based on text width?

I have a \divider command where it draws a thick hrule and a thin hrule to achieve the style I want: \newcommand{\divider}[1]{% \vskip-2pt % {% \color{black}% \hrule% }% ...
Yuchen Zhang's user avatar

1
2 3 4 5
12