Wrapfig leaves text permanently curtailed thereafter

  • Thread starter Thread starter brotherbobby
  • Start date Start date
  • Tags Tags
    Latex wrapfig
Click For Summary
SUMMARY

The forum discussion addresses issues with the LaTeX wrapfig package, specifically regarding text curtailment after images. Users reported that text following the wrapfigure environment was being cut off, even when the environment was correctly placed. Suggestions included changing the width parameter in the includegraphics command from textwidth to linewidth, but these did not resolve the issue. The discussion highlights the limitations of wrapfig in certain environments and offers links to additional resources for troubleshooting.

PREREQUISITES
  • Understanding of LaTeX document preparation system
  • Familiarity with the wrapfig package
  • Basic knowledge of image inclusion using includegraphics
  • Experience with LaTeX environments and commands
NEXT STEPS
  • Research wrapfig limitations in LaTeX environments
  • Learn about alternative image placement techniques in LaTeX
  • Explore the graphicx package for advanced image handling
  • Review LaTeX documentation on troubleshooting figure placements
USEFUL FOR

This discussion is beneficial for LaTeX users, particularly those working with document layouts involving images, such as academic writers, researchers, and technical authors seeking to optimize their use of the wrapfig package.

brotherbobby
Messages
756
Reaction score
170
TL;DR
The wrapfigure environment in ##\rm{LaTeX}## is leaving the text curtailed, long after the figure (image) has ended. The remaining text of the article is now permanently short from the right hand side, to the extent to which the wrapfig environment was defined using the \textwidth option. While the left hand margin remains, the right hand margin has shrunk to the defined dimensions of the environment (wrapfig). Details are below.
1748733611460.webp


Problem :

I copy and paste the image of the problem to the right.

I put the wrapfig environment before the section marked "Attempt" in order to bring the image as high up as possible.

As you can see, the following section (titled "Doubt") along with its contents are all curtailed long after the picture has ended along with its caption. The same moves on to the next page.





Code :

I copy and paste the code below.


Code:
\begin{wrapfigure}[10]{r}{0.3\textwidth}
  \centering
    \includegraphics[width=0.3\textwidth]{Problem.png}
  \caption{Cannon exploding}
\end{wrapfigure}

\section*{Attempt}

I start by putting the image of the problem to the right. \\

A cannon of mass $M$ moving with a velocity (say) $v$, splits into two parts of masses $kM$ and $(1-k)M$ following an explosion that generated an amount of energy $E$. The second piece falls straight to the ground while the first piece of mass $kM$ continues in the same direction with a velocity $v'$. What is the velocity ${\color{red}{v' =?}}$\\

Using momentum conservation, we have $Mv=kMv'\Rightarrow v=kv'\qquad (1).$


As you can see, the wrapfig environment was declared and ended before the section titled "Attempt".


Request :

Where am I going wrong?
 
Physics news on Phys.org
Try changing the textwidth to linewidth in the includegraphic descriptor
 
jedishrfu said:
Try changing the textwidth to linewidth in the includegraphic descriptor


Am sorry it didn't help.


1748752611687.webp


Here's the code :

Code:
\begin{wrapfigure}[10]{r}{0.3\textwidth}
  \centering
    \includegraphics[width=0.6\linewidth]{Problem.png}
  \caption{Cannon exploding}
\end{wrapfigure}

\section*{Attempt}
 
Worse, if you're there @jedishrfu, I'd like you to see what came up later. The text came over a second image I put below using Wrapfig.

Here's the image :

1748752800246.webp


Here's the code for the second image :

Code:
\section*{Doubt}

Let's have the answer again : $\boxed{v'=\sqrt{\dfrac{2E}{k(1-k)M}}}$, as the velocity of the piece of mass $kM$. Clearly, the value of $k$ has to be between 0 and 1.

(1) What happens (intuitively) when $k\approx 0$? \\

