包裹图后文本宽度错误

包裹图后文本宽度错误

我已附上图片wrapfigure,一切正常 - 问题是在我的下一个公式环境中,公式完全错误!在我看来,我在环境中设置的宽度wrapfigure也会影响公式。我怎样才能将宽度重新设置为标准?

这是我的代码:

\documentclass{book}
\usepackage{graphicx}
\usepackage{amsthm}
\usepackage{wrapfig}
\usepackage{mdframed}

\newtheoremstyle{mystyle}{}{}{}{}{}{}{0.5em}{}
\theoremstyle{mystyle}
\newmdtheoremenv{formel}{Formel}

\begin{document}
\begin{wrapfigure}{l}{8cm}
  \includegraphics[scale=0.48]{example-image-a}
\end{wrapfigure}
text text text text text text text text text text text text text text text text
text text text text text text text text text text text text text text text text
\begin{formel}[Formel]
$1+1=2$
\end{formel}
\end{document}

因此,文本环绕图形是可以的,但公式的宽度是错误的。在我看来,textwidth设置为 的wrapfiguretextwidth导致了错误的显示。

答案1

引用手册包裹图包,第 1 页:

您不得在任何类型的列表环境中指定或 或 紧接在 之前或之后。如果中间wrapfigure有一个空行 ( ),则可以跟在列表后面。\par

[...]

\linewidth现在已在换行文本中进行了调整,但由于一次只能为整个段落设置,因此换行后它将一直保留错误的值,直到该段落完成。

第 2 页:

出于美观原因,只有纯文本才应环绕图形。章节标题和大方程式看起来很糟糕;如果图形在左侧,列表也不好。(所有这些功能都正常,只是看起来不太好。)小方程式看起来不错。

因此:在\par前面放置一个\begin{formel}

\documentclass{book}
\usepackage{graphicx}
\usepackage{amsthm}
\usepackage{wrapfig}
\usepackage{mdframed}

\newtheoremstyle{mystyle}{}{}{}{}{}{}{0.5em}{}
\theoremstyle{mystyle}
\newmdtheoremenv{formel}{Formel}

%\usepackage{picins}

\begin{document}
\begin{wrapfigure}{l}{8cm}
  \includegraphics[scale=0.48]{example-image-a}
\end{wrapfigure}
text 
\par
\makeatletter
\loop
\ifnum\c@WF@wrappedlines>3
\hspace*{1sp}\newline
\advance\c@WF@wrappedlines by -1
\repeat
\makeatother
\par
\begin{formel}[Formel]
$1+1=2$
\end{formel}
\end{document}

如果要换行的文本太短,公式将放置在换行文本中,当然,换行文本的宽度较小。(并且\usepackage{picins}需要额外的内容,否则公式将打印在图片“上方”。)使用\c@WF@wrappedlineswrapfig 包并自动插入适当数量的空行可以解决此问题。

答案2

将 括wrapfig在 中minipage。通常

\begin{minipage}
\begin{wrapfig}
...
\end{wrapfig}
...text... to be wrapped
\end{minipage}
..more text which should be normal

相关内容