我正在尝试使用 wrapfigure 和 tikz 将交换图的插图插入我的 tex。第一个交换图(在 wrapfigure 环境中)按应有的方式显示,但第二个交换图(在其自己的 wrapfigure 内)在后面的段落中显示得比应有的位置低得多。这是一个最小工作示例:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix,arrows}
\usepackage{wrapfig}
\begin{document}
%+Title
\title{Article Title}
\author{Author}
\date{\today}
\maketitle
%-Title
%+Abstract
\begin{abstract}
test
\end{abstract}
%-Abstract
\section{test}
\begin{wrapfigure}[5]{r}{0.3\textwidth}
\vspace{-18pt}
\hspace{-0pt}
\begin{tikzpicture}[description/.style={fill=white,inner sep=0pt}]
\matrix (m) [matrix of math nodes, row sep=3em,
column sep=2.5em, text height=1.5ex, text depth=0.25ex]
{ M & & N \\
& D & \\ };
%\draw[double,double distance=5pt] (m-1-1) – (m-1-3);
\path[<->]
(m-1-1) edge node[description] {$ f $} (m-1-3)
edge node[description] {$ \Phi $} (m-2-2)
(m-1-3) edge node[description] {$ \Psi $} (m-2-2);
\end{tikzpicture}
\end{wrapfigure}
one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one\\
\begin{wrapfigure}[5]{r}{0.3\textwidth}
\vspace{-18pt}
\hspace{-0pt}
\begin{tikzpicture}[description/.style={fill=white,inner sep=0pt}]
\matrix (m) [matrix of math nodes, row sep=3em,
column sep=2.5em, text height=1.5ex, text depth=0.25ex]
{ M & & N \\
& D & \\ };
%\draw[double,double distance=5pt] (m-1-1) – (m-1-3);
\path[<->]
(m-1-1) edge node[description] {$ f $} (m-1-3)
edge node[description] {$ \Phi $} (m-2-2)
(m-1-3) edge node[description] {$ \Psi $} (m-2-2);
\end{tikzpicture}
\end{wrapfigure}two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two
\end{document}
第二张图出现在“二”部分的下方,而不是我想要的右侧。我做错了什么?
`
答案1
您需要\par
在第二个wrapfigure
环境之前放置一个空白行或一个命令,以便开始一个新段落。
环境wrapfigure
运行于段落文本;没有空行(或\par
命令),wrapfig
假定您仍在文本的第一段中。
以下是完整的代码
% arara: pdflatex
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix,arrows}
\usepackage{wrapfig}
\begin{document}
%+Title
\title{Article Title}
\author{Author}
\date{\today}
\maketitle
%-Title
%+Abstract
\begin{abstract}
test
\end{abstract}
%-Abstract
\section{test}
\begin{wrapfigure}[5]{r}{0.3\textwidth}
\vspace{-18pt}
\hspace{-0pt}
\begin{tikzpicture}[description/.style={fill=white,inner sep=0pt}]
\matrix (m) [matrix of math nodes, row sep=3em,
column sep=2.5em, text height=1.5ex, text depth=0.25ex]
{ M & & N \\
& D & \\ };
%\draw[double,double distance=5pt] (m-1-1) – (m-1-3);
\path[<->]
(m-1-1) edge node[description] {$ f $} (m-1-3)
edge node[description] {$ \Phi $} (m-2-2)
(m-1-3) edge node[description] {$ \Psi $} (m-2-2);
\end{tikzpicture}
\end{wrapfigure}
one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one one\\
\begin{wrapfigure}[5]{r}{0.3\textwidth}
\vspace{-18pt}
\hspace{-0pt}
\begin{tikzpicture}[description/.style={fill=white,inner sep=0pt}]
\matrix (m) [matrix of math nodes, row sep=3em,
column sep=2.5em, text height=1.5ex, text depth=0.25ex]
{ M & & N \\
& D & \\ };
%\draw[double,double distance=5pt] (m-1-1) – (m-1-3);
\path[<->]
(m-1-1) edge node[description] {$ f $} (m-1-3)
edge node[description] {$ \Phi $} (m-2-2)
(m-1-3) edge node[description] {$ \Psi $} (m-2-2);
\end{tikzpicture}
\end{wrapfigure}two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two two
\end{document}