0

I've been searching for hours and I can't find a hint about what did go wrong, except that nobody ever tried to do what I intend (?).

I need to include several circuits (via circuitikz) in a document using the tufte-book template, inside the same figure (I don't need the references, just some captions inside the subfloat).

Here is what I intend to do:

\documentclass[justified]{tufte-handout}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage[main=spanish,english]{babel}
\usepackage[caption=false]{subfig}

\usepackage{tikz}
\usepackage{tikz-3dplot}
\usetikzlibrary{shadings}
\usetikzlibrary{babel}

\usepackage{circuitikz}
\ctikzset{bipoles/length=.8cm}
\ctikzset{label/align=straight}

\usepackage[group-separator={.},output-decimal-marker={,}]{siunitx}

\begin{document}
\begin{figure}
  \subfloat[][]{
    \begin{circuitikz}[scale=.8]
      \draw (0,0) to [battery1,l=\SI{6}{\volt}] (2,0);
      % This line works:
      %\draw (0,0) to [R,l=\SI{2}{\ohm},i=$I_1$] (0,2);
      % This doesn't, and it's the one I need working:
      \draw (0,0) to [R,l=\SI{2}{\ohm},i<=$I_1$] (0,2);
      \draw (0,2) to [short] (2,2);
      \draw (2,2) to [R,l=\SI{2}{\ohm},i=$I_2$] (2,0);

      \draw (2,0) to [short] (4,0) to [R,l_=\SI{4}{\ohm},i=$I_3$]
      (4,2) to [battery1,l_=\SI{8}{\volt}] (2,2);
    \end{circuitikz}
  }
\end{figure}
\end{document}

The problem is that with I_1, I need the specific direction, so I need to include the < inside i<=$I_1$, but that bracket is what causes the problem (if I remove it, everything goes smoothly). I know that arrowheads conflict with Babel, so I included the tikz library required to fix that, but even removing Babel, the issue arrises.

My option is to manually create a label inside the figure for each subfigure, but I don't know how to properly align it or the best method for that, and I've read that subcaption doesn't work with Tufte books yet.

I use the latest TeXLive full installation on a Debian Testing (Stretch).

Thanks!

4
  • Can you make your code compilable in order to help you?
    – Very23
    Apr 11, 2016 at 17:13
  • Remove the < from i<=$I_1$, I'll add it now
    – oxio
    Apr 11, 2016 at 17:19
  • The easiest way to reverse the current direction is to switch the coordinates, (one can switch the label using l_=). Apr 11, 2016 at 21:39
  • I did not think that :o Should be worth a try, but maybe I will need to do it more times that I will be able to remember, so I will have it in mind, thanks!
    – oxio
    Apr 11, 2016 at 23:26

1 Answer 1

1

I wasn't sure which way you wanted your arrows to point, so I made them all point up.

As for subfigures and compatibility with babel, the easiest solution is to create your own. Babel defines \figurename and \listfigurename, but you really don't need a subfigure name. The only compatibility issue would be if the alphabet changes.

\documentclass[justified]{tufte-handout}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage[main=spanish,english]{babel}

\usepackage{tikz}
\usepackage{tikz-3dplot}
\usetikzlibrary{shadings}
\usetikzlibrary{babel}

\usepackage{circuitikz}
\ctikzset{bipoles/length=.8cm}
\ctikzset{label/align=straight}

\usepackage[group-separator={.},output-decimal-marker={,}]{siunitx}

\newcounter{subfig}[figure]

\newcommand{\subcaption}[1]% #1 = text
{\bgroup
  \stepcounter{subfig}%
  \sbox0{\textbf{(\Alph{subfig})}\ #1}%
  \par\vskip\abovecaptionskip
  \ifdim\wd0<\linewidth \makebox[\linewidth]{\box0}%
  \else\sbox0{\textbf{(\Alph{subfig})}\ }%
    \usebox0\parbox[t]{\dimexpr\linewidth-\wd0}{#1}%
  \fi
  \par\vskip\belowcaptionskip
\egroup}

\begin{document}
\begin{figure}
  \begin{minipage}[b]{0.5\textwidth}
    \centering
    \begin{circuitikz}[scale=.8]
      \draw (0,0) to [battery1,l=\SI{6}{\volt}] (2,0);
      % This line works:
      %\draw (0,0) to [R,l=\SI{2}{\ohm},i=$I_1$] (0,2);
      % This doesn't, and it's the one I need working:
      \draw (0,0) to [R,l=\SI{2}{\ohm},i=$I_1$] (0,2);
      \draw (0,2) to [short] (2,2);
      \draw (2,0) to [R,l_=\SI{2}{\ohm},i=$I_2$] (2,2);

      \draw (2,0) to [short] (4,0) to [R,l_=\SI{4}{\ohm},i=$I_3$]
      (4,2) to [battery1,l_=\SI{8}{\volt}] (2,2);
    \end{circuitikz}
    \subcaption{test}
  \end{minipage}
\end{figure}
\end{document}

demo

2
  • I had to do some changes to the format, but this will do the work, thanks :D I just have to figure how to vertically align the captions
    – oxio
    Apr 11, 2016 at 23:36
  • If the captions are the same number of lines, use the [b] option for the minipages. Apr 12, 2016 at 3:27

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.