答案1
是的,可以TikZ
。您可以通过两种方式进行操作:
- 通过将代码直接包含在文本中。
autour
通过创建一个名为包含代码的LaTeX 命令TikZ
。
下面是两个具有不同参数的可能性的示例,以便直观地展示其效果。
\documentclass{article}
\usepackage{tikz}
\newcommand{\autour}[1]{\tikz[baseline=(X.base)]\node [draw=red,fill=gray!40,semithick,rectangle,inner sep=2pt, rounded corners=3pt] (X) {#1};}
\begin{document}
Quick brown fox \tikz[baseline=(X.base)]\node [draw=black,fill=cyan!20,thick,rectangle,inner sep=3pt, rounded corners=4pt] (X) {jumped}; over the lazy dog.
\bigskip
Quick brown fox \autour{jumped} over the lazy dog.
\end{document}
替代tcolorbox
对手册第 16 页上的代码进行了简单改编,@CarlaTeX 在其评论中指出了这一点。
\documentclass{article}
\usepackage{tcolorbox}
\newtcbox{\entoure}[1][red]{on line,
arc=3pt,colback=#1!10!white,colframe=#1!50!black,
before upper={\rule[-3pt]{0pt}{10pt}},boxrule=1pt,
boxsep=0pt,left=2pt,right=2pt,top=1pt,bottom=.5pt}
\begin{document}
Quick brown fox \entoure{jumped} over the lazy dog.
Quick brown fox \entoure[blue]{jumped} over the lazy dog.
\end{document}
答案2
这有点类似于 AndréC 的回答,但要指出的是,\tikzmarknode
这个非常酷的tikzmark
库在某种程度上被重新发明了。tikzmark
当然,它允许您做更多的事情。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{tikzmark}
\begin{document}
\section*{Some basic examples}
The quick brown fox \tikzmarknode[draw,inner sep=2pt,rounded corners,fill=cyan!30]{A}{jumped} over the lazy dog.
\bigskip
The quick brown fox \tikzmarknode[draw,inner sep=2pt,rounded corners,fill=red!30]{B}{jumped} over the lazy dog.
\section*{Some more elaborate examples}
As it is well known,
\[ \sum\limits_{\tikzmarknode[rounded corners,fill=blue!30,inner sep=1pt]{k1}{k}=1}^\infty
k~=~-\frac{1}{12}\;,\]
where $\tikzmarknode[rounded corners,fill=blue!30,inner sep=2pt]{k2}{k}$ is a summation index.
\tikz[overlay,remember picture]{\draw[latex-latex] (B) to[bend left] (A);
\draw[latex-latex] (k1) to[bend right] (k2);
}
\end{document}