0

I am attempting to wrap document text around the equation below using the following code.

\begin{wrapfigure}{left}{0pt}
    $$ \begin{aligned}
        \sum\limits_{i=0}^{15} \frac{\cos{\frac{(2i+17)\pi}{32}}}{\frac{(2i+17)\pi}{32}}\frac{\pi}{16} &= \sum\limits_{i=0}^{15} \frac{\cos{\left(\frac{(2i+17)\pi}{32}\right)}\cdot         \cancelto{2}{32}}{(2i+17)\cancel{\pi}}\frac{\cancel{\pi}}{\cancel{16}} \\
        &= \sum\limits_{i=0}^{15}\frac{2\cos{\frac{(2i+17)\pi}{32}}}{2i+17}.
    \end{aligned} $$
\end{wrapfigure}

However, when I compile the document, I receive errors "\begin{align} only allowed in math environment" and "missing $ inserted." I've tried using equation*, as I've seen it used in the wrapfigure environment (here), but none of them will give me multiline equations.

I'm using Overleaf with the pdfLaTeX compiler, and the document still compiles and actually displays correctly, but I'm not sure why the error is there.Compiled document with correct formatting

P.S. I apologize if my formatting is poor, this is my first Tex.SE, and if my question has a very simple answer, I am very new to LaTeX.

leandriis
  • 62,593
JoDraX
  • 103

1 Answers1

2

Do not use a displaystyle syntax, but a simple $ ... $. This insertion can also be done with the \InsertBoxL command, from the plainTeX macro package insbox.

This command has two mandatory arguments: the number of unshortened lines before insertion, and the contents of the box, plus an optional argument: the number of supplementary shortened lines, in case TeX has computed erroneously the necessary number of short lines.

\documentclass{article}
\usepackage[latin]{babel}
\usepackage{mathtools}% for 'vmatrix*' and 'align*' env.
\usepackage{wrapfig}
\usepackage{cancel}
\input{insbox} % for 'S' column type
\usepackage{lipsum}

\begin{document}

\begin{wrapfigure}[7]{l}{0pt}
$ \begin{aligned}
        \sum\limits_{i=0}^{15} \frac{\cos{\frac{(2i+17)\pi}{32}}}{\frac{(2i+17)\pi}{32}}\frac{\pi}{16} &= \sum\limits_{i=0}^{15} \frac{\cos{\left(\frac{(2i+17)\pi}{32}\right)}\cdot \cancelto{2}{32}}{(2i+17)\cancel{\pi}}\frac{\cancel{\pi}}{\cancel{16}} \\
        &= \sum\limits_{i=0}^{15}\frac{2\cos{\frac{(2i+17)\pi}{32}}}{2i+17}.
    \end{aligned} $
\end{wrapfigure}
\noindent
\lipsum[2]
\vskip 1cm
\InsertBoxL{0}{$ \begin{aligned}
        \sum\limits_{i=0}^{15} \frac{\cos{\frac{(2i+17)\pi}{32}}}{\frac{(2i+17)\pi}{32}}\frac{\pi}{16} &= \sum\limits_{i=0}^{15} \frac{\cos{\left(\frac{(2i+17)\pi}{32}\right)}\cdot \cancelto{2}{32}}{(2i+17)\cancel{\pi}}\frac{\cancel{\pi}}{\cancel{16}} \\
        &= \sum\limits_{i=0}^{15}\frac{2\cos{\frac{(2i+17)\pi}{32}}}{2i+17}.
    \end{aligned} $}[2]
\noindent
\lipsum[2]

\end{document} 

Do

Bernard
  • 271,350