{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

1
vote
1answer
41 views

Checking a number with calculator package [duplicate]

I have a problem about calculator package, I need check if #1 is a number or not, could I use conditional command? ex: \def\CHECK#1{ % if #1 a number \if...? #1 is a number \else #1 is not a ...
3
votes
2answers
91 views

create node of own macro with tikz

i would like to draw a network of multiple queues. To build one node i would like to make a node out of this macro (DrawStation) and give it a name. \usepackage{tikz} \usetikzlibrary{positioning} % ...
3
votes
1answer
33 views

Perform math operation with values of \labels

I use \label to index the number of items in several environments. I wish to perform the sum of the quantities reported by those labels. Here is a working example: \documentclass{article} ...
2
votes
1answer
42 views

Creating a Test-Template

after hours of searching and trying i want to ask my special question. I'am a teacher and want to create a template for my test-document. Therefore i need to add points in every task. To control the ...
2
votes
2answers
105 views

Automated Creation of Questions and Solutions for a Worksheet/Exam

Overview My title is the not the best, and I will edit it if there are any better suggestions! In a nutshell, what I am trying to achieve is to randomly change numbers in a maths question and have a ...
12
votes
1answer
133 views

Understanding etoolbox macro \deflength

The etoolbox package documentation says about \deflength: This command may be used as a drop-in replacement for \setlength. I am having trouble getting it to work with the \minof macro from the ...
6
votes
1answer
58 views

Use floating point with calc

I wanted to use a pie chart in my document and tried this code example: http://www.texample.net/tikz/examples/pie-chart/ Now this seems to work perfectly with integer values but as for floating point ...
3
votes
2answers
47 views

overloading functions of the fp package

I have a document with several commands that store numeric variables inside an extra macro. This extra macro will highlight that text so I can track them in the printed document. Like so: ...
12
votes
2answers
302 views

Delete commas within numbers

To use package{calc} for calculation, number should not include any commas. So I tried to use \def\commatonone #1,#2.00 {#1#2} to get the number without commas. \documentclass{article} ...
3
votes
2answers
94 views

How to increment a variable in beamer slide?

I have this code: \documentclass{beamer} \mode<presentation> { \usetheme{Warsaw} } \usepackage{tikz} \AtBeginSection[] { \begin{frame} \tableofcontents[currentsection] \end{frame} } ...
2
votes
3answers
99 views

Evaluate binomial coefficient with \pgfmathtruncatemacro

How is it possible to evaluate complex formulas like \binom{2^{4}-3}{2^3} with \pgfmathtruncatemacro ? I want this to evaluate to 1287. What already works: \begin{tikzpicture} \foreach \l ...
2
votes
2answers
72 views

Date Calculations (output should be the fixed day of the month)

I'm building a LaTeX document that already got the date from other files. The date showed as 23 November 2015 as the example (by \today). Then I need to output another date related to this original ...
3
votes
3answers
65 views

Getting the `\pageref` out from under `hyperref`

I thought I was pretty cool when I modified \ref to also print a page number when the referenced float was more than a few pages back. But I really want it to be a nice link using the hyperref package ...
8
votes
1answer
83 views

Struggle with floor- and ceiling-functions in pgfplots

Could anyone help me with this struggle? I don't get, why the floor- and ceil-functions in the axis-environment of pgfplots and in floating text differ from each other. Aren't they both processed by ...
4
votes
2answers
120 views

Calculation of an angle in tikz (fraction of light) including sin^-1

I want to calculate the deviation angle \beta with the law of Snellius in a tikzpicture. My code is \documentclass{article} \usepackage[utf8]{inputenc} \usepackage{amsmath} \usepackage{array} ...
3
votes
0answers
29 views

How to do math on overlay arguments using pgfkeys (handle numbers and ranges)

Context I'm trying to do some basic operations on arguments on pgfkeys, and got stuck while trying to do simple arithmetic on them. Thankfully, egreg gave a nice solution for handling the arithmetic ...
4
votes
1answer
29 views

How to do math on pgfkeys arguments and asign them to other keys

I'm trying to reduce the work load of applying some overlays over and over with different numbers. However, I need to compute for a given frame the next or previous one, thus needing to do simple ...
4
votes
1answer
105 views

Problem with calculutor, calculus

MWE \documentclass[a4paper,11pt]{report} \usepackage[turkish]{babel} \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} \usepackage{lmodern} \usepackage{calculator} % 2014/02/20 v.2.0 ...
3
votes
1answer
109 views

