How to create invisible character or hidden text in LaTeX?

LaTeX offers various methods to customize and enhance text presentation. One fascinating and sometimes necessary technique is creating invisible characters or text.

You might wonder—why write something that can’t be seen? However, there are many situations where this characters or text are crucial.

In this article, we will discuss different methods to write invisible characters or text in LaTeX, ensuring your documents appear exactly as you want without displaying unnecessary elements.

Using the \phantom command

The \phantom command creates a space equal to the width of text inside the command, but this text itself is invisible. For example:


This command will insert an white space where “text” would usually appear.

Here is some text \phantom{more} text.

In this example, an invisible space equal to the width of the word “more” is created between “some text” and “text”.

Using the \hphantom and \vphantom commands

The \hphantom and \vphantom commands create horizontal and vertical spaces, respectively. They work similarly to the \phantom command.

 % Using phantom, hphantom, and vphantom together in a table
 \textbf{Left Text} & \textbf{Fruits} \\
 Row 1 & Row 1 \phantom{Mango} \\
 Row 2 & Row 2 \hphantom{Banana} \\
 Row 3 & Row 3 \vphantom{Orange} \\
 Row 4 & Row 4 \hphantom{Apple}\vphantom{Mango} \\

Using the \mbox command

The \mbox command prevents its contents from being broken across lines. You can make the contents invisible by setting their color to the background color, usually white:

\mbox{\color{white} white text}

This command can be combined with the \color command from the xcolor package to match the background color (usually white).

\usepackage{xcolor} % Required for \color command


Lorem ipsum dolor sit amet, \mbox{\color{white}consectetur adipiscing elit}, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. 

Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. \mbox{\color{white}Excepteur sint occaecat cupidatat non proident}, sunt in culpa qui officia deserunt mollit anim id est laborum.


Using the \comment package

The comment package is very effective for adding comments or metadata that won’t appear in the document:

This is a comment.

In this method, you can add comments or notes within the document that will only be visible in the source file and not in the final document.

This is especially useful when you want to keep notes for a specific section without displaying them to the readers.


You can use the \phantom, \hphantom, and \vphantom commands to create spaces, the \mbox command to hide text, or the comment package to add non-displaying notes. Each method has its unique applications.

We hope this article has given you a clear and thorough understanding of the various methods to create invisible characters and text in LaTeX.

Md Jidan Mondal

LaTeX expert with over 10 years of experience in document preparation and typesetting. Specializes in creating professional documents, reports, and presentations using LaTeX.

Leave a Comment

Your email address will not be published. Required fields are marked *