如何将带有标题的 tikzpicture 和带有标签的矩阵并排放置?

如何将带有标题的 tikzpicture 和带有标签的矩阵并排放置?

我有两件事想放在一起:

矩阵由下式给出:

\begin{align} \label{example}
    X = \quad
    \begin{blockarray}{ccccc}
    A & B & C & D \\
    \begin{block}{(cccc)c}
        0 & 0 & 0 & 0 & A \\
        0 & 0 & 0 & 0 & B \\
        0 & 0 & 0 & 0 & C \\
        0 & 0 & 0 & 0 & D, \\
    \end{block}
    \end{blockarray}
\end{align}

以及一个带有标题的 tikzpicture,到目前为止,我已经使用图形环境实现了它

\begin{figure}
    \begin{tikzpicture}[->,every node/.style={circle,draw},line width=1pt, node distance=1.6cm]
        \node (1)  {A};
        \node (2) [below right of=1] {B};
        \foreach \from/\to in {1/2}
        \node (3) [below left of=1] {C};
        \foreach \from/\to in {2/3,1/3}
        \draw (\from) -- (\to);   
        \node (4) [below left of=2] {D}; 
        \foreach \from/\to in {1/4,2/4,3/4}
        \draw (\from) -- (\to);   
        \path[every node/.style={font=\small}];
    \end{tikzpicture} \caption{Some figure}\label{example2}
\end{figure}

我现在想将它们并排放置,但我无法将图形放在小页面中,而且我也无法将 tikzpicture 放在小页面中 - 有什么聪明的方法可以做到这一点?

答案1

欢迎使用!您可以使用wrapfig

\documentclass{article}
\usepackage{amsmath}
\usepackage{blkarray}
\usepackage{tikz}
\usepackage{wrapfig}
\begin{document}
\begin{wrapfigure}[6]{r}[10pt]{4cm}
\centering
    \begin{tikzpicture}[->,every node/.style={circle,draw},line width=1pt, node distance=1.6cm]
        \node (1)  {A};
        \node (2) [below right of=1] {B};
        \foreach \from/\to in {1/2}
        \node (3) [below left of=1] {C};
        \foreach \from/\to in {2/3,1/3}
        \draw (\from) -- (\to);   
        \node (4) [below left of=2] {D}; 
        \foreach \from/\to in {1/4,2/4,3/4}
        \draw (\from) -- (\to);   
        \path[every node/.style={font=\small}];
    \end{tikzpicture} \caption{Some figure}\label{example2}
\end{wrapfigure}
\begin{align} \label{example}
    X = \quad
    \begin{blockarray}{ccccc}
    A & B & C & D \\
    \begin{block}{(cccc)c}
        0 & 0 & 0 & 0 & A \\
        0 & 0 & 0 & 0 & B \\
        0 & 0 & 0 & 0 & C \\
        0 & 0 & 0 & 0 & D, \\
    \end{block}
    \end{blockarray}
\end{align}
\end{document}

在此处输入图片描述

第一个可选参数[6]表示要跳过的行数。“最佳”值将取决于文档几何形状、字体大小等细节。以下是我选择 的原因6

\documentclass{article}
\usepackage{amsmath}
\usepackage{blkarray}
\usepackage{tikz}
\usepackage{wrapfig}
\begin{document}
\begin{wrapfigure}[6]{r}[10pt]{4cm}
\centering
    \begin{tikzpicture}[->,every node/.style={circle,draw},line width=1pt, node distance=1.6cm]
        \node (1)  {A};
        \node (2) [below right of=1] {B};
        \foreach \from/\to in {1/2}
        \node (3) [below left of=1] {C};
        \foreach \from/\to in {2/3,1/3}
        \draw (\from) -- (\to);   
        \node (4) [below left of=2] {D}; 
        \foreach \from/\to in {1/4,2/4,3/4}
        \draw (\from) -- (\to);   
        \path[every node/.style={font=\small}];
    \end{tikzpicture} \caption{Some figure}\label{example2}
\end{wrapfigure}
Consider the array
\begin{align} \label{example}
    X = \quad
    \begin{blockarray}{ccccc}
    A & B & C & D \\
    \begin{block}{(cccc)c}
        0 & 0 & 0 & 0 & A \\
        0 & 0 & 0 & 0 & B \\
        0 & 0 & 0 & 0 & C \\
        0 & 0 & 0 & 0 & D, \\
    \end{block}
    \end{blockarray}
\end{align}
The structure of the array is illustrated in Figure~\ref{example2}. 

Some more text \dots some more text \dots some more text \dots some more text
\dots some more text \dots some more text \dots some more text \dots some more
text \dots some more text \dots some more text \dots some more text \dots some
more text \dots some more text \dots some more text \dots some more text
\end{document}

在此处输入图片描述

这在标准文章中看起来相当好,但在其他文档中可能需要更改。

相关内容