Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

\psElectricfield only accepts a coordinate in space-separated values as follows. For example, a charge of -0.1 unit at (-1,0) is written as [-0.1 -1 0]. I have attempted to write in PS notation but it still does not work.

\documentclass{article}
\pagestyle{empty}

\usepackage{pst-electricfield,multido}
\def\M{2}

\begin{document}
\multido{\i=0+30}{12}{%
\begin{pspicture*}(-\M,-\M)(\M,\M)
    \psElectricfield
    [
        Q={[-0.1 -1 0][-0.1 1 0][0.1 !\i sin 2 mul \i cos 2 mul]}
    ]
\end{pspicture*}\newpage}
\end{document}

How to express a polar coordinate for a macro that only accepts space-separated values?

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted
\documentclass{article}
\pagestyle{empty}\parindent=0pt    
\usepackage{pst-electricfield,multido}
\def\M{2}

\begin{document}
\multido{\i=0+30}{12}{%
\begin{pspicture*}(-\M,-\M)(\M,\M)
    \psElectricfield[Q={
       [-0.1 -1 0]
       [-0.1 1 0]
       [0.1 \i\space sin 2 mul 
            \i\space cos 2 mul]}]
\end{pspicture*} }
\end{document}

you have to use {\i} or alternatively \i\space otherwise the following space gets lost and you'll get a wrong PostScript entry like 10sin where the space is missing ("eaten" by TeX)

enter image description here

share|improve this answer
    
+1 Why do we not need ! for PS notation? –  xport Jul 24 '11 at 9:46
    
there is only PS code possible, nothing else –  Herbert Jul 24 '11 at 9:55
add comment

Based on Herbert's solution, I added \pstVerb to it such that the code can be broken into several lines that are often needed when they are posted to a narrow HTML page.

\documentclass{article}
\pagestyle{empty}\parindent=0pt    
\usepackage{pst-electricfield,multido}
\def\M{2}

\begin{document}
\multido{\i=0+30}{12}{%
\begin{pspicture*}[showgrid](-\M,-\M)(\M,\M)
    \pstVerb{/xx \i\space sin 2 mul def}%
    \pstVerb{/yy \i\space cos 2 mul def}%   
    \psElectricfield
    [
        Q={[-0.1 -1 0][-0.1 1 0][0.1 xx yy]}
    ]
\end{pspicture*} }
\end{document}
share|improve this answer
1  
or: how can one make things complecated instead of easy ... –  Herbert Jul 24 '11 at 10:11
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.