我正在尝试将 tikzpicture 图表与问题并列,如下图所示:
但是,如图所示,wrapfig 与段落的第一行对齐不太好。有没有办法将图表向上移动?我尝试使用 \vspace{-1em},但无济于事。
以下是相应的乳胶代码:
\begin{wrapfigure}{R}{0pt}
\centering
%\vspace{-1em} (doesn't really do anything)
\begin{tikzpicture}
\draw (4,2) arc (60:180:2);
\draw (4,2) arc (300:180:2);
\draw (3,0.2679491924311226) arc (0:120:2);
\draw (3,0.2679491924311226) arc (240:120:2);
\draw (1,3.7320508075688785) arc (60:-60:2);
\draw (3,3.7320508075688785) arc (360:240:2);
\draw (0,3.7320508075688785)-- (4,3.7320508075688785);
\draw (4,3.7320508075688785)-- (4,0.2679491924311228);
\draw (4,0.2679491924311228)-- (0,0.2679491924311226);
\draw (0,0.2679491924311226)-- (0,3.732050807568877);
\begin{scriptsize}
\draw (1,2) node {$A$};
\draw (1.5,2.9) node {$B$};
\draw (2.5,2.9) node {$C$};
\draw (3,2) node {$D$};
\draw (2.5,1.2) node {$E$};
\draw (1.5,1.2) node {$F$};
\draw (-0.2,3.9) node {$P$};
\draw (4.2,3.9) node {$Q$};
\draw (4.2,0.1) node {$R$};
\draw (-0.2,0.1) node {$S$};
\end{scriptsize}
\end{tikzpicture}
\end{wrapfigure}
\begin{problem}
Consider the following diagram, where six petaled rosette (labelled with $A$ to $F$) is formed using unit circles enclosed by the rectangle $PQRS$.\\
Determine
\begin{equation*}
x=\frac{|A|+|B|+|C|+|D|+|E|+|F|}{|PQRS|}.
\end{equation*}
\end{problem}
“问题”环境定义如下:
\newcounter{problem}[section]
\newenvironment{problem}[1][]{\refstepcounter{problem}\par\medskip
\noindent \textbf{\textcolor{blue}{Problem~\theproblem}\space #1 \rmfamily}}{\medskip}
我使用了包 warpfig 和 tikz 来实现原始布局。
将不胜感激任何帮助-谢谢!
答案1
看看下面是不是你所追求的:
\documentclass[twocolumn, demo]{article}
\usepackage{newtxtext}
\usepackage{microtype}
\usepackage{wrapfig}
\usepackage{tikz}
\usepackage{lipsum}
\begin{document}
\lipsum[1]
\begin{wrapfigure}[12]{R}{50mm} % <--- manual centering of this wrapfigure
\centering
\small
\vspace{-0.6\baselineskip}
\begin{tikzpicture}[
every label/.style = {inner sep=1pt}
]
\node (s) [draw, minimum size=40mm, inner sep=0pt,
label= 45:$Q$,
label=135:$P$,
label=225:$S$,
label=315:$R$] {};
\foreach \i/\j in {0/4,60/5,120/5,180/4,240/5,300/5}
{
\pgfmathsetmacro{\m}{sqrt(\j)}
\draw[rotate around={\i:(0,0)}]
(0,0) arc (120:60:\m) arc (-60:-120:\m);
}
\foreach \i/\j in {0/D,60/C,120/B,180/A,240/E,300/D}
\path (\i:1) node {$\j$};
\end{tikzpicture}
\end{wrapfigure}
\lipsum[2-6]
\end{document}
注意:您没有提供 MWE(最小工作示例,它可以重现您的问题,因此上述建议使用lipsum
包生成的虚拟文本。