{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

4
votes
1answer
36 views

Calculator package and Math Times Pro 2

When I try to use the calculator the mtpro2 package at the same time I get an error message. Recently I found out that this issue has something to do with the \SQRT command. ...
12
votes
3answers
255 views

Drawing the three altitudes of a triangle with TikZ; incorrect orthocenter

You probably know that if you draw all three altitudes of a triangle, they will meet at a single point, the orthocenter. I'm trying to draw a picture that shows the intersecting altitudes with TikZ ...
3
votes
1answer
30 views

Using a variable to calculate the tax on an invoice

I've customized a class to obtain the tax value and also the total amount in an invoice. This is the portion I need to modify: { \hline\hline\hline {Valor venta} & & & {S/. \total{cost}} ...
4
votes
1answer
45 views

Length operation within a newtcblisting

Consider the following code: \documentclass[10pt,letterpaper]{article} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage[french]{babel} \usepackage{calc} \usepackage{tikz} ...
23
votes
5answers
1k views

Reducing fraction using LaTeX 3

Consider the following: \documentclass{article} \begin{document} \noindent Can I make \LaTeX{} reduce a fraction automatically?\\[\baselineskip] For example, I would like the fraction \[ ...
11
votes
4answers
442 views

Using LaTeX as calculator [duplicate]

I know that exist several packages, like fp that allow to make all kinds of computations. But I do not understand the correct way to use them. I need some simple examples of multiplication and ...
1
vote
1answer
14 views

Unable to make crop work with dynamic length and width from calc

I am using using XeTeX, Version 3.1415926-2.4-0.9998 (TeX Live 2012/W32TeX) to design a book cover. I thought of writing a generic document with customizable sizes of book width, height, bleed and ...
2
votes
1answer
14 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
26 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
338 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
28 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
102 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
45 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
46 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
267 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
136 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
55 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
90 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
43 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 - ...
5
votes
3answers
108 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
94 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
66 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
418 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
119 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
96 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
182 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
125 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
249 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
139 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
68 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
47 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
114 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
141 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
587 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
79 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
407 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
54 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
282 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
238 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
552 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
168 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 ...
7
votes
3answers
794 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
137 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
139 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
67 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
144 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
107 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
177 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: ...