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
6
votes
1answer
907 views

Arithmetic/calculations with lengths

I want to define a new command to add vertical "padding" before and after the content of a table cell. I'm stealing the idea of using rules/struts from the accepted answer to this question. My ...
4
votes
4answers
21k views

I'm searching for a table with cdf of standard normal distribution

I'm searching for a latex version of the mathematical table in german called "standard normalverteilung". Google spits out standard normal distribution but i don't think thats quite right. its this ...
2
votes
2answers
156 views

How can I create text that lists its own physical dimensions?

In a similar vein to XKCD 688, I am trying to make a latex document that textually describes its own content: In particular, I want to be able to have the text list its own physical dimensions. For ...
5
votes
2answers
580 views

print number of next page

I know I can use \thepage to print the current page number in my document. But is it possible to print the number of the next page, e.g. for phrases like "continue on page "? Thanks in advance :)
13
votes
3answers
999 views

Total number of points

I'm looking for a simple answer, as I'm not a programmer. Everything I've found online about this is way too dense for my knowledge level. I teach calculus, and every year the points for each ...
5
votes
2answers
345 views

Beamer / TIKZ / PGF: Using a Variable (Math / Calculations) as Part of a File Name for an External File

I want to indicate the progress of a beamer presentation using external pictures. Let's say we are at slide 24 out of 200 slides then I want to display a picture called 12.png (24/200 = 12 %) on ...
3
votes
1answer
2k views

Define a variable and add 1 to it's value

I'm programming a calendar in LaTeX and as it should be used for my univertsity planning, I want to split it up in semesters. So on one page there are the months from September to February and on the ...
3
votes
1answer
164 views

Escaping calculations in TikZ

I wanted to draw a diagram and didn't like the fact it contains magic constants, so I tried to parametrize it. However it seems that occurences of (1 + \N) / 2 and \N - 2 have to be somehow escaped. ...
3
votes
2answers
1k views

Two images with different size, side by side, automatic computation

The following Latex macro is taken from this answer. In this macro both the image width and the minipage width are hard-coded to .45. The issue with that is that the resulting two images are not ...
0
votes
3answers
86 views

How to perform calculations inside a .tex file in order to use the value in a function?

I'm trying to set a value to be used inside \vspace{} based on a value provided by a function which reads it from the keyboard. For example, if the provided value is 3, I would like for \vspace{} to ...
4
votes
2answers
575 views

Calculating a real inside an environment

I am trying to calculate real numbers within an environment. Unfortunately, I'll have to display the result of the calculations outside the environment. This is my minimal example. \documentclass{...
1
vote
1answer
239 views

How to Get Two Plots in Float to be side by side and proportional?

