{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

3
votes
2answers
151 views

Perform simple calculations on user-defined variables

In my document, I have a user-defined variable like: \newcommand{\MyNumber}{30} Suppose, if I want to use a derivative of \MyNumber, it could be \MyNumber+10, 100-\MyNumber, 5*\MyNumber of ...
2
votes
1answer
131 views

Apply shift to (current axis.left of origin)

I was trying to improve the solution at Drawing lines in a plot and give them a label? by using Jake's answer at How to access \xmin, \xmax, \ymin, \ymax from within PGFplots axis environment. So, ...
5
votes
2answers
159 views

Is it possible to extrapolate data for a 3d-plot in pgfplots?

I am having several measurements to plot and would like to use something like a 3d surface from pgfplots. I am having a frame as outer border and a grid as measurement raster. The measured values are ...
13
votes
5answers
442 views

Transform big number into scientific format

I want to convert my big integer number into a shorter form; for example \convert{123456789} = 1.23 x 10^9 Is there any package which allows me to do so?
2
votes
3answers
223 views

Efficient way to indicate steps in a derivation

Imagine you're writing up a long derivation, and sometimes, the step to go from one equality to the next is nonobvious (for example, maybe it requires application of a theorem). In such cases, you ...
4
votes
1answer
118 views

Calculating averages and more

I am translating a Word document into LaTeX as a learning experience. Now there is this table, that already has hard-coded values. However, I would like to have it generic, so that changing a single ...
11
votes
2answers
317 views

Factorial (or, even better, binomial coefficient) function

Is there a function in l3fp for calculating factorials or, even better, binomial coefficients directly?
11
votes
4answers
369 views

Calculations in TikZ for iterative procedure

In many \foreach iterative procedures in TikZ I would like to relate the generic node called n\x -- where x is a natural number -- to another node the name of which is obtained by applying basic ...
3
votes
2answers
97 views

How to calculate number of symbols in chapter heading?

Is there a simple way to calculate number of symbols in headings? I'm planning to change color and size of every even to red 16pt and every odd to blue 10pt. Like this one made in word: Or maybe ...
3
votes
2answers
64 views

identify pieces of text automatically generated from input and new command

I have a document where many of its values are defined in a separate file via \newcommand, and added to the main document using \input in the preamble. The file being included is the output of a ...
0
votes
0answers
84 views

Software/Programm: latex-based math trainer

I need some help, because I searched the internet for quite a long time, but I wasn't successfull in getting a solution: I'm looking for a program/software, which helps me to practice math, which is ...
1
vote
1answer
87 views

How do I store the x or y value of a named node in tikz \draw?

A big part of the question above has already been answered: "Use the calc tikzlibrary and the let syntax". \begin{tikzpicture} \draw [help lines] (0,0) grid (4,4); \node (A) at (2,1) {A}; ...
3
votes
1answer
431 views

fp calculation variable

I want to do some calculations in a LaTeX document; the result of the first is used in the next calculation. I figured out that the fp package should do the job. Here is an example: ...
4
votes
2answers
162 views

How to calculate a new length?

What I want to do is calculate the actual size between the edge of the paper, and my header. \evenmarginsize and \oddmarginsize do not do this. \settowidth{\msize}{((\paperwidth - \textwidth)/2)} ...
3
votes
1answer
189 views

A problem with underfull \hbox in alignment (tabular*) and/or perhaps the calc package

I am getting an underfull \hbox in alignment (badness 10000) with tabular*. The warning goes away if I adjust the table width by 0.00002pt (as per the MWE below). The difference seems to arise ...
52
votes
11answers
2k views

How can I define a mathematical function as a LaTeX macro?

I am attempting to create a usable function within LaTeX such that its inputs are transformed mathematically. However, I cannot find any documentation that can perform such mathematical function ...
2
votes
1answer
183 views

How to calculate intersections of a line defined by a segment and an ellipse in tikz

EDIT Here's what I intended to ask, but didn't clearly formulate initially. The Tikz package intersections allows one to calculate and manipulate the intersection point of two non-parallel lines ...
17
votes
4answers
395 views

How can I convert units in LaTeX environment?

Example: \usepackage{siunitx} \newcommand{\temperature}[1]{\SI{#1}{\celsius}} \temperature{100} output: 100°C I would like something like: \newcommand{\temperature}[1]{\SI{#1+273}{\kelvin} ...
6
votes
1answer
216 views

Multiplication to macro argument

Since the baselineskip parameter for fontsize should better be 1.2 times of the font size, I'd like to define a macro which accepts only one argument and deduces the baselineskip from the font size. ...
5
votes
1answer
797 views

Usage of the \dimexpr command

I have MiKTeX 2.3 and its version of e-TeX does not support \dimexpr command. I do not want to update this MiKTeX now and wonder, is it possible to define the \dimexpr command, probably with use of ...
2
votes
0answers
69 views

TikZ Dimension too large Matrix Transform

I'm working on some matrix transformation code, and I keep getting ! Dimension too large. I traced it down to the following simple example. The problem does not occur when 2e-17 is replaced with ...
3
votes
1answer
138 views

Applying Matrix Operation Code

I'm (relatively) new to LaTeX, and I'm having a syntactic problem using the wonderful code here, which allows arbitrary matrix operations in LaTeX. I wrote a macro to generate certain matrices. ...
5
votes
1answer
162 views

Why doesn't the calc package work?

I'm trying to span two column in table (using xtabular) by the following command: \multicolumn{2}{|p{(\linewidth-\tabcolsep*2-\arrayrulewidth*1)*2/2}|} The package calc must calculate this ...
8
votes
1answer
573 views

Rotate a path around a point

I have a named path (a triangle). How do I rotate it around point A in various angles without recalculating points B & C? Here's my code. I want to create the red and green triangles by simply ...
6
votes
1answer
313 views

Expand macro in Latex

I have a pretty simple problem but have been unable to look for a simple answer. It's about macro expansion. Let's say I define 4 symbols: \documentclass{minimal} \newcommand* \A {1} \newcommand* ...
7
votes
2answers
211 views

Why a calc operation in width of beamercolorbox doesn't work?

Trying to answer How to add the footnote in the right down corner with the background color(only page)&change time background color I wanted to calculate beamercolorbox width as ...
6
votes
4answers
313 views

Sum of values spread across tables in document? (like in Word)

My document is structured as follows: * Bla bla bla Quantity | Item | Price per item | Total price ---------+----------+----------------+------------ 5 | Sandwich | 5.00 | ...
1
vote
1answer
294 views

Can I calculate a square or square root to include as coordinates in a tikz picture?

I am trying to draw the folding lines of a paper plane. This as a template for my kids to learn how to fold a paper plane. I came as far as: % based on ...
6
votes
4answers
300 views

Is there a better way to check divisibility in LaTeX?

I want to draw a trimmed ruler, for example, from 2.3cm to 3.9cm where the distance between two consecutive marks is 1mm. I have difficulty to efficiently check whether or not the counter is a ...
6
votes
2answers
172 views

Delayed expression evaluation giving wrong result

I have made my own lists. I want to refer to them outside the lists. If I do a calculation using counters at a certain point in my list hierarchy, say \alph{listcounter}, how do I freeze that result ...
7
votes
2answers
128 views

Numerical calculations using PSTricks

Assume I have defined a constant \valueA as \def\valueA{25 2 sqrt sqrt mul } I would like to devide this value by the square root of 2, so I tried \pstFPdiv\valueB{\valueA}{2 sqrt} but this is ...
22
votes
4answers
1k views

How to add, subtract, multiply, and divide in plain TeX?

I find many cases where I need to calculate many numbers, using adding, subtracting, multiplying, and dividing, but it would save much time if TeX could simply compute these for me. This is a sample ...
1
vote
1answer
315 views

Using multicolumn and multirow together with spreadtab

I tried this piece down \documentclass[a4paper,12pt]{article} \usepackage[inner=0.75in,outer=0.65in,top=0.75in,bottom=0.65in]{geometry} \usepackage{multirow} \usepackage{spreadtab} ...
3
votes
1answer
473 views

Calculations in Table using spreadtab

When I use this piece, \documentclass[a4paper,12pt]{report} \usepackage[inner=0.75in,outer=0.65in,top=0.75in,bottom=0.65in]{geometry} \usepackage{multirow} \usepackage{spreadtab} \usepackage{url} ...
3
votes
1answer
589 views

Tikz: Scale coordinates perhaps using the calc package

I've drawn a rectangle like this: \draw[color=orange, fill=orange, opacity=0.1] (Q3term1) rectangle (Q3term2); and essentially, what I want is to do is stretch the rectangle by 10% horizontally and ...
10
votes
2answers
303 views

Lua calculation fails with a negative number

The macro runs except when the real b is negative. Why ? \documentclass[a4paper,12pt]{article} \usepackage[upright]{fourier} \usepackage[no-math]{fontspec} \usepackage{luacode,luatextra,luaotfload} ...
13
votes
1answer
184 views

Using calc-like (calc Package) Commands within LaTeX3/expl3

In my pursue to switch as much as possible from LaTeX2e code to LaTeX3/expl3, I got stuck with the usage of some of the calc package facilities. I've read of the l3calc package, but it seems it is ...
6
votes
2answers
224 views

Use input inside a spreadtab environment with calculations

My aim is to create a command for inserting tables, which will format the table, and add calculations on its values, given a file containing the raw data of the rows only. ...
7
votes
1answer
641 views

dimexpr: multiplication with constant real factor from macro

I want to multiply a constant from a macro with a deimension using dimexpr. When using real numbers the decimal point and the decimal digits are typeset behind the result and the result is a ...
9
votes
2answers
382 views

Fixed Point Arithmetic: Why does the fp work sometimes but others it errors?

Why does fixed point arithmetic like to error on parts of the code that aren't doing any math? I am using the package to improve the calculation of some angles I have it printing out, but it is ...
5
votes
1answer
126 views

How to cherry pick from datatool DB and calculate totals

I have a CSV file with current prices/item. These prices are updated regularly. I have loaded a DB with datatool. I would like to use these prices to calculate totals according to quantities I have ...
8
votes
2answers
292 views

How can you make custom counter display types?

I'm a comp sci prof working on an exam for my students in LaTeX, using the exam class. I like to throw in a few in-jokes here and there. Unfortunately, the class breaks if you try to use 0-indexing on ...
1
vote
3answers
707 views

How can I draw tikz arrows on a calculated triangle?

I am going to need a lot of vector triangles and would like to do them with TikZ. My TikZ experience is close to not existing. Therefore I would like to ask you, if there is a possibility to draw ...
5
votes
2answers
599 views

TikZ: Make node height span several others

How can I make the Z node span the total height of the ABCD column? My current code is: \documentclass{article} \usepackage{tikz} \usetikzlibrary{calc,positioning} \begin{document} ...
5
votes
1answer
269 views

How to preserve lenghts to use with \includegraphics scaling, when calculating them with pgf

This question is related to my earlier question here: How to define a macro that uses image width and height to define a variable for later use . There you can find a full MWE of the problematic code. ...
8
votes
1answer
250 views

How to define a macro that uses image width and height to define a variable for later use

Ok, the title might be a bit cryptic and my question is a bit lengthy, so please bear with me. What I want to do is: I have two images with different aspect ratios that I want to place next to each ...
23
votes
4answers
566 views

Day of the year

I'm using the day of the year a lot in my documents and I wonder if I can have LaTex calculating it for me? Example: 2013178 where 2013 is (surprise) the current year (which I know could be achieved ...
0
votes
1answer
116 views

Autosum Table contents in LaTeX

I am trying to add the contents of a latex table, having something like this in mind: How can I automatically calculate sums in a LaTeX table? But this solution does not work for me... Is there any ...
3
votes
0answers
32 views

Integer operations on cross references [duplicate]

I would like to perform integer operations on a cross reference. \documentclass{article} \usepackage{etoolbox} \begin{document} hello \label{here} \ifnumequal{\pageref{here}}{1}{You are on the 1st ...
3
votes
1answer
230 views

Calculating coordinates with postscript [duplicate]

I want to calculate coordinates for some lines using pstricks. How can I do this? Example: I want something like (0.5*cos(45) + 8, 0.5*sin(45) + 8) and use coordinate pairs like this one to ...