{calculations} is about calculations in (La)TeX documents. A popular package is calc.
2
votes
1answer
39 views
Modulo calculation in PGFplots tick label
I am printing a diagram and want to use a_[0...3] as tick labels on the x-axis. Right now I have a[0...7] as labels and look for a way to print a[\tick mod 4] (i.e. a_0, a_1, a_2, a_3, a_0, a_1, a_2, ...
10
votes
3answers
192 views
Calculate prices
I want to calculate prices in a LaTex file. This means I want to add two numbers with exactly 2 decimal places and I want to multiply these values by an integer.
An other thing is the output format. ...
14
votes
2answers
366 views
Golden ratio typography in TeX
Chris Pearson makes a number of claims in his article Secret Symphony: The Ultimate Guide to Readable Web Typography, which I find fascinating, and I would like to know: are the formulas he proposes ...
3
votes
1answer
97 views
Right Angle Symbol Alignment with TikZ/Calc
I used a solution from @Jake from this post Insertion of Perpendicular Symbol at Intersection of Two Lines, but the alignment is not quite right. I have my suspicions why, but I don't understand the ...
7
votes
1answer
61 views
How to perform arithmetic within siunitx?
I often put comments in my documents to remind me where a number comes from:
\SI{39.68}{\milli\metre} deep % 0.31 * 128
I'd like LaTeX to calculate the product by itself. I wrote a function to do ...
5
votes
3answers
108 views
How to subtract both very large numbers and numbers smaller than one?
In the context of Scientific Notation Only For Large Numbers have we been looking for a way to handle large numbers, as pgfmathparse can't cope with these. The only package we could find was ...
4
votes
2answers
105 views
Different Results for distance by sqrt and veclen
I'm trying a simple task of drawing a tangent to a circle. While I already succeded with the tangent cs option, I also want to use the library calc for the exact intersection points. I simply start ...
27
votes
4answers
558 views
Perform matrix operations (addition, product, transpose, etc.) in LaTeX?
I know the calc package can perform infix-notation arithmetic in LaTeX... but I want more!
I'd like to perform (not necessarily infix-notation) linear-algebra operations such as scalar ...
13
votes
3answers
447 views
PGF math engine imprecise?
The command \pgfmathparse{asin(1/\x)} yields for each \x in the range of 125 to 142 the same value, whereas \pgfmathparse{1/\x} yields the much more precise values for each \x. Is the ArcSin function ...
5
votes
2answers
914 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
0answers
83 views
What is the most convenient way to do general-arithmetic calculations involving lengths?
I know LaTeX can store at least two types of numbers: Dimensionless quantities (i.e. 1, pi, etc.) and lengths (i.e. 1pt, \textwidth, etc.). Is there some convenient, general way to do calculations, ...
6
votes
1answer
89 views
Computing value using pgfmath for use in coordinates?
Why can't I use the outcome of using pgfmath in a TikZ coordinate?
Here is a (minimal) example that does not work:
\documentclass[11pt]{article}
\usepackage{tikz}
\begin{document}
...
6
votes
3answers
103 views
How can I calculate the length of the longest word in a node?
I would like to create an inline brace command \inline{} for xelatex using TikZ. The difficult part is calculating the text width for the node without hardcoding it into the tikzpicture environment.
...
3
votes
1answer
91 views
Calculating the minimum height for a node based on the size of other nodes
Consider the following example:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{xcolor}
\begin{document}
\def\mydist{1mm}
\begin{tikzpicture}[
mystyle/.style={
...
3
votes
1answer
53 views
Adding constant to function (vspace) argument?
How can I get Latex to add a constant to a value as part of a \vspace argument?
Here's my minimal example:
\documentclass{article}
\usepackage{calc}
\begin{document}
ab
%\vspace{20mm+10mm} ...
5
votes
2answers
68 views
Floating Point multiplication in custom commands
I'd like to create a custom command which creates an underscore of a given length. However, this length should be the argument of the command multiplied be a floating point constant.
How can I ...
8
votes
2answers
407 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
1answer
121 views
Automatic calculation of error in pgfplots
When taking in data through a file (such as table[x index=0, y index=1, y error index=2]{plots/mydata.table};) is it possible to automatically calculate the error bars (instead of putting them in ...
2
votes
1answer
43 views
Store a ratio value in command and then use it to recalculate a length?
I want to store a ratio value in a command, e.g. \newcommand{\ratio}{0.7}, and then use it in recalculating a length, e.g. \setlength{\somelength}{\ratio*\width}.
Using lengths to store the ratio ...
1
vote
0answers
62 views
Generating pdf files that are “viewing-time” or current system-time dependent
The \FpEval{}{} function which can be used to do computations, and store the result in a variable, in latex. For details, kindly see How can I sum two values and store the result in other variable? .
...
2
votes
2answers
352 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.
17
votes
1answer
294 views
Setting TikZ curve control points and preserve area of closed curve
I would like to reproduce the shown periodic table, with more correct areas.
http://www.meta-synthesis.com/webbook/35_pt/relative_abundance.jpg
I would appreciate any ideas to how this can be ...
6
votes
1answer
201 views
tikz label coordinates using mathematical expression from foreach variables
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\foreach \x [count=\xi from 1] in {-3.0,-2.8,...,1.8}
\draw[thin] (0,0) ++(\x,2) rectangle ++(0.2, 0.2) ...
4
votes
1answer
127 views
sum two numbers in \ifnum
I would like to implement a command in LaTeX which would sum two numbers before comparing them to a third number as follows:
\ifnum #1+45>0
above
\else
left
\fi
where #1 is an angle in ...
13
votes
6answers
1k views
Calculating right angle triangle side inside LaTeX
I'd like compute the width of a screen from it's diagonal and its aspect ratio inside a LaTeX document. The formula is easy to get from the Pythagorean theorem, but needs square roots.
I currently ...
2
votes
0answers
47 views
Storing and manipulating real numbers [duplicate]
Is there any way to store real numbers (e.g. 4.5) as variable / macro / counter / whatever in standard LaTeX (no direct Lua code) and perform the 4 basic mathematical operations with them? I need to ...
8
votes
2answers
138 views
TikZ grouping expressions in calculations
I had to do some calculations like:
\node (A) {A};
\node (b) at (x,y) {B};
((A) + (B))*2
However I could not figure out how to group it in a calc statement, I tried ($((A)+(B))*2$) and ...
7
votes
2answers
64 views
Using calc and \year to get the years from a start date automatically in text?
I would like to say, "I have played piano for 23 years" -- but this document will have to be changed every year so I remember to make it 23, then 24, then 25. Is there a way to do something like:
I ...
16
votes
1answer
115 views
Using \fontdimen as an array to store data
Reading through pi.tex, I discovered the trick of using \fontdimen as an array of dimensions (which is equivalent to storing integers between ±(2^31-1)sp). Namely,
\font\x=cmr10 at 1sp % or whatever ...
4
votes
1answer
103 views
Manipulating arguments in newcommand
I'd like to manipulate the arguments in \newcommand. More explicitly, I'd like something like that:
\newcommand{\X}[1]{
#1+1
}
And if I call \X{0}, I want it to return 1 and not 0+1.
Thank you :-)
...
15
votes
4answers
2k views
Floating point calculations in LaTeX?
I am looking for a method to do minimal floating point / integer calculations in LaTeX, not for the purpose of package writing, but for the production of actual text.
Here is an example to ...
13
votes
5answers
277 views
Autocalculate result in math-mode
Are there any available programs/software/etc. that allow you to autocalculate and then autocomplete TeX equations? It would be great if for example, I were doing really long messy equations like
120 ...
14
votes
2answers
282 views
square root of number in counter
I would like to get the square root of a number which I have stored into a counter. I have been using the calc package for summation and multiplication operations, but I cannot find anything like
...
12
votes
3answers
1k 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}{
...
4
votes
2answers
78 views
settototalheight issue with empty lines
I am using \settototalheight to calculate the height of the text in order to use needspace correctly.
This is the code i am using :
\documentclass[12pt]{article}
\usepackage{graphicx}
...
10
votes
3answers
194 views
How to set a counter to double the value of another counter?
The title says it. Lets have to counters:
\newcounter{myCount}
\newcounter{anotherCount}
I set myCount to some value for example 10
\setcounter{myCount}{10}
How do I set counter anotherCount to ...
7
votes
1answer
185 views
Using let command in TikZ but want to have reference to new point later as well
I'm beginning to use TikZ and am having some issues understanding the proper way to reference my data points without specifying the precise absolute positions for all of them. An example of the simple ...
6
votes
4answers
115 views
How can I calculate within style values?
Is it possible to calculate (addition etc.) in style values? I wanted to do the following:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning,fit,chains}
...
13
votes
1answer
156 views
References for \dimexpr \numexpr
I'm not really sure whether this is the right place to ask this question, but here I go....
Over the holiday I've been taking time to read through a lot of the Q&A here. I've been running across ...
11
votes
3answers
384 views
How to do simple calculation in Latex?
Consider the following macro:
\newcommand{\sxfigure}[4]{
\includegraphics[width=#1*#3 cm, height=#2*#3 cm]{#4}
}
#1 and #2 is some value to determine the width and height of the figure, #3 is to ...
8
votes
4answers
274 views
Calculating the the exact width of the text and a lettrine
This is one question which technically could be broken into two minor questions.
I am using a lettrine and some verse text, but the calculation to determine how much to indent the text does not ...
9
votes
4answers
188 views
Dividing dimensions to get a count
Is there a way to divide two dimens and get a count? For example, if I have a box that doesn't fit on a single page, and I want to know the number of pages I'd need for the box (i.e., \heightofbox / ...
7
votes
2answers
592 views
Create a table with calculations of binomial and poisson distribution
Well, I was looking for some tables on the internet about the binomial and poisson distribution (not the cumulative ones) in LaTeX format. But I've only found the code of the cumulative distributions, ...
0
votes
0answers
27 views
How to do simple spreadsheat calculation (e.g., sum row values) [duplicate]
Possible Duplicate:
How can I automatically calculate sums in a LaTeX table?
Is there a package, or some tricks, by which one could get the sum of all the value in a table row and write it ...
9
votes
3answers
287 views
How to ensure document total page numbers is a multiple of four?
I'm producing a document (book class) that will ultimately be produced using offset lithography. It's therefore useful to ensure the total number of pages is a multiple of four by adding as many blank ...
9
votes
2answers
119 views
Set variable with mathematical expression
I need to do something like the following,
\includegraphics[width=(\textwidth - 50mm)/2]{myfig.eps}
What keywords can I use to search for doing this operation? Everything I've searched for was ...
3
votes
2answers
107 views
Undesired equal sign in beamer using \dimexpr
I'm using the following script in beamer to locate our logo at the right-most corner of all pages in the presentation,
\begin{textblock}{5}(10.0, \dimexpr 0.5\headheight - 7.5pt )
...
4
votes
1answer
94 views
How to get vertical size of table captions?
I found that the tabularht package, which allows to give a fixed vertical size for a tabular, does not take into account the vertical space taken up by a table's caption.
It stands to reason, the ...
1
vote
1answer
60 views
Adjust typeblocksize in light of paper size
I'm trying to figure out how to adjust the typeblocksize in memoir in light of the ratio of \paperheight to \paperwidth.
Right now, I have
\settypeblocksize{*}{\lxvchars}{1.414}
to adjust the ...
17
votes
2answers
2k 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 ...


