{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

12
votes
1answer
1k views

How to implicitly specify column width (in a columns-like environment)?

I am using the columns environment in Beamer-documents like this: \begin{columns} \begin{column}{0.8\textwidth} %% \end{column} \begin{column}{0.2\textwidth} %% ...
38
votes
3answers
3k views

Can LaTeX perform calculation like Excel formula table?

I wonder if this feature is available in TeX system? For example, given a formula within a table, it can apply the formula and display data after the calculation.
10
votes
2answers
625 views

Multiplication with dimexpr?

(This post bases on: lstaddons: Dynamic linewidth calculation) Hey everyone, is there a way to do this with a multiplication instead of two additions? ...
5
votes
1answer
114 views

How to calculate the number of cells per line

Assume I have a table with a dynamic number of rows and columns, and I want to fill the table with n elements. Assume an element has the constant length x, and I want to say make floor(linewitdth/x) ...
2
votes
1answer
1k views

\dimexpr \numexpr & calc package

Why doesn't this work? I use Windows, TeX Live 2012 and pdfLaTeX \documentclass{article} \usepackage{calc} \newlength{\perclenght} \setlength{\perclenght}{% \dimexpr% ...
4
votes
1answer
1k views

Calculate parbox width to make it meet the page border?

I'm using the program package to typeset my algorithms. I want my comments to have a light gray background, therefore I'm using colorbox with a parbox inside (for multi-line comments). Now the ...
12
votes
3answers
332 views

Arithmetic in arguments to the geometry package

I'd like to use the geometry package to auto-crop the output of my LaTeX (so that it looks bigger on-screen as I'm editing). I have found a way to remove the margins completely and brutally: ...
4
votes
2answers
235 views

divide table cells by a certain amount

I made a mistake in the values that i put in the table. I need to divide all the values by 105. Is there a method where i can do it without having to replace this with a completely new table ? % ...
2
votes
1answer
112 views

Counting lines and making calculations

This code snippet provides a way to highlight lines in a listings environment. If you consider the following line, though: \emphline{1-6} {7} {8-15} {potencia.f95} You'll notice how the #1 and the ...
11
votes
2answers
926 views

Compute the x distance between two nodes

Is there a way to define a macro which would evaluate to the x part of the distance between two nodes? I know there are the point registers \p and the correspoding \x commands, but I find them rather ...
5
votes
2answers
135 views

Can you add a constant value to a length macro?

I have a box that's the full width of the page. I would like to offset it back into the margin a little, but when I do that it no longer reaches the edge of the page. Is it possible to keep using a ...
3
votes
1answer
343 views

convert outcome of reference to regular number

Is it possible to transform the outcome of a reference (e.g., a line number) to a regular number that I can use in a calculation? I have this (and works fine): \FPeval{\result}{clip(5+6)} $\result$ ...
24
votes
4answers
615 views

duodecimal page number

I would like to have page numbers in my document written in base 12. Here's an MWE \documentclass[12pt]{article} \usepackage[paperheight=1.8in, textheight=0.8in]{geometry} ...
4
votes
1answer
645 views

Can't get \fancyheadoffset to work

I have loaded the fancyhdr package and I want to make the headers and footers wider (clamp them to the margin), so I inserted the following line after the package has loaded: ...
2
votes
0answers
475 views

Project management tables (with cost “spread sheets”) using spreadtab [closed]

I'm trying to create a simple project management table detailing costs per task and milestone, using spreadtab: The code for the latter is: \begin{spreadtab}{{tabularx}{\textwidth}{lXllr}} \toprule ...
5
votes
2answers
238 views

What is the easiest way to write dimensional expression?

I want to do the following arithmetic: (x-y)*unit/s where x, y, s are rational constants and unit is in length unit. \documentclass{article} \usepackage{calc} \newlength\unit \unit=16pt \def\x{0.5} ...
2
votes
1answer
182 views

Computing a simple maths calculation and use the result as page numbers in the Table of Contents

