If I have the following:
\lit*{\char`\\ b}
How do I combine this with a \hl (highlight) to get a highlighted version of \b?
(\lit is from the syntax package, and \hl is from soul)
If I have the following:
\lit*{\char`\\ b}
How do I combine this with a \hl (highlight) to get a highlighted version of \b?
(\lit is from the syntax package, and \hl is from soul)
The solution for me is usually to change how soul registers the command you are inputting
\documentclass{article}
\usepackage{syntax}
% \usepackage{xcolor} % for colouring
\usepackage{soul}
\soulregister\lit7 % this tells soul to register \lit as non expanded command.
% so the result is \hl{result of lit}
\usepackage{lipsum}
\begin{document}
Example
\lit{Example}
\hl{Example}
\hl{\lit{Example}}
\end{document}
For more details: How to make \hl (highlighting) to automatically place incompatible commands in \mbox?
According to quark67's comment, you can create a new command \newcommand{\newlit}[1]{\lit*{#1}} as register that one
\documentclass{article}
\usepackage{syntax}
\usepackage{xcolor} % for colouring
\usepackage{soul}
\newcommand{\newlit}[1]{\lit{#1}}
\soulregister\newlit7 % this tells soul to register \newlit as non expanded command. Yes the 7 at the end is what does it!
% so the result is \hl{result of \lit}
\usepackage{lipsum}
\begin{document}
Example
\lit{Example}
\hl{Example}
\hl{\lit{Example}}
\hl{\newlit{Example}}
\end{document}
hl will take as an argument, like cite.
– anis
Jan 18 '23 at 19:38
\newcommand{\newlit}[1]{\lit*{#1}}. Then \soulregister it: \soulregister\newlit7. Then in the document, use "\hl{\newlit{\char`\ b}}" (and probably uncomment the line "\usepackage{xcolor}" as the OP probably would use "\hl" with a colored background.
– quark67
Jan 18 '23 at 19:54
\litand\hldefined? – egreg Jan 17 '23 at 18:31\lit*is from thesyntaxpackage, and probably\hlfrom thesoulpackage. But it's better if the OP can confirm that. – quark67 Jan 17 '23 at 23:37