I have a set of commands in my document's preamble that look like this:


They are to allow my coauthors and I to make comments in the document that will appear in the pdf, to facilitate working on it. However, we find we quite often want to put several paragraphs inside such a comment (e.g. if we've written some new material that we're not sure about, and we want the other authors to notice it). If I try to do this:



then I get this error:

paragraph ended before \@textcolor was complete

I know I can use \\ to get a linebreak instead, but I'd prefer it if my custom command would just accept normal paragraph breaks. Is there some command that will cause LaTeX to accept multiple paragraphs as if they were a single one, or some other way to colour multiple paragraphs of text?


\textcolor is similar to \mbox, so it doesn't typeset paragraphs; use the declarative form, instead, in a group:


you could make an environment form




   in blue

can take paragraphs of text

  • I'm always unsure about this. The way it is defined here, the \endgroup triggering color-back-switching will come in vertical mode, hence the switching magic will go in the vertical list, making \lastbox and things more difficult. Hence I always try to have color switching in horizontal mode. Mar 29 '12 at 10:01
  • true but arranging environment switching to be always in hmode is a pain too (see missing item error question in today's list) When we added the colour support did experiment with a version that always delayed itself if used in hmode, and insert at start of next para but that complication had downsides as well as it broke more 3rd part packages and is harder to make work with rules and things. Mar 29 '12 at 10:18
  • Wouldn't this work: \newenvironment{thisnote}{\par\begingroup\color{blue}}{\endgroup\par}? Mar 29 '12 at 10:23
  • 1
    That makes it very sensitive to the contents of the environment, for example if there is a size change in the text but no ending para the size change and the colour will end at the \endgroup but the paragraph will end at the \par so you get big text set on normal baselineskip. Also in that form the start color is definitely in vertical mode so it doesn't really solve the problem (you could try delaying it into \everypar but then it gets delicate if the first thing in the environment isn't just simple text. In particular if the paragraph starts within a group. Mar 29 '12 at 11:06
  • Ok, thanks for the clarification. It seems color switching is too murky to be done right without a great amount of care. Mar 29 '12 at 11:07

This is what I use:

  • 4
    Great! Probably even better to put \color{blue} into the same braces as #1 and remove \color{black}, for example in case black is not default: \newcommand{\newstuff}[1]{{\color{blue}#1}}
    – root
    Jan 6 '19 at 17:46
  • Great! Probably even better to put \color{blue} into the same braces This definitely makes the difference. For some reason, in my case the entire document after that point was getting the color, though I would expect that the color command in \color{blue}{#1} should only affect {#1}. Apr 1 at 11:20

Just for a change:

%%---------------------------- colored box as paragraph---------------
%%----------------------------colored text as paragraph---------------

Disclaimer: This won't break across pages. If that is the requirement, one can use mdframed package.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.