Using a macro inside a Tikz coordinate calculation

I am trying to create a general macro that prints a particular custom character, based on an answer to a previous question of mine. Here is a minimal (non-)working example: %!TEX encoding = UTF-8 ...
2
votes
3answers
59 views

How can one number be divided by another number to give a real number result (not an integer)? [duplicate]

How could a function a bit like basiceval be written to give a real number result as opposed to an integer, making the third calculation here more accurate? \documentclass[american, a4paper]{report} ...
0
votes
2answers
81 views

Numerical calculations inside table environment

I am doing a coursework in mechanics and would like to write both the theory and calculations in LaTeX. However, as design is iterative process, I would like to escape the tedious cycle of: Select ...
4
votes
2answers
141 views

Tikz: Math with coordinates

I need to extract the coordinates of a node into a variable. I've tried \pgfextractx \documentclass[11pt]{article} \usepackage{fp} \usepackage{tikz} \usetikzlibrary{calc} ...
6
votes
1answer
84 views

calc breaks assoccnt? [closed]

I want to use totcount to get the number of parts and chapters in my document. To get the correct number of chapters in the presence of appendices, I use assoccnt (see totcount gives wrong chapter ...
3
votes
2answers
66 views

Show variable name, measurement unit and value in a single command invocation

I am using the fp package to write a coursework in mechanics and calculate the numerical values on the fly. Here is some example code: \documentclass{article} \usepackage[nomessages]{fp} % ...
2
votes
1answer
64 views

Calculation in a TeX function. How to do it?

I don't know anything of TeX but would like to improve a function. Here is the initial function: \newcommand{\setnewvsize}[1]{% \global\paperheight\dimexpr#1+\initialVerticalInset\relax% ...
3
votes
1answer
107 views

Determine width of a milticolumn cell

I am attempting to draw a rectangle within a multicolumn, and would like it to span the width of the cell and be consistant with a similar rectangle drawn in a standard cell. I am struggling to ...
6
votes
4answers
265 views

Error using \widthof inside tikzpicture

\documentclass{article} \usepackage{tikz} \usepackage{calc} \begin{document} \begin{tikzpicture} \newlength{\TextWidth} \setlength{\TextWidth}{\widthof{Text}} %\node[draw,text ...
5
votes
2answers
271 views

Enumerate every third item

Is there a way to have a enumerate environment that increment the counter every three item? I already see this question: Enumerate pattern: 1, 1, 2, 2, 3, 3, ... , etc but I'm looking for something ...
1
vote
0answers
92 views

Insert negative of \widthof into \hspace without defining a newlength

Following MWE does not work: \documentclass{article} \usepackage{calc} \newlength{\charwidth} \setlength{\charwidth}{\widthof{$-$}} \begin{document} \centering $\infty$ \centering ...
4
votes
1answer
56 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
388 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
73 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
69 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} ...
27
votes
5answers
1k views

Reducing fractions automatically using LaTeX 3

Consider the following code: \documentclass{article} \begin{document} \noindent Can I make \LaTeX{} reduce a fraction automatically?\\[\baselineskip] For example, I would like the fraction \[ ...
11
votes
4answers
603 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
20 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
21 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
41 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 ...
8
votes
2answers
500 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
51 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
257 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
57 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
73 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
307 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
316 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
61 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
173 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
49 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
159 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} ...