缩放 tikz 块中图形和文本的最简单方法

缩放 tikz 块中图形和文本的最简单方法

我正在使用 overleaf。我为需要转换为单列文档的 2 列文档编写了此代码块。

\begin{figure}
\centering
\begin{minipage}{0.2\textwidth}
\def\xspace{0}
\centering
\hspace{-6mm}
\begin{tikzpicture}
    \node[anchor=south west,inner sep=0] (image) at (0,0) {\includegraphics[width=0.8\textwidth,trim={0 0 0 0},clip]{Chapters/ICRA2022/figures/table_items.png}};
    \begin{scope}[x={(image.south east)},y={(image.north west)}]
          \foreach \i/\j in {{(0.2,0.6)/(0.2,1.1)},{(0.3,0.75)/(0.3,1.1)},{(0.39,1)/(0.39,1.1)},{(0.62,0.7)/(0.62,1.1)}} \draw [-stealth, red, thick] \i -- \j;
          \node[scale=0.45] at (0.42,1.15) {$\{O^{(1)},O^{(2)},O^{(3)}, \ ... \ , O^{(7)}\}$};
          \node[scale=0.45] at (0.42,1.25) {$O^{(n)}$ for Pick Action};
    \end{scope}
\end{tikzpicture}\\
\hspace{-9mm}
\subfloat[]{\begin{tikzpicture}
    \node[anchor=south west,inner sep=0] (image) at (0,0) {\includegraphics[width=0.8\textwidth,trim={0 0 0 0},clip]{Chapters/ICRA2022/figures/table_grid.png}};
    \begin{scope}[x={(image.south east)},y={(image.north west)}]
          \foreach \i/\j in {{(0.015,0.68)/(0.015,1.1)},{(0.15,0.7)/(0.15,1.1)},{(0.285,0.72)/(0.285,1.1)},{(0.42,0.74)/(0.42,1.1)},{(0.557,0.77)/(0.557,1.1)}} \draw [-stealth, red, thick] \i -- \j;
          \node[scale=0.45] at (0.33+\xspace,1.15) {$\{O^{(1)},\ O^{(2)},\ O^{(3)},\ O^{(4)}, \ O^{(5)}, \ ... \}$};
          \node[scale=0.45] at (0.35+\xspace,1.25) {$O^{(n)}$ for Place Action};
    \end{scope}
\end{tikzpicture}}
\end{minipage}\hfill
\begin{minipage}{0.28\textwidth}
\centering
\hspace{-10mm}
\subfloat[]{\includegraphics[width=1.1\textwidth,trim={1cm 0.32cm 0 0.25cm},clip]{Chapters/ICRA2022/figures/architecturenewest.pdf}}
\end{minipage}\caption{(a) $O^{(n)}$ for pick and place actions (b) Our gaze network. The gaze attention block attends to fixations relative to each object while the object attention block attends to objects that are most likely being fixated on.}\label{fig:architecture}
\end{figure}

这就是它在 2 列文档中的最初样子。

在此处输入图片描述

这就是它在单列文档中看起来的样子,中间有太多空间。

在此处输入图片描述

如何缩放代码块中的内容?改变小页面的大小不起作用,因为这会导致图形看起来像这样,其中文本不再与箭头对齐。我不想手动更新定位,因为我有 50 多个这样的图形。

在此处输入图片描述

我正在寻找一个函数,例如\scale_everything

\begin{figure}
\centering

% % % % % % % % % % % % % % % % % % %
% EXAMPLE USAGE OF SCALE EVERYTHING %
% % % % % % % % % % % % % % % % % % %

