1

How can I invalidate a style that was created using a \psset comand within a pspicture environment?

Take the following MWE, which compiles with XeLaTeX:

I would like to invalidate the current style after the middle black circle is drawn so that the red circle at the bottom has the same linewidth as the blue circle at the top.

three circles

% !TeX program = xelatex
\documentclass[pstricks]{standalone}

\begin{document}
    \begin{pspicture}(2,4)
    % Set new style
    \psset{linecolor=blue}
    % Draw top circle
    \pscircle(1,3){1}
    % Set new style
    \psset{linewidth=4pt, linecolor=black}
    % Draw middle circle
    \pscircle(1,2){1}

    % Invalidate current style here

    % Set new style
    \psset{linecolor=red} % linewidth is kept at 4pt!
    % Draw bottom circle
    \pscircle(1,1){1}
    \end{pspicture}
\end{document}
  • 1
    Very simple: \psset{linecolor=red, linewidth=0.8pt}. 0.8pt is the default value of the length \pslinewidth. – Bernard Jun 29 '16 at 12:41
  • @Bernard Thanks a lot Bernard! Are the default values of pstricks documented somewhere? – codeaviator Jun 29 '16 at 13:50
  • For pstricks-base, they're given with the definition of the parameters. For instance, linewidth default is in pst-user.pdf, §5, p. 8. For other packages, they generally have a list of parameters defined by the extension, with the default, at the end of the documentation. – Bernard Jun 29 '16 at 14:23
1

You can use a group

{% begin a group 
    % Set new local style
    \psset{linewidth=4pt, linecolor=black}
    % Draw middle circle
    \pscircle(1,2){1}
}% end the group

Then the settings are local.

enter image description here

% !TeX program = xelatex
\documentclass[pstricks]{standalone}
\begin{document}
    \begin{pspicture}(2,4)
    % Set new style
    \psset{linecolor=blue}
    % Draw top circle
    \pscircle(1,3){1}

    {% begin a group
        % Set new local style
        \psset{linewidth=4pt, linecolor=black}
        % Draw middle circle
        \pscircle(1,2){1}
    }% end the group

    % Set new style
    \psset{linecolor=red}
    % Draw bottom circle
    \pscircle(1,1){1}
    \end{pspicture}
\end{document}

Or you use the optional argument of \pscircle:

% Draw middle circle with new style
\pscircle[linewidth=4pt, linecolor=black](1,2){1}
  • That's great! I didn't know you could define groups with curly brackets. So simple. Using the optional arguments of \pscircle is a very elegant approach. Thanks a lot! – codeaviator Jun 29 '16 at 13:57
1

use always local settings without \psset which makes more or less only sense for global settings:

\documentclass[pstricks]{standalone}

\begin{document}
    \begin{pspicture}(2,4)
    \pscircle[linecolor=blue](1,3){1}
    \pscircle[linewidth=4pt](1,2){1}
    \pscircle[linecolor=red](1,1){1}
    \end{pspicture}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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