Tikz:使用 Tikz 元素排列表格

Tikz:使用 Tikz 元素排列表格

我正在尝试使用 CircuiTikz 元素设置一个表格。

该表如下所示:

表_现在

我希望它看起来像这样:

桌子

所以我希望所有内容都居中显示,并在“leitend”和“sperrend”部分添加换行符。Circuitikz 元素应居中显示。我画了一张图来形象化我的愿望。

我不知道如何在 Tikz 中获得它,所以帮助真的很好!

代码如下:

\documentclass[11pt,a4paper,DIV=calc]{scrartcl}
\usepackage{tikz}
\usepackage[europeanresistors,americaninductors,straightvoltages]{circuitikz}
\usepackage{amsmath,amssymb,amsthm}
\begin{document}

\begin{table}
\centering
\tikzset{baseline={([yshift=-0.5ex]current bounding box.center)}}% fixed position of current bounding box
\begin{tabular}{|c|c|c|}
    \hline
    Bauteil:
    & Schaltbild:
    & Ersatzschaltbild:
    \\ 
    \hline
    Kondensator:
    & \begin{circuitikz}
        \draw (0,0) to [C,o-o] (2,0);
        \end{circuitikz} 
    & \begin{circuitikz}
        \draw (0,0) to [C,l=$C$,o-] (2,0)
        to [R,l=$r_\mathrm{C}$,-o] (4,0);
        \end{circuitikz} 
    \\ \hline
    Spule:
    & \begin{circuitikz}
        \draw (0,0) to [L,o-o] (2,0);
        \end{circuitikz} 
    & \begin{circuitikz}
        \draw (0,0) to [L,l=$L$,o-] (2,0)
        to [R,l=$r_\mathrm{L}$,-o] (4,0);
        \end{circuitikz} 
    \\ \hline
    Diode:
    & \begin{circuitikz}
        \draw (0,0) to [D*,o-o] (2,0);
        \end{circuitikz} 
    & leitend: \begin{circuitikz}
        \draw (0,0) to [V=$U_D$,o-] (2,0)
        to [R,l=$r_\mathrm{D}$,-o] (4,0);
        \end{circuitikz}
    sperrend: \begin{circuitikz}
        \draw (0,0) to [short,-o] (0.5,0);
        \draw (1,0) to [short,o-] (1.5,0);
        \end{circuitikz}   
    \\ \hline
    MOSFET:
    & \begin{circuitikz}
      \draw (0,0) to node[nigfete,rotate=90,scale=0.85](nigfet){} (0,0);
      \end{circuitikz}
    & leitend: \begin{circuitikz}
      \draw (0,0) to [R,l=$R_{\mathrm{on}}$,o-o] (2,0);
        \end{circuitikz}  
      sperrend: \begin{circuitikz}
            \draw (0,0) to [short,-o] (0.5,0);
            \draw (1,0) to [short,o-] (1.5,0);
            \end{circuitikz}  
    \\ \hline
    IGBT:
    & \begin{circuitikz}
        \draw (0,0) to node[nigbt,rotate=90](nigigbt2){} (0,0);
        \end{circuitikz}
     & leitend: \begin{circuitikz}
        \draw (0,0) to [V=$U_\mathrm{D}$,o-] (2,0)
        to [R,l=$r_{\mathrm{S}}$,-o] (4,0);
        \end{circuitikz}
        sperrend: \begin{circuitikz}
            \draw (0,0) to [short,-o] (0.5,0);
            \draw (1,0) to [short,o-] (1.5,0);
            \end{circuitikz}  
    \\ \hline
\end{tabular}
\captionof{table}{Elektronische Bauelemente und deren Ersatzschaltbilder}
\label{tab:ESB}
\end{table}
\end{document}

答案1

您可以嵌套表格。

\documentclass[11pt,a4paper,DIV=calc]{scrartcl}
\usepackage{tikz}
\usepackage[europeanresistors,americaninductors,straightvoltages]{circuitikz}
\usepackage{amsmath,amssymb,amsthm}
\begin{document}

