Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I test my figures in an standalone file, and when I obtain what I want, I pass to my main file with text.

How can I do to adapt the size?

Because, sometimes I want to put 3 images in a row and I need to resize the original pstricks pictures.

Suppose this code typed by Herbert in other post:

\documentclass{article}
\usepackage{pstricks}
\newpsobject{pslineA}{psline}{linewidth=6\pslinewidth, linecolor=green}
\newpsobject{pslineB}{psline}{linewidth=10\pslinewidth, linecolor=red}

\begin{document}
\begin{pspicture}(5,5)
  \psline(0,1)(5,1)
  \psline[linewidth=1mm](0,2)(5,2)
  \pslineA(0,3)(5,3)
  \pslineB(0,4)(5,4)
\end{pspicture}
\end{document}

Are there any easy way with psset/xunit/yunit?

I thought that changing numbers in

\psset{xunit=1cm,yunit=1cm}

I could obtain what I want, but... no! I change this values and the picture is with the same length.

share|improve this question
    
there's a psgraph environment that allows you to specify the width and height –  cmhughes Apr 15 at 16:22

3 Answers 3

up vote 5 down vote accepted

Changing the units (unit itself and linewidth) does resize the image:

\documentclass{article}

\usepackage[pdf]{pstricks}
\newpsobject{pslineA}{psline}{linewidth=6\pslinewidth, linecolor=green}
\newpsobject{pslineB}{psline}{linewidth=10\pslinewidth, linecolor=red}

\begin{document}

\begin{pspicture}(5,5)
  \psline(0,1)(5,1)
  \psline[linewidth=1mm](0,2)(5,2)
  \pslineA(0,3)(5,3)
  \pslineB(0,4)(5,4)
\end{pspicture}\\[2cm]

\psset{unit =1.5cm, linewidth=1.5\pslinewidth}
\begin{pspicture}(5,5)
  \psline(0,1)(5,1)
  \psline[linewidth=1mm](0,2)(5,2)
  \pslineA(0,3)(5,3)
  \pslineB(0,4)(5,4)
\end{pspicture}
\end{document} 

enter image description here

share|improve this answer
    
that has no effect to the line width. –  Herbert Apr 15 at 16:45
    
@Herbert: I modified my answer accordingly. –  Bernard Apr 15 at 17:07

setting the linewidth as a multiple of \pslinewidth sets it as an absolute value, the reason why the \psset{unit=1.5} doesn't change the setting. Compare it with

\newpsobject{pslineA}{psline}{linewidth=0.05, linecolor=green}
\newpsobject{pslineB}{psline}{linewidth=0.2, linecolor=red}

which is a relative linewidth setting which refers to the current units, e.g. 1cm. Then you can say \psset{unit=..} or

\psscalebox{<value>}{%
  \begin{pspicture}(..)(..)
  ...
  \end{pspicture}}

for rescaling the pspicture environment.

share|improve this answer

Best practice suggestions

  1. Lengths in PSTricks accept either relative unit or absolute unit.

    a. Use relative unit for lengths that you might want to scale globally now or in the future. The best candidates for this case are coordinates such as in \psframe(2,3) which is a rectangle of width 2 relative unit and height 3 relative unit where these relative units based on the values given to xunit (=1cm by default) and yunit (=1cm by default).

    b. Use absolute unit for lengths that you might not want to scale globally now or in the future. The best candidate for this case, for example, is line width.

  2. If you just want to scale the lengths of the relative unit, set the base unit via unit, xunit, yunit or runit. For more detailed descriptions for these, see the manual.

  3. If you want to scale everything regardless of their units (either relative or absolute), use \psscalebox. \psscalebox even scales the characters.

  4. By using both unit (or its variants) and \psscalebox, you can adjust your diagrams to have proportional dimensions for both lengths and characters.

See how it works:

\documentclass[preview,border=12pt]{standalone}
\usepackage{pstricks}
\newpsobject{pslineA}{psline}{linewidth=6\pslinewidth, linecolor=green}
\newpsobject{pslineB}{psline}{linewidth=10\pslinewidth, linecolor=red}

\def\foo#1{%
\psset{unit=#1}
\begin{pspicture}(5,5)
  \psline(0,1)(5,1)
  \psline[linewidth=1mm](0,2)(5,2)
  \pslineA(0,3)(5,3)
  \pslineB(0,4)(5,4)
    \rput(2.5,2.5){\color{cyan}$\displaystyle \frac{a}{b}=\frac{c}{d}$}
\end{pspicture}}

\begin{document}
\noindent
\foo{1cm}\\
\psscalebox{3}{\foo{.5}}
\end{document}

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.