如何将文本环绕矩阵?

如何将文本环绕矩阵?

在段落中间(文本对齐),我有一个 5 行矩阵。我一直在尝试找到一种方法来将段落中的文本环绕在矩阵周围,这样该行文本的上方和下方就不会出现较大的间隙。我听说过 wrapfig 包,但还没有设法让它工作。下面是一个类似于我目前的代码的示例(在发现我可以使用 \begin{wraptable} 后,我从使用数组环境切换到表格环境):

`This is a paragraph containing random text which I want to wrap around the matrix $L$. This is a paragraph containing random text which I want to wrap around the matrix $L$. This is a paragraph containing random text which I want to wrap around the matrix $L$. This is a paragraph containing random text which I want to wrap around the matrix $L$. This is a paragraph containing random text which I want to wrap around the matrix $L$. This is a paragraph containing random text which I want to wrap around the matrix $L$. This is a paragraph containing random text which I want to wrap around the matrix $L$. $L =  \left[ \begin{tabular}{ccccc}
                $F_1$&$F_2$&$\cdots$&$F_{d-1}$&$F_d$ \\
                $P_1$&$0$&$\cdots$&$0$&$0$ \\
                $0$&$P_2$&$0$&$\cdots$&$0$ \\
                $\vdots$&$\ddots$&$\ddots$&$\ddots$&$\vdots$ \\
                $0$&$\cdots$&$0$&$P_{d-1}$&$0$
                \end{tabular} \right].$ This is a paragraph containing random text which I want to wrap around the matrix $L$. This is a paragraph containing random text which I want to wrap around the matrix $L$. This is a paragraph containing random text which I want to wrap around the matrix $L$.`

在此处输入图片描述

先感谢您!

答案1

您可以wrapfigurewrapfig包中使用。

\documentclass{article}
\usepackage{amsmath}
\usepackage{wrapfig}
\begin{document}
  This is a paragraph containing random text which I want to wrap around the matrix $L$. This is a paragraph containing random text which I want to wrap around the matrix $L$. This is a paragraph containing random text which I want to wrap around the matrix $L$. This is a paragraph containing random text which
       \begin{wrapfigure}[8]{r}[0pt]{6cm}
     \raggedleft $L =  \left[ \begin{array}{ccccc}
                F_1    & F_2    & \cdots & F_{d-1} & F_d    \\
                P_1    & 0      & \cdots & 0       & 0      \\
                0      & P_2    & 0      & \cdots  & 0      \\
                \vdots & \ddots & \ddots & \ddots  & \vdots \\
                0      & \cdots & 0      & P_{d-1} & 0      
                \end{array} \right].$
\end{wrapfigure}
    I want to wrap around the matrix $L$. This is a paragraph containing random text which I want to wrap around the matrix $L$. This is a paragraph containing random text which I want to wrap around the matrix $L$. This is a paragraph containing random text which I want to wrap around the matrix $L$. This is a paragraph containing random text which I want to wrap around the matrix $L$. This is a paragraph containing random text which I want to wrap around the matrix $L$. This is a paragraph containing random text which I want to wrap around the matrix $L$. This is a paragraph containing random text which I want to wrap around the matrix $L$. This is a paragraph containing random text which I want to wrap around the matrix $L$. This is a paragraph containing random text which I want to wrap around the matrix $L$.
\end{document}

在此处输入图片描述

顺便说一句,你可以用一个来array代替那个讨厌的tabular

答案2

由于您没有提供最小工作示例(MWE),我必须猜测一些事情。

首先:包提供的wraptableand环境不会完全满足您的要求。它们的构建目的是将图形或表格(或任何其他浮点类型)推入或推入边距。如下所示,两个必需参数表示边距(eft 或ight)和框的宽度(此处为矩阵的宽度)。wrapfigurewrapfiglr

第二:没有必要将矩阵重写为表格,因为(与所有浮点数一样)您可以将几乎所有可能的内容放入或中wrapfigurewraptable当您输入命令时,它们之间的差异就会生效\caption

\documentclass{article}
\usepackage{wrapfig}
\usepackage{lipsum}
\begin{document}
\lipsum[1]

\begin{wrapfigure}{l}{6cm}
  $L =  \left[ \begin{tabular}{ccccc}
                $F_1$&$F_2$&$\cdots$&$F_{d-1}$&$F_d$ \\
                $P_1$&$0$&$\cdots$&$0$&$0$ \\
                $0$&$P_2$&$0$&$\cdots$&$0$ \\
                $\vdots$&$\ddots$&$\ddots$&$\ddots$&$\vdots$ \\
                $0$&$\cdots$&$0$&$P_{d-1}$&$0$
                \end{tabular} \right]$
    \caption{The Matrix called $L$.}
    \label{matrix}
\end{wrapfigure}

\lipsum[2]
The aforementioned Matrix $L$ is shown in figure \ref{matrix}.
\lipsum[2]
\end{document}

相关内容