我想得到下面的图片,但避免手动尝试定位线条的错误。在使用 TikZ 之前,我尝试使用 LaTeX 下支撑和上支撑,但没有成功,因为:1. 我的下支撑和上支撑具有“相交范围”,2. 我不想要“支撑”形状,而是想要当前图片中使用的形状。
\documentclass{book}
\usepackage{tikz}
\newcommand{\reg}[1]{\textnormal{`}#1\textnormal{'}}
\begin{document}
\begin{tikzpicture}
\node[anchor=west] {$\reg{>><}$};
\draw[rounded corners=1pt] (0.27,-0.1) -- (0.27,-0.2) -- (0.82,-0.2) -- (0.82,-0.1);
\draw[rounded corners=1pt] (0.9,-0.1) -- (0.9,-0.2) -- (1.2,-0.2) -- (1.2,-0.1);
\draw[rounded corners=1pt] (0.58,0.08) -- (0.58,0.18) -- (1.2,0.18) -- (1.2,0.08);
\end{tikzpicture}
\end{document}
答案1
由于这是 Ti钾Z 问题,我提供一个 Ti钾Z 答案,即不要玩之\rlap
类的。tikzmark
那么,我会用这个。
\documentclass{book}
\usepackage{tikz}
\usetikzlibrary{tikzmark}
\newcommand{\reg}[1]{\textnormal{`}#1\textnormal{'}}
\begin{document}
$\reg{\tikzmarknode{n1}{>}\tikzmarknode{n2}{>}\tikzmarknode{n3}{<}}$
\begin{tikzpicture}[overlay,remember picture]
\draw[rounded corners=1pt] ([yshift=-0.5pt,xshift=0.85pt]n1.south west)
-- ++ (0,-0.1) -| ([yshift=-0.5pt,xshift=-0.85pt]n2.south east);
\draw[rounded corners=1pt] ([yshift=-0.5pt,xshift=0.85pt]n3.south west)
-- ++ (0,-0.1) -| ([yshift=-0.5pt,xshift=-0.85pt]n3.south east);
\draw[rounded corners=1pt] ([yshift=0.5pt,xshift=0.85pt]n2.north west)
-- ++ (0,0.1) -| ([yshift=0.5pt,xshift=-0.85pt]n3.north east);
\end{tikzpicture}
\end{document}