2

is there a way to make R_M and U_q italic in circuitikz?

\documentclass{article}
\usepackage[utf8]{inputenc}
%\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{float}
\usepackage{amssymb,amsfonts,textcomp}
\usepackage[LGR,T1]{fontenc}
\usepackage[greek,ngerman]{babel}
\usepackage[LGRgreek]{mathastext}
\usepackage{array}
\usepackage{supertabular}
\usepackage{hhline}
\usepackage{caption}
%\usepackage[tableposition=top]{caption}
\usepackage{biblatex}
\usepackage{graphicx}
\usepackage{subfig}
\usepackage{geometry}
\usepackage[european]{circuitikz}
%\usepackage[american]{circuitikz}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{siunitx}
\usepackage{hyperref}

\begin{document}

\clearpage
\begin{figure}[H]
\centering
\begin{circuitikz}[scale=1.0]
    \draw
    (0,0) node[anchor=east]{}
        %to[ammeter, -*] (1,0)
            to[short] (0,2)
            to[short,](1,2)
            to[R,l=$R_{M}$,-](3,2)
            to[short](3,0)
            to[short](0,0)

         (0,0) to [european voltage source,l=$U_{q}$] (0,2)   
        %to[voltmeter,] (0,1)
;
\end{circuitikz}
\caption{Ersatzschaltbild des Trogs}
\label{fig:trog_ersatz}
\end{figure}

\end{document}

[Circuit[1]

8
  • 1
    Welcome to TeX.SE...can you show a compatible MWE?
    – MadyYuvi
    Commented Jul 18, 2019 at 14:01
  • 2
    Your code produces math italic for me. So you must have something else in your document that is overriding it. Please edit your question to include a compilable document that shows the issue.
    – Alan Munn
    Commented Jul 18, 2019 at 14:03
  • 2
    It seems that you have somewhere defined upright math fonts. I tested your code slightly shortened (this not influence on result): \documentclass{article} \usepackage{circuitikz} \begin{document} \begin{circuitikz} \draw (0,0) to [V,l=$U_{q}$] (0,2) to [R,l=$R_{M}$,-] (3,2) |- (0,0); \end{circuitikz} \end{document} and with it I can't reproduce your image.
    – Zarko
    Commented Jul 18, 2019 at 14:42
  • I edited the question and included the whole code
    – Quai Chun
    Commented Jul 18, 2019 at 15:20
  • 2
    Yep: "The mathastext package changes the fonts which are used in math mode for letters, digits and a few other punctuation and symbol signs to replace them with the font as used for the document text." (from the first line of the package's documentation). So you have what you've asked...
    – Rmano
    Commented Jul 18, 2019 at 15:29

2 Answers 2

4

Since you are using mathastext and changing all the math to upright, the simplest solution for your circuit is to wrap the labels in \mathit:

\documentclass[]{article}
\usepackage{tikz}
\usepackage{circuitikz}
\usepackage[LGRgreek]{mathastext}

\begin{document}
\begin{circuitikz}[scale=1.0]
\draw
(0,0) node[anchor=east]{}
        to[short] (0,2)
        to[short,](1,2)
        to[R,l=$\mathit{R_{M}}$,-](3,2)
        to[short](3,0)
        to[short](0,0)

     (0,0) to [european voltage source,l=$\mathit{U_{q}}$] (0,2);   
  \end{circuitikz}
\end{document}

output of code

4
  • As Rmano mentioned, \usepackage[LGRgreek]{mathastext} changes it to non-italic (or regular font).
    – Quai Chun
    Commented Jul 18, 2019 at 15:32
  • This is solution, but it is not consistent with other math expressions in document (I suspect, that they exist in in it) . OP should decide what he like to have.
    – Zarko
    Commented Jul 18, 2019 at 16:49
  • @Zarko It seems that the OP is making a distinction between the two from the comments.
    – Alan Munn
    Commented Jul 18, 2019 at 16:51
  • 1
    yeah, it seems so. Personally I will not do this.TO have upright variable is not so disturbing to me. +1 for answer!
    – Zarko
    Commented Jul 18, 2019 at 16:53
1

Mostly off-topic, but may be helpful:

enter image description here

\documentclass{article}
\usepackage{circuitikz} % it also load "tikz"
\usepackage[LGRgreek]{mathastext}

\begin{document}
Current through resistance $R_M$ we can calculate by Ohm law:
    \[
I_M = \frac{U_q}{R_M}
    \]
As you can see, used font shape in the circuit diagram below is consistent with variable shapes in equation. I wouldn't change this.
    \begin{center}
\begin{circuitikz}
\draw
(0,0)   to [V,l=$U_{q}$]    (0,2)
        to [R,l=$R_{M}$,-]  (3,2)
        |-                  (0,0);
  \end{circuitikz}
    \end{center}
Note: code for your scheme is reorganized and consequently quite shorter. This may be useful for your other drawings.

\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .