diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..32edae4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,22 @@ + +*.dpth + +*.log + +*.md5 + +*.pdf + +*.dep + +*.aux + +*.auxlock + +test-tikzscale.synctex.gz + +*.ins + +*.sty + +README.txt diff --git a/groupplot.tikz b/groupplot.tikz new file mode 100644 index 0000000..e623a58 --- /dev/null +++ b/groupplot.tikz @@ -0,0 +1,26 @@ +\begin{tikzpicture} + \begin{groupplot}[ + group style={ + group size=2 by 2, + y descriptions at=edge left, + x descriptions at=edge bottom + }, + xlabel=$x$, + ylabel=$y$ + ] + + \nextgroupplot + \addplot {x^2 - x + 4}; + + \nextgroupplot + \addplot {x^2 - x + 4}; + + \nextgroupplot + \addplot {x^2 - x + 4}; + + \nextgroupplot + \addplot {x^2 - x + 4}; + + \end{groupplot} + +\end{tikzpicture} \ No newline at end of file diff --git a/test-tikzscale.tex b/test-tikzscale.tex index b95cceb..1db1b1b 100644 --- a/test-tikzscale.tex +++ b/test-tikzscale.tex @@ -6,6 +6,7 @@ \usepackage{pgfplots} \usepackage{tikz-3dplot} \usetikzlibrary{backgrounds} +\usepgfplotslibrary{groupplots} \usepackage{currfile} \usepackage{lmodern} % Use the package subcaption to test the subfigure command @@ -57,6 +58,12 @@ \includegraphics{pgfplots-test}% \item Use pgfplots with given width and height\\% \includegraphics[width=\linewidth,height=0.3\linewidth]{pgfplots-test}% + \item Use pgfplots with a 2x2 groupplot with a given total width\\% + \includegraphics[width=\linewidth]{groupplot} + \item Use pgfplots with a 2x2 groupplot with given total width and height\\% + \includegraphics[width=\linewidth,height=0.5\linewidth]{groupplot} + \item Use pgfplots with a 2x2 groupplot with given total width and axis ratio\\% + \includegraphics[width=\linewidth,axisratio=0.5]{groupplot} \item Use includegraphics with only a node\\% \includegraphics{testNode.tikz}% % \item Use includegraphics with scaling only a node results in an error\\% @@ -121,4 +128,4 @@ \end{subfigure} \end{figure} -\end{document} \ No newline at end of file +\end{document} diff --git a/tikzscale.dtx b/tikzscale.dtx index dd61f5f..02edce6 100644 --- a/tikzscale.dtx +++ b/tikzscale.dtx @@ -1583,8 +1583,8 @@ and the derived files tikzscale.ins, % \end{macrocode} % Correct the dimension by the error. Use a global assignment, as each iteration in the loop is put into a separate group. % \begin{macrocode} - \pgfmathsetglobalmacro{\tikzscale@width}{\tikzscale@width - \widthDifference}% - \pgfmathsetglobalmacro{\tikzscale@height}{\tikzscale@height - \heightDifference}% + \pgfmathsetglobalmacro{\tikzscale@width}{\requestedWidth / \wd\tikzscale@measuredSize * \tikzscale@width}% + \pgfmathsetglobalmacro{\tikzscale@height}{\requestedHeight / \ht\tikzscale@measuredSize * \tikzscale@height}% }{% \breakforeach }% @@ -1644,10 +1644,10 @@ and the derived files tikzscale.ins, % \begin{macrocode} \tikzscale@ifSizeDifference{\sizeDifference}{% \tikzscale@ifIsWidth{#1}{% - \pgfmathsetglobalmacro{\tikzscale@width}{\tikzscale@width - \sizeDifference}% + \pgfmathsetglobalmacro{\tikzscale@width}{\requestedSize / \measuredSize * \tikzscale@width}% \pgfmathsetglobalmacro{\tikzscale@height}{\tikzscale@width / \requestedAxisRatio}% }{% - \pgfmathsetglobalmacro{\tikzscale@height}{\tikzscale@height - \sizeDifference}% + \pgfmathsetglobalmacro{\tikzscale@height}{\requestedSize / \measuredSize * \tikzscale@height}% \pgfmathsetglobalmacro{\tikzscale@width}{\tikzscale@height * \requestedAxisRatio}% }% \tikzscale@ifSizeDifference{\sizeDifference-\tikzscale@oldSizeDifference}{%