換行後文字寬度錯誤

換行後文字寬度錯誤

我已經包含了一張圖片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設定為wrapfigurestextwidth會導致顯示錯誤。

答案1

引用手冊包裝圖包裝,第 1 頁:

您不得wrapfigure在任何類型的清單環境中指定 或 緊接在 1 之前或之後。如果\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

將 括wrapfigminipage.通常

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

相關內容