Following up this question here, I am looking for a way to compute a simple maths calculation inside the document and let the result of this calculation be the value that appears as page number in the ...
6
votes
1answer
621 views

Extract coordinates from 3D point

How do I extract coordinates from a three-dimensional point defined when using tikz-3dplot? I would like to perform some calculations on these (more specifically a cross-product of two vectors), but ...
11
votes
2answers
3k views

How to use \widthof as parameter to \kern

I sometimes encounter a problem when I attempt to use \widthof from the calc package, and don't know why. In the past I have just worked around it using a two step process of defining a \newdimen{} ...
13
votes
2answers
480 views

Is there a better way to do intersections and calculations with relative coordinates in TikZ?

I've been doing many TikZ diagrams lately and every so often I encounter a situation where I am forced to use some temporary coordinate in a \path. In the following short example, the problem is ...
8
votes
1answer
338 views

calc package incompatible with \setlength in \g@addto@macro?

I want to systematically have some indentation in \parboxes and minipage environments. To do this, I add the following code in the preambule of my LaTeX file: \makeatletter ...
8
votes
2answers
3k views

Multiply the value by decimal number in latex?

I used the following construct quite often: \includegraphics[width=\textwidth/2]{pic.png} But when I try to adjust the size a small bit, like this: \includegraphics[width=\textwidth*0.45]{pic.png} ...
9
votes
2answers
1k views

“Arithmetic overflow” error

factorials up to 12 are handled.How can make it to compute beyond that? Error: “Arithmetic overflow \documentclass{article} \begin{document} \newcount\n \newcount\p \newcount\m ...
7
votes
3answers
3k views

Line through two points with offset in TikZ

I could not find a native command in TikZ allowing to draw a line going through two specified points where an offset can be controlled. So far, I'm using the calc extension to perform what I need but ...
4
votes
2answers
289 views

Writing/Modifying Package

There is a package I'm trying to modify that essentially displays a grid. It uses counters to increment the distance. I want to change the distance each step instead of adding a constant value. In ...
4
votes
1answer
1k views

Can't find TikZ library calc

I've been googling for some time now, and can't find the manual for the TikZ library calc. All I see is people using it. Where can I find the manual or some info? Is it the same as the LaTeX package ...
5
votes
1answer
134 views

How to calculate with metadata in footer

I have footer that draws on a svn version data field (package: svn-multi). I would like to perform a simple calculation that subtracts a number from the reported version. The footer code is ...
1
vote
1answer
741 views

Sequent Calculus

What is sequent calculus? See wiki: http://en.wikipedia.org/wiki/Sequent_calculus So basicaly I'd like to produce something like this: Maybe using Tikz?
2
votes
2answers
599 views

Templates for generating timesheets

Are there templates for generating weekly time sheets in LaTeX? Ideally something that would minimize duplicate entries by computing totals and days-of-week.
20
votes
3answers
2k views

Extract first & last characters of macro argument?

In LaTeX, how do I extract/isolate/determine the first and last characters of a macro argument? Specifically, in the case I'm dealing with, the argument happens to be a base-10 integer (call it N). ...
7
votes
3answers
2k views

How to Intersect an arc with a line without calculating the angle

