Wrapfig leaves text permanently curtailed thereafter

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

Discussion Overview

The discussion revolves around issues encountered when using the wrapfig environment in LaTeX to position images alongside text. Participants explore the effects of different parameters on the layout and share experiences with similar formatting challenges.

Discussion Character

  • Technical explanation
  • Debate/contested
  • Experimental/applied

Main Points Raised

  • One participant describes a problem where text is being curtailed after using the wrapfig environment, indicating a layout issue with the placement of images and text.
  • Another suggests changing the width parameter from textwidth to linewidth in the includegraphics command, but this does not resolve the issue.
  • A later reply notes that the text overlaps with a second image when using wrapfig, raising further concerns about its functionality.
  • One participant shares a reference page on wrapfig and mentions that they are not an experienced LaTeX user, suggesting that experimentation may be necessary to achieve the desired layout.
  • Another participant discusses the limitations of wrapfig, specifically its incompatibility with itemized environments in LaTeX, and suggests alternative approaches to image placement.
  • There is a mention of using HTML within markdown to create sidebars, indicating a crossover of formatting techniques that may address layout challenges.

Areas of Agreement / Disagreement

Participants express various suggestions and experiences, but there is no consensus on a definitive solution to the layout issues presented. Multiple competing views on how to handle the wrapfig environment remain unresolved.

Contextual Notes

Participants note that the effectiveness of wrapfig may depend on specific document structures and that certain configurations can lead to unexpected results. Limitations regarding its use in itemized environments are also highlighted.

brotherbobby
Messages
766
Reaction score
171
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
944
  • · 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