#Why am I getting this Arithmetic Overflow Error?

1 messages · Page 1 of 1 (latest)

woeful mesa
#

This error appears to occur because I have too much content in my file. But when I searched it up, I only saw the error occurring for people doing calculations.

When the error comes, the PDF is just a blank white sheet of the same vertical height as if the content was there. But the content only appears when I remove the $$\dv{y}{x} = ... line.

winged granite
#

Because you're using standalone in the weirdest way possible, and defienitely not in the same it was designed to be used.

Note that the same overflow will happen if you were to insert lines of text thereafter Euler's method header

#

Also note, the code isn't fine, your line 388 is missing the closing $$

woeful mesa
winged granite
#

It’s not the Euler method that magically gives rise to error, don’t read into it

#

In any case, the limitation seems to be coming from preview

#

try varwidth in lieu of preview

lucid plume
#

which is around a few meters

lucid plume
valid quarry
valid quarry
winged granite
#

don't know

valid quarry
#

btw leo whats the command to view another user's preamble

winged granite
#

you can't

#

it's reserved for preamble reviewers

valid quarry
#

what about through texit support?

valid quarry
#

btw do you also see that account as "likely spammer"

waxen folio
# valid quarry why does TeX limit the dimensions?

TeX’s dimension limits trace back to its choice of a fixed‑point representation on 32‑bit hardware and conservative overflow protection in arithmetic. Internally, all lengths in TeX are stored as integral multiples of a “scaled point” (sp), with 1 pt = 65 536 sp, using a 32‑bit signed fixed‑point format (16 fractional bits) that Knuth implemented for efficiency and portability.

#

To avoid overflow during addition, TeX actually only expects 14 of the integer bits to be used, reserving the rest for sign and fractional precision.

valid quarry
waxen folio
valid quarry
winged granite
#

both

#

it's not you instructing TeX to do arithmetic, it's TeX doing internal arithmetic to figure out where to place what

valid quarry
#

leo can you view @woeful mesa's preamble

waxen folio
# valid quarry > Not directly. sp units affect precision, not visual resolution. is this regard...

When you say "sp affects precision," it's about the arithmetic, not the rendering.

TeX does all of this math using integer arithmetic in units of sp. So precision here means how accurately TeX can represent and calculate lengths.

So even though TeX might compute something like:

\hspace{123.456789012345 pt}

and store it internally as an integer number of sp, that doesn't visually degrade anything, the final graphic remains sharp and scalable.

valid quarry
#

if the sp is really that many digits by default, is there any harm in removing a few digits?

#

how do i reduce sp?

waxen folio
# valid quarry is it possible for me to reduce the precision

Technically it is possible, but with caveats.

Since TeX uses fpa where 1 pt = 65536 sp, you're asking: "Can I make it, say, 1 pt = 1000 sp instead?" i.e., fewer fractional bits.

The answer is not within standard TeX. The 65536 sp/pt ratio is hardcoded into the TeX engine. It's not configurable at runtime, and it's deeply baked into how all dimensions, glue, and arithmetic work.

Although, you can simulate lower precision.

valid quarry
#

ok i see how this might be a problem. but i don't understand why the exact same content works in article but not standalone

winged granite
#

I still think you're mis-using, and maybe even abusing, the standalone package. According to the user guide of the standalone package, the main (sole?) purpose of the standalone package is to generate well-contained objects—often, but not exclusively, pictures—that can be saved as external files in a suitable file format for subsequent pasting into other documents, e.g., Word and PowerPoint files

waxen folio
# valid quarry ok i see how this might be a problem. but i don't understand why the exact same ...

Basically, standalone adds extra scaling and cropping logic, which can interfere with large dimensions or precision-sensitive code.

standalone.cls loads the preview package internally. It sets up a tight bounding box around your content. And yes, this includes measuring the exact size of the content, croppin the PDF to that size, and possibly applying scaling.

This process uses additional boxes, glue, and calculations, and TikZ picture bounding boxes are sometimes computed twice or offset.

It also often uses \vbox/\hbox wrappers with zero margins. These amplify rounding errors or trigger overflows if for example your TikZ picture is either very large (e.g., 1000000pt wide), infinitesimally small (e.g., 0.00001pt elements), or uses a lot of math or transformations (these include options like scale, rotate, etc.)

All that, and article just puts stuff on a normal page.

valid quarry
waxen folio
valid quarry
#

can theoretically infinite content be stored in an article

winged granite
#

No, there’s a hard limit

valid quarry
winged granite
#

it’s not the limit of the class. it’s of TeX itself

waxen folio
# valid quarry i already understand why i __shouldnt__ be using `standalone`, but i dont unders...

You can use standalone, but the issue is not a moral "shouldn't", it's that standalone can hit TeX's internal limits in cases where article doesn't, due to implementation details, especially in page size computation, bounding box measurement, and output drive interaction (pdflatex, luatex, etc.)

Now, look at this:

\setbox0=\hbox{<your content>}
\pdfpagewidth=\wd0
\pdfpageheight=\ht0+\dp0

This happens (indirectly) inside its code path via preview, unless you disable it.

Now suppose your content involves a TikZ drawing with very large dimensions (e.g., something like \draw (0,0) -- (100000pt,0);), or there's an internal dimension (like a \pgfmathsetlength result) that rounds to > \maxdimen (≈ 16383.99999pt). Then this will literally fail:

\pdfpagewidth=\wd0  % ← this right here may overflow

even though the drawing is visually fine, the engine can't store that page size.

valid quarry
#

so the tex will fail because the drawing simply doesnt fit on the standalone page?

#

whereas article class is able to change the page dimensions to accomodate more things?

winged granite
#

a page that stretches metres (standalone) vs multiple pages that are centimetres long (article)

winged granite
#

In any case, i'll consider this thread resolved