1

[1]: https://i.stack.imgur.com/L7Fuh.png

enter image description here

My image is leaving a gap through the whole page, here is my code:

\documentclass[12pt,a4paper,notitlepage]{book}

\usepackage{wrapfig} \usepackage{float} \usepackage{graphicx} \newcommand\fixedalign{\hspace{0.5\linewidth} & \hspace{0.5\linewidth} \nonumber \[-\baselineskip]}

\begin{document} \begin{wrapfigure}{R}{0.4\textwidth} \includegraphics[width=0.4\textwidth]{examples-examples.jpg} \label{fig:example_graph} \caption{dfxdxkjfrgbdxjhb guijchbg jrcb g dxhjgmhbjfbgdm xg dxjgbjmdxbx jgexmdgjx ymgsjdxuygh esjdrg ddjshx ujsegyrj hgxddj ghsmdx djx ygsjdxy gmesjy gaku esr aeyr aerhkjaekrit iea urhuarhku} \end{wrapfigure} \subsection{hjbmbjbjj kiihiki,l} \subsubsection{iiihkihuhi 827883} % make a command kbhhfj: $$3233 31 4 331 32 2313$$

zxdfg, ahgvcsgdc 3 gyg uu tgff jkfddvfxjn,d xfk j kjfskjsbkfdjdbs z bj sfkjzkdnkzjjn k zj ks form fhddz hbdjazs,bhszzszj

\begin{align} %\fixedalign 3232434242 3142 4321 14324&31 \ 5353253235 53 & 4353425234234\ 4221244 423421412 4213412 &424421 1212 \ 4421424121423 4123142 &4324424343432432\ \end{align}

3241412332 tgfgfd gx nfhfdg gfgfx bgfc gf gfb ccgf cvcbbcvbbcvvbbfrgf fs dg sfgafygagyregryvc craywkcrjscr $$32413243421 42 42142143 333 3 43 43 3 3$$

\subsubsection*{Example 1.1.2} rggdd: $$fgfggfg324342313421$$

\begin{align}\fixedalign 424224 &234343233 \ 2342414124v 5412412 & 22312332413412 \ 3234342 & 4224142 3241314132 1122121 \ \end{align} 32414gd gh g hfgsh ghg shghd sg asgh g shsg hgh hgfs sh gshsg hghsghs g shgshhgsgsh tswhhhhhhhhhhhgggggggggggggggggggggggggshfg \end{document}

epR8GaYuh
  • 2,432

1 Answers1

1

The most important problem is that wrapfig assumes every line, equation, and box takes precisely \baselineskip of space. The easiest solution is to manually adjust the optional argument of wrapfigure to fit the text. The second problem is that \@afterheading (used by \section and \subsection) messes with \everypar, hense the \WFclear.

I replaced some of the random characters so that I could tell whether of not it was working without doing a letter by letter check. \label should go after \caption.

\documentclass[12pt,a4paper,notitlepage]{book}

\usepackage{wrapfig} \usepackage{float} \usepackage{graphicx} \usepackage{mathtools} \newcommand\fixedalign{\hspace{0.5\linewidth} & \hspace{0.5\linewidth} \nonumber \[-\baselineskip]}

\usepackage{lipsum}

\begin{document} \begin{wrapfigure}[5]{R}{0.4\textwidth} \includegraphics[width=0.4\textwidth]{example-image} \caption{Figure capton here.}\label{fig:example_graph} \end{wrapfigure} \subsection{An intelligible strng} \subsubsection{Some more identifiable text} % make a command Start of paragraphe: $$3233 31 4 331 32 2313$$

\LipsumPar{2}

\WFclear% not sure why this is needed - proabably @afterheading \begin{align} %\fixedalign 3232434242 3142 4321 14324&31 \ 5353253235 53 & 4353425234234\ 4221244 423421412 4213412 &424421 1212 \ 4421424121423 4123142 &4324424343432432\ \end{align}

3241412332 tgfgfd gx nfhfdg gfgfx bgfc gf gfb ccgf cvcbbcvbbcvvbbfrgf fs dg sfgafygagyregryvc craywkcrjscr $$32413243421 42 42142143 333 3 43 43 3 3$$

\subsubsection*{Example 1.1.2} rggdd: $$fgfggfg324342313421$$

\begin{align}\fixedalign 424224 &234343233 \ 2342414124v 5412412 & 22312332413412 \ 3234342 & 4224142 3241314132 1122121 \ \end{align} 32414gd gh g hfgsh ghg shghd sg asgh g shsg hgh hgfs sh gshsg hghsghs g shgshhgsgsh tswhhhhhhhhhhhgggggggggggggggggggggggggshfg \end{document}

John Kormylo
  • 79,712
  • 3
  • 50
  • 120