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?


7 Answers 7


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

  • 1
    What's the purpose of \leavevmode here? (And why is it within the braces?) tex.stackexchange.com/a/22853 says that \leavevmode is to avoid paragraph-break problems, but when I omit \leavevmode I don't see paragraph-break problems.
    – root
    Jan 6, 2019 at 20:08
  • @root It's best not to have \color between paragraphs, so this implementation adds \leavevmode in order to start the paragraph before setting the color. Inside or outside the braces is immaterial.
    – egreg
    Jan 6, 2019 at 20:19
  • 2
    @root No, I mean if \nathaniel comes after a blank line. If issued between paragraphs, \color inserts an object that can affect pagination.
    – egreg
    Jan 6, 2019 at 20:27
  • 2
    it would be better to change [#1] to {#1} so as to remove the bracket appearing in the blue texts. Jun 23, 2023 at 2:02
  • 1
    @MingmingQiu The brackets are wanted by the OP.
    – egreg
    Jun 23, 2023 at 9:06

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, 2012 at 10:01
  • 1
    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, 2012 at 10:18

This is what I use:

  • 7
    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, 2019 at 17:46
  • 1
    You could add \AtBeginDocument{\colorlet{default}{.}} to the preamble and replace \color{black} by \color{default} for cases where the default color is set to something different than black. Sep 21, 2022 at 23:45

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.


I'd like to highlight the solution given by @root in the comments:


For example, this works just fine:

Paragraph 1 ...

Paragraph 2 ...
  • Just to note this is essentially the same as the accepted answer. (But that one has a \leavevmode to prevent edge cases involving pagination.)
    – N. Virgo
    Apr 12, 2022 at 0:29

Medium experience user here, I am working on Overleaf but it should work on your setup too. Merging the answers from "root" and "doncherry" I made one that worked for me and I love it, here you go... enjoy:

\usepackage[dvipsnames]{xcolor} %permits using colors for text, to check all the colors that are available with "dvipsnames" check https://www.overleaf.com/learn/latex/Using_colours_in_LaTeX to know what to choose as the "color name"


%The number after the "!" indicates the opacity of your text, so that way we can control the transparency. 0 means is fully transparent and 100 means is fully opaque.
{\multilinecolortext{Green!80}{My first dad-joke goes like this:\\
A girl comes to her dad and says ``Dad, make me a sandwich". So he taps her head and says: ``Puff! You're a sandwich! ... XD 

Ok since you liked, it here is another joke to exemplify multiple lines, :

\noindent I went on a one-in-a-lifetime vacation... never again}}

This is Plum color text at 25\% opacity:


This is Bittersweet color text at 50\% opacity:


This is Turquoise color text at 75\% opacity:


This is CadetBlue color text at 100\% opacity:


just like that you will have something that looks like this:

enter image description here


A nasty solution, but it may be suitable for some specific purposes. Rather than the usual line break with \\, use \\ \phantom{a} \\ combination to break the line inside the \color block. For example, -

\textcolor{red}{paragraph 1 \\ \phantom{a} \\
 paragraph 2 \\ \phantom{a} \\
 paragraph 3

The output is -

enter image description here

Note that this will not add indentation before the new paragraph. But you can also add that manually.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .