4

How can I make all labels in my circuit monospaced? I found this: Can I change all math output to use monospaced text? but this also affects my equations outside figures.


    \documentclass{minimal}
    \usepackage{pst-circ}
    \usepackage{amsmath}
    \everymath{\mathtt{\xdef\tmp{\fam\the\fam\relax}\aftergroup\tmp}}
    \usepackage[utf8]{inputenc}
    \begin{document}
    \setbox0\hbox{$ $}
        \begin{pspicture}(5,2)
        \psset{linewidth=1pt}
        \pnode(0,1){A}
        \pnode(3,1){B}
        \pnode(5,1){C}
        \newdiode(A)(B){$D_1$}
        \resistor(B)(C){$R_1$}
        \end{pspicture}
    $ \frac{1}{2\sqrt{x}} $
    \end{document}
Can I redefine pst-circ label command to use monospaced font?

  • What about just using $\mathtt{D_1}$ and $\mathtt{R_1}$? – Werner Jun 2 '13 at 6:21
  • The final circuits are far more complicated and there is an exact solution for sans serif fonts: tex.stackexchange.com/questions/26145/… however I can't merge two mentioned methods to work together. – user15941 Jun 2 '13 at 9:47
3

You're using the wrong order; first you have to set \everymath and then set a box to initialize the mechanism. If you set \everymath inside the pspicture, the effect will vanish with its end.

\documentclass{standalone}
\usepackage{pst-circ}
\usepackage{amsmath}

\usepackage[utf8]{inputenc}
\begin{document}
\begin{pspicture}(5,2)
\everymath{\mathtt{\xdef\tmp{\fam\the\fam\relax}\aftergroup\tmp}}
\sbox0{$$}% initialize tt for all math formulas
\psset{linewidth=1pt}
\pnode(0,1){A}
\pnode(3,1){B}
\pnode(5,1){C}
\newdiode(A)(B){$D_1$}
\resistor(B)(C){$R_1$}
\end{pspicture}
$\frac{1}{2\sqrt{x}}$
\end{document}

enter image description here

Note that using the minimal class is not recommended for making examples; use article or standalone.


You can define a handier command to get this:

\documentclass{standalone}
\usepackage{pst-circ}
\usepackage{amsmath}

\newcommand{\ttmath}{%
  \everymath{\mathtt{\xdef\tmp{\fam\the\fam\relax}\aftergroup\tmp}}%
  \sbox0{$$}% initialize tt for all math formulas
}

\usepackage[utf8]{inputenc}
\begin{document}
\begin{pspicture}(5,2)
\ttmath
\psset{linewidth=1pt}
\pnode(0,1){A}
\pnode(3,1){B}
\pnode(5,1){C}
\newdiode(A)(B){$D_1$}
\resistor(B)(C){$R_1$}
\end{pspicture}
$\frac{1}{2\sqrt{x}}$
\end{document}
  • Now can I use it with everyhook package? – user15941 Jun 3 '13 at 19:44
  • @user15941 The important thing is to assign \everymath locally in the pspicture environment. I added something. – egreg Jun 3 '13 at 19:59
1

try the latest version of pst-circ.tex from http://texnik.dante.de/tex/generic/pst-circ/. It knows two additional arguments:

\documentclass{article}
\usepackage{pst-circ}
\begin{document}
\psset{mathlabel,labelstyle=\tt} %%%%
  \begin{pspicture}(5,2)
    \psset{linewidth=1pt}
    \pnode(0,1){A}
    \pnode(3,1){B}
    \pnode(5,1){C}
    \newdiode(A)(B){D_1}%% without $..$
    \resistor(B)(C){R_1}
    \end{pspicture}
    $ \frac{1}{2\sqrt{x}} $
\end{document}

enter image description here

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.