I have a simple command which creates coloured text. This works without any issues when there is a single paragraph without a line break. With a linebreak/new paragraph this does not work (commented code in MWE below produces this). The error that is given is
Too many }'s.
\tbn #1->\textcolor {blue}{{#1} }
A simple method is to use \tbn{} separately for each paragraph after line break. But can the command be redefined so that it works across paragraphs/line breaks?
\documentclass{article}
\usepackage{xcolor}
\newcommand{\tbn}[1]{\textcolor{blue}{{#1}}}
\usepackage{lipsum}
\begin{document}
\tbn{This works if there is no line break.}
% \tbn{This doesn't work if there is a line break.
% If there is a line break.}
\end{document}
leavevmodeis needed? – Damitr Mar 03 '24 at 11:52\specialwhich outputs a whatsit that might have side effects if used in the wrong place, the\leavevmodereduces the risk of strange things. – Skillmon Mar 03 '24 at 13:45