The Stack Overflow podcast is back! Listen to an interview with our new CEO.

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

479 questions
Filter by
Sorted by
Tagged with
33 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 ...
37 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, ...
312 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{...
112 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} \...
146 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 ...
38 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{\...
53 views

Doing iterative arithmetic inside of an iterative tabularx

I'm trying to create a matrix table that will iteratively fill in the cells based on inputs that I can change. I originally tried the solution shown here, but I wasn't able to get Latex to properly ...
36 views

How to Calculate x-Position in a pgfplots with Information from a Table

Situation and Problem This question is a follow-up and based on marmots answers to this question and this. The general situation is described there. Now I want to simplify input. More specifically I ...
51 views

Distributing tikz elements evenly using positioning library and length precalculation leads to wrong result

I am trying to distribute a number of tikz elements/groups consisting of one \pic (= an icon) and one text \node (= label) each evenly across the length of the text area. I went about it by using a ...
134 views

ConTeXt: MetaPost graphic in overlay setups shifts between pages

Background A line is being drawn using MetaPost on an overlay, which is used as the background for a framed layer. The layer is embedded within a setups so that a dot's position on the timeline is ...
46 views

How can you typeset keys to get the impression of a Calculator?

How can you typeset keys to get the impression of a Ti-84 Calculator? The only responses I see are for French calculators.
97 views

NFSS: Can I scale fonts using fractions (more accurate) instead of decimals?

I would like to be able to pass a fraction expression to s*[<number>] in a \DeclareFontShape. The ultimate goal is to instruct LaTeX2e’s New Font Selection Scheme (NFSS) to perform more ...
339 views

Perform and show arithmetic with LuaLaTeX

The function I'm trying to create is one that takes two numbers and prints the result with some math. The following is my code: \documentclass[12pt,a4paper]{article} \begin{document} \directlua{ ...
465 views

Programmatically populating tables with probability data

I have the following template for a journal article featuring a basic table: The code looks something like this: \documentclass[jou,apacite]{apa6} \usepackage[utf8]{inputenc} \usepackage{amsmath} ...
98 views

Day of year for date format Month/Day/Year

I want to know "day of year" for a calendar. Here's an example: Date format : Month/Day/Year = Day of year 3/19/2019 = 78 3/19/2020 = 79 How can I find/display the Day of the year?
333 views

Exact Fraction of a length

I want to place some elements on my page for which I need to calculate their size. For my example lets say three of those elements should exactly occupy a \linewidth when put side by side without ...
64 views

Explicit artihmetic functions as alternative to calc

Is there a way to perform compile time arithmetic with explicit functions that respect dimensions? Here is a strawman example of arithmetic functions: \mul{4}{7} % expands to 28 \mul{4}{...
330 views

Inaccurate Calculations By pgfplots

In graphing a certain function using pgfplots (link here) I noticed a distortion in the curve that at first I assumed must have been a point of inflexion - but on investigating the maths, found that ...
36 views

how to get the monday of a years first week?

I would like to get the date of the monday of the first week of a year from only the year The purpose is a week planner where I put one week on each page and as most of the years first weeks monday is ...
277 views

How to do calculations with a LaTeX counter in a newtcolorbox environment?

I created a course summary box. In order to distinguish the summaries by school year, I have put an optional argument that displays the latter in the upper left corner (highlighted in yellow on the ...
145 views

Using the minipage enviroment inside \newcommand

i want to put the minipage enviroment inside a newcommand to avoid typing. \documentclass[aspectratio=169]{beamer} \usepackage[T1]{fontenc} \usepackage{lmodern} \usepackage[nomessages]{fp} \...
62 views

Aligned TOC with titletoc

I'm trying to get my toc build with the titletoc package as I'm using it to do other content tables with it. I get it to work almost like i want it to, but i have some issues: First of all i have do ...
72 views

Reference variables from package calculator in TiKZ

I have this code: \documentclass[letterpaper,12pt]{report} \usepackage[letterpaper, landscape, margin=0in]{geometry} \usepackage{graphicx} \usepackage[spanish]{babel} \usepackage{tikz} \usepackage{...
267 views

using division to calculate column size

I am converting from another format and creating tables with varying numbers of columns. I would like the column to be approximately layed out. If there are two columns, I want each column to get ...
1k views

Calculating the value of a formula without duplication, using LuaTeX or similar

If I have a numerical equation (i.e. no unknowns) in LaTeX, is it possible to have the equation typeset and evaluated in one go? I know calculations can be done relatively easily by embedding Lua ...
163 views

Adding width of text to node coordinate?

I am currently trying to position some text in the center of a square drawn in a tikzpicture, like so: However, I am having a bit of trouble. Take the following example: \documentclass{article} \...
225 views

Calculations on variables using LaTeX

I'm trying to do some basic calculations using values stored on a command, but it doesn't do the calculation: \newcommand{\lenghtHeatExchanger}{0.820} \newcommand{\heightHeatExchanger}{1.081} \...
114 views

Plotting a sequence of points defined by a simple formula

This shouldn't be difficult, but I cannot make it work. I expected this code to generate the plot a certain sequence of blue points on a black circle: \begin{tikzpicture}[scale=3] \def\n{7} \def\...
156 views

Using calc library with background package

Im trying to place a page border on every page using ornaments and the background package. I'd like to place this frame 0.6cm away from the border of the page and therefore I'm using the calc library ...
63 views

Why is binomial probability calculation wrong in pgfplots?

During my investigation of this nice question by @Sentient, I found a rather bizarre problem: Given the binomial parameters n=15 and p=0.7, @Sentient’s code produces some probability ...
66 views

Is there a problem rounding numbers with the calculator package?

I am using the calculator package to round a number and am having trouble in some cases. Is there an issue with what I am doing? I have included a MWE, uncommenting the line which rounds 0.0 will ...
35 views

Copy value from one spreadtab to another

I have two tables. The first only does calculations with spreadtab and has some final result that I tag (with spreadtab's ommand tab). Later, I want to reuse the value in another spreadtab, but I do ...
258 views

Scale images in proportion to textwidth

[I rewrite this post to address the questions posed in the comments.] First I formulate what I want to accomplish as clearly as I can. After that, I explain why I want to do that. My question: How ...
107 views

How TeX does its scale factor calculation? [duplicate]

With the following example \documentclass{article} \begin{document} \dimen0=1sp \dimen1=0.5\dimen0 \dimen2=0.99999\dimen0 \dimen3=0.999992\dimen0 \dimen4=0.999993\dimen0 \count255=\dimen0 \the\...
261 views

xcolor wrong conversion to cmyk color model

This is a MWE: \documentclass{article} \usepackage{xcolor} \begin{document} \definecolor{mycolor}{HTML}{4CAF50} \extractcolorspecs{mycolor}{\tmpmodel}{\tmpcolorspec} My color model: \...
528 views

Evaluate calculations on label

I would like to display the evaluation of data on node instead display the values. What I mean is instead \x + 3*\y evaluate to 0 + 3*0 it should display 0, the result of calculation. How to do that? ...
2k views

How to make table less cramped

I have a table which is defined using etoolbox but I'm not sure how to make it look less cramped. \documentclass{article} \usepackage{calculator} \usepackage{pgffor,etoolbox} \begin{document} \...
423 views

Rewrite a postscript macro in LaTeX

I wrote a macro in PSTricks with which the number pi is calculated approximately with the so-called "Monte-Carlo-Method". A table will be setup with two randomly chosen numbers x and y (each of ...
58 views

How to perform calculations(Not just display) [closed]

I have almost zero knowledge of TEX. I want an easy way to take common algorithms and use them to calculate values. This would ideally be done in the browser, but if not appropriate I could run on a ...
430 views

Support for “tables of functions”

Prior to that arrival of calculators, we were cursed (or blessed) with "log tables", tables of functions to a fixed number of significant figures Is there any (La)TeX support for such tables? Or ...
348 views

Addition & Multiplication of parameter and constant with unit

I want to substract and multiply with an optional parameter and a constant with cm as unit. Like this: \documentclass{article} \usepackage{changepage, xintexpr} \newcommand{\test}{ \begin{...
70 views

Feasibility of a Latex “Computation Verifier”

This may be more appropriate on stackoverflow, but as it pertains specifically to the existence of a utility for LaTeX, I thought I should ask it here. In my experience as an undergraduate, it's very ...
161 views

Cumulative binomal distribution using pgfplots

This is a follow-up question to Declaring a function to be used by pgfplots. The MWE \documentclass{article} \usepackage{pgfplots} \usetikzlibrary{arrows.meta} \pgfplotsset{compat=1.15} \begin{...
176 views

making a function to calculate average [closed]

How I can make to create a \newcommand to calculate an average between three numbers (can be numbers or numeric variables)? Usage would be \numberavg{<A>}{<B>}{<C>} Should be ...
184 views

Is there a sane way to visualize a division in “german style”

I need to visualize divisions in "german style". I managed to do it with TikZ, but it's a hard job! \documentclass[parskip=half]{scrreprt} \usepackage{tikz} \usetikzlibrary{chains} \begin{document} \...
1k views

How can I calculate geometric sequence in LaTeX?

I am trying to make my own command to calculate geometric sequence in LaTeX example: 10*4^(n+1) I've tried couple of things similar to this but non of them seemed to work: \newcommand{\...
145 views

Beamer: uncover frame number based on variable/counter

Current Situation: \begin{frame} % Part one of frame (including several \pause commands) % I am working on this % Part two (finished) \begin{itemize} \item<7-> Text \visible<8>{more ...
28 views

Treat content of a column as numbers, not a boxes

I'm making documentation for data communication protocol and trying to make a table column which shows an offset of the message fields, calculated for each field (table row) and takes field width ...