{calculations} is about calculations in (La)TeX documents. A popular package is calc although may other also exist (fp, pgf, and LaTeX3 packages).

learn more… | top users | synonyms

2
votes
1answer
13 views

Package that receives a number #1 and return #1-1

I'm working with a counter but I'm having some problems with the index. This is my problem: I'm using a command with \arabic{#1} with some input #1. But I need to print \arabic{#1-1}. I would like ...
3
votes
1answer
20 views

Computation of size in titlespacing

Consider the following example: \documentclass[11pt,a4paper]{book} \usepackage{lipsum} \usepackage{titlesec} \newlength{\textsize} \makeatletter \setlength{\textsize}{\f@size pt} \makeatother ...
7
votes
2answers
307 views

Length plus minus other length?

Consider the following example: \newlength{\textsize} \makeatletter \setlength{\textsize}{\f@size pt} \makeatother \setlength{\parskip}{12pt plus 1pt} % WORKS \setlength{\parskip}{\textsize plus ...
1
vote
1answer
18 views

Inline calculation gives `Could not parse input` error in PGFplots

The inline calculation exp(\tick) in PGFplots gives me a Could not parse input error when compiling the code \documentclass[margin=1cm]{standalone} \usepackage{pgfplots} \begin{document} ...
2
votes
1answer
54 views

Tikz coordinate calculations inside foreach

As part of a drawing that will go with an explanation of diffraction, I want to draw the "outer rays" of a beam of light and draw several rays in between. An MWE of how I'm going about this is shown ...
1
vote
0answers
24 views

Convert decimal to integer in Visual TeX IDE [duplicate]

I want to convert decimal number to integer in latex program with Visual Tex IDE. I found this function \pgfmathparse{ceil(2.7)} which requires installing the package pgfmath and pgfkeys. And after ...
2
votes
3answers
44 views

Using reference labels in mathematical calculations

EDIT: This answer points to a good solution. I wanted to use reference labels in mathematical calculations and was under the impression that if I use the calc package, it will be rather ...
2
votes
1answer
37 views

Make \droptotalpoints look like \droppoints (exam documentclass)

To save typing, I have \newcommand{\q}{\question[1]} defined in my exam documentclass. Then, after the question, I use \droppoints to get [1 pt] printed in the right margin. But sometimes, my ...
5
votes
1answer
252 views

Simple arithmetic in an exam

How can I do some simple calculations in LaTeX? Specifically, I want to divide \numpoints (part of the exam package) by 1.10. That is, I want to do something like this: Grade: ...
5
votes
2answers
91 views

Missing number, treated as zero with amsmath and calc

This simple code produces "Missing number, treated as zero" \documentclass{article} \newcounter{test} \newcounter{testtwo} \usepackage{calc} \usepackage{amsmath} \begin{document} ...
2
votes
1answer
50 views

Why is \glueexpr used in etoolbox's \deflength instead of \dimexpr

Consider the following snippet from etoolbox: \newrobustcmd*{\deflength}[2]{% \ifundef{#1} {\etb@noglobal\etb@err@nolen{#1}}% {#1\glueexpr#2\relax}} Maybe I do not understand the ...
1
vote
3answers
66 views

Multirow and rotated column headers

I want to typeset a table with rotatetd column headers (so far it works) stretching over multiple rows. The problem seems to be that multirow does not adjust the tables row heights, thus I have to do ...
4
votes
1answer
40 views

TikZ: Move points towards center

I want to move a set of points towards the center of my figure, but I want the distance to depend inversely on the relative distance to the center. Thus, for instance move a point at (-2,-3) to ( -2 - ...
4
votes
2answers
68 views

Comparing calculated real numbers

"\ifdimless" can compare two real numbers. But, how can we feed the result of a calculation to this function ? \documentclass[]{article} \usepackage{tikz} \usetikzlibrary{calc} \usepackage{etoolbox} ...
6
votes
1answer
89 views

Modifying the equation number with simple calculation

I am trying to modify the equation numbering as follows \renewcommand{\theequation}{FFF(\arabic{SomeCounter}).\arabic{equation}}, where SomeCounter is a counter defined as \newcounter{SomeCounter} ...
4
votes
0answers
63 views

guess a number proportional to another [closed]

This is a challenging question. I am not sure how to begin coding it, or whether it is easily possible in TeX. I wish to define a command that takes in input of a simple formula such as Z = X x N + ...
9
votes
4answers
380 views

Chain addition mod 10

Is it possible in LaTeX create a table-like structure that represents successive modulo-10 addition of the individual units modulo 10 with wrap-around? This is referred to as chain-addition. For ...
5
votes
1answer
87 views

Calculations in PGFplots \addplot3 inline table

Plotting a rectangular patch with the code \documentclass{standalone} \usepackage{pgfplots} \begin{document} \begin{tikzpicture} \begin{axis} \addplot3[patch,patch ...
5
votes
1answer
94 views

Calculate quartiles of data set

Comment: The following code is taken from egreg's answer here. Code: \documentclass{beamer} \usepackage{lmodern} \usepackage{booktabs} \usepackage{siunitx} \usepackage{xparse} \ExplSyntaxOn ...
2
votes
1answer
120 views

Calculating a point in TikZ that completes a right trangle?

I am trying to draw an incline plane free body diagram for my Physics class ( a little like the one pictured here): Currently, my code looks like this (using TikZ, tkz-euclide, TiKz libraries calc ...
6
votes
1answer
108 views

Calculate axis limits depending on depicted data

In a pgfplots axis environment, I want to make the axis limits dependent on the depicted data or some other data. Consider the minimum working example \documentclass{standalone} ...
1
vote
3answers
189 views

How to calculate a percentage and use result in progressbar?

With the progressbar package, I want to show bars on pages depending on a counter. Progressbar works like: \progressbar{0.7} I use the calc package anyway, so I thought it should be easy to ...
2
votes
1answer
105 views

Tikz 3d trimetric view coordinate calculation bug

I'm trying to draw a line in the x-y-plane and circles in the y-z-plane at constant x position. Problem is, that the circle is far out of position (x-coordinate of center point of the circle is ...
3
votes
1answer
64 views

Parse numerical value from glossaries variable

Can I parse the text returned from \gls*{...} and get latex to recognize it as a numerical variable so that I can use it in a calculation? This calculation could be done using calculator, fp, calc or ...
1
vote
1answer
33 views

How to print a past value of a counter [duplicate]

I have this counter which I have defined using \newcounter{myCounter}. Printing the value of myCounter can be easily done via \arabic{myCounter}. How can I print the value of (myCounter - 2)?
5
votes
1answer
106 views

Does anyone have an explanation of the algorithm for calculating weeknumber by Taco Hoekwater?

Taco Hoekwater wrote an algorithm in 2006 calculating the weeknumber. The algorithm mostly computes the weeknumber correctly, but apparantly misses out for the first 4 days of 2015. Without an ...
4
votes
1answer
95 views

Is it possible to use the width of one TikZ node to calculate the width of another?

Question Is it possible to store the variable width of a node and use that width to calculate the text width of another node in TikZ? Example I have a list of similar nodes side-by-side (inline, ...
8
votes
3answers
542 views

What is the best way to do math inside LaTeX macros?

I'm interested in writing a little personal package (or sharing it if it's actually useful) to speed up typesetting Trigonometry. I'd like commands like ...
4
votes
1answer
77 views

How can I calculate the distance added between a title and a titlerule?

Question How can I calculate the distance after a title such that I can place a node where the title rule would go? Example I would like a bar to drop from the top righthand corner of the page down ...
4
votes
3answers
353 views

How to round number to two digits after the decimal place and have a comma separator?

I have the following function: % Formats inputed number with 2 digits after the decimal place \newcommand*{\formatNumber}[1]{\FPround{\cost}{#1}{2}\cost} % \cost goes through some calculations ...
0
votes
0answers
51 views

Perpendicular line to a line on a 3D plane

\documentclass{standalone} \usepackage{pgfplots} \usetikzlibrary{calc} \pgfplotsset{compat=1.10} \begin{document} \begin{tikzpicture} \begin{axis}[ view={125}{35}, axis lines=center, ...
2
votes
1answer
203 views

How to solve the Arithmetic overflow problem?

I was making an article and everything was going alright, when suddenly I got an error: The error: Arithmetic overflow. \calc@Acount l.78 ...qwe dqweqwrwf qewrfrQ aRF EFCas drfFR}{62} My article ...
4
votes
1answer
230 views

How to divide two lengths and get a result as an integer?

I have a problem dividing two lenghts and getting a result as an integer. I was trying to use this package: \usepackage[nomessages]{fp} It didn't really work for me. I tried it multiple ways, but it ...
21
votes
2answers
525 views

Sum of finite series using LaTeX 3

Is it possible to calculate the value of a finite series, say, using LaTeX 3?
2
votes
1answer
135 views

How can I put a minipage that fits to the actual line width inside of a TikZ Node?

Question I would like to put a minipage environment inside of a tikz node. I know this is done already with the align=left command, but if you set a minimum width of the node to \linewidth, then the ...
6
votes
3answers
662 views

Tikz: drawing in perspective

I am working on drawing a beam in perspective. I have my point I want to use as the perspective point (10, 3). What would be the way to draw along this line? For instance, consider ...
3
votes
1answer
113 views

calculating polar coordinates with tikz

Random polar coordinates has an example of the general sort of syntax I'm aiming to follow. For some reason the result is not working as intended. In the MWE, I've commented out the line where I ...
3
votes
1answer
131 views

Why can't I use a variable from a \foreach loop inside a calc library macro?

Question Why can't I use the \foreach variable as a percentage in my calculations with the calc library of TikZ? Sample Code In the following, I could replace the variable \mypercentage with an ...
3
votes
0answers
31 views

Formatting numbers the Indian way [duplicate]

This is a follow-up question to Handling numbers and calculations. The numbers printed by \num[group-separator={,},group-minimum-digits=4]{\the\numexpr(5000)\relax} will produce comma separated ...
2
votes
2answers
52 views

Handling numbers and calculations [duplicate]

I have to deal with a lot of numbers in my latex documents. So far, I have been using a rudimentary \newcommand{\VarOne}{1000} to define \VarOne and then use it as it is using \VarOne{} in the ...
5
votes
1answer
143 views

Adding a number to every element

I have a table, whose entries are a list of one or more numbers. Now, I need that all numbers in the table are to be incremented by 1. For example, say, I have the table: \documentclass{article} ...
3
votes
1answer
74 views

global variables and/or array of variables

I'm looking for a way to obtain (in tex/latex - still difficult for me to determine the difference - I guess it should state latex) run-time defineable global variables to be used with the fp package. ...
3
votes
2answers
159 views

Compute the difference between two time points on different dates

This is a follow-up question to How to compute the difference between two time points (e.g., 11:30 am and 01:20 pm => 110 min)?. Consider the code from David's excellent answer here: ...
1
vote
1answer
61 views

How to reuse a term in calc macro of latexcalc?

Although latexcalc seems to be no longer in active development, I'd like to know whether it is possible to reuse a term which I want to both display and calculate, but only maintain once, e.g ...
1
vote
1answer
28 views

interactive tooltipp improvement

according to this article, especially to AlexGs tooltipp code [1], it seems to me, that if the text inside the tooltipp will exceed more than one line, it disappears outside the page. It would be ...
0
votes
0answers
44 views

Command-scopes in a tabular-environment

I'm trying to use a command which aggregates some values. When using it with normal text, it is properly working but if I call the command in a table it seems that there is a problem with scopes or ...
8
votes
2answers
325 views

How to do simple calculation in latex tables

Here I wish to do three things: 1) I want my table to be like this one below whereas mine is 2) I want numbers to appear in the same format as their heading p (in bold) 3) I want latex to ...
3
votes
1answer
52 views

spacing from calculator package

I'm trying to include images and overlay them with their width and height info in mm. I save the image to a box and then use the calculator package to calculate the mm width and height of that box. ...
6
votes
2answers
145 views

Trying to convert Hrs:Mins to Mins

I am having a bit of trouble trying to convert a time format from Hours:Minutes for instance 12:05 into 12*60+5 = 725, ie I would like to use 725 as a number of minutes. I am already using the number ...
4
votes
2answers
177 views

Calculator and calculus package: result [.] dot instead [,] comma

My codes, \documentclass{article} \usepackage{calculator} \usepackage{calculus} \newcommand\teo{3} \newcommand\job{,5} \begin{document} \MULTIPLY{\teo}{340}\W \MULTIPLY{\job}{5605}\WW ...