我想在文档中将tikzcircuit
s 嵌入 es 中;我正在努力寻找一种方法,让该框在宽度方面tcolorbox
表现得或多或少像一个。fbox
我正在通过手动设置宽度来解决问题(参见下面的代码),但如果有一种方法可以告诉您tcolorbox
根据需要设置框的宽度,那就更好了。可能吗?
这是 MWE:
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usepackage{tcolorbox}
\tcbset{common/.style={
colback=yellow!10,
colframe=blue!60,
halign=flush left, leftrule=4mm,
}}
\newtcolorbox{circbox}[3][]{common,
width=#2\linewidth, title = {#3}, nobeforeafter,
#1}
\begin{document}
\begin{circbox}{0.3}{Polarización}
\begin{tikzpicture}
\draw[thick] (0,0) circle (1cm);
\end{tikzpicture}
\end{circbox}
\begin{circbox}{0.5}{Señal}
\begin{tikzpicture}
\draw[thick] (0,0) circle (1cm) (1.3,0) circle (1cm);
\end{tikzpicture}
\end{circbox}
\bigskip
\fbox{
\begin{tikzpicture}
\draw[thick] (0,0) circle (1cm);
\end{tikzpicture}
}
\fbox{
\begin{tikzpicture}
\draw[thick] (0,0) circle (1cm) (1.3,0) circle (1cm);
\end{tikzpicture}
}
\end{document}
经过编译,结果如下:
答案1
有一个名为的选项,hbox
它基本上可以做你想做的事,根据内容调整宽度。
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usepackage{tcolorbox}
\tcbset{common/.style={
colback=yellow!10,
colframe=blue!60,
halign=flush left, leftrule=4mm,
}}
\newtcolorbox{circbox}[2][]{common,
hbox, title = {#2}, nobeforeafter,
#1}
\begin{document}
\begin{circbox}{Polarización}
\begin{tikzpicture}
\draw[thick] (0,0) circle (1cm);
\end{tikzpicture}
\end{circbox}
\begin{circbox}{Señal}
\begin{tikzpicture}
\draw[thick] (0,0) circle (1cm) (1.3,0) circle (1cm);
\end{tikzpicture}
\end{circbox}
\bigskip
\fbox{
\begin{tikzpicture}
\draw[thick] (0,0) circle (1cm);
\end{tikzpicture}
}
\fbox{
\begin{tikzpicture}
\draw[thick] (0,0) circle (1cm) (1.3,0) circle (1cm);
\end{tikzpicture}
}
\end{document}