[Tex/LaTex] How to wrap text around a matrix

matriceswrapfigure

In the middle of a paragraph (text is justified), I have a 5-row matrix. I've been trying to find a way to wrap the text in the paragraph around the matrix, so there aren't large gaps above and below the text on that line. I have heard of the wrapfig package, but haven't managed to get this to work yet.
Below is a sample similar to the code I have so far (I switched from using an array environment to tabular after discovering I may be able to use \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$.`

enter image description here

Thank you in advance!

Best Answer

You can use wrapfigure from wrapfig package.

\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}

enter image description here

By the way, you can use an array instead of that nasty tabular

Related Question