![在 pspicture 环境中重置 \psset](https://linux22.com/image/336720/%E5%9C%A8%20pspicture%20%E7%8E%AF%E5%A2%83%E4%B8%AD%E9%87%8D%E7%BD%AE%20%5Cpsset.png)
\psset
如何使使用环境中的命令创建的样式无效pspicture
?
以以下使用 XeLaTeX 编译的 MWE 为例:
我想在绘制中间的黑色圆圈后使当前样式无效,以便底部的红色圆圈linewidth
与顶部的蓝色圆圈相同。
% !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
您可以使用组
{% begin a group
% Set new local style
\psset{linewidth=4pt, linecolor=black}
% Draw middle circle
\pscircle(1,2){1}
}% end the group
然后设置就是本地的。
% !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}
或者使用可选参数\pscircle
:
% Draw middle circle with new style
\pscircle[linewidth=4pt, linecolor=black](1,2){1}
答案2
始终使用本地设置,而没有\psset
它,全局设置或多或少才有意义:
\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}