\begin{table}
\centering
\tikzset{baseline={([yshift=-0.5ex]current bounding box.center)}}% fixed position of current bounding box
\begin{tabular}{|c|c|c|}
    \hline
    Bauteil:
    & Schaltbild:
    & Ersatzschaltbild:
    \\ 
    \hline
    Kondensator:
    & \begin{circuitikz}
        \draw (0,0) to [C,o-o] (2,0);
        \end{circuitikz} 
    & \begin{circuitikz}
        \draw (0,0) to [C,l=$C$,o-] (2,0)
        to [R,l=$r_\mathrm{C}$,-o] (4,0);
        \end{circuitikz} 
    \\ \hline
    Spule:
    & \begin{circuitikz}
        \draw (0,0) to [L,o-o] (2,0);
        \end{circuitikz} 
    & \begin{circuitikz}
        \draw (0,0) to [L,l=$L$,o-] (2,0)
        to [R,l=$r_\mathrm{L}$,-o] (4,0);
        \end{circuitikz} 
    \\ \hline
    Diode:
    & \begin{circuitikz}
        \draw (0,0) to [D*,o-o] (2,0);
        \end{circuitikz} 
    & \begin{tabular}{cc}
leitend &
    sperrend\\ 
    \begin{circuitikz}
        \draw (0,0) to [V=$U_D$,o-] (2,0)
        to [R,l=$r_\mathrm{D}$,-o] (4,0);
        \end{circuitikz} & \begin{circuitikz}
        \draw (0,0) to [short,-o] (0.5,0);
        \draw (1,0) to [short,o-] (1.5,0);
        \end{circuitikz}   
    \end{tabular}\\ \hline
    MOSFET:
    & \begin{circuitikz}
      \draw (0,0) to node[nigfete,rotate=90,scale=0.85](nigfet){} (0,0);
      \end{circuitikz}
    &  \begin{tabular}{cc} leitend &
      sperrend \\  
      \begin{circuitikz}
      \draw (0,0) to [R,l=$R_{\mathrm{on}}$,o-o] (2,0);
        \end{circuitikz}  & \begin{circuitikz}
            \draw (0,0) to [short,-o] (0.5,0);
            \draw (1,0) to [short,o-] (1.5,0);
            \end{circuitikz}
    \end{tabular}
    \\ \hline
    IGBT:
    & \begin{circuitikz}
        \draw (0,0) to node[nigbt,rotate=90](nigigbt2){} (0,0);
        \end{circuitikz}
     & \begin{tabular}{cc} leitend &
      sperrend \\   \begin{circuitikz}
        \draw (0,0) to [V=$U_\mathrm{D}$,o-] (2,0)
        to [R,l=$r_{\mathrm{S}}$,-o] (4,0);
        \end{circuitikz}
        & \begin{circuitikz}
            \draw (0,0) to [short,-o] (0.5,0);
            \draw (1,0) to [short,o-] (1.5,0);
            \end{circuitikz} 
        \end{tabular}        
    \\ \hline
\end{tabular}
\captionof{table}{Elektronische Bauelemente und deren Ersatzschaltbilder}
\label{tab:ESB}
\end{table}
\end{document}

在此处输入图片描述

为了正确对齐电路,您可能需要将两者合二为一circuitikz,并使用局部边界框。这样您就可以根据规则将事物居中circuitikz,即对齐电路。

\documentclass[11pt,a4paper,DIV=calc]{scrartcl}
\usepackage{tikz}
\usepackage[europeanresistors,americaninductors,straightvoltages]{circuitikz}
\usetikzlibrary{calc}
\usepackage{amsmath,amssymb,amsthm}
\begin{document}

