我试图让tikzmarknode
s 生成的线以小钩子开始和结束,即从末端突出的水平细线,或多或少类似于括号。我不知道如何操作节点代码。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{tikzmark}
\begin{document}
This is some text and \tikzmarknode{a}this is some text.
This is some text and \tikzmarknode{b}this is some text.
\begin{tikzpicture}[remember picture] \draw[overlay,semithick] (a.west) -- (b.west); \end{tikzpicture}
This is some text and \begin{tikzpicture}\draw[overlay,very thin] (0.05,0.1) -- (0,0.1); \draw[overlay,semithick] (0,0.1) -- (0,-0.35); \draw[overlay,very thin] (0,-0.35) -- (0.05,-0.35); \end{tikzpicture}~this is some text.
This is some text and ~this is some text.
\end{document}
最后两行的代码或多或少实现了我所设想的结果:
这里有 tikz 大师提供的帮助吗?
答案1
一种可能的方法。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{tikzmark}
\begin{document}
This is some text and \tikzmarknode{a}{~this} is some text.
This is some text and \tikzmarknode{b}{~this} is some text.
\begin{tikzpicture}[overlay,remember picture] \draw[very thin]
([xshift=0.2em]a.west) -- ([xshift=-0.3pt]a.west)
([xshift=0.2em]b.west) -- ([xshift=-0.3pt]b.west);
\draw[semithick] (a.west) -- (b.west); \end{tikzpicture}
This is some text and \begin{tikzpicture}\draw[overlay,thin] (0.05,0.1) -- (0,0.1); \draw[overlay,semithick] (0,0.1) -- (0,-0.35); \draw[overlay,thin] (0,-0.35) -- (0.05,-0.35); \end{tikzpicture}~this is some text.
This is some text and ~this is some text.
\end{document}
附录:对于更常规的设置,您可能需要使用样式和fill
。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{tikzmark}
\tikzset{brace me/.style n args={2}{insert path={([xshift=0.2em,yshift=0.1pt]#1.west) --
([xshift=-0.3pt,yshift=0.1pt]#1.west) --
([xshift=-0.3pt,yshift=-0.1pt]#2.west) --
([xshift=0.2em,yshift=-0.1pt]#2.west) --
([xshift=0.2em,yshift=0.1pt]#2.west) --
([xshift=0.3pt,yshift=0.1pt]#2.west) --
([xshift=0.3pt,yshift=-0.1pt]#1.west) --
([xshift=0.2em,yshift=-0.1pt]#1.west) --
cycle}}}
\begin{document}
This is some text and \tikzmarknode{a}{~this} is some text.
This is some text and \tikzmarknode{b}{~this} is some text.
\begin{tikzpicture}[overlay,remember picture]
\fill[brace me={a}{b}] ;
\end{tikzpicture}
This is some text and \tikzmarknode{a'}{~this} is some text.
This is some text ~and \tikzmarknode{b'}{~this} is some text.
\begin{tikzpicture}[overlay,remember picture]
\fill[brace me={a'}{b'}] ;
\end{tikzpicture}
\end{document}