I have not got any solution after a few try. In latex, how we can comment out a single word from a line. I mean for example

Hello %this is so on

it comments out this and the rest of the line as well. Is there any way to comment out only this part, not the rest of the line ?

  • 2
    just, at the end of the line. Press the enter button to go to another line.
    – Chamanga
    Jun 20, 2023 at 6:46

1 Answer 1


Basically, no.

But in LaTeX

Hello this is so on

is the same has

Hello this
is so on

So you can just do

Hello %this
is so on

You can use tricks to just remove part of a line, like

Hello \iffalse this\fi is so on 

(Or several other things, like using the comment package), but that's overly complex.

  • 1
    you would be better without the {} after \fi (get a double space as it is) Jun 20, 2023 at 7:39
  • Ach, darn, I was thinking about changing it into a \iftrue later... as I said, overly complex.
    – Rmano
    Jun 20, 2023 at 7:49
  • 1
    You can also write a macro that gobbles its argument, e.g. \newcommand{\mycomment}[1]{}, and then write Hello \mycomment{This is a comment} world Jun 20, 2023 at 11:16
  • Or use \sbox0{this } (although the ghost of this will linger). Jun 20, 2023 at 14:30

You must log in to answer this question.

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