% starts an end-of-line comment in LaTeX. Is there any way I comment an entire paragraph without putting a % in front of each individual line?

Note: I write my LaTeX code in texmaker.

  • 1
    Hi! This quite depends on your text editor. For instance in TeXworks, this is done by selecting the lines and pressing Ctrl+{ (= Ctrl+Shift+[ on English keyboard). – yo' Jan 14 '14 at 13:36
  • 3
    Most LaTeX friendly editors have this feature, often called Outcomment or Comment out – daleif Jan 14 '14 at 13:37
  • 1
    take a look at How to write hidden notes in a LaTeX file? – barbara beeton Jan 14 '14 at 13:41
  • In texmaker the comment and uncomment are in the Edit menu. Comment out is Ctrl-t and uncomment is Ctrl-u, just highlight the reqion to be commented and hit Ctrl-t. – daleif Jan 14 '14 at 14:04

The verbatim package provides a comment environment for dealing with chunks of the input:

Sample output




Normal text that will be printed.

  Text and other input \( x^2 \) that will be ignored.


Even this heading.

Further material that will be printed.

  • didn't work after doing this, does it mean i don't have the package? would there be a compiling error if if i write \usepackage{verbatim}, but I don't actually have it? – Lost1 Jan 14 '14 at 13:43
  • @Lost1 verbatim is part the standard distributions. What error do you get? – Andrew Swann Jan 14 '14 at 13:47
  • 2
    I would not recommend using comment as it is really easy to miss that this is commented out (unless your editor is good a coloring the contents of the comment env). Most LaTeX friendly editors mark outcommented lines very visually and is thus prefered – daleif Jan 14 '14 at 13:47
  • texmaker highlights something in orange when it is a comment it does not recognise - this is exactly what happened. If i just add the package into the file, there is no error in compiling but it does not recognise the \begin{comment} command – Lost1 Jan 14 '14 at 13:54
  • Then please provide more information about your document, ie post a MWE – daleif Jan 14 '14 at 14:08

If the question is how to comment a block of text without manually adding a % at the beginning of each line, you can do the following in texmaker.

Mac OS

Select the block of text you want to comment and hit

Cmd + T to comment, and

Cmd + U to uncomment.

Windows/Linux (I think...)

Select the block of text you want to comment and hit

Ctrl + T to comment, and

Ctrl + U to uncomment.

  • i tried ctrl+T for windows, didn't work, sorry. :( – Lost1 Jan 14 '14 at 14:03
  • @Lost1, you can see the actual shortcut in the Edit menu. – daleif Jan 14 '14 at 14:05
  • Just tested latest TM on windows, I cannot get Ctrl-t to react in my virtual Win7 either. You will have to choose comment from the Edit menu using the mouse. Might also be an idea to report this to the developers. (Though this may be an effect of the virtualizaition software I use) – daleif Jan 14 '14 at 14:11
  • @daleif I don't have a Windows machine. Perhaps you should report it to them (him, really). – jub0bs Jan 14 '14 at 14:13

There is a comment package for this exact functionality and more.









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