I am using the following code to get two figures side by side. The code (MWE) is: \documentclass{article} \usepackage{tikz} \usetikzlibrary{calc} \usepackage{adjustbox} \usepackage{float} \begin{...
5
votes
2answers
598 views

Calculating content of newcommand

In order to have a tikz picture adjust to some input values I have created something as the code below. In the code below the distance between A and C is twice as long as the distance between A and B ...
1
vote
1answer
96 views

Is it possible to compute arguments to `\put` from variables when using overpic?

Consider the following example (substitute any image). \documentclass{report} \usepackage[percent]{overpic} \begin{document} \newcommand{\numberLeftOffset}{3} \newcommand{\numberTopOffset}{...
3
votes
2answers
2k views

Convert a latex-terminology equation into a version suitable for wolfram alpha [closed]

I asked a combinatorics question on math stack exchange and received the following LaTeX-flavored answer. I have attempted to convert that equation into something that can be understood by wolfram ...
8
votes
3answers
526 views

How do I typeset multiple additions nicely?

For some project, I'm trying to typeset something into approximately this: 1234 321 12345 6 ----- + 13906 I've seen people do this using xlop for the addition of two values, which works ...
5
votes
1answer
360 views

Cross-referencing on total counts between different files

Suppose that we have three .tex files in one folder called PhDThesis.tex, Synopsis.tex and conclusion.tex. There is also one bib-file called my_bibio.bib In Synopsis we have a short description of ...
6
votes
3answers
611 views

Calculating the minimum of two distances with tikz

I am trying to make the middle circle fit inside the two larger circles: \documentclass{article} \usepackage{tikz} \usetikzlibrary{calc} \usetikzlibrary{positioning} \usepackage{amsmath} \begin{...
4
votes
1answer
150 views

Placing characters of a text exactly in grid boxes (w/ TikZ grid)

For generating a large number of Exercise-sheets for my math class I'd like to set the problem in a grid so the kids have a given structure to add their calculation. Example with quite a large code ...
6
votes
2answers
700 views

pgfplots - calculate tick position

Follow-up to pgfplots: multiple loops for ticks, positioning, etc (and Passing a macro to an environment option (TikZ/pgfplots)), but there may be a LateX-only solution. I suppose there is a trivial ...
9
votes
2answers
2k views

Direct evaluation of fp expression

This code \documentclass{article} \usepackage[nomessages]{fp} \begin{document} \FPeval{result}{clip(cos(pi))} $\cos(\pi)=$\result \end{document} would produce the following output: Is it possible ...
3
votes
2answers
93 views

Help recalling a package which automatically calculates derivative orders

I distinctly recall stumbling upon a package which typeset derivatives nicely, and moreover automatically calculated some of the indices involved in partial differentiation. Unfortunately, I can't ...
1
vote
1answer
1k views

`abs` inside coordinate calculation

How can I put abs inside a coordinate calculation in TikZ? I have tried the following but it doesn't work (see lines 4 and 5 inside the MWE). \documentclass{article} \usepackage{tikz} \usetikzlibrary{...
3
votes
1answer
264 views

Let LaTeX calculate the value of a fraction

I am making a plot and I would like a tick to appear on the x-axis at the location c/(1 + c) , where c is a constant that I would like to be able to vary. I do not know how to do that. I tried using \...
8
votes
2answers
565 views

I want \edef to work

I want to generate a list called anglelist to generate a graph... the prefered command for me is \edef\anglelist{\fullanglelist} but gives me an error. But using \edef\anglelist{\fullanglelist} and \...
1
vote
1answer
144 views

Difference of lengths

This should be a very basic problem, but I can't find it anywhere: \documentclass[tikz,border=1pt]{standalone} \usepackage{fp} \usetikzlibrary{fixedpointarithmetic} \newlength{\radiustai} \...
0
votes
1answer
79 views

Refer to a page just before a label

Is there a simple way to refer to the page before a certain \label? Or is it possible to add or subtract a certain number (like the number of pages of an included PDF)?
8
votes
2answers
2k views

How to add numbers occuring in a text?

How make LaTeX to remember some numbers and output the total sum by calling another command? Consider this example: \documentclass{article} \usepackage{lipsum} \begin{document} The price of the ...
3
votes
1answer
543 views

How can I achieve textpos relative positioning in a document set to absolute positioning?

This is as close as I've got, but I can't work out how to do the calculation so that textblock accepts it: \documentclass[11pt]{article} \usepackage[paperheight=93.884mm,paperwidth=68.992mm,margin=...
2
votes
2answers
262 views

Use “length without unit” as scale parameter

I'd like to have a number variable in Latex to be used for the scale parameter in an includegraphics command (for example, to let all finite state machine pictures be scaled to the same size). This ...
1
vote
0answers
45 views

Calculations in TikZ [duplicate]

I need to draw two tangent circles with their common tangent. I drew the first circle centered at C radius CA, the tangent AB. Now I need to find the position of the center for the second circle on ...
1
vote
1answer
1k views

How to calculate a square root of the area?

I am trying to tikz-euclide the following picture (it is made in Geogebra). Two solid circles are equal. To guarantee that, the length of the red segment should be \sqrt{S}, where S is the area of ...
9
votes
1answer
344 views

Sort Numbers After Their Values

Consider the numbers 2^4, 4^2, 3^2, and 5^2 Is it possible to make LaTeX calculate the values of these numbers and then arrange then automatically according to their values? That is, in this ...
1
vote
1answer
190 views

Time calculation with spreadtab

I come from this question: How can I automatically calculate sums in a LaTeX table? I want to do the same but with "timing" calculations. So my example would look like this: \documentclass{article} \...
2
votes
3answers
868 views

How to convert \textwidth to mm and use the number as a command?

I am trying to convert \textwidth to other units I want and do calculations with the number (without the unit). How does one do this?
2
votes
3answers
2k views

Tikz and variables

I have defined two variables \def\aa{3} \def\bb{1} \def\qq{\multiply\aa by \bb} but when I try to use \qq in a \matrix command like \matrix[matrix of math nodes]{12 & \qq\\}; ktikz says: ...
4
votes
2answers
289 views

How to create a table with fixed-width cells and use cellcolor and multicolumn to create time bars? Or: How to substitute ganttbar with tabular?

Failing to combine a gantt chart with a table I now try to avoid the gantt chart by just using a tabular environment. However I like to keep some neat features of the pgfgantt-package and I'm facing ...
1
vote
1answer
150 views

Convert count into length

I want to decrease a length by a number (count). I tried some variations with \newlength{\temp} and \addtolength but I got problems there with the minus. I also tried variants with \dimexpr. The ...
3
votes
1answer
246 views

Output age on Birthday with Calendar \usepackage{montly}

I want to display the age of multiple people on my calendar. I can get the current year to come through with \the\year, but I can't figure out how to solve an equation in the option below (part of ...
4
votes
2answers
333 views

Multiply a label by 3 and print result

I would like to create a quiz for my students where the more parts I add to the question the more points it is worth. For each extra part, I want it to be 3 more points. In the following example, I ...
1
vote
1answer
827 views

Number formatting, addtocounter and calc package

I have been having troubles with the following issue: I am making an invoice template in LaTeX. I use \addtocounter to calculate values like subtotal, tax and total. This works fine, until the value ...
6
votes
1answer
499 views

In-place calculation of color with tikz and calc

Is it possible to calculate a color value like this in-place with tikz and its calc library? \filldraw[fill=black!{50-95.7/2},draw=black] (1,0) rectangle (2,1); %Gives a 'Missing number, treated as ...
1
vote
1answer
52 views

Mysterious summing: when calculator 's \ADD macro adds too much inside a table

Background: In my previous question, Robert Fuster taught me how to define a global variable using calculator package. I want to define a "counter" that also works with non-integers. I thus defined ...
1
vote
2answers
94 views

Using locally defined calculator commands inside tables (tabularx)

Inside a table, I want to draw rules. Their length equals the cell length times a predefined ratio (i.e. \rule{\ratio\linewidth}{1ex}). I use the \DIVIDE{A}{B}{\ratio} function of the calculator-...
2
votes
1answer
573 views

Positioning with `current axis` depending on limits?

I try to specify the x axis label position below the x axis arrow at the same baseline like the xticklabels. It works fine for most plots. However, when modifying the range of the y axis with ymin=...,...
1
vote
2answers
152 views

pfg conditional addition of a number

I have coordinates stored in \xCoor and \yCoor, and and converting these into polar coordinates to express on paper. I'm wanting this done automatically, and have been able to define: \...
2
votes
2answers
201 views

Draw path if distance is below threshold

I want to draw an intersection graph and for this purpose I have an array with coordinates. Now I loop through them and calculate the distance between the coordinates and if it below the radius of ...
25
votes
5answers
11k views

Simplifying square roots

I want to create a command that, for a given integer n, type sets a simplified square root of n. For example, the output of \rsqrt{4} \rsqrt{8} \rsqrt{18} \rsqrt{7} would be the same as that of 2 2\...
5
votes
1answer
285 views

How can I calculate the correct offset for fancyhdr when using geometry to change layout?

I have a document with the following configuration: a custom layout is defined using geometry in the preamble; custom headers/footers are defined using fancyhdr in the preamble; an alternative layout ...
2
votes
2answers
365 views

Tikz macro with calculation error

I'm very new to this so bare with me. To get the hang of macros I wanted to write a simple command to draw a square in tikz. Now I know there are a lot of ways to do this, but I want to be able to ...

1 2 3
4
5
11