\scale_everything{0.5\textwidth}{

\begin{minipage}{0.2\textwidth}
\def\xspace{0}
\centering
\hspace{-6mm}
\begin{tikzpicture}
    \node[anchor=south west,inner sep=0] (image) at (0,0) {\includegraphics[width=0.8\textwidth,trim={0 0 0 0},clip]{Chapters/ICRA2022/figures/table_items.png}};
    \begin{scope}[x={(image.south east)},y={(image.north west)}]
          \foreach \i/\j in {{(0.2,0.6)/(0.2,1.1)},{(0.3,0.75)/(0.3,1.1)},{(0.39,1)/(0.39,1.1)},{(0.62,0.7)/(0.62,1.1)}} \draw [-stealth, red, thick] \i -- \j;
          \node[scale=0.45] at (0.42,1.15) {$\{O^{(1)},O^{(2)},O^{(3)}, \ ... \ , O^{(7)}\}$};
          \node[scale=0.45] at (0.42,1.25) {$O^{(n)}$ for Pick Action};
    \end{scope}
\end{tikzpicture}\\
\hspace{-9mm}
\subfloat[]{\begin{tikzpicture}
    \node[anchor=south west,inner sep=0] (image) at (0,0) {\includegraphics[width=0.8\textwidth,trim={0 0 0 0},clip]{Chapters/ICRA2022/figures/table_grid.png}};
    \begin{scope}[x={(image.south east)},y={(image.north west)}]
          \foreach \i/\j in {{(0.015,0.68)/(0.015,1.1)},{(0.15,0.7)/(0.15,1.1)},{(0.285,0.72)/(0.285,1.1)},{(0.42,0.74)/(0.42,1.1)},{(0.557,0.77)/(0.557,1.1)}} \draw [-stealth, red, thick] \i -- \j;
          \node[scale=0.45] at (0.33+\xspace,1.15) {$\{O^{(1)},\ O^{(2)},\ O^{(3)},\ O^{(4)}, \ O^{(5)}, \ ... \}$};
          \node[scale=0.45] at (0.35+\xspace,1.25) {$O^{(n)}$ for Place Action};
    \end{scope}
\end{tikzpicture}}
\end{minipage}}\hfill

\scale_everything{0.4\textwidth}{

\begin{minipage}{0.28\textwidth}
\centering
\hspace{-10mm}
\subfloat[]{\includegraphics[width=1.1\textwidth,trim={1cm 0.32cm 0 0.25cm},clip]{Chapters/ICRA2022/figures/architecturenewest.pdf}}
\end{minipage}}\caption{(a) $O^{(n)}$ for pick and place actions (b) Our gaze network. The gaze attention block attends to fixations relative to each object while the object attention block attends to objects that are most likely being fixated on.}\label{fig:architecture}
\end{figure}

以下是 MWE:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{float}
\usepackage{subfig}
\usepackage{graphicx}

\usepackage{tikz}
\begin{document}

\begin{figure}
     \centering
     \subfloat[][a]{
     \begin{tikzpicture}
        \node[anchor=south west,inner sep=0] (image) at (0,0) {\includegraphics[width=0.3\textwidth,trim={0 0 0 0},clip]{example-image-a}};
        \begin{scope}[x={(image.south east)},y={(image.north west)}]
          \foreach \i/\j in {{(0.2,0.6)/(0.2,1.1)},{(0.3,0.75)/(0.3,1.1)},{(0.39,1)/(0.39,1.1)},{(0.62,0.7)/(0.62,1.1)}} \draw [-stealth, red, thick] \i -- \j;
          \node[scale=0.45] at (0.42,1.15) {$\{O^{(1)},O^{(2)},O^{(3)}, \ ... \ , O^{(7)}\}$};
          \node[scale=0.45] at (0.42,1.25) {$O^{(n)}$ for Pick Action};
        \end{scope}
    \end{tikzpicture}}   
     \subfloat[][a]{
     \begin{tikzpicture}
        \node[anchor=south west,inner sep=0] (image) at (0,0) {\includegraphics[width=0.3\textwidth,trim={0 0 0 0},clip]{example-image-a}};
        \begin{scope}[x={(image.south east)},y={(image.north west)}]
          \foreach \i/\j in {{(0.2,0.6)/(0.2,1.1)},{(0.3,0.75)/(0.3,1.1)},{(0.39,1)/(0.39,1.1)},{(0.62,0.7)/(0.62,1.1)}} \draw [-stealth, red, thick] \i -- \j;
          \node[scale=0.45] at (0.42,1.15) {$\{O^{(1)},O^{(2)},O^{(3)}, \ ... \ , O^{(7)}\}$};
          \node[scale=0.45] at (0.42,1.25) {$O^{(n)}$ for Pick Action};
        \end{scope}
    \end{tikzpicture}}
     \label{steady_state}
\end{figure}

\end{document}

答案1

这可能是一个糟糕的选择,但您可以将[scale=2, transform shape]其添加到tikzpicture。这将按照您的建议“缩放所有内容”,但缩放后的文本在文档中看起来会不合适。另一方面,看起来子浮点数 (a) 已经与子浮点数 (b) 相比缩小了(包括文本),所以也许这会达到您想要的效果。

在此处输入图片描述

相关内容