答案1
像这样 ?
编辑:hpekristiansen 的评论
\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\begin{document}
\tikzset{
% soul/.style args={#1}{label={\underline{#1}},node contents=},%<-- bof
soul/.style args={#1}{node contents={\underline{#1}}},%<-- with hpekristiansen'comment
}
\begin{tikzpicture}
\node[soul=Some text that should be underlined.];
\end{tikzpicture}
\end{document}
答案2
您可以使用与@Skillmon 的精彩答案相同的技巧https://topanswers.xyz/tex?q=6276#a6152
(用TL2023编译,TL2024好像有问题)
% !TeX TS-program = lualatex
\documentclass[]{book}
\usepackage{tikz}
\usepackage{lua-ul}
\makeatletter
\NewDocumentCommand\myunderline{}{
\@underLine
}
\makeatother
\begin{document}
\begin{tikzpicture}
\node[font=\myunderline]{Some text that should be underlined.};
\end{tikzpicture}
\end{document}