LaTeX forum ⇒ Graphics, Figures & TablesPST/PSTricks not working at all

Information and discussion about graphics, figures & tables in LaTeX documents.
Posts: 1
Joined: Mon Sep 14, 2020 10:19 am

PST/PSTricks not working at all

Postby adrienm » Mon Sep 14, 2020 10:41 am

Hi !

I'm using MiKTeX compiler and Visual Studio Code as my editor. I tried to plot a function using PSTricks but I always get fatal errors even when copying the exact same code as written on my manual book (LaTeX for teachers, Ellipses). So I create a empty document and add some code found on the web ([url=""]this pdf[/url]) to try understand what's going wrong but it fails too. Here's the code I use from the pdf linked before :

Code: [Select all] [Expand/Collapse] [Download] ({untitled.tex})
  1. \documentclass[11pt]{article}
  3. % Packages
  4. \usepackage[utf8]{inputenc} % support for accents
  5. \usepackage[T1]{fontenc}
  6. \usepackage[francais]{babel} % doc language
  7. \usepackage{lmodern}
  8. \usepackage[a4paper]{geometry} % marges
  9. \usepackage{amssymb}
  10. \usepackage{amsmath} % Text into equation
  11. \usepackage{pstricks-add}
  13. \begin{document}
  15. \psset{unit=2cm}
  16. \begin{pspicture}(-2.5,-1.5)(2.5,2.5)
  17. \psaxes{->}(0,0)(-2.5,-1.5)(2.5,2.5)
  18. \psplot[linewidth=1.5pt,algebraic]{-2.5}{+2.5}{(2*x+4)/(2+x^2)}
  19. \psline[linestyle=dashed](-1.5,-1.5)(2.5,2.5)
  20. \def\function{ xVal dup add 4 add xVal dup mul 2 add div }%
  21. \pstVerb{ /xVal -1 def }% start value
  22. \multido{\nA=0+1}{10}{%
  23. \psline[linestyle=dotted](! xVal 0 )(! xVal xVal)
  24. \psline[linecolor=red](! xVal xVal )(! xVal \function )
  25. \psline[linecolor=red](! xVal \function )(! \function\space dup)
  26. \pstVerb{ /xVal \function\space def}
  27. }
  28. \end{pspicture}
  30. \end{document}

On the \psplot, \psline and \def\function commands I get the following errors :
Code: [Select all] [Expand/Collapse] [Download] ({untitled.tex})
  1. Undefined control sequence.
  2. \c@lor@to@ps ->\PSTricks
  3. Undefined control sequence.
  4. \XC@usec@lor ...string \color@ #1#2\endcsname \@@

Every other example of PST code I use gives me the same errors. I don't understand what's going wrong and why it works for everyone and not me... Can you help me please !
Thanks !

PS : When I delete everything in the pspicture environment except from the \psaxes line, I got something strange : numbers are displayed but no line nor arrow at all !

User avatar
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Postby Johannes_B » Tue Sep 15, 2020 4:44 am

You have to use LaTeX in dvi mode, or use XeLaTeX.

You cannot use pdfLaTeX to generate a pdf directly if you want to work with pstricks.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

Return to “Graphics, Figures & Tables”

Who is online

Users browsing this forum: No registered users and 2 guests