我知道这个问题以前已经被问过,但我找不到合适的答案,所以请耐心等待。
我想使用wrapfigure
环境将图形放入文档中。它应该位于文档左侧,宽度为 = 0.25\textwidth
。我已在环境flushleft
中使用环境wrapfigure
来保持所有内容正确格式化。这在文档的某些部分运行良好,但在其他部分,图形最终位于页面中间,正文位于其上方。
我注意到这种情况发生在长文本块附近。如果我有一个应该位于长正文块左侧的图形,那么它就会混乱。但是,如果我将文本分成几个小段落,并wrapfigure
在它们之间放置环境,它就可以正常工作。问题是我不想让我的段落在奇怪的地方被分割以容纳我的图形。一定有更好的方法来格式化它。提前感谢您的帮助!
注意:我认为问题区域没有分页符。我发现这是一个人的问题,所以我认为我应该提前指出这一点。除了正文外,只有sections
显示方程式的分页符。当然,我不是排版专家,所以我可能是错的。
[编辑]:这是我的 MWE。我意识到它并不是最小的,但它是在不让问题消失的情况下我能做的最好的事情。
\documentclass[]{amsart}
\usepackage{amsmath,amssymb}
\usepackage{tikz}
\usepgflibrary{shapes}
\usepackage{wrapfig}
\usepackage{caption}
\usepackage{lipsum}
\begin{document}
\captionsetup{justification=raggedright,singlelinecheck=false}
\pgfmathsetmacro{\ex}{0}
\pgfmathsetmacro{\ey}{0}
\newcommand{\figureone}[1]{
\begin{tikzpicture}[#1]
\draw [fill = lightgray] (0,0) circle [radius = 1.25 cm];
\draw (0,0) -- (0.8838834765,0.8838834765);
\node [above left] at (0.5,0.5) {$r$};
\node [above left] at (-1.0,0.575) {$C$};
\draw [->] (\ex,\ey) ++(135:1.5cm) arc (135:85:1.5cm);
\draw [->] (\ex,\ey) ++(160:1.5cm) arc (160:210:1.5cm);
\end{tikzpicture}
}
\newcommand{\figuretwo}[1]{
\begin{tikzpicture}[#1]
\draw [fill = lightgray] rectangle (2,2);
\node [right, rotate=90] at (2.35,0.4) {1 unit};
\node [below] at (1,-0.1) {1 unit};
\node [above] at (1,1) {$A = 1$};
\node [below] at (1,1) {$\textrm{unit}^2$};
\draw [<-] (0,-0.375) -- (0.35,-0.375);
\draw [->] (1.65,-0.375) -- (2,-0.375);
\draw (0,-0.15) -- (0,-0.6);
\draw (2,-0.15) -- (2,-0.6);
\draw [<-](2.375,0) -- (2.375,0.35);
\draw [->](2.375,1.65) -- (2.375,2);
\draw (2.15,0) -- (2.6,0);
\draw (2.15,2) -- (2.6,2);
\end{tikzpicture}
}
\begin{wrapfigure}{l}{0.25\textwidth}
\begin{flushleft}
\figureone{}
\end{flushleft}
\caption{Caption}
\end{wrapfigure}
\noindent
Filler text: here is some filler text. In my document this is 7 lines long, including one displayed equation. The first figure should be positioned directly to the right of this text.
\section*{Section 1}
\begin{wrapfigure}{l}{0.25\textwidth}
\begin{flushleft}
\figuretwo{}
\end{flushleft}
\caption{Caption}
\end{wrapfigure}
\lipsum[1]
\section*{Section 2}
\lipsum[2-3]
\end{document}
答案1
您需要有足够的文本来围绕您的图片。当我在这里添加一些虚拟文本时,效果很好。
如果文本不够,您可以使用multicolumn
环境,或者将其放在tabbing
简单的中tabular
。这将使其灵活性降低但完全可控。
% arara: pdflatex
\documentclass{amsart}
\usepackage{tikz}
\usepackage{wrapfig}
\usepackage{caption}
\captionsetup{justification=raggedright,singlelinecheck=false}
\usepackage{lipsum}
\pgfmathsetmacro{\ex}{0}
\pgfmathsetmacro{\ey}{0}
\newcommand{\figureone}[1]{
\begin{tikzpicture}[#1]
\draw [fill = lightgray] (0,0) circle [radius = 1.25 cm];
\draw (0,0) -- (0.8838834765,0.8838834765);
\node [above left] at (0.5,0.5) {$r$};
\node [above left] at (-1.0,0.575) {$C$};
\draw [->] (\ex,\ey) ++(135:1.5cm) arc (135:85:1.5cm);
\draw [->] (\ex,\ey) ++(160:1.5cm) arc (160:210:1.5cm);
\end{tikzpicture}
}
\newcommand{\figuretwo}[1]{%
\begin{tikzpicture}[#1]
\draw [fill = lightgray] rectangle (2,2);
\node [right, rotate=90] at (2.35,0.4) {1 unit};
\node [below] at (1,-0.1) {1 unit};
\node [above] at (1,1) {$A = 1$};
\node [below] at (1,1) {$\textrm{unit}^2$};
\draw [<-] (0,-0.375) -- (0.35,-0.375);
\draw [->] (1.65,-0.375) -- (2,-0.375);
\draw (0,-0.15) -- (0,-0.6);
\draw (2,-0.15) -- (2,-0.6);
\draw [<-](2.375,0) -- (2.375,0.35);
\draw [->](2.375,1.65) -- (2.375,2);
\draw (2.15,0) -- (2.6,0);
\draw (2.15,2) -- (2.6,2);
\end{tikzpicture}
}
\begin{document}
\begin{wrapfigure}{l}{0.25\textwidth}
\figureone{}
\caption{Caption}
\end{wrapfigure}
\noindent
Filler text: here is some filler text. In my document this is 7 lines long, including one displayed equation. The first figure should be positioned directly to the right of this text.
\section*{Section 1}
\begin{wrapfigure}{l}{0.25\textwidth}
\figuretwo{}
\caption{Caption}
\end{wrapfigure}
\lipsum[1-3]
\section*{Section 2}
\lipsum[2-3]
\end{document}