I need to draw the plans of a house and make them fit on a page. I would really like to have one set of dimensions/coordinates both in the real life and in my TeX file (I tried in the past to have some dirty scalings, i.e. one dimension in the TeX file others in the real life, but that's not ok).
Is there a way to overcome this error? Thank you! (Please remark the 50m by 50m both in drawing and in the grid)
[Loading MPS to PDF converter (version 2006.09.02).]
)
! Dimension too large.
<to be read again>
\relax
l.28 \end{scaletikzpicturetowidth}
A MWE (Miktex 2.9.4248 x64; pdfTeX, Version 3.1415926-2.5-1.40.14):
\documentclass[fleqn]{article}
\usepackage{tikz}
\usepackage{pdflscape}
\usepackage{environ}%%%%%%%%%%%%%%%%%%%%%%%%%%
\makeatletter%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newsavebox{\measure@tikzpicture}%%%%%%%%%%%%%
\NewEnviron{scaletikzpicturetowidth}[1]{%
\def\tikz@width{#1}%
\def\tikzscale{1}\begin{lrbox}{\measure@tikzpicture}%
\BODY
\end{lrbox}%
\pgfmathparse{#1/\wd\measure@tikzpicture}%
\edef\tikzscale{\pgfmathresult}%
\BODY
}
\makeatother
\begin{document}
\begin{center}
\begin{scaletikzpicturetowidth}{\textwidth}
\begin{tikzpicture}[scale=\tikzscale]
\draw [step=10cm, lightgray, very thin] (0,0) grid (50000mm,50000mm);
\draw [draw=black, thin] (0.0mm, 0.0mm) rectangle ++(50000mm,50000mm) node[pos=.5] {some labels};
\end{tikzpicture}
\end{scaletikzpicturetowidth}
\end{center}
\end{document}


xandydoes not affect labels. As you will notice in the example,some labelsappears in normal size. The grey background is the result of your 10cm-grid. – gernot Aug 07 '21 at 16:03\def\tikzscale{0.001}%and\pgfmathparse{#1/\wd\measuretikzpicture*0.001}%). This will be visible when I'm going to redraw some parts of the original drawing in a separate figure (e.g. one room, which will be much smaller than the entire house); the part drawn separately will not resize to fill the page & will remain (maybe) too small. – radui Aug 07 '21 at 16:181, but which lead to an overflow. The constraint for choosing the number is just that the drawing can be typeset without over- and underflows. So, if you decide to draw a world map with lengths in mm,0.001will be too big, so you might have to shrink it further. – gernot Aug 07 '21 at 16:23