1

I have made a latex document which is a huge diagram. In fact, it is so huge, that when I try to add to it, I get a Dimension too large. error by LaTeX. I would still like to add to it, but I need to get around the issue of exceeding \maxdimen. Here is what I have tried:

  • using the relsize package with \relscale{0.5} did not actually help, even though I was expecting it to
  • rescaling the tikzpicture which is the diagram using \begin{tikzpicture}[scale=0.50], however this rescaled the shapes only, while the fonts remained the same size as before

This is all for personal use (I am the only person making and updating the diagram) so I am comfortable solving this in a hacky way, but I would still like to find a way to keep growing my diagram.

John
  • 528
  • 2
    You have not given enough information for anyone to help. Unless your picture is several metres wide, the problem is not the size of the picture, but some internal calculation that is going out of range, so scaling the picture (probably) makes no difference. – David Carlisle Oct 20 '22 at 22:26
  • It is not a picture; it is a diagram made up of many nodes (100s), placed in a flowchart together. – John Oct 20 '22 at 22:30
  • I used "picture" here as a generic name as it's a tikzpicture same answer. Unless your diagram is bigger than 5.7 metres in size it is not the diagram but an internal calculation that is overflowing. – David Carlisle Oct 20 '22 at 22:39
  • It is in fact larger than 5.7m, that is why I am asking for a workaround. – John Oct 20 '22 at 22:46
  • 1
  • I guess as a workaround you could try using something like \small to change font size which kind of works. – user202729 Oct 21 '22 at 06:30
  • Yes, but how do I apply the scaling to all elements at the same time? Not just the fonts, but the shapes, thickness of lines, etc? – John Oct 21 '22 at 06:38
  • If I remember correctly my TeXbook, that 5.7m is a hard one (I don't think that the new engines change that). Use a smaller font, and scale everything so that it stay into it. Maybe x=1mm, y=1mm may help. You can try to make an example with just a couple of nodes wildly apart... – Rmano Oct 21 '22 at 06:38
  • To scale everything you can use transform canvas, but if it's done after the building of the picture, it will not work. – Rmano Oct 21 '22 at 06:40

1 Answers1

2

I produced a small example (it was not so difficult ...) that I think shows the problem (if I understood correctly) and the solution I proposed in the comments. Let's start with this:

\documentclass[border=10pt]{standalone}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[every node/.style={draw, thick},
    ]
    \node  at (0,0) {First};
    \node  at (100,100) {One Meter away};
    \node  at (500,500) {Five Meter away};
    \node  at (600,600) {In outer space};
\end{tikzpicture}
\end{document}

This gives the error, because the node "In outer space" is outside TeX's universe. If you remove the last node, it works, and it gives in the upper right corner this thing:

enter image description here

The only way out is to make the picture smaller. I tried scale and transform canvas, but they don't work --- maybe they scale after building the picture. Changing the base vectors, which by default are 1 cm, do work, though:

\documentclass[border=10pt]{standalone}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[every node/.style={draw, thick},
    x=1mm, y=1mm,
    % scale=0.1, transform shape        % doesn't work
    % transform canvas={scale=0.1},     % neither
    ]
    \node  at (0,0) {First};
    \node  at (100,100) {One Meter away};
    \node  at (500,500) {Five Meter away};
    \node  at (600,600) {In outer space};
\end{tikzpicture}
\end{document}

But now the same corner is like that:

enter image description here

where the font is (comparatively) much bigger.

So, reduce the font size. Be sure to use a scalable font (there are details here --- font shapes, in good fonts, change a bit for such a small size, but the idea is this).

\documentclass[border=10pt]{standalone}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{tikz}
\begin{document}
\fontsize{1pt}{1.2pt}\selectfont
\begin{tikzpicture}[every node/.style={draw, thick},
    x=1mm, y=1mm,
    % scale=0.1, transform shape        % doesn't work
    % transform canvas={scale=0.1},     % neither
    ]
    \node  at (0,0) {First};
    \node  at (100,100) {One Meter away};
    \node  at (500,500) {Five Meter away};
    \node  at (600,600) {In outer space};
\end{tikzpicture}
\end{document}

Now the upper right corner (zoomed 50 times!) is

enter image description here

Clearly, the line thickness did not scale. Using the nice solution proposed by @Tiuri to change line thickness, now you have:

\documentclass[border=10pt]{standalone}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{tikz}
\begin{document}
\fontsize{1pt}{1.2pt}\selectfont
\newlength\mylinewidth
\setlength\mylinewidth{0.04pt}

\tikzset{ ultra thin/.style= {line width=0.25\mylinewidth}, very thin/.style= {line width=0.5\mylinewidth}, thin/.style= {line width=\mylinewidth}, semithick/.style= {line width=1.5\mylinewidth}, thick/.style= {line width=2\mylinewidth}, very thick/.style= {line width=3\mylinewidth}, ultra thick/.style={line width=4\mylinewidth}, every picture/.style={semithick} } \begin{tikzpicture}[every node/.style={draw, thick}, x=1mm, y=1mm, % scale=0.1, transform shape % doesn't work % transform canvas={scale=0.1}, % neither ] \node at (0,0) {First}; \node at (100,100) {One Meter away}; \node at (500,500) {Five Meter away}; \node at (600,600) {In outer space}; \end{tikzpicture} \end{document}

and the upper right corner is

enter image description here

Rmano
  • 40,848
  • 3
  • 64
  • 125
  • Thank you, this all works great when I tried your code. However, in my case the font scaling does not work as intended, because I am using cyrillic and it seems that cyrillic fonts are not fully scalable. Is there a work-around for that too? – John Oct 27 '22 at 22:00
  • @John You can switch to lualatex and use a otf font (Noto for sure has Cyrillic). If you add a minimal example, it would be much easier to target your problem.... – Rmano Oct 28 '22 at 05:49