1

I want to use PSTricks for making figures, and I have any code that I know that is good code, because I have viewed the results in images (code compiled well).

I'm trying and trying, but I don't obtain a good result compiled. Could you help me?

A friend of mine tells me that he thinks that I must compile with LaTeX and not with pdflatex.

I tried, but... I have many errors, and have problems with the pst-plot package. WinEdt8 tells me that I may fix the problems with this option in the global options of the documentclass, but I tried... and nothing.

When I put option dvips this... appears in light gray... attenuated

Here is the simple code.

https://dl.dropboxusercontent.com/u/56475675/mini_pstricks.zip other thing... in any code i must use pst-all... but i think that today is not available. I think that if i don't include pst-all and include all the packeges pst-alll includes.... is enough.

For an example with the code visit this link: How can I draw a landscape picture using PSTricks?

I compile and.... I obtain NO ERRORS ( :-) ) but the result is https://dl.dropboxusercontent.com/u/56475675/borra10.pdf

I would like to can start learning PSTricks, but... I need to make a good compiled result with a simple example (i.e., an axis and a function graph).


Morevover, I have a similar problem trying this example, using TikZ How to put a brace and a title?

I compile with any errors, and obtain this: https://dl.dropboxusercontent.com/u/56475675/borra11.zip.

Mika Ike
  • 3,751

2 Answers2

3

First Problem

Removing a huge load of unneeded packages, your document now compiles fine. I also added some extra things, like \begin{figure}...\end{figure}.

Implementation

Compile with xelatex or latex -> dvips -> ps2pdf

\documentclass{report}
\usepackage{pstricks-add}
\usepackage{pst-poly}
\begin{document}

\begin{figure}[!htb]
    \centering
    \begin{pspicture}(0,0)(5,3)
        \psgrid(1,1)(0,0)(4,2)
    \end{pspicture}
    \caption{Figure 1}
    \label{fig:pst1}
\end{figure}

\begin{figure}[!htb]
    \centering
    \begin{pspicture}(0,0)(5,3)
        \psgrid
    \end{pspicture}
    \caption{Figure 2}
    \label{fig:pst2}
\end{figure}

\begin{figure}[!htb]
    \centering
    \begin{pspicture}(0,0)(5,3)
        \psgrid(1,1)(0,0)(4,2)
    \end{pspicture}
    \caption{Figure 3}
    \label{fig:pst3}
\end{figure}

\begin{figure}[!htb]
    \centering
    \begin{pspicture}(0,0)(5,3)
        \psgrid
    \end{pspicture}
    \caption{Figure 4}
    \label{fig:pst4}
\end{figure}

\begin{figure}[!htb]
    \centering
    \newcommand{\sides}{6}
    \begin{pspicture}(-3,-3)(3,3)
        \providecommand{\PstPolygonNode}{\psdot[dotsize=0.15](1;\INode)}
        \PstPolygon[PstPicture=false,PolyNbSides=\sides,unit=3]
    \end{pspicture}
    \caption{Figure 5}
    \label{fig:pst5}
\end{figure}

\begin{figure}[!htb]
    \centering
    \begin{pspicture}(4,5)
        \psframe(0.7,2)(3.3,3)
        \rput(2,2.5){First Example}
    \end{pspicture}
    \caption{Figure 6}
    \label{fig:pst6}
\end{figure}

\begin{figure}[!htb]
    \centering
    \begin{pspicture}(-1,-1)(5,5)   
        \psaxes{->}(0,0)(-0.5,-0.5)(4.5,4.5)[x,0][y, 90]
        \psdot(2,1)
        \uput[0](2,1){A}
    \end{pspicture}
    \caption{Figure 7}
    \label{fig:pst7}
\end{figure}

\begin{figure}[!htb]
    \centering
    \begin{pspicture}(0,0)(5,3)
        \psgrid(1,1)(0,0)(4,2)
    \end{pspicture}
    \caption{Figure 8}
    \label{fig:pst8}
\end{figure}

\begin{figure}[!htb]
    \centering
    \begin{pspicture}(0,0)(5,3)
        \psgrid
    \end{pspicture}
    \caption{Figure 9}
    \label{fig:pst9}
\end{figure}

\end{document}

Output (Just the first page)

enter image description here


Second Problem

God only knows, why there was a figure in the preamble...

Implementation

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc,decorations.pathreplacing}
\begin{document}

