我有以下两栏文章,其中我正在调整子图内的 3 个 TikZ 图的大小以将它们放在一栏中(下面的代码)。
我想全部这TikZ 图形中的文本(在这个特定例子中,是正方形内的 A 和 B)与文档的字体大小匹配(即 TikZ 字体大小等于乱码字体大小)。
调整大小后如何确保这一点?
如何强制 TikZ 图形中的文本与文档的文本大小匹配?
\documentclass[12pt,twocolumn]{article}
\usepackage{tikz}
\usetikzlibrary{arrows.meta, positioning}
\usepackage{circuitikz}
\usepackage[hypcap=true]{subcaption}
\begin{document}
\begin{figure}[!h]
\centering
\begin{subfigure}[b]{0.33\columnwidth}
\centering
\resizebox{\columnwidth}{!}{%
\begin{tikzpicture}[box/.style={draw, thick, minimum size=10mm}]
\node [box] (A) {A};
\node [box, right=20mm of A] (B) {B};
\path (A) to [lowpass, name=lpf] (B);
\draw [-{Latex[length=2mm]}] (A.east) to (lpf.west);
\draw [-{Latex[length=2mm]}] (lpf.east) to (B.west);
\end{tikzpicture}
}
\caption{}
\end{subfigure}%
\begin{subfigure}[b]{0.33\columnwidth}
\centering
\resizebox{\columnwidth}{!}{%
\begin{tikzpicture}[box/.style={draw, thick, minimum size=10mm}]
\node [box] (A) {A};
\node [box, right=20mm of A] (B) {B};
\path (A) to [lowpass, name=lpf] (B);
\draw [-{Latex[length=2mm]}] (A.east) to (lpf.west);
\draw [-{Latex[length=2mm]}] (lpf.east) to (B.west);
\end{tikzpicture}
}
\caption{}
\end{subfigure}%
\begin{subfigure}[b]{0.33\columnwidth}
\centering
\resizebox{\columnwidth}{!}{%
\begin{tikzpicture}[box/.style={draw, thick, minimum size=10mm}]
\node [box] (A) {A};
\node [box, right=20mm of A] (B) {B};
\path (A) to [lowpass, name=lpf] (B);
\draw [-{Latex[length=2mm]}] (A.east) to (lpf.west);
\draw [-{Latex[length=2mm]}] (lpf.east) to (B.west);
\end{tikzpicture}
}
\caption{}
\end{subfigure}
\end{figure}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis laoreet, quam quis tristique hendrerit, neque massa sagittis ante, ac interdum ante nisi in diam. Nunc purus ante, luctus vitae eleifend a, euismod et urna. Suspendisse potenti. Sed accumsan hendrerit enim, eu fermentum orci lacinia non. Sed dignissim nisl diam, at sagittis mi faucibus in. Donec mauris massa, sollicitudin maximus ullamcorper eu, dapibus eget ex. Nulla bibendum vel lectus non ullamcorper. Vivamus cursus nunc sed imperdiet sodales. Mauris tristique leo ligula, id pretium massa congue eget. Mauris est dolor, cursus vitae augue vitae, tempus commodo turpis. Etiam vel leo nec ligula mollis iaculis vel ac augue. Praesent libero augue, ultrices ac gravida eget, rhoncus in neque. Aliquam sit amet ultrices ipsum, a commodo erat. Quisque eu ante libero. Etiam sit amet malesuada purus.
Praesent eget mollis augue. Integer vehicula sem eget ipsum congue, in tincidunt lacus pharetra. Nam tincidunt turpis in molestie laoreet. Nullam mattis, enim vitae volutpat molestie, lacus tellus tempor dui, et scelerisque urna metus a tellus. In id orci in metus feugiat tempor. Etiam vel diam eu neque rutrum venenatis et vel erat. Proin varius placerat ullamcorper. Praesent sapien ligula, semper et ultricies vel, tristique sit amet lacus. Etiam porta leo diam, nec consectetur nulla elementum eu. Nullam in venenatis ipsum. Nunc elit turpis, imperdiet vel neque a, maximus elementum orci. Nam pellentesque arcu id sem finibus ultrices. Etiam hendrerit lacus non felis hendrerit, in aliquam mi euismod. Sed ac egestas diam, a ultrices nisl.
Mauris odio felis, venenatis id lorem ac, consectetur gravida nunc. Etiam consequat sem at gravida tempus. Nam et eros aliquet, tristique lacus et, mollis mi. Morbi quam felis, maximus nec feugiat a, egestas in erat. Donec mattis ipsum vel bibendum ultricies. In in ipsum erat. Morbi dignissim ultricies nunc, viverra iaculis metus laoreet at. Morbi fringilla bibendum posuere. Quisque nisl risus, porta fermentum leo auctor, consequat laoreet velit.
Vivamus in neque vulputate neque facilisis pellentesque. Fusce id varius libero. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Aenean vitae mauris nisl. Curabitur lacinia est vitae cursus dignissim. Vestibulum luctus neque nec libero molestie, a tempus nunc cursus. Curabitur nec nunc eros. Nullam sed pharetra ligula, eget volutpat nunc. Pellentesque non nunc vel metus fringilla efficitur. Mauris quis luctus justo. In vel erat in magna eleifend scelerisque vel consequat tellus. Cras ornare arcu vel dui aliquet, tristique efficitur mi dapibus. Nulla in tincidunt justo. Sed tortor tellus, congue vel dapibus ac, tincidunt eu quam. Donec laoreet neque eu suscipit tempor.
Integer consectetur nunc ac eros malesuada, eget dapibus nunc laoreet. Cras vel nisl ante. Fusce metus purus, malesuada in pretium quis, eleifend a mi. Fusce lobortis nisl enim, at laoreet est sodales a. Pellentesque egestas condimentum urna. Ut porta eget felis vitae semper. Praesent varius ligula efficitur sollicitudin tempor.
\end{document}
答案1
像这样?
您需要减小节点大小和节点之间的距离,而不是图像。circuitikz
应该缩放节点。我通过“反复试验”找到了合适的比例因子。在下面的 mwe 中,图像的代码也略微简化了。
\documentclass[12pt,twocolumn]{article}
\usepackage{circuitikz}
\usetikzlibrary{arrows.meta, positioning}
\usepackage[hypcap=true]{subcaption}
\usepackage{lipsum}
\begin{document}
\lipsum[1]
\begin{figure}[htb]
\tikzset{box/.style = {draw, thick, inner sep=2pt, minimum size=6mm},
LA/.style = {-{Latex[length=2mm]}},
node distance = 13mm
}
\ctikzset{bipoles/length=9mm}
\centering
\begin{subfigure}[b]{0.32\linewidth}
\centering
\begin{tikzpicture}
\node [box] (A) {A};
\node [box, right=of A] (B) {B};
\path (A) to [lowpass, name=lpf] (B);
\draw [LA] (A) to (lpf.west);
\draw [LA] (lpf.east) to (B);
\end{tikzpicture}
\caption{}
\end{subfigure}
\hfill
\begin{subfigure}[b]{0.32\linewidth}
\centering
\begin{tikzpicture}
\node [box] (A) {A};
\node [box, right=of A] (B) {B};
\path (A) to [lowpass, name=lpf] (B);
\draw [LA] (A) to (lpf.west);
\draw [LA] (lpf.east) to (B);
\end{tikzpicture}
\caption{}
\end{subfigure}
\hfill
\begin{subfigure}[b]{0.32\linewidth}
\centering
\begin{tikzpicture}
\node [box] (A) {A};
\node [box, right=of A] (B) {B};
\path (A) to [lowpass, name=lpf] (B);
\draw [LA] (A) to (lpf.west);
\draw [LA] (lpf.east) to (B);
\end{tikzpicture}
\caption{}
\end{subfigure}
\end{figure}
\lipsum[2-4]
\end{document}
笔记:
您的问题是由于混合了两个不同包中的元素而引起的:tikzpicture
并且tikz
它们对缩放元素有不同的方法(据我所知)。因此,您有三种可能的方法来解决您的问题:
- 使用上面显示的解决方案
- 使用图像的自然大小并将每个子图像放在自己的行中
- 跨度
figure
浮动在两列上,即改用{figure}
。{figure*}
但是它只能放在下一页的顶部,或者在您使用包stfloats
插入它的同一页的底部的情况下。
\resizebox
当然,你可以坚持你的方法并接受字体大小随着使用而缩小的事实。