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.

  • 1
    Regarding: "I receive errors" and "the document still compiles and actually displays correctly": Even if you get something that on first glance resembles a pdf file, there can still be issues with it. After an error, TeX only tries to recover enough to syntax check more of the file, it does not try to make sensible output after an error. – leandriis Dec 18 '19 at 20:14
  • 2
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

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for?Browse other questions tagged or ask your own question.