[Tex/LaTex] Current Arrows in Circuitikz

circuitikz

I would like to label a current arrow in circuitikz with the label:

i=$i(x+\Delta x,t)$ 

but it does not appear correctly. My code is:

\documentclass[]{article}
\usepackage{mathtools}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{array}
\usepackage{bm}
\usepackage{circuitikz}
\usepackage{tikz}
\usepackage{siunitx}
\usepackage[hypcap]{caption}
\begin{document}

\begin{center}\begin{circuitikz} \draw
(0,0) to[short,i=$i(x+\Delta x,t)$] (4,0)
; \end{circuitikz} \end{center}

\end{document}

What happens is this:

Is it possible to label it like this?

I ideally want an arrow which I can label, and I thought this would be the easiest way to do so. Anything like this would be fine. I've tried another suggestion of doing \draw[-latex] (2.5,0.5) -- (1.5,0.5); to get this but it does not work for me.

Thanks

Best Answer

The comma in your example is interpreted as an option separator by circuitikz, thus resulting in a compilation error. By adding brackets around the mathematical expression, this will be prevented, and your example will compile nicely.

For your other example, you have to include the line \usetikzlibrary{arrows} to load the latex arrow.

\documentclass{standalone}
\usepackage{circuitikz}
    \usetikzlibrary{arrows}

\begin{document}

\begin{circuitikz}
    \draw (0,0) to [short,i=${i(x+\Delta x,t)}$] (4,0);
    \draw[-latex] (0,-1) -- (4,-1) node[below] {$i(x+\Delta x,t)$};
\end{circuitikz}

\end{document}

enter image description here

Related Question