[pstricks] \psline \pscurve ...

Jean-Côme Charpentier jean-come.charpentier at wanadoo.fr
Thu Jul 19 14:10:28 CEST 2007


cyrille Piatecki a écrit :
> Dear all,
> 
> is there a way to  input a file containing the points for command like 
> \psline or \pscurve as :
> 
> \psline[options]{\input data.tex}
> 
> 
> with data.tex containing
> (x1,y1)\ldots(xn,yn)

Sure it is! (There is alway a way :-) )

-----%<----- coor.dat -----%<-----
(0,0)(1,1)(2,0)(3,1)(4,0)
-----%<-----%<-----%<------%<-----

-----%<----- test.tex -----%<-----
\documentclass{article}
\usepackage{pstricks}

\makeatletter
\newcommand\ps at cmdfile{} % precaution

% general command
\newcommand\pscmdfile[3][]{%
  \def\ps at cmdfile{\csname ps#2\endcsname[#1]}%
  \expandafter\ps at cmdfile\@@input #3
}
\makeatother

% just for line
\newcommand\pslinefile[2][]{\pscmdfile[#1]{line}{#2}}

\begin{document}
\begin{pspicture}(0,0)(4,1)
%  \pscmdfile[linecolor=red]{line}{coor.dat}
  \pslinefile[linecolor=red]{coor.dat}
  \pscmdfile[linecolor=green]{curve}{coor.dat}
  \pscmdfile{dots}{coor.dat}
\end{pspicture}
\end{document}
-----%<-----%<-----%<------%<-----

  Jean-Côme Charpentier




More information about the PSTricks mailing list