绘制简单的尖锐注释到数字部分

绘制简单的尖锐注释到数字部分

我想在 latex 上绘制下图,而无需深入研究许多低级 tikz 命令和细节。这些类型的图表有特定的名称吗?这个对我来说,这个例子看起来很棒,但它只显示了 y 轴上的一个组件。代码也很容易修改。那么你能给我推荐其他例子来处理这种图表吗?谢谢

在此处输入图片描述

答案1

我可以建议使用tikzmark这个非常出色且用途广泛的库吗?(至少需要编译两次)

指向数字部分的注释

\documentclass[12pt]{article}
\usepackage{tikz}
\usetikzlibrary{tikzmark,arrows.meta}

\tikzset{every tikzmarknode/.append style={inner xsep=1pt,inner ysep=3pt}}

\begin{document}
    \sffamily
    {\Huge \textbf{\tikzmarknode{a}{P}\,\tikzmarknode{b}{0}\,\tikzmarknode{c}{2}\,\tikzmarknode{d}{3 7}}}
    
    \begin{tikzpicture}[overlay,remember picture,>=Stealth,line width=1.5pt,blue]
        \foreach \i in {a,b,c,d}
            \draw[blue] (\i.west) -- (\i.south west) -| (\i.east);
        
        \newcommand{\esp}{20pt}
            
        \draw[->] (a.south) |- ++ (5,-3) coordinate (P) node [right,black] {Position of P};
        \draw[->] (b.south) |- ([yshift=\esp]P) node [right,black] {Position of 0};
        \draw[->] (c.south) |- ([yshift=2*\esp]P) node [right,black] {Position of 2};
        \draw[->] (d.south) |- ([yshift=3*\esp]P) node [right,black] {Position of 37};
    \end{tikzpicture}           
\end{document}

编辑

由于所需的图片应插入到图形中,因此将所有内容创建到 中会是一个更好的解决方案tikzpicture。以下是代码(我没有插入图形和标题,以便您使用自己的参数进行操作):

\documentclass[12pt]{article}
\usepackage{tikz}
\usepackage{blindtext}
\usetikzlibrary{chains,arrows.meta}

\begin{document}
    
    \blindtext
    
    \begin{tikzpicture}[
        start chain=going right,
        node distance=1mm,
        every node/.style={
            inner xsep=1pt,
            inner ysep=3pt},
            font={\sffamily \bfseries \Huge}]

        \node[on chain] (a) {P};
        \node[on chain] (b) {0};
        \node[on chain] (c) {2};
        \node[on chain] (d) {3\,7};

        \begin{scope}[blue,line width=1.5pt,>=Stealth,every node/.style={font= \normalsize}]
            \foreach \i in {a,b,c,d}
                \draw[blue] (\i.west) -- (\i.south west) -| (\i.east);
            
            \newcommand{\esp}{20pt}
                
            \draw[->] (a.south) |- ++ (5,-3) coordinate (P) node [right,black] {Position of P};
            \draw[->] (b.south) |- ([yshift=\esp]P) node [right,black] {Position of 0};
            \draw[->] (c.south) |- ([yshift=2*\esp]P) node [right,black] {Position of 2};
            \draw[->] (d.south) |- ([yshift=3*\esp]P) node [right,black] {Position of 37};
        \end{scope}
    \end{tikzpicture}
    
    \blindtext  
    
\end{document}

导致:

在此处输入图片描述

相关内容