Wrapfig leaves text permanently curtailed thereafter

  • Thread starter Thread starter brotherbobby
  • Start date Start date
  • Tags Tags
    Latex wrapfig
AI Thread Summary
The discussion centers on issues related to the use of the wrapfig environment in LaTeX for placing images alongside text. The user is experiencing problems with text being cut off after an image, despite placing the wrapfig environment correctly before the "Attempt" section. Suggestions to modify the image width from textwidth to linewidth did not resolve the issue. The user also encountered further complications when adding a second image, leading to overlapping text. The conversation highlights the challenges of using wrapfig, particularly in itemized environments, and suggests that users may need to resort to alternative methods, such as using includegraphics without wrapfig, to achieve desired layouts. References to external LaTeX resources and tutorials are provided for further assistance. The user expresses a desire to learn and improve their LaTeX skills, acknowledging the complexities involved in achieving efficient document formatting.
brotherbobby
Messages
749
Reaction score
169
TL;DR Summary
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.
 
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
Views
4K
Replies
2
Views
5K
Replies
3
Views
2K
Replies
4
Views
692
Replies
1
Views
8K
Replies
2
Views
3K
Replies
4
Views
4K
Replies
7
Views
2K
Back
Top