把所有东西都放在同一条线上

把所有东西都放在同一条线上

所以我想把下面的图放在同一行。我的工作代码是这样的:

\documentclass{article} % say
\usepackage{tikz}
\usepackage{changes}
\usepackage{amsmath}
\usepackage{float}
\begin{document}
    \begin{figure}
        \centering
        \[
        \begin{bmatrix}
        k & 0 \\
        0 & 1
        \end{bmatrix}
        \]
        \caption{Standard Matrix} 
    \end{figure}
    \begin{figure}
        \centering
    \begin{tikzpicture}
    \definecolor{colorforline}{RGB}{49,4,71};

    \draw [very thick, color=colorforline] (-0.5,0) -- (4,0) node [right]{$x\textsubscript{1}$};
    \draw  [very thick, color=colorforline] (0,-0.5) -- (0,4) node [above]{$x\textsubscript{2}$};
    \definecolor{recshade}{RGB}{233,226,234};
    \filldraw[very thick, color=colorforline,fill=recshade] (0,0) rectangle (1.2,2.2);
    \draw[colorforline,  very thick] (0,2.2) -- (1.2,2.2) -- (1.2,0) node[below] {} ;%rotation
    \foreach \y in {0,...,9}{
        \draw[colorforline, thick](0,0.\y) -- (1.2,0.\y);
        \draw[colorforline, thick](0,1.\y) -- (1.2,1.\y);
    }
    \draw[colorforline, thick](0,2.0) -- (1.2,2.0);
    \draw[colorforline, thick](0,2.1) -- (1.2,2.1);
    \draw[colorforline, thick](0,2.2) -- (1.2,2.2);

    \filldraw [colorforline] (0,2.2) circle [radius=2pt] node[left] {
        $   \begin{bmatrix}
        0 \\
        1
        \end{bmatrix}$
    };
    \coordinate (O) at (3.6,1.4,0);
    \coordinate (1) at (3.6,1,0);
    \coordinate (A) at (1.9,1.4,0);
    \coordinate (B) at (1.9,1,0);
    \draw[very thick, ->, color=colorforline] (O) to  (A);
    \draw[very thick, ->, color=colorforline] (1) to  (B);

    \filldraw [colorforline] (1.2,0) circle [radius=2pt] node[below] {
        $   \begin{bmatrix}
        k \\
        0
        \end{bmatrix}$
    };

    \end{tikzpicture}
    \caption{0$<$k$<$1} 
\end{figure}


    \begin{figure}[H]
        \centering
        \begin{tikzpicture}
        \definecolor{colorforline}{RGB}{49,4,71};

        \draw [very thick, color=colorforline] (-0.5,0) -- (4,0) node [right]{$x\textsubscript{1}$};
        \draw  [very thick, color=colorforline] (0,-0.5) -- (0,4) node [above]{$x\textsubscript{2}$};
        \definecolor{recshade}{RGB}{233,226,234};
        \filldraw[very thick, color=colorforline,fill=recshade] (0,0) rectangle (3,2.2);
        \draw[colorforline,  very thick] (0,2.2) -- (1.2,2.2) -- (3,2.2) node[below] {} ;%rotation
        \foreach \y in {0,...,9}{
            \draw[colorforline, thin](0,0.\y) -- (3,0.\y);
            \draw[colorforline, thin](0,1.\y) -- (3,1.\y);
        }
        \draw[colorforline, thin](0,2.0) -- (3,2.0);
        \draw[colorforline, thin](0,2.1) -- (3,2.1);
        \draw[colorforline, thin](0,2.2) -- (3,2.2);

        \filldraw [colorforline] (0,2.2) circle [radius=2pt] node[left] {
            $   \begin{bmatrix}
            0 \\
            1
            \end{bmatrix}$
        };
        \coordinate (O) at (2.5,1.4,0);
        \coordinate (1) at (0.5,1,0);
        \coordinate (A) at (0.5,1.4,0);
        \coordinate (B) at (2.5,1,0);
        \draw[very thick, ->, color=colorforline] (A) to  (O);
        \draw[very thick, ->, color=colorforline] (1) to  (B);

        \filldraw [colorforline] (3,0) circle [radius=2pt] node[below] {
            $   \begin{bmatrix}
            k \\
            0
            \end{bmatrix}$
        };

        \end{tikzpicture}
        \caption{k$>$1} 
    \end{figure}
