[Tex/LaTex] How to end wrapfigure environment

wrapfigure

I used wrapfigure when I want insert a figure, but can's stop it after the figure.
I used the code

\begin{wrapfigure}[8]{r}{20cm}

\documentclass[landscape,12pt,a3paper]{article}
\usepackage{graphicx}
\usepackage{wrapfig}
\usepackage[left=2.00cm,right=2cm,top=2cm,bottom=2cm]{geometry}
\begin{document}

\setlength{\intextsep}{1cm}
\begin{wrapfigure}[35]{r}{20cm}
    \centering
    \includegraphics[width=20cm]{03-1.pdf}\\
\end{wrapfigure}

    \subsubsection*{Shell sort}
\addcontentsline{toc}{subsubsection}{Shell sort}

Main article: Shell sort

Shell sort was invented by Donald Shell in 1959. It improves upon bubble sort and insertion sort by moving out of order elements more than one position at a time. One implementation can be described as arranging the data sequence in a two-dimensional array and then sorting the columns of the array using insertion sort.

\subsubsection*{Comb sort}
\addcontentsline{toc}{subsubsection}{Comb sort} 
Main article: Comb sort

Comb sort is a relatively simple sorting algorithm originally designed by Wlodzimierz Dobosiewicz in 1980.[19] Later it was rediscovered and popularized by Stephen Lacey and Richard Box with a Byte Magazine article published in April 1991. Comb sort improves on bubble sort. The basic idea is to eliminate turtles, or small values near the end of the list, since in a bubble sort these slow the sorting down tremendously. (Rabbits, large values around the beginning of the list, do not pose a problem in bubble sort)

\subsection*{Distribution sort}
\addcontentsline{toc}{subsection}{Distribution sort}    
See also: External sorting

Distribution sort refers to any sorting algorithm where data are distributed from their input to multiple intermediate structures which are then gathered and placed on the output. For example, both bucket sort and flashsort are distribution based sorting algorithms. Distribution sorting algorithms can be used on a single processor, or they can be a distributed algorithm, where individual subsets are separately sorted on different processors, then combined. This allows external sorting of data too large to fit into a single computer's memory.    \end{document}

enter image description here

Best Answer

The syntax for using wrapfigure (from manual):

enter image description here

You have used a number 35 so expect to get that much narrow lines. Looking at the picture in your question, a vlue of 15-17 is appropriate . Adjust this number properly. Also it would be better to give some more text in the paragraph so that wrapping looks good.

\documentclass[landscape,12pt,a3paper]{article}
\usepackage[demo]{graphicx}      %% remove demo
\usepackage{wrapfig}
\usepackage[left=2.00cm,right=2cm,top=2cm,bottom=2cm]{geometry}
\usepackage{lipsum}
\begin{document}

\setlength{\intextsep}{1cm}
\begin{wrapfigure}[8]{r}{20cm}  %% I used 8 here, change suitably
    \centering
    \includegraphics[width=20cm]{03-1.pdf}\\
\end{wrapfigure}
\lipsum[1-2]  %% just for putting more text, yes put more text here
text text  text text  text text  text text  text text ........

\end{document}

enter image description here

Regarding the edited question, put the wrapfigure after the section like

\subsubsection*{Shell sort}
\addcontentsline{toc}{subsubsection}{Shell sort}
\setlength{\intextsep}{1cm}
\begin{wrapfigure}[9]{r}{20cm}
    \centering
    \includegraphics[width=20cm]{03-1.pdf}\\
\end{wrapfigure}

Main article: Shell sort
.
.
.

enter image description here

However, you have too less text in the paragraph Main article: Shell sort...

Related Question