Questions tagged [arithmetic]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
1 answer
47 views

How to multiply all the components of a skip length by the same number?

I am looking for a way to simply multiply all the components in a skip expression ( the natural length plus the plus-length minus the minus-length ) by the same number. I've tried some examples in my ...
User23456234's user avatar
  • 1,611
3 votes
1 answer
57 views

Asinh scale in pgfplots with small parameters

I have recently asked a question about introducing an asinh scale in pgfplots. While the solution given in there does implement an asinh scale, when I tried to implement it in my particular case I've ...
Níckolas Alves's user avatar
2 votes
2 answers
212 views

Simplify arithmetics +-, -+, --, 1x, -1x

I made some command \pcoef and \mcoef that simplifies +- and -+ to -, and -- to + in arithmetic expressions, and a \coef that simplifies 1x and -1x to x and -x respectively. They are not really ...
mathteacher's user avatar
2 votes
1 answer
58 views

How do I correctly align, center, and number a multi-step arithmetic problem?

As indicated in the picture, I would like to have several things: Numbered steps (if possible, on the left side) Aligned and centered properly, so it looks professional. The summation in step #2 ...
anon's user avatar
  • 35
0 votes
2 answers
118 views

Looking for an alternative to \numexpr: an intuitive interface for LaTeX numeric expressions

The xparse package makes writing commands easier and more flexible. The ifthen package does the same to conditionals. Is there a similar package for numeric expressions? Even better if it interacts ...
Evan Aad's user avatar
  • 10.9k
0 votes
1 answer
107 views

Multiply length using \expr

I have a length that I wish to scale, however I am not sure of how to do it, and none of the answers i have found online have been helpful. The function I attempted to derive this from is: % #1 is the ...
cdickstein's user avatar
2 votes
1 answer
88 views

Calculate ratio between lengths/scale

I would like to calculate the the ratio between two lengths in order to automatically get the scale for a map included using the mercatormap package. For instance, I want the map to show 1km in the ...
Ninoett's user avatar
  • 179
1 vote
1 answer
86 views

Turning this addition code into subtraction

