4

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!

5
  • Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format.
    – Symbol 1
    Commented Feb 3, 2015 at 8:20
  • How exactly do you want to wrap the text around the matrix? For example, do you want to place the matrix in some corner of the paragraph? Right in the middle... vertically? And/or horizontally? Please elaborate.
    – Werner
    Commented Feb 3, 2015 at 8:20
  • Albeit the good solution using wrapfigure I have to ask: Is there a reason why you're not willing to use the usual displaymath \[…\]? You get more whitespace, but on the other hand the matrix is placed exactly where you put it in the paragraph. This could make for a more fluid reading experience in my opinion.
    – JBantje
    Commented Feb 3, 2015 at 8:42
  • Also I would recommend to use the bmatrix environment from amsmath/mathtools instead of tabular or array to typeset matrices
    – JBantje
    Commented Feb 3, 2015 at 8:46
  • 1
    Thanks heaps to everyone for being so quick and thorough with your replies and explanations!!
    – Jacinta
    Commented Feb 3, 2015 at 10:17

2 Answers 2

5

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

6
  • 1
    Does this kind of figure need, in the manner of typography, a caption? to appear in lof?
    – Symbol 1
    Commented Feb 3, 2015 at 8:25
  • 1
    To appear in the lof you'll need a caption. But as Harish shows none is needed otherwise. Commented Feb 3, 2015 at 8:27
  • 1
    @Symbol1 Is it a figure? I am not sure! ;-)
    – user11232
    Commented Feb 3, 2015 at 8:27
  • no, but I was once taught that everything not in the main stream should have a caption. Your figure, I mean the PNG in your answer, looks pretty so I wish I was wrong.
    – Symbol 1
    Commented Feb 3, 2015 at 8:34
  • 1
    @Symbol1 Whatever comes inside figure (or wrapfigure) is a float and it can be any thing (including text). If if is a picture or tabular, then it needs a caption. This is a matrix.
    – user11232
    Commented Feb 3, 2015 at 8:37
0

As you did not provide a Minimal Working Example (MWE), I have to guess some things.

First: The wraptable and wrapfigure-environment provided by the wrapfig package will not exactly do what you want. They are build to push a figure or table (or any other float-type) next to or into the margin. As seen below the two mandatory Parameters denote the side (left or right) and the width of the box (here the width of your matrix).

Second: There was no need to rewrite your Matrix into a tabular as (like with all floats) you can put almost every possible content into a wrapfigure or wraptable. The difference between them comes into effect, when you put a \caption command.

\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}
2
  • 2
    In what way this is different from my answer?
    – user11232
    Commented Feb 3, 2015 at 8:26
  • I was writing while your answer appeared and only realized after finishing. Beside: I put a caption (but that was not in the original question so there's no real difference). Commented Feb 3, 2015 at 8:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .