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
1answer
66 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} \...
6
votes
3answers
132 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 ...
1
vote
0answers
35 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{\...
3
votes
0answers
52 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 ...
1
vote
0answers
35 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 ...
1
vote
2answers
47 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 ...
6
votes
2answers
111 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 ...
0
votes
0answers
43 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.
0
votes
1answer
82 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 ...
5
votes
3answers
302 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{ ...
5
votes
2answers
444 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} ...
0
votes
2answers
85 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?
6
votes
1answer
310 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 ...
2
votes
2answers
59 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}{...
5
votes
2answers
265 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 ...
0
votes
1answer
32 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 ...
5
votes
2answers
244 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 ...
3
votes
1answer
111 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} \...
0
votes
2answers
56 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 ...
1
vote
2answers
63 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{...
2
votes
2answers
164 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 ...
12
votes
4answers
995 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 ...
2
votes
3answers
136 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} \...
5
votes
3answers
202 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} \...
0
votes
1answer
97 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\...
2
votes
3answers
139 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 ...
5
votes
1answer
55 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 ...
2
votes
1answer
62 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 ...
0
votes
0answers
32 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 ...
1
vote
2answers
227 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 ...
2
votes
1answer
101 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\...
5
votes
2answers
219 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: \...
6
votes
2answers
426 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? ...
8
votes
5answers
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} \...
8
votes
3answers
412 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 ...
1
vote
1answer
57 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 ...
5
votes
4answers
372 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 ...
1
vote
1answer
291 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}[2][1]{ \begin{...
1
vote
0answers
69 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 ...
2
votes
1answer
148 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{...
0
votes
2answers
137 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 ...
6
votes
1answer
177 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} \...
7
votes
4answers
960 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{\...
1
vote
2answers
118 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 ...
0
votes
1answer
25 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 ...
3
votes
1answer
82 views

Show logical calculations

For my students, I'd like a macro to show logical calculations bit by bit ( AND, OR, XOR ) between two numbers in base b ( b integer from 2 to 36) . Parameters would be number1, number2 and b; ...
1
vote
0answers
130 views

Show calculations in base b

For showing to my students, I'd like a macro who shows how add, and substract numbers in base b , with b =2 or b=16. Parameters would be : number1, number2 , et base b in wich number1 and number2 are ...
1
vote
1answer
262 views

How can I illustrate point decimal number to binary conversion

I'd like to convert point decimal number to binary as made by the command \baseexpansion in the jfbu's answer to the question: How can I illustrate decimal to binary conversion? For example, I'd ...
0
votes
1answer
227 views

Calculation with Latex

I am currently trying to create an exam template for my institute. What I want to receive is like this: Task 1 [8 Points] (text text text) Subtask 1.1 [3 Points] (text text text) Subask 1.2 [5 ...
1
vote
1answer
53 views

Add Rows to Table With Macro (calc fields result the same for each row)

I use as template macro from this articale: Add Rows to Table With Macro. All work fine if values in cells not to calculate. But othewise results of calculation is the same for each row. How to avoid ...