\end{document}

这给了我这个结果:

在此处输入图片描述

但我希望它是这样的:

在此处输入图片描述

现在我注意到图片的尺寸可能很大,无法将它们放在同一行,但还有其他方法吗?比如缩小一点或动态设置大小而不改变坐标,这对我来说会很麻烦,因为我已经做了很多这样的工作

答案1

使用以下解决方案minipage

您不能使用figureminipage您可以改用\usepackage{caption}我还使用adjustbox来调整图像:

在此处输入图片描述

\documentclass{article} % say
\usepackage{tikz}
\usepackage{changes}
\usepackage{amsmath}
\usepackage{float}
\usepackage{caption}
\usepackage{adjustbox}

\begin{document}
\begin{minipage}[b]{.3\linewidth}
    \[
      \begin{bmatrix}
        k & 0 \\
        0 & 1
      \end{bmatrix}
    \]
    \captionof{figure}{Std Matrix}
\end{minipage}
\hfill
\begin{minipage}[b]{.3\linewidth}
  \begin{adjustbox}{width=\linewidth}
  \begin{tikzpicture}
    \definecolor{colorforline}{RGB}{49,4,71};

    \draw [very thick, color=colorforline] (-0.5,0) -- (4,0) node [right]{$x\textsubscript{1}$};
    \draw  [very thick, color=colorforline] (0,-0.5) -- (0,4) node [above]{$x\textsubscript{2}$};
    \definecolor{recshade}{RGB}{233,226,234};
    \filldraw[very thick, color=colorforline,fill=recshade] (0,0) rectangle (1.2,2.2);
    \draw[colorforline,  very thick] (0,2.2) -- (1.2,2.2) -- (1.2,0) node[below] {} ;%rotation
    \foreach \y in {0,...,9}{
      \draw[colorforline, thick](0,0.\y) -- (1.2,0.\y);
      \draw[colorforline, thick](0,1.\y) -- (1.2,1.\y);
    }
    \draw[colorforline, thick](0,2.0) -- (1.2,2.0);
    \draw[colorforline, thick](0,2.1) -- (1.2,2.1);
    \draw[colorforline, thick](0,2.2) -- (1.2,2.2);

    \filldraw [colorforline] (0,2.2) circle [radius=2pt] node[left] {
      $   \begin{bmatrix}
        0 \\
        1
      \end{bmatrix}$
    };
    \coordinate (O) at (3.6,1.4,0);
    \coordinate (1) at (3.6,1,0);
    \coordinate (A) at (1.9,1.4,0);
    \coordinate (B) at (1.9,1,0);
    \draw[very thick, ->, color=colorforline] (O) to  (A);
    \draw[very thick, ->, color=colorforline] (1) to  (B);

    \filldraw [colorforline] (1.2,0) circle [radius=2pt] node[below] {
      $   \begin{bmatrix}
        k \\
        0
      \end{bmatrix}$
    };
  \end{tikzpicture}
  \end{adjustbox}
  \captionof{figure}{0$<$k$<$1} 
\end{minipage}
\hfill
\begin{minipage}[b]{.25\linewidth}
  \begin{adjustbox}{width=\linewidth}
  \begin{tikzpicture}
    \definecolor{colorforline}{RGB}{49,4,71};

    \draw [very thick, color=colorforline] (-0.5,0) -- (4,0) node [right]{$x\textsubscript{1}$};
    \draw  [very thick, color=colorforline] (0,-0.5) -- (0,4) node [above]{$x\textsubscript{2}$};
    \definecolor{recshade}{RGB}{233,226,234};
    \filldraw[very thick, color=colorforline,fill=recshade] (0,0) rectangle (3,2.2);
    \draw[colorforline,  very thick] (0,2.2) -- (1.2,2.2) -- (3,2.2) node[below] {} ;%rotation
    \foreach \y in {0,...,9}{
      \draw[colorforline, thin](0,0.\y) -- (3,0.\y);
      \draw[colorforline, thin](0,1.\y) -- (3,1.\y);
    }
    \draw[colorforline, thin](0,2.0) -- (3,2.0);
    \draw[colorforline, thin](0,2.1) -- (3,2.1);
    \draw[colorforline, thin](0,2.2) -- (3,2.2);

    \filldraw [colorforline] (0,2.2) circle [radius=2pt] node[left] {
      $   \begin{bmatrix}
        0 \\
        1
      \end{bmatrix}$
    };
    \coordinate (O) at (2.5,1.4,0);
    \coordinate (1) at (0.5,1,0);
    \coordinate (A) at (0.5,1.4,0);
    \coordinate (B) at (2.5,1,0);
    \draw[very thick, ->, color=colorforline] (A) to  (O);
    \draw[very thick, ->, color=colorforline] (1) to  (B);

    \filldraw [colorforline] (3,0) circle [radius=2pt] node[below] {
      $   \begin{bmatrix}
        k \\
        0
      \end{bmatrix}$
    };

  \end{tikzpicture}
