1

I'm intent on doing some freelance work. I use LaTeX in my primary job. It's on a Linux platform maintained by others. I've gotten a few requests which I cannot honor at my primary job, but doing the work on my own is not verboten.

I've downloaded MikTeX onto my PC / Windows10 at home. My first job includes making a graph. X and Y coordinates >0 Each unit has a horizontal or vertical line extending the entire dimension of the square graph. I.e. a bunch of squares. At the intersections are circles.

My training did not include this kind of graphic work, only text. Can anyone point me in the right direction to get started making these simple figures? I have acquired a LaTeX Graphic Companion book, but it's dated 1997. The first code I copied from the text choked on \usepackage{pstcol}. The error message indicated it was an obsolete term and suggested pstricks, which I used. But I cannot seem to get anything on the .pdf page.

When I posted this question on another LaTeX site, they immediately tried to sell me something.

I the preamble I'm declaring \usepackage{pstricks}

\begin{document}
\begin{pspicture}(0,0)(2,2)\showgrid
\psline[linewidth=1pt,linecolor=gray] 
{<->}(0.5,0)(0,1)(1,1.5)(1.5,1)(.5,.5)
\end{pspicture}
\end{document} 

Gets me an error message

! Undefined control sequence.
l.96 \begin{pspicture}(0,0)(2,2)\showgrid

? 

Commenting out the \showgrid with % gets me the following.

! Undefined control sequence.
\c@lor@to@ps ->\PSTricks 
                         _Not_Configured_For_This_Format
l.98 {<->}
          (0.5,0)(0,1)(1,1.5)(1.5,1)(.5,.5)
? 

Can someone point me in the right direction?

I can do the text, but the graphics befuddle me.

  • Search on pgfplots – Scott Seidman Sep 28 '17 at 0:29
  • You should compile with latex > dvips > ps2pdf. Did you? Or did you compile with pdflatex? – Werner Sep 28 '17 at 0:40
  • This is a new environment for me, coming linux, so bear with me. I clicked TypeSet, then .pdflatex. I'm not finding ps2pdf. – TommyK Sep 28 '17 at 0:45
  • "Search on pgfplots" - Scott Seidman.. I'm not sure what to do with this information. Search where? – TommyK Sep 28 '17 at 0:51
  • run the document with xelatex – user2478 Sep 28 '17 at 12:07
3

I think pstricks is easier to learn because it uses a LaTeX-like syntax – actually it's a LaTeX interface to Adobe Postscript.

There is a difficulty when using it: for quite some time, people have been compiling with pdflatex to obtain directly a .pdf document from .tex source file. However, pdflatex has no computation engine to perform the computations required by Postscript. That is why you have this error message. So you have three possibilities:

  • Compile along the classic chain latex -> dvips -> pstopdf;
  • Compile with pdflatex, and delegate the compilation to an external program, loading the auto-pst-pdf package after `pstricks. This will extract the pstricks code to a temporary file, produce a (cropped) pdf graphic file from an auxiliary compilation, and incorporate this image file to your main document.
  • Compile with xelatex.

Here is your code, slightly modified, to show a little more of the syntax. It has to be compiled with pdflatex. If you want to follow one of the two other ways, just remove (or comment) \usepackage{auto-pst-pdf}.

One more word: for the auxiliary compilation to work, you have to add the switch --enable-write18 to pdflatex. This is done from your editor configuration.

\documentclass[border=3pt, svgnames]{standalone}
\usepackage{pstricks-add,}
\usepackage{auto-pst-pdf} 

\begin{document} 

\psset{arrowinset=0.15, linejoin=1,}
\begin{pspicture}[showgrid](0,0)(2,2)
 \psline[linewidth=1pt,linecolor=SteelBlue] {<->}(0.5,0)(0,1)(1,1.5)(1.5,1)(.5,.5)
\end{pspicture}

\end{document} 

enter image description here

To configure pdflatex in TeXworks, you have to fo to the Edit -> Preferences menu, click on the Typesetting tab, select the pdflatexline, and click on the Edi button. Your configuration for pdflatex should be something like this:

enter image description here

  • I copied and pasted your code. Now it is trying to compile, adding packages along the way. Looks like we be on to something – TommyK Sep 28 '17 at 1:07
  • Okay, now i have a warning message about an escaped turtle: Package ifplatform Warning: shell escape is disabled, so I can only detect \ifwindows. ) ! Package auto-pst-pdf Error: "shell escape" (or "write18") is not enabled: auto-pst-pdf will not work! . See the auto-pst-pdf package documentation for explanation. Type H <return> for immediate help. ... l.134 Or turn off auto-pst-pdf.} % ? – TommyK Sep 28 '17 at 1:08
  • You have to add the switch from your editor. Which one do you use? – Bernard Sep 28 '17 at 1:10
  • I'm editing int TeXworks – TommyK Sep 28 '17 at 1:11
  • You do type in an editor. TeXworks? TeXmaker? TeXstudio? – Bernard Sep 28 '17 at 1:13

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.