tikzpicture 在我的盒子外面

tikzpicture 在我的盒子外面

我想要一个tikzpicture在里面的tcolorbox。但由于某种原因,它浮在了框外。我该如何正确地将图像居中?

在此处输入图片描述

\documentclass[10pt, a4paper, twoside, titlepage, openbib]{article}

    \usepackage{tikz}
        %Tikz is een library die toestaat om tekeningen te maken
        \usetikzlibrary{shapes}
            %Shapes
        \usetikzlibrary{arrows}
            %Arrows
        \usetikzlibrary{calc}
            %Calculation
        \usetikzlibrary{decorations}
            %Decorations
        \usetikzlibrary{backgrounds}
            %Backgrounds
        \usetikzlibrary{fit}
            %
        \usetikzlibrary{positioning}
            %
        \usetikzlibrary{chains}
            %
    \usepackage[europeanresistors,americaninductors]{circuitikz}
    \usepackage{tcolorbox}
        %http://mirror.unl.edu/ctan/macros/latex/contrib/tcolorbox/tcolorbox.pdf
        \tcbuselibrary{listings}
        \tcbuselibrary{theorems}

\begin{document}

%---Image--------------------------------------------------------------------------------------------   
\begin{figure*}[ht!] %het blokschema
    \centering
    \begin{tcolorbox}[colback=white]
    \begin{tikzpicture}[node distance = 0.2cm, auto]
        \begin{circuitikz}
            \draw
                (8.5,-1.) node[draw,minimum width=2cm,minimum height=2.4cm] (load) {Load}
                    ($(load.west)!0.75!(load.north west)$) coordinate (la)
                    ($(load.west)!0.75!(load.south west)$) coordinate (lb)
                (1,3) node[spdt,xscale=1, yscale=1,anchor=in] (myspdt1) {}
                (4,3) node[spdt,xscale=-1,yscale=1,anchor=in] (myspdt2) {}
                (5,0)   node[ground, yscale=1]{}
                        to[full led]        (5,3)
                        to(myspdt2.in)
                (0,0)   node[ground]{}
                        to[vsourcesin]      (0,3)
                        to(myspdt1.in)
                (0,2) node[right]{$V_{s}(t)$}
                (myspdt1.out 1) -- (myspdt2.out 1)
                (myspdt1.out 2) -- (myspdt2.out 2);
        \end{circuitikz}
    \end{tikzpicture}
    \end{tcolorbox}   
        \caption{Het eerste probleem} 
        \label{fig:Het eerste probleem} 
\end{figure*}
%---Image--------------------------------------------------------------------------------------------

\end{document}

答案1

circuitikz问题在于环境内的嵌套tikzpicture,这是不推荐的。

删除外部环境并“稍微”tikzpicture改变框架的垂直位置:Load

\documentclass[10pt, a4paper, twoside, titlepage, openbib]{article}

    \usepackage{tikz}
        %Tikz is een library die toestaat om tekeningen te maken
        \usetikzlibrary{shapes}
            %Shapes
        \usetikzlibrary{arrows}
            %Arrows
        \usetikzlibrary{calc}
            %Calculation
        \usetikzlibrary{decorations}
            %Decorations
        \usetikzlibrary{backgrounds}
            %Backgrounds
        \usetikzlibrary{fit}
            %
        \usetikzlibrary{positioning}
            %
        \usetikzlibrary{chains}
            %
    \usepackage[europeanresistors,americaninductors]{circuitikz}
    \usepackage[most]{tcolorbox}
    % http://mirror.unl.edu/ctan/macros/latex/contrib/tcolorbox/tcolorbox.pdf
    \tcbuselibrary{listings}
    \tcbuselibrary{theorems}

\begin{document}

%---Image--------------------------------------------------------------------------------------------   
\begin{figure*}[ht!] %het blokschema
    \centering
    \begin{tcolorbox}[colback=white]
        \begin{circuitikz}[node distance = 0.2cm, auto]
            \draw
                (8.5,2) node[draw,minimum width=2cm,minimum height=2.4cm] (load) {Load}
                    ($(load.west)!0.75!(load.north west)$) coordinate (la)
                    ($(load.west)!0.75!(load.south west)$) coordinate (lb)
                (1,3) node[spdt,xscale=1, yscale=1,anchor=in] (myspdt1) {}
                (4,3) node[spdt,xscale=-1,yscale=1,anchor=in] (myspdt2) {}
                (5,0)   node[ground, yscale=1]{}
                        to[full led]        (5,3)
                        to(myspdt2.in)
                (0,0)   node[ground]{}
                        to[vsourcesin]      (0,3)
                        to(myspdt1.in)
                (0,2) node[right]{$V_{s}(t)$}
                (myspdt1.out 1) -- (myspdt2.out 1)
                (myspdt1.out 2) -- (myspdt2.out 2);
        \end{circuitikz}
    \end{tcolorbox}   
    \caption{Het eerste probleem} 
    \label{fig:Het eerste probleem} 
\end{figure*}
%---Image--------------------------------------------------------------------------------------------

\end{document}

在此处输入图片描述

相关内容