\begin{table}
\centering
\begingroup
\tikzset{baseline={([yshift=-0.5ex]current bounding box.center)},every
picture/.append style={execute at end picture={\path (current bounding
box.north) -- ++ (0,2pt) (current bounding
box.south) -- ++ (0,-2pt);}}}% fixed position of current bounding box
\begin{tabular}{|c|c|c|}
    \hline
    Bauteil:
    & Schaltbild:
    & Ersatzschaltbild:
    \\ 
    \hline
    Kondensator:
    & \begin{circuitikz}
        \draw (0,0) to [C,o-o] (2,0);
        \end{circuitikz} 
    & \begin{circuitikz}
        \draw (0,0) to [C,l=$C$,o-] (2,0)
        to [R,l=$r_\mathrm{C}$,-o] (4,0);
        \end{circuitikz} 
    \\ \hline
    Spule:
    & \begin{circuitikz}
        \draw (0,0) to [L,o-o] (2,0);
        \end{circuitikz} 
    & \begin{circuitikz}
        \draw (0,0) to [L,l=$L$,o-] (2,0)
        to [R,l=$r_\mathrm{L}$,-o] (4,0);
        \end{circuitikz} 
    \\ \hline
    Diode:
    & \begin{circuitikz}
        \draw (0,0) to [D*,o-o] (2,0);
        \end{circuitikz} 
    & 
    \begin{circuitikz}
       \begin{scope}[local bounding box=leitend]
        \draw (0,0) to [V=$U_D$,o-] (2,0)
        to [R,l=$r_\mathrm{D}$,-o] (4,0);
    \end{scope}
    \path let \p1=($(leitend.east)-(leitend.west)$) in
    \pgfextra{\xdef\mywidth{\x1}};
   \begin{scope}[local bounding box=sperrend,xshift=\mywidth/2+2.6cm]
        \draw (0,0) to [short,-o] (0.5,0);
        \draw (1,0) to [short,o-] (1.5,0);
    \end{scope}     
    \path (leitend.north) node[above]{leitend} (sperrend|-leitend.north)
    node[above]{sperrend};
        \end{circuitikz}   
    \\ \hline
    MOSFET:
    & \begin{circuitikz}
      \draw (0,0) to node[nigfete,rotate=90,scale=0.85](nigfet){} (0,0);
      \end{circuitikz}
    & 
    \begin{circuitikz}
       \begin{scope}[local bounding box=leitend]
        \draw (0,0) to [R,l=$R_{\mathrm{on}}$,o-o] (2,0);
    \end{scope}
    \path let \p1=($(leitend.east)-(leitend.west)$) in
     (leitend.center) --++ (-\mywidth/2,0)
    \pgfextra{\xdef\mywidth{\x1}};
   \begin{scope}[local bounding box=sperrend,xshift=\mywidth/2+2.6cm]
        \draw (0,0) to [short,-o] (0.5,0);
            \draw (1,0) to [short,o-] (1.5,0);
    \end{scope}     
    \path (leitend.north) node[above]{leitend} (sperrend|-leitend.north)
    node[above]{sperrend};
        \end{circuitikz}   
    \\ \hline
    IGBT: & \begin{circuitikz}
        \draw (0,0) to node[nigbt,rotate=90](nigigbt2){} (0,0);
        \end{circuitikz}
    & \begin{circuitikz}
       \begin{scope}[local bounding box=leitend]
        \draw (0,0) to [V=$U_\mathrm{D}$,o-] (2,0)
        to [R,l=$r_{\mathrm{S}}$,-o] (4,0);
    \end{scope}
    \path let \p1=($(leitend.east)-(leitend.west)$) in
    \pgfextra{\xdef\mywidth{\x1}};
   \begin{scope}[local bounding box=sperrend,xshift=\mywidth/2+2.6cm]
       \draw (0,0) to [short,-o] (0.5,0);
       \draw (1,0) to [short,o-] (1.5,0);
    \end{scope}     
    \path (leitend.north) node[above]{leitend} (sperrend|-leitend.north)
    node[above]{sperrend};
        \end{circuitikz}   
            \\ \hline
\end{tabular}\endgroup
\captionof{table}{Elektronische Bauelemente und deren Ersatzschaltbilder}
\label{tab:ESB}
\end{table}
\end{document}

在此处输入图片描述

答案2

\multicolumn以下是使用和\multirow以及 4 列(而不是 3 列)的不同版本:

