我的论文的独立摘录:
\documentclass{article}
\usepackage{amsmath, tikz, wrapfig, array}
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\usetikzlibrary{decorations.pathreplacing}
\setlength{\tabcolsep}{2pt}
\begin{document}
\section{Answer}
% wrapfiure start
\begin{wrapfigure}{l}{4.4cm}
\begin{tikzpicture}
\draw (-2, 0) -- (2, 0) (1, 0) -- (1, 2) coordinate (a) (-1, 0) -- (-1, 3) coordinate (b);
\draw[fill=black] (1, 2) circle (2pt) (-1, 3) circle (2pt);
\draw[decorate, decoration={brace, mirror, amplitude=5pt, raise=5pt}] (1, 0) -- (a) node[midway, xshift=.8cm] {\footnotesize 100 m};
\draw[decorate, decoration={brace, amplitude=5pt, raise=5pt}] (-1, 0) -- (b) node[midway, xshift=-.8cm] {\footnotesize 150 m};
\end{tikzpicture}
\end{wrapfigure}
% wrapfiure end
\begin{align*}
\text{Initial difference in heights} & = 150\ \mathrm{m} - 100\ \mathrm{m} \\
& = 50\ \mathrm{m}
\end{align*}
Distance travelled by the body in 2 seconds:
\begin{align*}
h_1 & = ut + \frac{1}{2}gt^2 \\
& = 0 + \frac{1}{2}g(2)^2 \\
h_1 & = 2g
\end{align*}
After 2 seconds, height at which the first body will be $H_1 = 150 - 2g$.\\
Similarly, $h_2 = 2g$ and $H_2 = 100 - 2g$\\\\
\begin{tabular}{ll}
& After 2 seconds, difference in height \\
= & $H_1 - H_2$ \\
= & (150 - 2g) - (100 - 2g) \\
= & 150 - 2g - 100 + 2g \\
= & 50
\end{tabular}\\\\
This difference in heights doesn't vary with time.
\end{document}
好像wrapfigure
还没有完成工作。如何让它完成工作?
答案1
\InsertBoxL
我会使用纯 TeX 宏包中的命令;以及稍微不同的代码来执行此操作insbox
。此外,我将显示样式中的分数系数替换为中型分数nccmath
,在我看来,这样看起来更好。
\documentclass{article}
\usepackage{amsmath, tikz, wrapfig, array, calc}
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\usetikzlibrary{decorations.pathreplacing}
\usepackage{nccmath}
\input{insbox}
\begin{document}
\section{Answer}
\InsertBoxL{0}{\begin{tikzpicture}
\draw (-2, 0) -- (2, 0);
\draw (1, 0) -- (1, 2) coordinate (a);
\draw (-1, 0) -- (-1, 3) coordinate (b);
\draw[fill=black] (1, 2) circle (2pt);
\draw[fill=black] (-1, 3) circle (2pt);
\draw[decorate, decoration={brace, mirror, amplitude=5pt, raise=5pt}] (1, 0) -- (a) node[midway, xshift=.8cm] {\footnotesize 100 m};
\draw[decorate, decoration={brace, amplitude=5pt, raise=5pt}] (-1, 0) -- (b) node[midway, xshift=-.8cm] {\footnotesize 150 m};
\end{tikzpicture}}[-4]
\noindent Initial difference in heights
$ \begin{aligned}[t]
& = 150\,\mathrm{m} - 100\,\mathrm{m} \\
& = 50\,\mathrm{m}
\end{aligned} $ \medskip\\
Distance travelled by the body in 2 seconds:
\begin{align*}
h_1 & = ut + \mfrac{1}{2}gt^2 \\
& = 0 + \mfrac{1}{2}g(2)^2 \\
h_1 & = 2g
\end{align*}
After 2 seconds, height at which the first body will be $H_1 = 150 - 2g$.\\
Similarly, $h_2 = 2g$ and $H_2 = 100 - 2g$\\\\
\addtolength{\tabcolsep}{-4pt}
\begin{tabular}{L{\widthof{=}}l}
& After 2 seconds, difference in height \\
= & $H_1 - H_2$ \\
= & (150 - 2g) - (100 - 2g) \\
= & 150 - 2g - 100 + 2g \\
= & 50
\end{tabular}\\\\
\addtolength{\tabcolsep}{4pt}
This difference in heights doesn't vary with time.
\end{document}
答案2
可以wrapfigure
完美使用 。问题是您在一个段落中处理了很多内容,并且align
在某些情况下,在一个段落中使用两个 可能会导致问题。相反,请使用空白行创建段落:
\section{Answer}
% wrapfiure start
\begin{wrapfigure}[7]{l}{4.7cm}
\begin{tikzpicture}
\draw (-2, 0) -- (2, 0) (1, 0) -- (1, 2) coordinate (a) (-1, 0) -- (-1, 3) coordinate (b);
\draw[fill=black] (1, 2) circle (2pt) (-1, 3) circle (2pt);
\draw[decorate, decoration={brace, mirror, amplitude=5pt, raise=5pt}] (1, 0) -- (a) node[midway, xshift=.8cm] {\footnotesize 100 m};
\draw[decorate, decoration={brace, amplitude=5pt, raise=5pt}] (-1, 0) -- (b) node[midway, xshift=-.8cm] {\footnotesize 150 m};
\end{tikzpicture}
\end{wrapfigure}
% wrapfiure end
\leavevmode
\begin{align*}
\text{Initial difference in heights} & = 150\ \mathrm{m} - 100\ \mathrm{m} \\
& = 50\ \mathrm{m}
\end{align*}
Distance travelled by the body in 2 seconds:
\begin{align*}
h_1 & = ut + \frac{1}{2}gt^2 \\
& = 0 + \frac{1}{2}g(2)^2 \\
h_1 & = 2g
\end{align*}
After 2 seconds, height at which the first body will be $H_1 = 150 - 2g$.
Similarly, $h_2 = 2g$ and $H_2 = 100 - 2g$.
\begin{tabular}{ll}
& After 2 seconds, difference in height \\
= & $H_1 - H_2$ \\
= & (150 - 2g) - (100 - 2g) \\
= & 150 - 2g - 100 + 2g \\
= & 50
\end{tabular}
This difference in heights doesn't vary with time.
您应该始终尝试避免在普通文本中使用强制换行符。如果您因为不喜欢自动缩进而不得不使用强制换行符,请添加\usepackage{parskip}
。这将在段落之间留出间距,而不是缩进新段落。
此外,wrapfigure
有时会对您的身材高度做出错误猜测。您可以看到,[7]
您的身材高度以“线条”的数量来定义,这通过使用数学方法而略有扭曲。
此外,\leavevmode
是必需的,因为align
前面应该始终有文本。插入\leavevmode
就像您插入了没有任何高度的文本一样。但是您仍然会看到等式前面有一些空白。同样,您应该始终在等式前面添加文本。
与其他答案相反,wrapfigure 的想法是您可以使用\caption
等。那边不行。