Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [arithmetic]

The tag has no usage guidance.

5
votes
2answers
72 views

known benchmarks for floating point calculations?

I frequently have the problem that I have to perform some simplistic calculations, mostly products and sums of two or three quantities. I used to use the fp package for it, but it does look somewhat ...
2
votes
1answer
31 views

Doing math with a value from readarray

I have some numbers that have been read in from a file, using the readarray package. But now I need to add two of these numbers together and output their sum into the file. Is there a way to do this ...
7
votes
2answers
916 views

Bamboozling Arithmetic!

While creating some pgfmathsetmacro arithmetic macros, I stumbled upon a very perplexing result. Take the following example: \documentclass{article} \usepackage{tikz} \usepackage{xstring} \begin{...
2
votes
1answer
50 views

How to do arithmetic and get a string version of an integer expression?

How, in the context of a Tex macro, do I do arithmetic on integers and also capture the string representation of the value of an expression so that it can be displayed? Addition and subtraction would ...
1
vote
1answer
34 views

How to do arithmetic with variables used in for loop?

How can I use arithmetic inside a node's curly brackets? I have this, and it prints for example "0+1" in a circle. I would like to have circles that show the sum of their coordinates. \begin{...
2
votes
1answer
1k views

Next step in formatting long division

I have posted this and this later item on long division. I thought what appears below worked perfectly. But only today I tried it with an example that has several digits before the decimal point in ...
3
votes
2answers
505 views

How to do arithmetic without assignment?

I have known that I can use "advance...by..." to do arithmetic on number in TeX, but is there any way to do arithmetic without changing the value of number? For example, if I want to determine whether ...
1
vote
0answers
18 views

How to dynamically refer to nodes within tikz environment? [duplicate]

Here is my code with two tikzpictures. I was expecting both to produce similar output. \documentclass{article} \usepackage{tikz} \begin{document} \begin{tikzpicture} \node[rectangle,draw,minimum ...
2
votes
2answers
334 views

More on formatting of long division

Among the several proposals for formatting long division in LaTeX, the one that has worked best for my purposes is the one for which the code appears below. It is necessary for me: to stop the process ...
6
votes
0answers
282 views

Arithmetic overflow in TiKZ/pgfmath

I am writing some material on the trinomial theorem and Pascal's pyramid, and I'm trying to typeset a single layer. Here is my code so far: \documentclass{article} \usepackage{tikz} \begin{...
3
votes
1answer
289 views

Arithmetic operation in tikz

Consider the following MWE \documentclass{article} \usepackage{tikz} \usepackage{amsmath} \begin{document} \begin{tikzpicture} \path[black] (0,-1) node{$N=0$} (-1,0) node{$g=0$}; \path[black] (1,-1)...
6
votes
2answers
954 views

Divide two lengths

How do I divide two lengths and get a length out? \documentclass{article} \newlength\A \newlength\B \newlength\C \setlength\A{10pt} \setlength\B{5pt} \setlength\C{\dimexpr\A/\B\relax} \begin{document}...
4
votes
3answers
313 views

Arithmetic temporaries in tex

Can i call macros something like this \StrMid{\mystring}{\X}{\X+2}\par So, i would like to have running window of length 3. And for this end i would like to be able to use temporary unnamed local ...
3
votes
1answer
67 views

Forming totals in cell of tabular environment. Macro expansion or inline eval possible for simple arithmetic?

I have a tabular environment with a dozen or so itemized lines, each with a numeric integer cost. I would like to display a total in the last row. I've edited items in the table several times over a ...
1
vote
1answer
89 views

Breaking numbers Simple addition

I want to make something like the following (I made it in photoshop). Basically I want to make questions for my students to do but without the numbers in the boxes. I don't mind if there is no ...
2
votes
2answers
92 views

Single-Digit xlop exercises

I am creating worksheets for young children in which they'll be doing single digit operations vertically. How do I set them up vertically so that there is: An exercise worksheet with no answers. A ...
0
votes
1answer
159 views

Typesetting long division with tabular and overlining repeating part

I used some of the solution proposed in this post: How to present a vertical multiplication/addition and my code is as follows: \documentclass{standalone} \begin{document} \begin{tabular}{c*{11}{@{...
1
vote
1answer
102 views

Separate Pages for Questions & Solutions

I am making basic arithmetic worksheets with random numbers. I want to separate the questions from the answer page. Not sure how to do that. Ideally, it would look something like this, but with more ...
1
vote
1answer
67 views

Use arithmetic of counters inside \cline

I have a custom counter \myCounter set to, say 3. I need to produce such a table: The following code does not work: \documentclass{article} \newcounter{myCounter} \setcounter{myCounter}{3} \begin{...
3
votes
1answer
527 views

Arithmetic operation between command arguments and latex parameters

I'm defining a new command that places two images one next to the other and I want to add an horizontal space between the two images which corresponds to one third of the space that remains blank. The ...
2
votes
1answer
188 views

Arithmetic overflow with pax?

I am heavily using pdfpages to concatenate a set of papers. One of the papers has a big table, rotated, using the sidewaystable environment. That paper, by itself, compiles perfectly, with the desired ...
1
vote
1answer
57 views

Why is 'pt' printed when multiplying two point-based dimensions?

In this MWE: \documentclass{article} \begin{document} \dimen1=10pt \multiply\dimen1 by 20pt \rule{\dimen1}{10pt} \end{document} I multiply 10pt with 20pt, expecting a value of 200pt (which is ...
4
votes
3answers
665 views

How to type short division?

I am typing elementary arithmetics, is there any one knows how to type this ? I know perhaps there's a package "polynom" could solve this problem, but is there any method that could work without ...
2
votes
1answer
73 views

Arithmetic in tabular lengths ( p{…} )

I'm trying to do some simply arithmetic for a dynamic column type in tabularx. What I want is to be able to calculate (n-1) * X. I tried to use the calc package, but I just cant figure it out. \...
9
votes
1answer
1k views

How do counts differ from numexpr

To do basic arithmetic on numbers, one can utilize TeX counts, \newcount\c \c=2 \advance\c 3 \typeout{\the\c} LaTeX counters \newcounter{c} \setcounter{c}{2} \addtocounter{c}{3} \typeout{\thec} or ...
3
votes
0answers
39 views

How to get the counter value for a reference? [duplicate]

The command \label{here} defines a label and \ref{here} outputs the corresponding representation in the text. Is it possible to get the correspondig (numeric) counter value for the here reference so ...
2
votes
1answer
2k views

Increment/display the content of a (variable)/(section number) under latex?

To have something equivalent to echo of the shell. For instance in .tex file we have: \def \var{2} The content of var is $var How to edit the tex file in such a way we have as output: The ...
1
vote
1answer
979 views

Calculating with different types of variables

Is there any way to calculate the height of a node in a tikz pictures and to divide a length by an another length to get a counter and to round it up? If yes where could i read after the subject of ...
1
vote
2answers
533 views

Asking spreadtab to add all rows above?

I love the idea behind spreadtab. The author should be congratulated. However, it seems to require that I specify specific numbers for the rows that I want to add. What if I have a document, where I ...