在此处输入图片描述

    \documentclass[11pt,a4paper,DIV=calc]{scrartcl}
    \usepackage{tikz}
    \usepackage[europeanresistors,americaninductors,straightvoltages]{circuitikz}
    \usepackage{amsmath,amssymb,amsthm}

    \usepackage{multirow}
    \begin{document}

    \begin{table}
    \centering
    \tikzset{baseline={([yshift=-0.5ex]current bounding box.center)}}% fixed position of current bounding box
    \begin{tabular}{|c|c|cc|}
        \hline
        Bauteil:
        & Schaltbild:
        & \multicolumn{2}{c|}{Ersatzschaltbild:}
        \\ 
        \hline
        Spule:
        & \begin{circuitikz}
            \draw (0,0) to [L,o-o] (2,0);
            \end{circuitikz} 
        & \multicolumn{2}{c|}{\begin{circuitikz}
            \draw (0,0) to [L,l=$L$,o-] (2,0)
            to [R,l=$r_\mathrm{L}$,-o] (4,0);
            \end{circuitikz}} 
        \\ \hline
        \multirow{4}{*}{Diode:}
        & \multirow{4}{*}{\begin{circuitikz}
            \draw (0,0) to [D*,o-o] (2,0);
            \end{circuitikz}} 
        & leitend: 
        & sperrend:\\
        && \begin{circuitikz}
            \draw (0,0) to [V=$U_D$,o-] (2,0)
            to [R,l=$r_\mathrm{D}$,-o] (4,0);
            \end{circuitikz}
         & \begin{circuitikz}
            \draw (0,0) to [short,-o] (0.5,0);
            \draw (1,0) to [short,o-] (1.5,0);
            \end{circuitikz}
        \\ \hline
    \end{tabular}
    \captionof{table}{Elektronische Bauelemente und deren Ersatzschaltbilder}
    \label{tab:ESB}
    \end{table}
    \end{document}


Here is the code for the complete table:

在此处输入图片描述

\documentclass[11pt,a4paper,DIV=calc]{scrartcl}
\usepackage{tikz}
\usepackage[europeanresistors,americaninductors,straightvoltages]{circuitikz}
\usepackage{amsmath,amssymb,amsthm}

\usepackage{multirow}
\begin{document}

\begin{table}
\centering
\tikzset{baseline={([yshift=-0.5ex]current bounding box.center)}}% fixed position of current bounding box
\begin{tabular}{|c|c|cc|}
    \hline
    Bauteil:
    & Schaltbild:
    & \multicolumn{2}{c|}{Ersatzschaltbild:}
    \\ 
    \hline
    Kondensator:
    & \begin{circuitikz}
        \draw (0,0) to [C,o-o] (2,0);
        \end{circuitikz} 
    & \multicolumn{2}{c|}{\begin{circuitikz}
        \draw (0,0) to [C,l=$C$,o-] (2,0)
        to [R,l=$r_\mathrm{C}$,-o] (4,0);
        \end{circuitikz}} 
    \\ \hline
    Spule:
    & \begin{circuitikz}
        \draw (0,0) to [L,o-o] (2,0);
        \end{circuitikz} 
    & \multicolumn{2}{c|}{\begin{circuitikz}
        \draw (0,0) to [L,l=$L$,o-] (2,0)
        to [R,l=$r_\mathrm{L}$,-o] (4,0);
        \end{circuitikz}} 
    \\ \hline
    \multirow{4}{*}{Diode:}
    & \multirow{4}{*}{\begin{circuitikz}
        \draw (0,0) to [D*,o-o] (2,0);
        \end{circuitikz}} 
    & leitend: 
    & sperrend:\\
    && \begin{circuitikz}
        \draw (0,0) to [V=$U_D$,o-] (2,0)
        to [R,l=$r_\mathrm{D}$,-o] (4,0);
        \end{circuitikz}
     & \begin{circuitikz}
        \draw (0,0) to [short,-o] (0.5,0);
        \draw (1,0) to [short,o-] (1.5,0);
        \end{circuitikz}
    \\ \hline
    \multirow{3}{*}{MOSFET:}
    & \multirow{3}{*}{\begin{circuitikz}
      \draw (0,0) to node[nigfete,rotate=90,scale=0.85](nigfet){} (0,0);
      \end{circuitikz}}
    & leitend: 
    & sperrend:\\
    && \begin{circuitikz}
      \draw (0,0) to [R,l=$R_{\mathrm{on}}$,o-o] (2,0);
        \end{circuitikz}  
     & \begin{circuitikz}
            \draw (0,0) to [short,-o] (0.5,0);
            \draw (1,0) to [short,o-] (1.5,0);
        \end{circuitikz}  
    \\ \hline
    \multirow{4}{*}{IGBT:}
    & \multirow{4}{*}{\begin{circuitikz}
        \draw (0,0) to node[nigbt,rotate=90](nigigbt2){} (0,0);
        \end{circuitikz}}
    & leitend: 
    & sperrend:\\   
    && \begin{circuitikz}
        \draw (0,0) to [V=$U_\mathrm{D}$,o-] (2,0)
        to [R,l=$r_{\mathrm{S}}$,-o] (4,0);
        \end{circuitikz}
     & \begin{circuitikz}
            \draw (0,0) to [short,-o] (0.5,0);
            \draw (1,0) to [short,o-] (1.5,0);
        \end{circuitikz}  
    \\ \hline
