「wrapfigure」とその段落が一緒に表示されないのはなぜですか?

「wrapfigure」とその段落が一緒に表示されないのはなぜですか?

wrapfigは通常、それを囲む特定のテキストと並べてタイプセットする目的で使用されます。ただし、 の近くに多くのフロートを使用すると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内に書かれていない限り、フロートとして認識しません。環境内に存在するものはすべて、LaTeXが選択したどのページにも一度に表示される必要があります。したがって、良い回避策はfigurefiguretable

\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}

関連情報