I'd like to draw an optics-related figure, for which I need to draw several beams with varying opening angles, which will need to be labeled. What I've come up at the moment (boiled down to a minimal ...
3
votes
1answer
895 views

Multiplying a length by a factor

I am trying to create a package that will use grid typesetting (in the humanities, so not much of a problem) but that should allow the user to freely set the \baselinestretch. I am using the memoir ...
11
votes
3answers
494 views

Calculating checksum

I would like to calculate a checksum in LaTeX. My problem is that I don't know how to get the numeric value of a char. Here is the pseudo code of the algorithm: var input = "123456789"; car output = ...
6
votes
2answers
783 views

Add two lengths in raisebox argument, without the calc package

I've seen people use such constructs as \raisebox{-\height+\baselineskip}{...}, which works well using the calcpackage. What equivalent would you use to achieve the same behaviour without the calc ...
6
votes
2answers
2k views

Coordinates A, B: compute |B-A| and angle between +x and (B-A)

This question has two parts: why is the angle computed always 0 (should be 45) what is a straightforward way to compute distance between coordinates (there is How can I compute the distance between ...
4
votes
1answer
448 views

Prevent tikz to calculate

I just played with an answer to a question I asked here some time ago: Divide a rectangle into n times k equal cells. I wanted to be able to generate the list of points in a separate macro, however ...
17
votes
6answers
2k views

Checking if a number is a multiple of 4

Using etoolbox, ifthen, or another form of conditional checking, how can I check if a value is a multiple of 4? E.g. if the number is 4, 8, 12, 16, etc., then it returns "true".
16
votes
2answers
4k views

How can I compute the distance between two coordinates in TikZ?

Given two points (defined, for instance using nodes), I want to compute the distance between them. Is there some build in functionality in tikz to do this? If not, how can it be done using the ...
12
votes
3answers
1k views

How can I calculate the difference of 2 counters (pageref)?

How can I calculate the difference between 2 counters (like page numbers), so that pdfLateX outputs "3" in the last line of my example? and how could I calculate the difference between the "current" ...
10
votes
2answers
702 views

Calculating percentage

I have tried to use the calc package to write a macro which prints a percentage based on two numbers. E.g.: \printpercent{100}{200} should display 50% as 100 is the half-way point of 200. I have tried ...
4
votes
1answer
282 views

Why don't modern TeX variants support floating point?

I understand that, at the time when TeX was devised, no single standard for floating-point calculations was available. But these days, there's IEEE 754. Why doesn't any TeX variant support it? ...
5
votes
2answers
780 views

Anomalies and a question regarding a line-filling rule

I've created a command for filling a line with a black rectangle. It's called \fullrule, you can find it in the code below. I have several questions regarding this MWE: \documentclass[10pt]{article} ...
9
votes
6answers
1k views

Parse simple arithmetics and return the result

I want a command \ca which takes a simple arithmetic calculation as an argument and returns the result with proper decimal places. Additionally I want an boolean argument which decides if only the ...
16
votes
3answers
760 views

Using command to compute sum?

I must admit this sounds like an easy question. I'm creating a grading model for a homework assignment, and I'm adding the maximum amount of points to each question. Is there a way to have LaTeX ...
33
votes
7answers
6k views

How do I calculate n modulo 3 in LaTeX?

I don't want to display the modulo symbol, I want to programmatically calculate n modulo 3 and display the result.
24
votes
2answers
32k views

How to fit a large figure to page [duplicate]

Possible Duplicate: Best figure size adjustment when dealing with different image sizes Given: a large figure, whose height:width ratio is unknown. Todo: Include this fig in LaTeX, such ...
9
votes
2answers
2k views

How to enable use of minus and plus in tex documents?

I see many cls files using plus and minus operators to set lengths. How can I use these operators (or some equivalent macro(s)) to do something like the following? \setlength{\lengtha}{.5\textwidth} ...
22
votes
2answers
6k views

Problems with TikZ calculations

When can I use functions and do calculations in TikZ? How do I make this work: \draw (0,0) arc(0:90:sqrt(15)); %not ok why is this working: \draw (0,0) arc(0:asin(1):5); %ok with ...
17
votes
2answers
5k views

Is plotting exponential graphs a known source of bugs in TikZ?

I want to plot $y = 2^x$ over a small domain. Unfortunately, even though tikz (v 2.1) seems to be able to calculate 2^{negative numbers} it is not plotting them correctly. My minimal example is: ...
5
votes
1answer
897 views

Insert relative date and time specifications?

How can I specify a relative date and let LaTeX insert the resulting absolute one? For example like this: \somedatecommand{next thursday} Which should result in: Thursday, 20.10.2011 Or: ...