\end{tabular}
\captionof{table}{Elektronische Bauelemente und deren Ersatzschaltbilder}
\label{tab:ESB}
\end{table}
\end{document}

借助该cellspace包,您还可以在每个单元格内部添加一些空白,以防止图像与水平线重叠。借助\tikzset{baseline={([yshift=0.5ex]0,0)}},两个 tikzpicture 也可以相对于水平线对齐,如所建议的那样约翰·科米洛薛定谔的猫

在此处输入图片描述

\documentclass[11pt,a4paper,DIV=calc]{scrartcl}
\usepackage{tikz}
\usepackage[europeanresistors,americaninductors,straightvoltages]{circuitikz}
\usepackage{amsmath,amssymb,amsthm}

\usepackage{multirow}

\usepackage{array,cellspace}
\setlength\cellspacetoplimit{4pt} 
\setlength\cellspacebottomlimit{4pt}

\begin{document}

\begin{table}
\centering
\tikzset{baseline={([yshift=0.5ex]0,0)}}
\begin{tabular}{|Sc|Sc|ScSc|}
    \hline
    Bauteil:
    & Schaltbild:
    & \multicolumn{2}{Sc|}{Ersatzschaltbild:}
    \\ 
    \hline
    Kondensator:
    & \begin{circuitikz}
        \draw (0,0) to [C,o-o] (2,0);
        \end{circuitikz} 
    & \multicolumn{2}{Sc|}{\begin{circuitikz}
        \draw (0,0) to [C,l=$C$,o-] (2,0)
        to [R,l=$r_\mathrm{C}$,-o] (4,0);
        \end{circuitikz}} 
    \\ \hline
    Spule:
    & \begin{circuitikz}
        \draw (0,0) to [L,o-o] (2,0);
        \end{circuitikz} 
    & \multicolumn{2}{Sc|}{\begin{circuitikz}
        \draw (0,0) to [L,l=$L$,o-] (2,0)
        to [R,l=$r_\mathrm{L}$,-o] (4,0);
        \end{circuitikz}} 
    \\ \hline
    \multirow{5}{*}{Diode:}
    & \multirow{5}{*}{\begin{circuitikz}
        \draw (0,0) to [D*,o-o] (2,0);
        \end{circuitikz}} 
    & leitend: 
    & sperrend:\\
    && \begin{circuitikz}
        \draw (0,0) to [V=$U_D$,o-] (2,0)
        to [R,l=$r_\mathrm{D}$,-o] (4,0);
        \end{circuitikz}
     & \begin{circuitikz}
        \draw (0,0) to [short,-o] (0.5,0);
        \draw (1,0) to [short,o-] (1.5,0);
        \end{circuitikz}
    \\ \hline
    \multirow{4}{*}{MOSFET:}
    & \multirow{4}{*}{\begin{circuitikz}
      \draw (0,0) to node[nigfete,rotate=90,scale=0.85](nigfet){} (0,0);
      \end{circuitikz}}
    & leitend: 
    & sperrend:\\
    && \begin{circuitikz}
      \draw (0,0) to [R,l=$R_{\mathrm{on}}$,o-o] (2,0);
        \end{circuitikz}  
     & \begin{circuitikz}
            \draw (0,0) to [short,-o] (0.5,0);
            \draw (1,0) to [short,o-] (1.5,0);
        \end{circuitikz}  
    \\ \hline
    \multirow{5}{*}{IGBT:}
    & \multirow{5}{*}{\begin{circuitikz}
        \draw (0,0) to node[nigbt,rotate=90](nigigbt2){} (0,0);
        \end{circuitikz}}
    & leitend: 
    & sperrend:\\   
    && \begin{circuitikz}
        \draw (0,0) to [V=$U_\mathrm{D}$,o-] (2,0)
        to [R,l=$r_{\mathrm{S}}$,-o] (4,0);
        \end{circuitikz}
     & \begin{circuitikz}
            \draw (0,0) to [short,-o] (0.5,0);
            \draw (1,0) to [short,o-] (1.5,0);
        \end{circuitikz}  
    \\ \hline
