How to find the ratio of a length command (e.g., \textwidth
) to a reference value (e.g., 6cm
) ? Actually I want to use the ratio for the \scalebox
argument, e.g., \scalebox{<ratio>}
.
\documentclass{article}
\usepackage[showframe=true]{geometry}
\usepackage{pst-node}
\usepackage{graphicx}
\usepackage{fp}
\usepackage{pgf}
\pgfmathsetmacro{\ratio}{\the\textwidth/(6cm)}
\makeatletter
\FPdiv\thecm{6}{2.54} %72.27
\FPmul\thecminpoints{\thecm}{72.27}
\FPdiv\thescale{\strip@pt\textwidth}{\thecminpoints}%
\makeatother
\begin{document}
\noindent%
%\scalebox{\thescale}{%
\scalebox{\ratio}{%
\begin{pspicture}(6,4)
\pnode(2,2){A}\psframe(A)
\pnode(4,2){B}\pscircle(B){2}
\end{pspicture}}
\uput[-135](A){$A$}
\rput(B){$B$}
\end{document}
\begin{pspicture}(6,4)
to\begin{pspicture}(\textwidth)
?