为什么“wrapfig”会缩短其后每个段落的第一行?

为什么“wrapfig”会缩短其后每个段落的第一行?

我正在尝试在此段落的右侧输入 tikz 图片。但环境wrapfig结束后,它似乎仍然会裁剪其后每个段落的前三行,我似乎无法修复它。

\documentclass[12pt]{article}

\usepackage[a4paper]{geometry}
\geometry{total={170mm,257mm},
 left=20mm,
 top=20mm}
\renewcommand{\baselinestretch}{1.25}
\setlength{\parindent}{0em}
\setlength{\parskip}{0.8em}
\usepackage{amsmath}
\usepackage{wrapfig}
\usepackage{pgfplots}

% axis style
\pgfplotsset{
    every axis/.append style={
            axis x line=middle,
            axis y line=middle,
            xlabel={$x$},
            ylabel={$y$},
            axis line style={->},
        },
    grid style={dotted,gray},
}

% arrow style
\tikzset{>=stealth}

\pgfplotsset{width=5cm,compat=1.18}

\usepackage{lipsum}

\begin{document}

\begin{wrapfigure}[3]{r}{3.8cm}
\begin{tikzpicture}
    \begin{axis}[
            grid=both,
            %axis equal,
            xmin=-2,xmax=4,
            ymin=-2,ymax=8.5,
            yticklabels={,,},
            xticklabels={,,}
        ]
        \addplot[blue,thick,domain=-2:4,samples=50]({x},{x^3});
        \draw [red, dashed](axis cs: 1,1) -- (axis cs: 2,8) node [pos=0.5,anchor=south east]{$\Delta s$};
        \draw [red, dashed](axis cs: 1,1) -- (axis cs: 2,1) node [pos=0.5,anchor=north]{$\Delta x$};
        \draw [red, dashed](axis cs: 2,1) -- (axis cs: 2,8) node [pos=0.5,anchor=west]{$\Delta y$};
    \end{axis}
\end{tikzpicture}
\end{wrapfigure}

\section*{Buelengde av par. kurver}
Vi har at \( (ds)^2 = (dx)^2 + (dy)^2 \), som gir at
\(ds = \sqrt{(dx)^2 + (dy)^2} dt \).\\
Dermed blir
\begin{align*}
    s &= \int_a^b ds = \int_a^b \sqrt{(dx)^2 + (dy)^2} dt\\
    &= \int_a^b \sqrt{ (f'(t))^2 + (g'(t))^2 } dt
\end{align*}
\lipsum[1-3]

\end{document}

答案1

您不能在组中开始或结束 wrapfig,并且在这里您结束于为标题设置的组中。

由于标题较短,您可以先进入标题,然后将情节稍微上移以进行补偿。

在此处输入图片描述

\documentclass[12pt]{article}

\usepackage[a4paper]{geometry}
\geometry{total={170mm,257mm},
 left=20mm,
 top=20mm}
\renewcommand{\baselinestretch}{1.25}
\setlength{\parindent}{0em}
\setlength{\parskip}{0.8em}
\usepackage{amsmath}
\usepackage{wrapfig}
\usepackage{pgfplots}

% axis style
\pgfplotsset{
    every axis/.append style={
            axis x line=middle,
            axis y line=middle,
            xlabel={$x$},
            ylabel={$y$},
            axis line style={->},
        },
    grid style={dotted,gray},
}

% arrow style
\tikzset{>=stealth}

\pgfplotsset{width=5cm,compat=1.18}

\usepackage{lipsum}

\begin{document}

\section*{Buelengde av par. kurver}

\begin{wrapfigure}[3]{r}{3.8cm}
\vspace{-2\baselineskip}
\begin{tikzpicture}
    \begin{axis}[
            grid=both,
            %axis equal,
            xmin=-2,xmax=4,
            ymin=-2,ymax=8.5,
            yticklabels={,,},
            xticklabels={,,}
        ]
        \addplot[blue,thick,domain=-2:4,samples=50]({x},{x^3});
        \draw [red, dashed](axis cs: 1,1) -- (axis cs: 2,8) node [pos=0.5,anchor=south east]{$\Delta s$};
        \draw [red, dashed](axis cs: 1,1) -- (axis cs: 2,1) node [pos=0.5,anchor=north]{$\Delta x$};
        \draw [red, dashed](axis cs: 2,1) -- (axis cs: 2,8) node [pos=0.5,anchor=west]{$\Delta y$};
    \end{axis}
\end{tikzpicture}
\end{wrapfigure}


Vi har at \( (ds)^2 = (dx)^2 + (dy)^2 \), som gir at
\(ds = \sqrt{(dx)^2 + (dy)^2} dt \).\\
Dermed blir
\begin{align*}
    s &= \int_a^b ds = \int_a^b \sqrt{(dx)^2 + (dy)^2} dt\\
    &= \int_a^b \sqrt{ (f'(t))^2 + (g'(t))^2 } dt
\end{align*}
\lipsum[1-3]

\end{document}

相关内容