\documentclass{article} \usepackage{xintexpr}[2018/05/18]% because we use randrange() \newcommand{\BaseTenAddition}{% % temporarily make definitions have global scope, because % xint creation of ...
Paul A's user avatar
  • 711
0 votes
1 answer
212 views

How to use dynamic numerical variables in tikzpicture?

I am currently creating technical documentation that depicts through a tikzpicture the data flow across something called the I2C bus (example-like graphic). I initially started doing this by hand with ...
Code Doggo's user avatar
1 vote
1 answer
92 views

Multiplying length values

I am trying to make a macro \scalelen that scales an existing length value \len by the input value. However, \len is actually a string containing a unit. I made a code: \documentclass{article} \begin{...
Hermis14's user avatar
  • 423
1 vote
1 answer
65 views

New command: Arithmetic-based image width

Theoretically, I think this command should create an environment which is slightly wider than the image it is meant to house: \newcommand{\ListedFig}[3]{ \piccaption{\small #1} \parpic(#2cm,0pt){\...
kiwi's user avatar
  • 13
1 vote
3 answers
60 views

To emulate lookahead for variable evaluation, run a macro laden block of text twice. How to suppress text output in the first pass?

I'm writing a little supplement for my friends, we use the GURPS tabletop role playing game system. This system uses a points pool to buy aspects of characters. I would like to have the point total of ...
Worm of Love's user avatar
1 vote
1 answer
295 views

Adding a number to command parameter and outputting it

I have a command that takes a single parameter. I want to add a constant number to that parameter and include it in the output. Something like (pseudo-code): \newcommand*{\label}[1]{% Here is the ...
me--'s user avatar
  • 377
4 votes
3 answers
575 views

Calculation summations in Latex

Anyone can help me please? I need to calculate the sum 1+1/2+1/3+...1/n (n given) by using only Latex commands. I have no idea how can I do this. Many thanks.
Angelo Aliano Filho's user avatar
1 vote
1 answer
109 views

pgffor loop with arithmetic expression

I've grown fond of this xintexpr package for its nice syntax. I'd like to repeat a command M times and another one 5-M = N times. I'm getting an error due to the arithmetic expression of the latter ...
likethevegetable's user avatar
0 votes
1 answer
522 views

Tikz \def arithmetic division

This is, I hope, a trivial question, but one that has cost me a lot of time. I am drawing a simple TikZ picture. I define some variables which specify the coordinates of the lines, nodes and so on. \...
Mike Tanner's user avatar
0 votes
0 answers
28 views

The tikz variable resets before the loop finishes [duplicate]

In tikz, I define a variable outside \foreach loop, and use \pgfmathtruncatemacro command to increase it inside the loop. Below is my MWE. \documentclass{article} \usepackage{pgfplots,tikz,tikz-3dplot}...
padawan's user avatar
  • 1,502
4 votes
3 answers
534 views

\numexpr with parentheses / order of operations

I feel very silly. Basically I want to divide the result of an addition with \numexpr, such as: (10 + 5) / 3 The problem is that if I put parentheses there, like \numexpr (10+5)/3 \relax my online ...
Gaspa79's user avatar
  • 143
1 vote
2 answers
45 views

command which creates a variable number of spaces

Basically my problem is that I want to treat the argument to a command as a number (and perform arithmetic operations on it), but I can only get it to be treated as a string. In particular, I want my ...
push33n's user avatar
  • 115
0 votes
0 answers
118 views

Random Arithmetic overflow with Tikz

\documentclass [11pt,a4paper]{article} \usepackage{pgfplots} % per i plot \tikzstyle{mybox} = [draw=black, thick, rectangle, rounded corners, inner ysep=5pt, inner xsep=5pt]%per riquadrare una parte ...
Tommaso Iaquinta's user avatar
2 votes
1 answer
81 views

Have MetaFont read an arithmetic expression from a file

I know this is a question that possibly does not belong to pure TeX, as MetaFont is part of a project to which TeX relates, ie as part of building TeX. My question is as follows: I call MetaFont from ...
Yaacov NNNNM's user avatar
1 vote
1 answer
109 views

tikz:arithmetic in calculating coordinates

Consider this example: \documentclass[margin=5pt]{standalone} \usepackage{tikz} \begin{document} \begin{tikzpicture} \def\xstart{-1} % \def\xstart{-0.2-0.8} ...
Viesturs's user avatar
  • 7,665
4 votes
1 answer
102 views

Shortening lengths in LaTeX

I'm trying to create a a bipartite object that has the \textwidth at most, and doesn't overflow from the right, but has the width of the separator given as an argument. I attempted to achieve this ...
Alex Petrosyan's user avatar
0 votes
1 answer
77 views

Is typesetting of elementary arithmetic exercises without tables or TikZ possible?

Is there a way to avoid using TikZ or tables typesetting elementary arithmetic exercises like these: I would like to have a some kind of a placeholder character and the distance between numbers have ...
georgmierau's user avatar
  • 1,588
1 vote
0 answers
74 views

How to do long division of an angle in degrees

Is there a way to display the basic operations with angles in degrees, just like xlop does with integers? For example, with integers we use: \documentclass{article} \usepackage{xlop} \begin{...
Ulysses's user avatar
  • 197
1 vote
1 answer
926 views

How to calculate factorial with xfp package

I'm trying to calculate the factorial with the xfp package. In the documentation (http://ctan.cs.uu.nl/macros/latex/contrib/l3packages/xfp.pdf), I have found the function name to be fact. My code ...
Carl's user avatar
  • 11
3 votes
2 answers
1k views

Modulo 2 binary long division in European notation [duplicate]

I need to represent binary modulo 2 long division in my tex document. Notation needed is same as https://en.wikipedia.org/wiki/Long_division#Eurasia under Austria, Germany, etc. I know about ...
TexUser's user avatar
  • 31
15 votes
4 answers
2k views

7.0pt ≠ x⋅10.0pt for all x

Consider the following input: \documentclass{article} \begin{document} \newlength{\smallertopskip} \setlength{\smallertopskip}{.700004577636718749999999999999999999999999999999\topskip} \newlength{\...
user avatar
5 votes
3 answers
1k views

What is wrong with the use of `isodd` of `xifthen`?

The white/black board can be drawn by testing the parity of node positions as follows: \documentclass[tikz]{standalone} \usepackage{xifthen} \begin{document} \begin{tikzpicture}[every node/.style = ...
hengxin's user avatar
  • 2,321
11 votes
2 answers
363 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 ...
John Frazer's user avatar
2 votes
1 answer
391 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 ...
Draconis's user avatar
  • 900
7 votes
2 answers
980 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{...
Code Doggo's user avatar
2 votes
1 answer
506 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 ...
Rosie F's user avatar
  • 444
2 votes
2 answers
998 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{...
user3435407's user avatar
2 votes
1 answer
2k 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 ...
Michael Hardy's user avatar
3 votes
2 answers
864 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 ...
Evian's user avatar
  • 211
1 vote
0 answers
22 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 ...
Lone Learner's user avatar
  • 3,206
4 votes
2 answers
3k 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 ...
Michael Hardy's user avatar
6 votes
0 answers
1k 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{...
Alasdair's user avatar
  • 5,227
4 votes
1 answer
953 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)...
Larara's user avatar
  • 303
11 votes
2 answers
4k 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}...
Carucel's user avatar
  • 1,035
4 votes
3 answers
357 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 ...
Yola's user avatar
  • 481
3 votes
1 answer
76 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 ...
init_js's user avatar
  • 257
1 vote
1 answer
114 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 ...
Matthew Tang's user avatar
2 votes
2 answers
232 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 ...
WeCanLearnAnything's user avatar
1 vote
1 answer
517 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}{@{...
kjetil b halvorsen's user avatar
1 vote
1 answer
156 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 ...
WeCanLearnAnything's user avatar
2 votes
1 answer
435 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{...
iago-lito's user avatar
  • 1,452
7 votes
1 answer
2k 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 ...
David's user avatar
  • 259
2 votes
1 answer
453 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 ...
Alberto's user avatar
  • 464