6
\documentclass[pstricks,border=12pt]{standalone}
\usepackage{pst-circ}
\begin{document}
\begin{pspicture}[showgrid](4,4)
\pnodes
    (0,2){A}
    (4,2){B}
    \resistor
    [
        intensitylabel=$i_1$,
        intensitylabeloffset=.3,
        tensionlabel=$v_1$,
        tensionoffset=-.5,
        tensionlabeloffset=-.8,
    ](A)(B){$R$}
\end{pspicture}
\end{document}

enter image description here

I want to change the above diagram to the following.

enter image description here

How to change the tension symbol from an arrow to a pair of plus and minus signs?

8

the pst-circ.tex from http://texnik.dante.de/tex/generic/pst-circ/ or the latest TeXLive update from today knows tensionstyle=pm (the default is tensionstyle=line). Should work for all elements.

\documentclass[pstricks,border=12pt]{standalone}
\usepackage{pst-circ}
\begin{document}
\begin{pspicture}[showgrid](4,4)
\pnodes(0,2){A}(4,2){B}
\resistor[
        intensitylabel=$i_1$,
        intensitylabeloffset=.3,
        tensionlabel=$v_1$,
        tensionoffset=-.5,
        tensionlabeloffset=-.8,
        tensionstyle=pm         ](A)(B){$R$}
\end{pspicture}
\end{document}

enter image description here

  • ...hot off the press I guess. – Werner Oct 3 '13 at 6:51
  • I think arrow is more semantic and clearer than line. – kiss my armpit Oct 3 '13 at 6:55
3

The following MWE provides a starred version of \resistor which sets a +/- instead of an arrow:

enter image description here

\documentclass{article}
\usepackage{pst-circ}% http://ctan.org/pkg/pst-circ
\makeatletter
\let\@oldresistor\resistor
\def\resistor{\@ifstar\@newresistor\@oldresistor}
\def\@newresistor{\@ifnextchar[\@newresistor@i{\@newresistor@i[]}}
\def\@newresistor@i[#1](#2)(#3)#4{{%
  \def\pst@tension##1##2{%
    \psset{linestyle=none}% Remove lines
    \ifPst@tension
      \pcline[arrows=-,fillstyle=none,%linestyle=none,
        offset=\psk@tension@offset](##1)(dipole@1)
      \ncput[npos=.9]{\pnode{tension@1}}
      \pcline[arrows=-,fillstyle=none,%linestyle=none,
        offset=-\psk@tension@offset](##2)(dipole@2)
      \ncput[npos=.9]{\pnode{tension@2}}
      \ifPst@directconvention
        \ifPst@Dconvention
          \rput{0}(tension@1){$\scriptstyle-$}\rput{0}(tension@2){$\scriptstyle+$}
        \else
          \rput{0}(tension@1){$\scriptstyle+$}\rput{0}(tension@2){$\scriptstyle-$}
        \fi
      \else
        \ifPst@Dconvention
          \rput{0}(tension@1){$\scriptstyle+$}\rput{0}(tension@2){$\scriptstyle-$}
        \else
          \rput{0}(tension@1){$\scriptstyle-$}\rput{0}(tension@2){$\scriptstyle+$}
        \fi
      \fi
      \pcline[arrows=-,linestyle=none,fillstyle=none,%
        offset=\psk@tension@label@offset](dipole@1)(dipole@2)
      \ncput[nrot=\psk@label@angle]{%
    \csname\psk@tension@labelcolor\endcsname\psk@tension@label}
    \fi
  }
  \@oldresistor[#1](#2)(#3){#4}%
}}
\makeatother
\begin{document}
\begin{pspicture}[showgrid](4,4)
\pnodes
    (0,2){A}
    (4,2){B}
    \resistor*
    [
        intensitylabel=$i_1$,
        intensitylabeloffset=.3,
        tensionlabel=$v_1$,
        tensionoffset=-.5,
        tensionlabeloffset=-.8,
    ](A)(B){$R$}
\end{pspicture}
\end{document}

The macro \pst@tension is responsible for drawing the arrow and label below the \resistor. It has been changed to move the location of the endpoints of the lines (formerly midway between A/B and the edge of the resistor using a npos=.5 placement) using an npos=.9 placement. Also, instead of drawing the line with an arrow, it now \rputs a +/- at the respective "tension" ends. The entire definition of \pst@tension is otherwise kept the same, so it should work with other options/definitions (including a change in direction).

  • This should be added to the pst-circ package to facilitate users to use it. – kiss my armpit Oct 3 '13 at 6:36

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.