平均能量损失
\documentclass[12pt]{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usepackage{pgflibraryshapes}
\newcommand*\circled[1]{%
\tikz[baseline=(x.base)]
\node[draw,red,circle,thick,fill=white,inner sep=2pt](x) {$\displaystyle#1$};}
\begin{document}
a\circled{b}a
\end{document}
但我尝试做的
你能帮我修复它吗?
答案1
您可以使用overlay
(进行一些宽度调整)。
\documentclass[12pt]{article}
\newlength{\mywida}
\newlength{\mywidb}
\newlength{\mywidback}
\usepackage{tikz}
\newcommand{\circled}[2]{\phantom{\emph{#1}}#2%
\settowidth{\mywida}{#2}%
\settowidth{\mywidb}{\emph{#1}}%
\setlength{\mywidback}{.5\mywidb}%
\addtolength{\mywidback}{\mywida}%
\hspace{-\mywidback}%
\tikz[baseline=(x.base), overlay]
\node[draw,red,circle,thick,inner sep=2pt] (x) {\emph{#1}};%
\hspace{\mywidback}%
}
\begin{document}
a\circled{b}{a} another exam\circled{p}{le}
\end{document}