{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

5
votes
2answers
610 views

Adding numerical values in a LaTeX tabular column [duplicate]

Possible Duplicate: How can I automatically calculate sums in a LaTeX table? Does anyone know if the is a TeX/LaTeX package which will make an ordinary tabular environment work as a simple ...
3
votes
2answers
1k views

Calculate maximum of lengths

How can I calculate a maximum of lengths? I am aware of pgfmath's function max(x_1,x_2,...) \documentclass[a4paper,draft]{article} \usepackage{tikz} \pgfmathparse{max(3,4)} \begin{document} ...
4
votes
1answer
1k views

Measuring height of fixed-width text box

Suppose some text is put inside a fixed width box. The text will then continue in vertical direction. How can you measure the total height of that text? Original text: text text text text text ...
15
votes
3answers
2k views

Why doesn't \settoheight of \parbox work?

Consider the following code: \documentclass[a4paper]{letter} \usepackage{calc} \usepackage{printlen} \newsavebox{\foobox} \newlength{\fooboxheight} \savebox{\foobox}{ ...
18
votes
2answers
777 views

Automated age calculation

How can I calculate my age at compile-time in LaTeX? Something like: I'm \myage{day}{month}{year} years old. would be most awesome.
17
votes
3answers
2k views

Doing maths with distance values in LaTeX source code

I have a sty file with the command \newcommand{\foo}[1]{\noindent\kern#1} but I'd actually like to have something like \newcommand{\foo}[1]{\noindent\kern{#1 *0.5}} meaning that I'd like to have ...
4
votes
3answers
2k views

Can LaTeX perform simple math operations? [duplicate]

Possible Duplicate: How can I automatically calculate sums in a LaTeX table? Can LaTeX do simple math? I have a table with two columns and want to automatically add a third column which ...
5
votes
2answers
1k views

\widthof within tikzpicture

In this minimal example \documentclass{scrartcl} \usepackage{calc} \usepackage{tikz} \newlength{\TestLength} \begin{document} \setlength{\TestLength}{\widthof{\tikz \node {bla};}} ...
5
votes
2answers
1k views

How to use pgf-math inside an argument?

I response to xport's recent questions, I tried to do the following \usepackage{pgf} [...] \rule{\pgfmathdivide{4}{3}\pgfmathresult mm}{5mm} Unfortunately, this fails with the following error ...
2
votes
1answer
440 views

How to pass in a ratio in fraction form (as opposed to decimal form) to table column definition?

My scenario is to pass in a ratio (in fractional form as opposed to decimal form) to each table column definition. The following code cannot be compiled. \documentclass{article} \usepackage{pgf} ...
2
votes
3answers
898 views

How to pass in a ratio in fractional form?

How to pass in a ratio of 4/15 (instead of its approximated decimal form of 0.266) to table definition. Final solution can be seen here. I need one more vote to close this topic.
0
votes
1answer
174 views

Why did my exact calculation still produce small gaps on the most left and right table rules?

I have specified each tabular cell width exactly using formula ##1\linewidth-2\tabcolsep-1.5\arrayrulewidth as shown in the following code snippet: \documentclass[dvips,dvipsnames,rgb]{book} ...
7
votes
4answers
2k views

How to find the ratio of a length command (e.g., \textwidth) to a reference value (e.g., 6cm) ?

How to find the ratio of a length command (e.g., \textwidth) to a reference value (e.g., 6cm) ? Actually I want to use the ratio for the \scalebox argument, e.g., \scalebox{<ratio>}. ...
8
votes
5answers
731 views

ConTeXt / e-TeX Real Numbers?

I've been using LaTeX for about 6 years and the calc package for a long time. Therefore, not being able to use real / floating point numbers was never really a problem. Thanks, \real! I've been ...
24
votes
2answers
1k views

Date calculations

I'm building a LaTeX document that helps me to formulate quotations for my customers. Since I decided to offer monthly recurring payments I'd like to have payment dates calculated automatically ...
27
votes
6answers
3k views

How to use \pageref{foo} as a number?

What I want to do is to show a "progress bar" in the header to show how far you are in the document, by making a rule with width pagenumber divided by total pages times the paper width. This is what ...
34
votes
5answers
10k views

How can I automatically calculate sums in a LaTeX table?

Sometimes I would like LaTeX to automatically calculate sums (or other simple arithmetic) for me, eg. in a table. I would like to ensure that when I update the table, I don't accidentally forget to ...
10
votes
2answers
5k views

Performing basic arithmetic in custom commands

One thing annoying in sparklines is its verbosity and dependence on external arithmetics. For example, to depict a three bar graph of 16%, 53%, 31%, one has to write: \begin{sparkline}{4} ...
9
votes
1answer
420 views

Resources For Calculating Average Sentence Length

I'm writing my masters thesis and my supervisor has picked up my sentence structure, in that they are too long. She commented that Microsoft Word has a feature to investigate 'large' sentences. How ...
12
votes
4answers
4k views

Why is this let expression not working in TikZ (calculating a midpoint)?

I have a rectangle in TikZ and the top left and bottom right corners are called (topleft) and (bottomright) respectively. I wanted to have a label midway down the left hand side of the rectangle, so I ...