GeneralPSTRICKS: How to hide some grids at the final?

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
yoyoimut
Posts: 120
Joined: Mon Oct 19, 2009 6:58 am

PSTRICKS: How to hide some grids at the final?

Post by yoyoimut »

Assume I have many pspicture environments in my input file.
During the development, I want the grid to be shown as the guidance in each pspicture.

At the final stage, some grids must be removed and the others are left intact.

I do as follows:

Code: Select all

\documentclass{article}
\usepackage{pstricks}

\def\tempgrid{\psgrid}

\begin{document}

%permanent grid
\begin{pspicture}(-2,-2)(2,2)
\psgrid
\pscircle*[fillcolor=red]{1}
\end{pspicture}

\vspace{1cm}

%temporary grid
\begin{pspicture}(-2,-2)(2,2)
\tempgrid
\pscircle*[fillcolor=red]{1}
\end{pspicture}
\end{document}
Actully this way works.
However, I want to know whether or not there exists a feature in PSTRICKS or LATEX to do that.

Thank you.

yoyo
Last edited by yoyoimut on Wed Oct 06, 2010 10:58 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

CrazyHorse
Posts: 351
Joined: Sat Aug 02, 2008 8:47 am

PSTRICKS: How to hide some grids at the final?

Post by CrazyHorse »

yoyoimut wrote:Assume I have many pspicture environments in my input file.
During the development, I want the grid to be shown as the guidance in each pspicture.

At the final stage, some grids must be removed and the others are left intact.

However, I want to know whether or not there exists a feature in PSTRICKS or LATEX to do that.

Thank you.

yoyo

Code: Select all

    \documentclass{article}
    \usepackage{pstricks}

    \newpsobject{psGrid}{psgrid}{style=gridstyle}
%    \let\psGrid\relax % to supress \psGrid

    \begin{document}

    %permanent grid
    \begin{pspicture}(-2,-2)(2,2)
    \psgrid
    \pscircle*[fillcolor=red]{1}
    \end{pspicture}

    \vspace{1cm}

    %temporary grid
    \begin{pspicture}(-2,-2)(2,2)
    \psGrid
    \pscircle*[fillcolor=red]{1}
    \end{pspicture}
    \end{document}
Herbert
yoyoimut
Posts: 120
Joined: Mon Oct 19, 2009 6:58 am

Re: PSTRICKS: How to hide some grids at the final?

Post by yoyoimut »

Thank you, Herbert.

I will use your method. It looks sophisticated.

Because I don't like gridstyle, I make the third arguments of \newpsobject empty.
CrazyHorse
Posts: 351
Joined: Sat Aug 02, 2008 8:47 am

PSTRICKS: How to hide some grids at the final?

Post by CrazyHorse »

yoyoimut wrote:
Because I don't like gridstyle, I make the third arguments of \newpsobject empty.

Code: Select all

\newpsstyle{gridstyle}{ ... your definitions ...}
Herbert
yoyoimut
Posts: 120
Joined: Mon Oct 19, 2009 6:58 am

PSTRICKS: How to hide some grids at the final?

Post by yoyoimut »

CrazyHorse wrote:

Code: Select all

\newpsstyle{gridstyle}{ ... your definitions ...}
OK. Thanks.


Is it possible to redefine grid style in one go rather than doing the redefinition twice (as shown in my code below).

Code: Select all

\documentclass{article}
\usepackage{pstricks}

\newpsstyle{gridstyle}{%for showgrid and \psGrid
gridcolor=magenta!30,
subgridcolor=yellow!30,
gridlabels=5pt,
gridlabelcolor=red,
gridwidth=0.4pt,
subgridwidth=0.2pt}

\psset{%for \psgrid
gridcolor=magenta!30,
subgridcolor=yellow!30,
gridlabels=5pt,
gridlabelcolor=red,
gridwidth=0.4pt,
subgridwidth=0.2pt}

\newpsobject{psGrid}{psgrid}{style=gridstyle}
%\let\psGrid\relax

\begin{document}

%permanent grid using showgrid
\begin{pspicture}[showgrid](-2,-2)(2,2)
\pscircle*[fillcolor=red]{1}
\end{pspicture}
\vspace{1cm}


%permanent grid using \psgrid
\begin{pspicture}(-2,-2)(2,2)
\psgrid
\pscircle*[fillcolor=red]{1}
\end{pspicture}
\vspace{1cm}

%temporary grid using \psGrid
\begin{pspicture}(-2,-2)(2,2)
\psGrid
\pscircle*[fillcolor=red]{1}
\end{pspicture}
\vspace{1cm}

\end{document}
CrazyHorse
Posts: 351
Joined: Sat Aug 02, 2008 8:47 am

PSTRICKS: How to hide some grids at the final?

Post by CrazyHorse »

yoyoimut wrote:
CrazyHorse wrote:

Code: Select all

\newpsstyle{gridstyle}{ ... your definitions ...}
OK. Thanks.


Is it possible to redefine grid style in one go rather than doing the redefinition twice (as shown in my code below).

Code: Select all

\psset{%for \psgrid
gridcolor=magenta!30,
subgridcolor=yellow!30,
gridlabels=5pt,
gridlabelcolor=red,
gridwidth=0.4pt,
subgridwidth=0.2pt}

was already shown in my pevious example:

Code: Select all

\psset{style=gridstyle}
instead off all the single definitions

Herbert
yoyoimut
Posts: 120
Joined: Mon Oct 19, 2009 6:58 am

Re: PSTRICKS: How to hide some grids at the final?

Post by yoyoimut »

:o
Thank you, Herbert!
Post Reply