{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
47 views

Tikz: How to combine orthogonal edge syntax with coordinate calculation? [duplicate]

I'm trying to combine the syntax for orthogonal edges (p |- q) with the syntax for calculation relative coordinates ($ (a) + (1,0) $). Example: \draw ($ (node1.south) + (1,0) $) to ( ($ (node1.south) ...
6
votes
1answer
66 views

Add (n) working days to a specific date

My g-brief will contain something like "I have noted a deadline for your answer of ten working days until...". Is there a package or way to add n working-days (ie. mon-fri, let's not over complicate ...
2
votes
1answer
53 views

How to get float numbers as parameter of \newcommand

I have defined a \newcommand function like into this code: \documentclass{scrartcl} \usepackage{pbox,calc} \newcounter{pointsExo} \setcounter{pointsExo}{4} \newcounter{pointsSousTotal} ...
4
votes
1answer
63 views

Resize tikzfigure in tcolorbox depending on height of tcolorbox

in my book I got many different type of boxes so I made some macros placing the boxes automatically according to their arguments. That's one of them. So far I made some boxes that have big "+" and ...
10
votes
3answers
679 views

TikZ coding style

I've got a piece of TikZ code here and since I am only starting to learn how to use it, I wanted to ask whether this code would be regarded to be ok or rather completely unreadable and what I can do ...
9
votes
1answer
125 views

Floating point and fixed point arithmetic in LaTeX3: Where documented? Safe to use?

Since about twenty years, I use a private fixed point arithmetic package which I would like to replace by something newer and better. There is the equally old (but good) fp package, but LaTeX3 is ...
12
votes
3answers
325 views

Formatting numbers while printing

Is there a way to format number strings while printing? Suppose I have the following declaration: \newcommand{\MyNumberA}{40} \newcommand{\MyNumberB}{60} The following in the text: ...
3
votes
1answer
51 views

How do I do currency calculations in text?

I am writing a long document, which has a lot of money references in Indian rupees (easily typeset using package tfrupee). Some definitions peculiar to Indian money before we proceed: Its grouped ...
2
votes
0answers
42 views

Perform spreadsheet-like calculations and display formula and result

Currently I am performing calculations using excel and manually formatting them for printing using an online LaTeX equation editor. The end result looks something like this: As you may imagine this ...
6
votes
1answer
44 views

Dynamic calculation within regular expression quantifier in LaTeX3's l3regex package

I am trying to do some simple calculations to be applied to a regular expression quantifier used in l3regex's \regex_replace_all:nnN function. I've built my code around what I found here: Defining a ...
1
vote
1answer
69 views

Effect of adding plus and minus to \includegraphics

I have a document with a lot of pictures. The exact scale of the pictures isn't all that important. Is it possible to allow the pictures a little bit of "stretch" to help squeeze everything together? ...
3
votes
2answers
84 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
37 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
120 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 ...
2
votes
3answers
92 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
96 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
231 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
209 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
72 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
46 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
50 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
62 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
79 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
99 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
61 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 ...
51
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
139 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
299 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
109 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. ...
4
votes
1answer
335 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
56 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
104 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
115 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
172 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
171 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
143 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
262 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
197 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
208 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 ...
5
votes
2answers
113 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 ...
0
votes
0answers
106 views

Spread tab and Calculation in Table

I tried the following, \documentclass[a4paper,12pt]{article} \usepackage[inner=0.75in,outer=0.65in,top=0.75in,bottom=0.65in]{geometry} \usepackage{multirow} \usepackage{spreadtab} ...
7
votes
2answers
94 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
743 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
140 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
235 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} ...
2
votes
1answer
382 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
237 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
160 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 ...
2
votes
0answers
85 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. ...
6
votes
1answer
234 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 ...