3

I'm using another language to generate a latex file, specifically a document with a tikz picture. The picture contains about 2000 straight line segments, (+ nodes) but it produces the error

! TeX capacity exceeded, sorry [.6=200000]. 

(it still works with about 1500 segments).

But I think it surely should be possible to create way more complex graphics than that, but if so, how?

I am using pdflatex from MikTex on Windows.

This is the code I used:

\documentclass[a4paper]{article}
\usepackage[margin=1cm]{geometry}
\usepackage{graphicx}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.14}
\begin{document}
\begin{center}
\begin{figure}
\begin{tikzpicture}[scale=14]
\draw[-,very thin](0.0:0.4)-- +(0.0:0.2)+(0.0:0.22)node{$1$}
(108.371:0.4)-- +(108.37:0.184)+(108.37:0.201)node{$2$};
%...more line segments
\end{tikzpicture}
\end{figure}
\end{center}
\end{document}
flawr
  • 1,123
  • 1
  • 9
  • 19
  • off-topic: figure float van not be inside begin{center} ... \end{center} ... correct is \begin{figure} \centering \begin{tikzpicture}[scale=14] \draw[very thin](0.0:0.4)-- +(0.0:0.2)+(0.0:0.22) node{$1$} (108.371:0.4)-- +(108.37:0.184)+(108.37:0.201) node{$2$}; %...more line segments \end{tikzpicture} \end{figure}. – Zarko May 28 '17 at 19:27
  • 4
    does it work with lualatex instead of pdflatex (luatex uses dynamic memory allocation) – David Carlisle May 28 '17 at 20:04
  • Can you provide some more line segment examples? Are these segments regular in any way? Any patterns that we can exploit in a foreach etc.? – Troy May 29 '17 at 02:37
  • With \draw plot file{…} I can draw some 5000 line segments. Maybe you can provide your data in an external file and plot it from there. (Needs a recent TeX dist, I know it does not work with a 2012 one.) How old is your installation? Have you tried some of the capacity increasing tricks, i.e. allocate more memory to TeX? – Huang_d May 29 '17 at 07:52
  • Could you split the picture into pieces and join of overlay them together? A useful trick is to use the same bounding rectangle on every image: \path (sw corner) rectangle (ne corner); – John Kormylo May 29 '17 at 11:14
  • You could break the picture into smaller sections and overlay them. A useful trick is to start each picture with \path (...) rectangle (...); for some corner coordinates. See https://tex.stackexchange.com/questions/137356/how-can-i-access-the-size-of-a-tikzpictures-bounding-box-outside-the-tikzpictur?s=1|2.4077 – John Kormylo May 29 '17 at 11:21
  • Thanks for all the tips, I'm going to try and see what works for me! – flawr May 29 '17 at 20:23

0 Answers0