\end{tabular}
\captionof{table}{Elektronische Bauelemente und deren Ersatzschaltbilder}
\label{tab:ESB}
\end{table}
\end{document}

答案3

这解决了垂直对齐问题,特别是对齐引线而不是框。有多种方法可以在边框处添加空间。 \arraystretch是表格的内置功能,当足够大时,可以使每行的高度相同。

\documentclass[11pt,a4paper,DIV=calc]{scrartcl}
\usepackage{tikz}
\usepackage[europeanresistors,americaninductors,straightvoltages]{circuitikz}
\usepackage{amsmath,amssymb,amsthm}
\begin{document}

\begin{table}
\centering
\tikzset{baseline={(0,-0.5ex)}}% fixed position of current bounding box
\def\arraystretch{3}%
\begin{tabular}{|c|c|c|}
    \hline
    Bauteil:
    & Schaltbild:
    & Ersatzschaltbild:
    \\ 
    \hline
    Kondensator:
    & \begin{circuitikz}
        \draw (0,0) to [C,o-o] (2,0);
        \end{circuitikz} 
    & \begin{circuitikz}
        \draw (0,0) to [C,l=$C$,o-] (2,0)
        to [R,l=$r_\mathrm{C}$,-o] (4,0);
        \end{circuitikz} 
    \\ \hline
    Spule:
    & \begin{circuitikz}
        \draw (0,0) to [L,o-o] (2,0);
        \end{circuitikz} 
    & \begin{circuitikz}
        \draw (0,0) to [L,l=$L$,o-] (2,0)
        to [R,l=$r_\mathrm{L}$,-o] (4,0);
        \end{circuitikz} 
    \\ \hline
    Diode:
    & \begin{circuitikz}
        \draw (0,0) to [D*,o-o] (2,0);
        \end{circuitikz} 
    & leitend: \begin{circuitikz}
        \draw (0,0) to [V=$U_D$,o-] (2,0)
        to [R,l=$r_\mathrm{D}$,-o] (4,0);
        \end{circuitikz}
    sperrend: \begin{circuitikz}
        \draw (0,0) to [short,-o] (0.5,0);
        \draw (1,0) to [short,o-] (1.5,0);
        \end{circuitikz}   
    \\ \hline
    MOSFET:
    & \begin{circuitikz}
      \draw (0,0) to node[nigfete,rotate=90,scale=0.85](nigfet){} (0,0);
      \end{circuitikz}
    & leitend: \begin{circuitikz}
      \draw (0,0) to [R,l=$R_{\mathrm{on}}$,o-o] (2,0);
        \end{circuitikz}  
      sperrend: \begin{circuitikz}
            \draw (0,0) to [short,-o] (0.5,0);
            \draw (1,0) to [short,o-] (1.5,0);
            \end{circuitikz}  
    \\ \hline
    IGBT:
    & \begin{circuitikz}
        \draw (0,0) to node[nigbt,rotate=90](nigigbt2){} (0,0);
        \end{circuitikz}
     & leitend: \begin{circuitikz}
        \draw (0,0) to [V=$U_\mathrm{D}$,o-] (2,0)
        to [R,l=$r_{\mathrm{S}}$,-o] (4,0);
        \end{circuitikz}
        sperrend: \begin{circuitikz}
            \draw (0,0) to [short,-o] (0.5,0);
            \draw (1,0) to [short,o-] (1.5,0);
            \end{circuitikz}  
    \\ \hline
\end{tabular}
\captionof{table}{Elektronische Bauelemente und deren Ersatzschaltbilder}
\label{tab:ESB}
\end{table}
\end{document}

演示

相关内容