两个带有 tikz 图片和文本的并排迷你页面

两个带有 tikz 图片和文本的并排迷你页面

我正在尝试实现附图中的相同效果。以下是我的尝试在此处输入图片描述

\documentclass[conference]{IEEEtran}
\usepackage[demo]{graphicx}
\usepackage{tikz,pgfplots,pgfplotstable}
\usepackage{xparse}

\NewDocumentCommand\DownArrow{O{2.0ex} O{black}}{%
\mathrel{\tikz[baseline] \draw [<-, line width=0.5pt, #2] (0,0) -- ++(0,#1);}
}
\begin{document}

\begin{enumerate}
\item This is the fist point

\begin{minipage}{.2\textwidth}
    \begin{itemize}
        \item Component 1
        \item Component 2
        \item Component 3
        \item Component 4
    \end{itemize}
\end{minipage}
\begin{minipage}{.2\textwidth}
    $\DownArrow[60pt][>=latex,red, ultra thick] minimum weight$
\end{minipage}

\item This is the second point. 

\end{enumerate}

\end{document}

要获得向下箭头,请使用以下链接中提供的代码 如何拉长向下的箭头?

给定的图片将成为列表的一部分,如代码所示(枚举)。

答案1

我会采用不同的方法,使用tikzmark和 pgf 键。这样您可以随意添加选项,而无需更改语法。您只需将项目设为\tikzmarknodes,然后使用\DownArrowMWE 中所示的:

\documentclass[conference]{IEEEtran}
\usepackage[demo]{graphicx}
\usepackage{tikz}
\usetikzlibrary{tikzmark,fit,positioning}
\tikzset{DownArrow/.cd,x sep/.initial=1em,arrow/.style={-latex,red, ultra
thick},label sep/.initial=0em and 0.5em,label/.style={}}
\newcommand{\DownArrow}[5][]{%
\begin{tikzpicture}[overlay,remember picture,DownArrow/.cd,#1]
\def\pv##1{\pgfkeysvalueof{/tikz/DownArrow/##1}}
\node[fit=(#2)(#3),inner sep=0pt] (Faux){};
\draw[/tikz/DownArrow/arrow] ([xshift=\pv{x sep}]Faux.north east) 
node[below right=\pv{label sep},/tikz/DownArrow/label] {#4}
 -- ([xshift=\pv{x sep}]Faux.south east) 
 node[above right=\pv{label sep},/tikz/DownArrow/label] {#5};
\end{tikzpicture}}
\begin{document}

\begin{enumerate}
\item This is the fist point

 \begin{itemize}
        \item \tikzmarknode{1}{Component 1}
        \item Component 2
        \item Component 3
        \item \tikzmarknode{4}{Component 4}%
        \DownArrow[label/.style={text=blue}]{1}{4}{First}{Last}
 \end{itemize}




\item This is the second point. 

 \begin{itemize}
        \item \tikzmarknode{1'}{Component 1}
        \item Component 2
        \item Component 3
        \item \tikzmarknode{4'}{Component 4}%
        \DownArrow[x sep=2em,arrow/.style={-stealth,very thick,blue}]{1'}{4'}{First}{Last}
 \end{itemize}

\end{enumerate}

\end{document}

在此处输入图片描述

相关内容