答案1
通常的 Ti钾当然,Z 方法有效。只需将节点选项添加到路径即可。
\documentclass[border=5mm]{standalone}
\usepackage[american]{circuitikz}
\begin{document}
\begin{circuitikz}[thick]
\draw[nodes={align=center}] (0,0) to[V, l= some very \\ long label ,a=some very \\ long annotation] ++(2,0);
\end{circuitikz}
\end{document}
当然,你也可以区分标签。
\documentclass[border=5mm]{standalone}
\usepackage[american]{circuitikz}
\begin{document}
\begin{circuitikz}[thick]
\draw (0,0) to[V,nodes={align=center}, l= some very \\ long label ,
nodes={align=left,},a=some very \\ long annotation] ++(2,0);
\end{circuitikz}
\end{document}
或者,对于更复杂的操作,更改本地该元素的样式。
\documentclass[border=5mm]{standalone}
\usepackage[american]{circuitikz}
\begin{document}
\begin{circuitikz}[thick]
\draw (0,0) to[V,nodes={align=center}, l= some very \\ long label,
bipole annotation style/.style={text=white,fill=blue,align=left},
a=some very \\ long annotation] ++(2,0);
\end{circuitikz}
\end{document}
答案2
标签实际上是作为单独的节点实现的,因此如果您想做一些奇特的事情,不妨使用单独的节点。使用\centering
,\\
效果比 更好\newline
。
请注意,实际宽度(5cm)大于文本,但由于文本居中,因此您无法分辨。您也可以查看 varwidth 包。
\documentclass[border=5mm]{standalone}
\usepackage[american]{circuitikz}
\begin{document}
\begin{circuitikz}[thick]
\draw (0,0) to[V, l={\parbox[b]{5cm}{\centering some very \\ long label}},
a={\parbox[t]{5cm}{\centering some very \\ long annotation}}] ++(2,0);
\draw (3,0) to[V, name=V1] ++(2,0);
\node[above, text width=5cm, align=center] at (V1.n) {some very \\ long label};
\node[below, text width=5cm, align=center] at (V1.s) {some very \\ long annotation};
\end{circuitikz}
\end{document}
答案3
粗略的破解:将标签和注释放在tabular
环境中。
\documentclass[border=5mm]{standalone}
\usepackage[american]{circuitikz}
\newcommand\ml[3][c]{\begin{tabular}[#2]{@{}#1@{}}#3\end{tabular}}
\begin{document}
\begin{circuitikz}[thick]
\draw (0,0) to[V, l=\ml{b}{some very \\ long label} ,a=\ml{t}{some very \\ long
annotation}] ++(2,0);
\end{circuitikz}
\end{document}
答案4
要更改注释和标签样式,请设置bipole annotation style
和bipole label style
。
参见 MWE:
\documentclass[border=5mm]{standalone}
\usepackage[american]{circuitikz}
\ctikzset{
bipole annotation style/.style={red,text width=3cm,align=center},
bipole label style/.style={fill=blue!20, text width=3cm,align=center,anchor=south},
}
\begin{document}
\begin{circuitikz}[thick]
\draw (0,0) to[V, l= some very long label ,a=some very long annotation] ++(2,0);
\end{circuitikz}
\end{document}
输出: