I want to highlight some things to do or alternative words/phrases for future refinement in a draft.
I have tried to highlight text with \hl in soul package or \colorbox in xcolor package.
But \colorbox is not able to detect line breaks automatically, while \hl always results in compilation errors when there are user commands.
I have tried to add curly braces around the user command, but it didn't work.
I have tried to use \mbox to wrap the command, but the result is the same as \colorbox.
\documentclass{article}
\usepackage{color}
\usepackage{soul}
\newcommand{\reftab}[1]{\mbox{Table \ref{#1}}}
\newcommand{\reftabb}[1]{Table \ref{#1}}
\soulregister{\reftab}{1}
\soulregister{\reftabb}{1}
\begin{document}
\begin{table}
\caption{tab \label{tab1}}
\end{table}
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaa aaaaaaa \hl{{\reftab{tab1}}}
\noindent\makebox[\linewidth]{\rule{\textwidth}{1pt}}
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaa aaaaaaa \hl{\mbox{\reftabb{tab1}}}
\end{document}
The picture above shows that the highlighted text is out of margin (the width of the line is text width), is it possible to make it wrap properly?
Even with microtype package, the output is still not desirable.


\sloppyor thesloppyparenvironment, but it comes at the expense of excessive inter-word spacing. The overfull box is a warning, perhaps, to restructure your document. – Steven B. Segletes Oct 27 '16 at 11:10\mboxwhen there is no user command. @StevenB.Segletes – Mr. Ree Oct 27 '16 at 13:27\mboxis definitely without hyphens, so that won't help. – Steven B. Segletes Oct 27 '16 at 13:39Tableetc. – samcarter_is_at_topanswers.xyz Oct 27 '16 at 14:03