I would like to highlight text including user-defined commands with linebreaks. I found a solution for linebreaks (Colorbox does not linebreak), but the \ctext{} command cannot treat other commands in its argument.
My MWE is as follows:
\documentclass{article}
\usepackage{lipsum}
\usepackage{xcolor}
\usepackage{soul}
\usepackage{etoolbox}
\usepackage{ifmtarg}
\newcommand{\red}[1]{{\color{red} #1}}
\newcommand{\ctext}[3][RGB]{%
\begingroup
\definecolor{hlcolor}{#1}{#2}\sethlcolor{hlcolor}%
\hl{#3}%
\endgroup
}
%Frame of command '\spec'
\newcommand{\defineSpecies}[2]{\csdef{spec@#1}{#2}}
\newrobustcmd{\spec}[1]{%
\ifcsname spec@#1\endcsname%
\csuse{spec@#1}%
\else
\GenericError{}{Undefined species `#1'}{}{}
\fi
}
\defineSpecies{h216o}{H$_2^{~16}$O}
\begin{document}
\ctext[RGB]{0,209,0}{\red{\spec{h216o}}}
\end{document}
lua-ulpackage instead of thesoulpackage. Else theulempackage is more robust than thesoulpackage, but inside ofulemyou get no automatic hyphenation. – Skillmon Apr 18 '23 at 09:31ctextcommand cannot be repaired? And what command do you think about inulem? – TobiR Apr 18 '23 at 09:37soul's documentation, it states a list of stuff that doesn't work (not sure whether that list is exhaustive), in summary:soulis not stable and only works for simple stuff. I thinkulemdoesn't have a\hl-like command out of the box, but you can define it yourself (you should be able to find examples on this site). – Skillmon Apr 18 '23 at 10:59\text_expand:nwhich might be what you want. – egreg Apr 18 '23 at 15:22ifmtarg-based command. – TobiR Apr 18 '23 at 15:37