For the sizes, you can use the current bounding box
together with \pgfgetlastxy
:
\documentclass{standalone}
\usepackage{tikz}
\newcommand*{\ExtractCoordinate}[3]{\path (#1); \pgfgetlastxy{#2}{#3};}%
\newdimen\tlx
\newdimen\tlx
\newdimen\brx
\newdimen\bry
\begin{document}
\begin{tikzpicture}
\draw (-3,-1) rectangle (3,1) (-2,-2) rectangle (2,2);
\foreach \x in {north west,south west,south east,north east}
{ \fill[red] (current bounding box.\x) circle (0.01);
}
\ExtractCoordinate{current bounding box.north west}{\tlx}{\tly}
\ExtractCoordinate{current bounding box.south east}{\brx}{\bry}
\pgfmathsetmacro{\myheight}{(+\tly-\bry)/28.452755}
\pgfmathsetmacro{\mywidth}{(-\tlx+\brx)/28.452755}
\node[below right] at (-2,1) {height: \myheight\ cm};
\node[above left] at (2,-1) {width: \mywidth\ cm};
\end{tikzpicture}
\end{document}
Edit 1: Ah, now I get it. Here is a still not automatic version. You set two commands in each tikzpicture
:
\maximumdimensions{4}{3}
, which is the desired width and height, at the beginning of the picture.
\getscalingfactors
which will draw nodes with a recommended scaling factor in the middle of your picture if the image if to high/wide:
\documentclass{scrartcl}
\usepackage{tikz}
\usepackage{lipsum}
\usepackage{xifthen}
\newcommand*{\ExtractCoordinate}[3]{\path (#1); \pgfgetlastxy{#2}{#3};}%
\newdimen\tlx
\newdimen\tlx
\newdimen\brx
\newdimen\bry
\def\xscalefactor{}
\def\yscalefactor{}
\parindent0mm
\newcommand{\getscalingfactors}{%
\ExtractCoordinate{current bounding box.north west}{\tlx}{\tly}
\ExtractCoordinate{current bounding box.south east}{\brx}{\bry}
\pgfmathsetmacro{\myheight}{(+\tly-\bry)/28.452755}
\pgfmathsetmacro{\mywidth}{(-\tlx+\brx)/28.452755}
\pgfmathsetmacro{\xsf}{\maxwidth/\mywidth}
\pgfmathsetmacro{\ysf}{\maxheight/\myheight}
\global\edef\xscalefactor{\xsf}
\global\edef\yscalefactor{\ysf}
\pgfmathtruncatemacro{\xsfc}{\xsf*10000}
\pgfmathtruncatemacro{\ysfc}{\ysf*10000}
\ifthenelse{\xsfc > 10000}{}{\node[fill=white,above] at (current bounding box.center) {x-s: \xsf};}
\ifthenelse{\ysfc > 10000}{}{\node[fill=white,below] at (current bounding box.center) {y-s: \ysf};}
}
\newcommand{\maximumdimensions}[2]{% width, height
\global\edef\maxwidth{#1} % in cm
\global\edef\maxheight{#2} % in cm
}
\begin{document}
\begin{tikzpicture}[scale=1]
\maximumdimensions{4}{3}
\draw[fill=orange] (-3,-1) rectangle (3,1) (-2,-2) rectangle (2,2);
\getscalingfactors
\end{tikzpicture}
\lipsum[1]
\begin{tikzpicture}[scale=1]
\maximumdimensions{4}{3}
\draw[fill=orange!50!gray] (0,0) circle (3);
\draw[fill=red!50!gray] (3,1) circle (1);
\draw[fill=blue!50!gray] (-2,2) circle (1);
\draw[fill=green!50!gray] (-3,-2) circle (1);
\draw[fill=yellow!50!gray] (2,-1) circle (1);
\getscalingfactors
\end{tikzpicture}
\end{document}
If you scale the picture down enough, the nodes inside the picture vanish:
\begin{tikzpicture}[scale=0.66]
and \begin{tikzpicture}[scale=0.497]
As documented a table
is a box so can not break over a page longtable
should not be used with it. Removing that fixes most of the problems, then just change the size and squeeze the columns a bit and it all fits.
\documentclass[a4paper,12pt]{article}
\usepackage{longtable}
\usepackage{pdflscape}
\usepackage{graphicx}
\begin{document}
\footnotesize % Switch from 12pt to 11pt; otherwise, table won't fit
\setlength\LTleft{-30pt} % default: \fill
\setlength\LTright{-30pt} % default: \fill
\begin{longtable}{@{\extracolsep{\fill}}llllllllll@{}}
\hline\hline %inserts double horizontal lines
cat. & level & type & num1 & num2 & num3 & \multicolumn{2}{c}{$S1$} & \multicolumn{2}{c}{$S2$} \\ [0.5ex]
\hline % inserts single horizontal line
& & & & & & PP3 & PP4 & PP3 & PP4 \\
E1 & 7E-54 & S2 & NA & NA & NA & NA & NA & NA & NA \\
E2 & 4E-8 & S1 & 1 & 25428038:25828097 & 10023824146 & 9 & 91 & 50 & 50 \\
& & & 1 & 25456834:25856893 & 10025905748 & 0.129 & 2.26 & 0.133 & 0.23 \\
& & S & 1 & 25428038:25828097 & 10023824146 & 8.9 & 91.1 & 49.7 & 50.3 \\
& & & 1 & 25456834:25856893 & 10025905748 & 0.129 & 2.22 & 0.133 & 0.226 \\
E3 & 4E-8 & S2 & 1 & 25488669:25888728 & 10025910500 & 12 & 88 & 57.7 & 42.2 \\
& & S & 1 & 25488669:25888728 & 10025910500 & 13.2 & 86.8 & 60.5 & 39.5 \\
E4 & 2E-145 & S1 & 1 & 25626305:26026364 & 10023820955 & 1.04 & 99 & 10.3 & 89.7 \\
& & & 1 & 25624780:26024839 & 10025907287 & 1.92 & 98 & 16.9 & 82.5 \\
& & & 1 & 25625807:26025866 & 10025935784 & 2.45 & 97.5 & 20.7 & 79.3 \\
& & S2 & 1 & 25626305:26026364 & 10023820955 & 1.09 & 98.9 & 10.6 & 89.4 \\
& & & 1 & 25624780:26024839 & 10025907287 & 1.92 & 98 & 16.9 & 82.5 \\
& & & 1 & 25625807:26025866 & 10025935784 & 3.29 & 96.7 & 25.9 & 74.1 \\
E5 & 1E-13 & S2 & 1 & 62870388:63270447 & 10023831002 & 9.39 & 90.6 & 51.1 & 48.9 \\
& & S3 & 1 & 62870388:63270447 & 10023831002 & 9.47 & 90.5 & 51.3 & 48.7 \\
& & S4 & 1 & 62870388:63270447 & 10023831002 & 7.64 & 92.4 & 45.5 & 54.5 \\
E6 & 1E-22 & S2 & 1 & 62849818:63249877 & 10023825945 & 5.44 & 94.6 & 36.9 & 63.1 \\
& & & 1 & 62720869:63120928 & 10023851197 & 1.56 & 13.5 & 1.79 & 1.54 \\
& & S3 & 1 & 62849818:63249877 & 10023825945 & 4.63 & 95.4 & 33.1 & 66.9 \\
& & & 1 & 62720869:63120928 & 10023851197 & 1.56 & 13.8 & 1.79 & 1.58 \\
& & S2 & 1 & 62849818:63249877 & 10023825945 & 5.54 & 94.5 & 37.3 & 62.7 \\
& & & 1 & 62720869:63120928 & 10023851197 & 1.55 & 14.3 & 1.79 & 1.64 \\
E7 & 5E-94 & S1 & 1 & 109618271:110018330 & 10025913212 & 0.159 & 99.8 & 2.43 & 97.6 \\
& & S2 & 1 & 109618271:110018330 & 10025913212 & 0.189 & 99.8 & 2.72 & 97.3 \\
E8 & 9.00E-17 & S1 & 1 & 109744528:110144587 & 10025910902 & 0.702 & 99.3 & 7.38 & 92.6 \\
E8 & 1E-22 & S2 & 1 & 62849818:63249877 & 10023825945 & 5.44 & 94.6 & 36.9 & 63.1 \\
& & & 1 & 62720869:63120928 & 10023851197 & 1.56 & 13.5 & 1.79 & 1.54 \\
& & S3 & 1 & 62849818:63249877 & 10023825945 & 4.63 & 95.4 & 33.1 & 66.9 \\
& & & 1 & 62720869:63120928 & 10023851197 & 1.56 & 13.8 & 1.79 & 1.58 \\
& & S2 & 1 & 62849818:63249877 & 10023825945 & 5.54 & 94.5 & 37.3 & 62.7 \\
& & & 1 & 62720869:63120928 & 10023851197 & 1.55 & 14.3 & 1.79 & 1.64 \\
E9 & 1E-22 & S2 & 1 & 62849818:63249877 & 10023825945 & 5.44 & 94.6 & 36.9 & 63.1 \\
& & & 1 & 62720869:63120928 & 10023851197 & 1.56 & 13.5 & 1.79 & 1.54 \\
& & S3 & 1 & 62849818:63249877 & 10023825945 & 4.63 & 95.4 & 33.1 & 66.9 \\
& & & 1 & 62720869:63120928 & 10023851197 & 1.56 & 13.8 & 1.79 & 1.58 \\
& & S2 & 1 & 62849818:63249877 & 10023825945 & 5.54 & 94.5 & 37.3 & 62.7 \\
& & & 1 & 62720869:63120928 & 10023851197 & 1.55 & 14.3 & 1.79 & 1.64 \\
E10 & 1E-22 & S2 & 1 & 62849818:63249877 & 10023825945 & 5.44 & 94.6 & 36.9 & 63.1 \\
& & & 1 & 62720869:63120928 & 10023851197 & 1.56 & 13.5 & 1.79 & 1.54 \\
& & S3 & 1 & 62849818:63249877 & 10023825945 & 4.63 & 95.4 & 33.1 & 66.9 \\
& & & 1 & 62720869:63120928 & 10023851197 & 1.56 & 13.8 & 1.79 & 1.58 \\
& & S2 & 1 & 62849818:63249877 & 10023825945 & 5.54 & 94.5 & 37.3 & 62.7 \\
& & & 1 & 62720869:63120928 & 10023851197 & 1.55 & 14.3 & 1.79 & 1.64 \\
E11 & 1E-22 & S2 & 1 & 62849818:63249877 & 10023825945 & 5.44 & 94.6 & 36.9 & 63.1 \\
& & & 1 & 62720869:63120928 & 10023851197 & 1.56 & 13.5 & 1.79 & 1.54 \\
& & S3 & 1 & 62849818:63249877 & 10023825945 & 4.63 & 95.4 & 33.1 & 66.9 \\
& & & 1 & 62720869:63120928 & 10023851197 & 1.56 & 13.8 & 1.79 & 1.58 \\
& & S2 & 1 & 62849818:63249877 & 10023825945 & 5.54 & 94.5 & 37.3 & 62.7 \\
& & & 1 & 62720869:63120928 & 10023851197 & 1.55 & 14.3 & 1.79 & 1.64 \\
E12 & 1E-22 & S2 & 1 & 62849818:63249877 & 10023825945 & 5.44 & 94.6 & 36.9 & 63.1 \\
& & & 1 & 62720869:63120928 & 10023851197 & 1.56 & 13.5 & 1.79 & 1.54 \\
& & S3 & 1 & 62849818:63249877 & 10023825945 & 4.63 & 95.4 & 33.1 & 66.9 \\
& & & 1 & 62720869:63120928 & 10023851197 & 1.56 & 13.8 & 1.79 & 1.58 \\
& & S2 & 1 & 62849818:63249877 & 10023825945 & 5.54 & 94.5 & 37.3 & 62.7 \\
& & & 1 & 62720869:63120928 & 10023851197 & 1.55 & 14.3 & 1.79 & 1.64 \\
E13 & 1E-22 & S2 & 1 & 62849818:63249877 & 10023825945 & 5.44 & 94.6 & 36.9 & 63.1 \\
& & & 1 & 62720869:63120928 & 10023851197 & 1.56 & 13.5 & 1.79 & 1.54 \\
& & S3 & 1 & 62849818:63249877 & 10023825945 & 4.63 & 95.4 & 33.1 & 66.9 \\
& & & 1 & 62720869:63120928 & 10023851197 & 1.56 & 13.8 & 1.79 & 1.58 \\
& & S2 & 1 & 62849818:63249877 & 10023825945 & 5.54 & 94.5 & 37.3 & 62.7 \\
& & & 1 & 62720869:63120928 & 10023851197 & 1.55 & 14.3 & 1.79 & 1.64 \\
E14 & 1E-22 & S2 & 1 & 62849818:63249877 & 10023825945 & 5.44 & 94.6 & 36.9 & 63.1 \\
& & & 1 & 62720869:63120928 & 10023851197 & 1.56 & 13.5 & 1.79 & 1.54 \\
& & S3 & 1 & 62849818:63249877 & 10023825945 & 4.63 & 95.4 & 33.1 & 66.9 \\
& & & 1 & 62720869:63120928 & 10023851197 & 1.56 & 13.8 & 1.79 & 1.58 \\
& & S2 & 1 & 62849818:63249877 & 10023825945 & 5.54 & 94.5 & 37.3 & 62.7 \\
& & & 1 & 62720869:63120928 & 10023851197 & 1.55 & 14.3 & 1.79 & 1.64 \\
E15 & 1E-22 & S2 & 1 & 62849818:63249877 & 10023825945 & 5.44 & 94.6 & 36.9 & 63.1 \\
& & & 1 & 62720869:63120928 & 10023851197 & 1.56 & 13.5 & 1.79 & 1.54 \\
& & S3 & 1 & 62849818:63249877 & 10023825945 & 4.63 & 95.4 & 33.1 & 66.9 \\
& & & 1 & 62720869:63120928 & 10023851197 & 1.56 & 13.8 & 1.79 & 1.58 \\
& & S2 & 1 & 62849818:63249877 & 10023825945 & 5.54 & 94.5 & 37.3 & 62.7 \\
& & & 1 & 62720869:63120928 & 10023851197 & 1.55 & 14.3 & 1.79 & 1.64 \\
\hline
\end{longtable}
\end{document}
Best Answer
It should also be noted that
\resizebox
has roundoff issues, and often slightly exceeds its limits.