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`).
590
questions
0
votes
2
answers
92
views
Inside German abbreviations, how to set the penalty and the width of the internal space including the stretch and shrink attributes?
Continuing How to letter space (German) abbreviations automatically and http://tex.stackexchange.com/a/134856 , some of us tend to typeset a usual or a thin space in abbreviations and write, e.g.,
d.\@...
0
votes
1
answer
112
views
How to compare aspect ratios?
I have a box whose side lengths are recorded as lengths as in
\newlength{\imageWidth} \setlength{\imageWidth}{300mm}
\newlength{\imageHeight} \setlength{\imageHeight}{200mm}
I am trying to create a ...
2
votes
3
answers
194
views
\def a variable for sqrt with parameters
I tried to define variables with the sqrt command but couldn't get the result printed .
\def \radius {sqrt(4^2+2^2)}
\draw (4,3) node [right] {$The radius is \radius for x=4, y=2$};
The \draw shows &...
0
votes
1
answer
109
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}
\...
0
votes
1
answer
21
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 ...
4
votes
1
answer
269
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}
\...
0
votes
0
answers
58
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 ...
6
votes
2
answers
318
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 ...
3
votes
2
answers
149
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} %...
0
votes
0
answers
92
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 ...
0
votes
1
answer
65
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, ...
1
vote
0
answers
20
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 ...
3
votes
2
answers
896
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 ...
0
votes
1
answer
148
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 ...
1
vote
1
answer
83
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 ...
2
votes
1
answer
78
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 ...
1
vote
1
answer
99
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 ...
2
votes
1
answer
67
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 ...
0
votes
0
answers
25
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 ...
1
vote
1
answer
157
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}{...
11
votes
4
answers
1k
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 ...
1
vote
3
answers
352
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 ...
5
votes
2
answers
114
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 ...
0
votes
1
answer
148
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 ...
0
votes
1
answer
79
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{...
0
votes
3
answers
87
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. ...
3
votes
3
answers
49
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.
...
4
votes
3
answers
58
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 ...
2
votes
1
answer
131
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 ...
3
votes
1
answer
673
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 ...
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[...
1
vote
2
answers
134
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 ....
0
votes
2
answers
71
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 ...
2
votes
1
answer
181
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 ...
3
votes
1
answer
184
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 ...
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 ...
5
votes
2
answers
864
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 ...
0
votes
1
answer
106
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}
\...
2
votes
1
answer
73
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 ...
0
votes
2
answers
102
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. ...
3
votes
1
answer
223
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=...
3
votes
2
answers
482
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 ...
4
votes
0
answers
164
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-...
3
votes
3
answers
337
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{...
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\...
3
votes
1
answer
170
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}
...
4
votes
3
answers
419
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 ...
0
votes
0
answers
47
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
3
votes
8
answers
926
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
...
3
votes
1
answer
74
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)}...