\begin{tikzpicture}[domain=0:5,scale=1,thick]
    %Define linear parameters for supply and demand
    \def\dint{4.5}          %Y-intercept for DEMAND.
    \def\dslp{-0.5}         %Slope for DEMAND.
    \def\sint{1.2}          %Y-intercept for SUPPLY.
    \def\sslp{0.8}          %Slope for SUPPLY.

    \def\pfc{2.5}           %Price floor or ceiling

    \def\demand{\x,{\dslp*\x+\dint}}
    \def\supply{\x,{\sslp*\x+\sint}}

    % Define coordinates.
    \coordinate (ints) at ({(\sint-\dint)/(\dslp-\sslp)},{(\sint-\dint)/(\dslp-\sslp)*\sslp+\sint});
    \coordinate (ep) at  (0,{(\sint-\dint)/(\dslp-\sslp)*\sslp+\sint});
    \coordinate (eq) at  ({(\sint-\dint)/(\dslp-\sslp)},0);
    \coordinate (dint) at (0,{\dint});
    \coordinate (sint) at (0,{\sint});
    \coordinate (pfq) at  ({(\pfc-\dint)/(\dslp)},0);
    \coordinate (pfp) at  ({(\pfc-\dint)/(\dslp)},{\pfc});
    \coordinate (sfq) at  ({(\pfc-\sint)/(\sslp)},0);
    \coordinate (sfp) at  ({(\pfc-\sint)/(\sslp)},{\pfc});

    % DEMAND
    \draw[thick,color=blue] plot (\demand) node[right] {$P(q) = -\frac{1}{2}q+\frac{9}{2}$};

    % SUPPLY
    \draw[thick,color=purple] plot (\supply) node[right] {Supply};

    % Draw axes, and dotted equilibrium lines.
    \draw[->] (0,0) -- (6.2,0) node[right] {$Q$};
    \draw[->] (0,0) -- (0,6.2) node[above] {$P$};

    %Price floor and ceiling lines
    \draw[dashed,color=black] plot (\x,{\pfc}) node[right] {$P_c$};
    \draw[dashed] (pfp) -- (pfq) node[below] (qd) {$Q_d$};
    \draw[dashed] (sfp) -- (sfq) node[below] (qs) {$Q_s$};

    \draw[->,baseline=5] ($(0,{\pfc})+(-1.5,0.7)$) node[label= left:Price Ceiling] {} -- ($(0,{\pfc})+(-.1,0.1)$);

    \draw[decorate,decoration={brace,mirror}] (qs.south) -- node[below] {some text} (qd.south);
\end{tikzpicture}

\end{document}

Output

enter image description here

Henri Menke
  • 109,596
1

run the document with pdflatex -shell-escape

\documentclass{report}
\usepackage{pst-poly}
\usepackage{auto-pst-pdf}
\begin{document}

\begin{figure}[!htb]
    \centering
    \begin{pspicture}(0,0)(5,3)
        \psgrid(1,1)(0,0)(4,2)
    \end{pspicture}
    \caption{Figure 1}\label{fig:pst1}
\end{figure}

\begin{figure}[!htb]
    \centering
    \begin{pspicture}(0,0)(5,3)
        \psgrid
    \end{pspicture}
    \caption{Figure 2}\label{fig:pst2}
\end{figure}

\begin{figure}[!htb]
    \centering
    \begin{pspicture}(0,0)(5,3)
        \psgrid(1,1)(0,0)(4,2)
    \end{pspicture}
    \caption{Figure 3}\label{fig:pst3}
\end{figure}

\begin{figure}[!htb]
    \centering
    \begin{pspicture}(0,0)(5,3)
        \psgrid
    \end{pspicture}
    \caption{Figure 4}\label{fig:pst4}
\end{figure}

\begin{figure}[!htb]
    \centering
    \newcommand{\sides}{6}
    \begin{pspicture}(-3,-3)(3,3)
        \providecommand{\PstPolygonNode}{\psdot[dotsize=0.15](1;\INode)}
        \PstPolygon[PstPicture=false,PolyNbSides=\sides,unit=3]
    \end{pspicture}
    \caption{Figure 5}\label{fig:pst5}
\end{figure}

\begin{figure}[!htb]
    \centering
    \begin{pspicture}(4,5)
        \psframe(0.7,2)(3.3,3)
        \rput(2,2.5){First Example}
    \end{pspicture}
    \caption{Figure 6}\label{fig:pst6}
\end{figure}

\begin{figure}[!htb]
    \centering
    \begin{pspicture}(-1,-1)(5,5)   
        \psaxes{->}(0,0)(-0.5,-0.5)(4.5,4.5)[x,0][y, 90]
        \psdot(2,1)
        \uput[0](2,1){A}
    \end{pspicture}
    \caption{Figure 7}\label{fig:pst7}
\end{figure}

\begin{figure}[!htb]
    \centering
    \begin{pspicture}(0,0)(5,3)
        \psgrid(1,1)(0,0)(4,2)
    \end{pspicture}
    \caption{Figure 8}\label{fig:pst8}
\end{figure}

\begin{figure}[!htb]
    \centering
    \begin{pspicture}(0,0)(5,3)
        \psgrid
    \end{pspicture}
    \caption{Figure 9}\label{fig:pst9}
\end{figure}

\end{document}