Skip to main content
The 2024 Developer Survey results are live! See the results

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
4 votes
1 answer
80 views

LaTeX error during base conversion : Missing number, treated as zero

I found in this page in the first answer a way to write beautiful base conversions. But, I had a compile error if Y try to use the last example, the ConverToBase command. I searched, but I don't find ...
alberic89's user avatar
2 votes
1 answer
50 views

Function values in columns rather then rows with numerica-tables

Package numerica-tables helps create of multi-column tables of mathematical function values, the package arranges values on rows like in this simple example \documentclass{article} \usepackage{...
Salim Bou's user avatar
  • 17.1k
2 votes
2 answers
89 views

Misunderstanding yunit in pstricks, or a bug, or extreme imprecision?

Feeding latex with \documentclass{article} \pagestyle{empty} \usepackage{pstricks} \begin{document} {1: \begin{pspicture}(-.1,-1)(.1,5) \psline(0,0)(0,5) \end{pspicture}} {$10^{-4}$: \psset{yunit=....
AlMa1r's user avatar
  • 541
0 votes
2 answers
98 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.\@...
AlMa1r's user avatar
  • 541
0 votes
1 answer
121 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 ...
Julian's user avatar
  • 751
2 votes
3 answers
214 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 &...
Leon Chang's user avatar
0 votes
1 answer
113 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
26 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
  • 137
4 votes
1 answer
270 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
  • 273
0 votes
0 answers
65 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,515
6 votes
2 answers
403 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
175 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
95 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,211
0 votes
1 answer
69 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
21 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
3 votes
2 answers
2k 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
192 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,323
1 vote
1 answer
99 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,147
2 votes
1 answer
82 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,147
1 vote
1 answer
131 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
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 ...
Stanley's user avatar
  • 371
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 ...
hschmauder's user avatar
1 vote
1 answer
191 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,890
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 ...
ded4943's user avatar
  • 111
1 vote
3 answers
379 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
  • 497
5 votes
2 answers
118 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
210 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
84 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
91 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
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. ...
curies's user avatar
  • 199
4 votes
3 answers
60 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
149 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,885
3 votes
1 answer
783 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,289
1 vote
2 answers
161 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
76 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,747
2 votes
1 answer
194 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
237 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
865 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
123 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
75 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
108 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
231 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
534 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
169 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
365 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
  • 15.4k
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
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} ...
Zeljko Hrcek's user avatar
4 votes
3 answers
493 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,329

1
2 3 4 5
12