\begin{wrapfigure}[10]{r}{0.3\textwidth}
  \centering
    \includegraphics[width=0.9\linewidth]{Plot.png}
  \caption{Plot of $v'$ versus $k$}
\end{wrapfigure}

When $k$ goes to 0, the first piece has neglible mass while (almost) the whole of the mass of the cannon is taken by the second piece which has no kinetic energy. Hence the first piece must take (almost) the entire kinetic energy of the original cannon. Having negligle mass, it means that its velocity $v'\rightarrow \infty$. \\

Thus, we can say that $\displaystyle{\lim_{k\to 0}\; v'\rightarrow \infty}\qquad (2)$\\

I plotted the solution for $v'$ in \verb|Desmos| as given above, $v'=\sqrt{\dfrac{2E}{k(1-k)M}}$, taking $E=\dfrac{1}{2}$ and $M=1$. I copy and paste the image of the plot to the right. From the plot, as $k\rightarrow 0$, the velocity $v\rightarrow\infty$. \\
 
I suppose this is something you'll have to experiment with until you achieve what you want.

I found this LaTeX reference page on wrapfig, which mentions some areas where it's difficult to get it to work correctly:

https://www.overleaf.com/learn/latex/Wrapping_text_around_figures

https://ctan.org/pkg/wrapfig

And here's a couple of tutorials:



https://latex-tutorial.com/wrap-image-text/

And here's a tex.stackexchange discussion on it:

https://tex.stackexchange.com/questions/56176/handling-of-wrapfig-pictures-in-latex

I'm not an experienced LaTeX user, nor am I an expert in HTML and CSS. I usually look for examples that I can work with and learn how to use the package effectively.

At work, using the GridBag layout, we encountered similar issues, and my coworker was a true master of the Java package within the context of the NetBeans Matisse editor. When I encountered a placement issue, he knew just what margins and spacing to adjust.

However, none of that helps with your layout problem here.
 
Thank you @jedishrfu. Lots to read and study. ##\rm{\LaTeX}## is all about reading and finding ways out, though efficiency can come into question beyond a point - "am I getting enough out for the effort I am putting in"? I try to avoid the question as far as possible.

##\verb|Wrapfig|## has another problem - you cannot use it in itemised (enumerated) environments in ##\rm{\LaTeX}##. There are ways out it though, but that would entail what people call ##\rm{\LaTeX}\, \text{gymnastics}##. This is where the hard work and efficiency come into question. That gymnastics is quite hard for me at the moment, see here. Alternately, one might only use includegraphics in the image enviromnent and ignore wrapfig altogether. In that case, the image will appear above (or below) the itemised point to which it may be referred to.

Thank you for your interest.
 
  • Like
Likes   Reactions: jedishrfu
Yes, I know the feeling. I use iaWriter for markdown documents and wanted to have sidebars but markdown has no facility for that construct. However I found an example where someone added html to their markdown document to create them and that was enough for my needs.

**Notice how I had to embed html within the markdown to get it to work.

Markdown (GitHub flavored):
# RIGHT SIDEBAR
<div style="display: flex; align-items: flex-start; gap: 20px;">

<div style="flex: 3;">
<p>
## **Main Text**

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed non risus. Suspendisse lectus tortor, dignissim sit amet, adipiscing nec, ultricies sed, dolor.
</p>
</div>

<div style="flex: 1; background-color: #f9f9f9; padding: 10px; border-left: 3px solid #ccc;">
<p>
**Sidebar Note**

This is additional commentary related to the main text. It helps the reader understand the context better.
</p>
</div>

</div>

# LEFT SIDEBAR
<div style="display: flex; align-items: flex-start; gap: 20px;">

<!-- Left Sidebar -->
<div style="flex: 1; background-color: #f0f0f0; padding: 10px; border-right: 3px solid #ccc;">
<p>
**Sidebar**

This is a left sidebar that provides supplemental notes, references, or commentary.
</p>
</div>

<!-- Main Content -->
<div style="flex: 3;">
<p>
## **Main Text**

This is the body of the content. You can write your main ideas, explanations, or lessons here. The left sidebar complements it.
</p>
</div>

</div>

IMG_4273.webp
 

Similar threads

  • · Replies 5 ·
Replies
5
Views
5K
  • · Replies 2 ·
Replies
2
Views
5K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 4 ·
Replies
4
Views
911
  • · Replies 1 ·
Replies
1
Views
8K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 4 ·
Replies
4
Views
1K
  • · Replies 4 ·
Replies
4
Views
5K
  • · Replies 17 ·
Replies
17
Views
5K
  • · Replies 7 ·
Replies
7
Views
2K