![Wrapfig 环境不换行](https://linux22.com/image/418239/Wrapfig%20%E7%8E%AF%E5%A2%83%E4%B8%8D%E6%8D%A2%E8%A1%8C.png)
我的图像在整个页面上留下了空隙,这是我的代码:
\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}
答案1
最重要的问题是,wrapfig 假设每条线、方程和方框占用\baselineskip
的空间恰好为 。最简单的解决方案是手动调整 wrapfigure 的可选参数以适合文本。第二个问题是\@afterheading
(由\section
和使用\subsection
)与 混淆\everypar
,因此\WFclear
。
我替换了一些随机字符,这样我就可以判断它是否正常工作,而无需逐个字母检查。 \label
应该在之后\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}