3

In a document, I would like to vertically align cell text. The only problem is that my array is contained in a begin {circuitikz} so the few tests I was able to do (with begin {center} in particular) don't work.

Can you help me ?

\documentclass[border=2mm]{standalone} 
usepackage{multirow}
\usepackage[utf8]{inputenc}
\usepackage[siunitx, european, straightvoltages, RPvoltages]{circuitikz}
\begin {document}

\begin{circuitikz} \node at (0,0) {\begin{tabular}{|c|c|c|c|} \hline Type & Composant & Code & Image résultant\ \hline \multirow{7}{*}{Alimentation} & pile & to[battery1] & \begin{circuitikz} \draw (0,0) to[battery1] (2,0);\end{circuitikz} \ \cline{2-4} & source de courant & to[isource] & \begin{circuitikz} \draw (0,0) to[isource] (2,0);\end{circuitikz} \ \cline{2-4} & source de tension & to[vsource] & \begin{circuitikz} \draw (0,0) to[vsource] (2,0);\end{circuitikz} \ \cline{2-4} & source sinusoidale & to[sV] ou to[vsourcesin] & \begin{circuitikz} \draw (0,0) to[sV] (2,0);\end{circuitikz} \ \cline{2-4} & source sinusoidale & to[sV] ou to[vsourcesin] & \begin{circuitikz} \draw (0,0) to[sV] (2,0);\end{circuitikz} \ \cline{2-4} & source créneau & to[sqV] ou to[vsourcesquare] & \begin{circuitikz} \draw (0,0) to[sqV] (2,0);\end{circuitikz} \ \cline{2-4} & source triangulaire & to[tV] ou to[vsourcetri] & \begin{circuitikz} \draw (0,0) to[tV] (2,0);\end{circuitikz} \ \hline \end{tabular} }; \end{document}

Nicolas
  • 1,023
  • \tikzset{ baseline=(current bounding box.center)} should help to vertically center the contents of the second column with respect to the third column. – leandriis Jan 25 '21 at 21:35
  • Please make your MWE compilable. It contain many errors. – Zarko Jan 25 '21 at 21:35
  • 3
    You shouldn't nest tikzpicture and/or circuitikz environments. – Skillmon Jan 25 '21 at 21:37
  • 2
    Nesting tikzpicture (and circuitikz are the same as them) is going to explode before or later: https://tex.stackexchange.com/questions/47377/proper-nesting-of-tikzpicture-environments-reset-all-pgf-values-to-their-defaul – Rmano Jan 25 '21 at 21:39
  • @Rmano : Ah, I'm not an expert: I must have found it hard to understand what should be done to allow me to mix tabular (or similar) and circuitikz? – Nicolas Jan 25 '21 at 22:05
  • You can put a tabular in a node, but you can't put a tikzpicture in that tabular. The form of having tabulated material in a tikzpicure is to use a matrix element. In this case, @Zarko answer is the correct one in my opinion. – Rmano Jan 26 '21 at 07:52

1 Answers1

4

I wonder, why you insert this table in TikZ node?. Removing it and adjusting images baseline gives:

enter image description here

\documentclass[border=2mm]{standalone}
\usepackage{makecell, multirow}
\usepackage[siunitx, european, straightvoltages, RPvoltages]{circuitikz}

\begin{document} \begingroup \makegapedcells \setcellgapes{3pt} \tikzset{every picture/.style={baseline=-0.5ex}} \begin{tabular}{|c|c|c|c|} \hline Type & Composant & Code & Image résultant\ \hline \multirow{16}{*}{Alimentation} & pile & to[battery1] & \begin{circuitikz} \draw (0,0) to[battery1] (2,0); \end{circuitikz} \ \cline{2-4} & source de courant
& to[isource] & \begin{circuitikz} \draw (0,0) to[isource] (2,0); \end{circuitikz} \ \cline{2-4} & source de tension & to[vsource] & \begin{circuitikz} \draw (0,0) to[vsource] (2,0); \end{circuitikz} \ \cline{2-4} & source sinusoidale & to[sV] ou to[vsourcesin] & \begin{circuitikz} \draw (0,0) to[sV] (2,0); \end{circuitikz} \ \cline{2-4} & source sinusoidale & to[sV] ou to[vsourcesin] & \begin{circuitikz} \draw (0,0) to[sV] (2,0); \end{circuitikz} \ \cline{2-4} & source créneau & to[sqV] ou to[vsourcesquare] & \begin{circuitikz} \draw (0,0) to[sqV] (2,0); \end{circuitikz} \ \cline{2-4} & source triangulaire & to[tV] ou to[vsourcetri] & \begin{circuitikz} \draw (0,0) to[tV] (2,0); \end{circuitikz} \ \hline \end{tabular} \endgroup \end{document}

Zarko
  • 296,517
  • nice, this is that I want ! Can you explain me why, in the multirow command, it is indicated 16 ? I counted the cells but i can't find a number that matches 16 – Nicolas Jan 26 '21 at 06:14
  • @Nicolas, you should count number of text rows which can be fir in these cells (on the such way are measured multirow cell height). Due to contained image and added vertical space, their sum of height is approximately of 16 text lines. – Zarko Jan 26 '21 at 06:47
  • Ok, thanks for the precision – Nicolas Jan 26 '21 at 07:04