為什麼“wrapfigure”和它的段落不一起顯示?

為什麼“wrapfigure”和它的段落不一起顯示?

wrapfig通常用於將其與應包裹它的特定文字並排排版。但是,當我在 close 附近使用大量浮動時wrapfig,所有文字的一部分將不會靠近包裹的圖形。此外,該數字與其他數字並不一致。我該如何解決這個問題?

在此輸入影像描述

我的MWE

\documentclass[a4paper,12pt]{article}

\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{wrapfig}
\usepackage{blindtext}
\usepackage[showframe]{geometry}
\usepackage{ragged2e}


\begin{document}

    \newcommand{\commonfigwidth}{0.35\linewidth}

    \begin{figure}
        \centering
        \includegraphics[width=\commonfigwidth]{example-image-a}
        \caption{My Fig}
    \end{figure}


    \begin{figure}
        \centering
        \includegraphics[width=\commonfigwidth]{example-image-b}
        \caption{My Fig}
    \end{figure}

    \begin{figure}
        \centering
        \includegraphics[width=\commonfigwidth]{example-image-c}
        \caption{My Fig}
    \end{figure}

    \begin{wrapfigure}{O}{\commonfigwidth} 
        \includegraphics[width=\linewidth]{example-image-a}
        \centering This is a circuit
    \end{wrapfigure}
    \blindtext

    \begin{figure}
        \centering
        \includegraphics[width=\commonfigwidth]{example-image-b}
        \caption{My Fig}
    \end{figure}

    \begin{figure}
        \centering
        \includegraphics[width=\commonfigwidth]{example-image-c}
        \caption{My Fig}
    \end{figure}

\end{document}

答案1

wrapfigure與通常的浮動機制沒有聯繫,所以如果您同時使用兩者,您需要管理出現的任何問題,在這裡我認為如果您阻止下一頁上的剪切,您會得到可接受的輸出,通過

    \begin{wrapfigure}[8]{O}{\commonfigwidth} 
    \includegraphics[width=\linewidth]{example-image-a}
    \centering This is a circuit
    \end{wrapfigure}

因此將其限制為 8 行(而不是預設使用的 10 行)

在此輸入影像描述

答案2

在此輸入影像描述

LaTeX 不會將其視為wrapfigure浮點數,除非它是在figure環境中編寫的。內部figure或環境中存在的所有內容table必須立即顯示在 LaTeX 選擇的任何頁面上。因此,一個好的解決方法是

\begin{figure}

    \begin{wrapfigure}{<other wrapfig arguments>} 
        \includegraphics[width=\linewidth]{<image file name>}
    \end{wrapfigure}

  <the text that should wrap the figure>

\end{figure}

這樣,即使周圍的材料有很多浮動,應該位於包裹圖形附近的段落也將被迫保留在那裡。另外,LaTeX 會按照它們在原始碼中出現的順序放置所有浮動,因此這也解決了提到的順序問題。

\documentclass[a4paper,12pt]{article}

\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{wrapfig}
\usepackage{blindtext}
\usepackage[showframe]{geometry}
\usepackage{ragged2e}


\begin{document}

    \newcommand{\commonfigwidth}{0.35\linewidth}

    \begin{figure}
        \centering
        \includegraphics[width=\commonfigwidth]{example-image-a}
        \caption{My Fig}
    \end{figure}


    \begin{figure}
        \centering
        \includegraphics[width=\commonfigwidth]{example-image-b}
        \caption{My Fig}
    \end{figure}

    \begin{figure}
        \centering
        \includegraphics[width=\commonfigwidth]{example-image-c}
        \caption{My Fig}
    \end{figure}

    \begin{figure}

        \begin{wrapfigure}{O}{\commonfigwidth} 
            \includegraphics[width=\linewidth]{example-image-a}
            \centering This is a circuit
        \end{wrapfigure}

    \blindtext

    \end{figure}

    \begin{figure}
        \centering
        \includegraphics[width=\commonfigwidth]{example-image-b}
        \caption{My Fig}
    \end{figure}

    \begin{figure}
        \centering
        \includegraphics[width=\commonfigwidth]{example-image-c}
        \caption{My Fig}
    \end{figure}

\end{document}

相關內容