文本标记和解释的环境

文本标记和解释的环境

我正在寻找一个允许我标记如下文本的 tex 环境:在此处输入图片描述 由于“标签”一词已被占用,我不知道如何通过 Google 寻找解决方案。有人有想法吗?也许有 tikz 解决方案?

答案1

可以为此定义一个简单的宏

\documentclass{article}
\usepackage{lipsum}
\usepackage{tikz}
\usetikzlibrary{calc,positioning}
\newcommand{\yourcmd}[3]{%
    \begin{center}
    \begin{tikzpicture}
        \node[inner xsep=0pt,inner ysep=1pt,red] (a) {#1};
        \draw[red] (a.south west)--(a.south east);
        \coordinate (a1) at (a.south);
        \node[inner xsep=0pt,right=0pt of a] (b) {#2};
        \node[inner xsep=0pt,inner ysep=1pt,right=0pt of b,green!50!black] (c) {#3};
        \draw[green!50!black] (c.south west)--(c.south east);
        \coordinate (c1) at (c.south);
        \draw[red] ($(a1)+(-110:0.1)$)--($(a1)+(-110:1)$) node[fill=white,font=\tiny\sffamily,inner sep=2pt] {Some text};
        \draw[green!50!black] ($(c1)+(-70:0.1)$)--($(c1)+(-70:1)$) node[fill=white,font=\tiny\sffamily,inner sep=2pt] {Hello world};
    \end{tikzpicture}
    \end{center}
}
\begin{document}
\lipsum[1]

\yourcmd{12}{34567}{8910}

\lipsum[2]
\end{document}

在此处输入图片描述

相关内容