\end{adjustbox}
  \captionof{figure}{k$>$1}
\end{minipage}
  \captionof{figure}{The whole caption}
\end{document}

答案2

如果你确实想要在同一行上显示三个单独的图形,flav 的答案非常好。如果你真的想将三幅图像合并为一个带有一个数字和标题的图形,请尝试subcaption包。如果您根本不想要单独的标题,您也可以将所有三张图片放在同一张图中。

我在上面的评论中也提到过,有几种方法可以缩放图片,具体取决于您的意图。您可以 a) 向环境tikzpicture本身添加缩放因子,或者 b) 在渲染图片后缩放图片。第一种方法将使某些元素不缩放,例如文本和线宽,而第二种方法会缩放所有内容。

我在下面说明了这些不同的方法(为了简洁起见,使用了更简单的虚拟图片)。

\documentclass{article} % say
\usepackage{tikz,changes,amsmath,subcaption}
\begin{document}
\begin{figure}
  \begin{subfigure}[b]{.3\linewidth}
    \centering
    \[
    \begin{bmatrix}
    k & 0 \\
    0 & 1
    \end{bmatrix}
    \]
    \caption{Standard Matrix}
    \label{subfig:matrix}
  \end{subfigure}
  \hfill
  \begin{subfigure}[b]{.3\linewidth}
    \centering
    \begin{tikzpicture}[scale=.5]
      \draw[very thick] (0,0) rectangle node {$0<k<1$} (5,3);
    \end{tikzpicture}
    \caption{$0<k<1$}
    \label{subfig:smallk}
  \end{subfigure}
  \hfill
  \begin{subfigure}[b]{.3\linewidth}
    \centering
    \begin{tikzpicture}[scale=.5]
      \draw (0,0) node[above right] {Text} rectangle (5,5) node[below left] {$x\geq 3$};
    \end{tikzpicture}
    \caption{$k>1$}
    \label{subfig:largek}
  \end{subfigure}
  \caption{Three figures arranged using \texttt{subcaption} with scaling directly on the \texttt{tikzpicture} environments.}
  \label{fig:first}
\end{figure}
Using \texttt{subcaption}, you can refer to subfigures \ref{subfig:matrix}, \ref{subfig:smallk}, \ref{subfig:largek}, or figure \ref{fig:first}. You can even refer to subfigure \subref{subfig:matrix} of figure \ref{fig:first}.

\begin{figure}
  \centering
  $\displaystyle % This gets the styling of math display mode without the line breaks.
  \begin{bmatrix}
  k & 0 \\
  0 & 1
  \end{bmatrix}
  $
  \hfill
  \scalebox{.5}{
  \begin{tikzpicture}
    \draw[very thick] (0,0) rectangle node {$0<k<1$} (5,3);
  \end{tikzpicture}
  }
  \hfill
  \scalebox{.5}{
  \begin{tikzpicture}
    \draw (0,0) node[above right] {Text} rectangle (5,5) node[below left] {$x\geq 3$};
  \end{tikzpicture}
  }
  \caption{The same three figures with no subcaption, scaled using \texttt{scalebox}.}
  \label{fig:second}
\end{figure}

Without \texttt{subcaption}, you can only refer to figure \ref{fig:second}.

\end{document}

(请注意,参数[b]表示subfigure图形应该底部对齐。)

相关内容