You can also highlight the text in any document and research paper. That’s why many document processors like LaTeX support the source code to highlight a text in LaTeX. If you want to highlight a text, this LaTeX tutorial is for you. Let’s get started!
How to Highlight a Text in LaTeX
There are various ways to highlight a text. Let’s divide this section into two parts to explain the approaches to highlighting a text in LaTeX.
1. Highlight a Text
To simply highlight a text, use the {xcolor, soul} \usepackage, \sethcolour, and \hl source codes as shown in the following:
\usepackage{xcolor, soul}
\sethlcolor{red}
\begin{document}
Please do visit our \hl{official website}
\end{document}
Output:
Similarly, you can highlight the text and change the font color through the following source code:
\usepackage{xcolor, color, soul}
\sethlcolor{red}
\begin{document}
Please do visit our {\color{white}\hl{official Website}}
\end{document}
Output:
In this example, the color source code is used for the font color and xcolor is used for highlighting the text.
2. Highlight a Font Color
If you want to change the color of the text to highlight it, use the following source code:
\usepackage{color, soul}
\begin{document}
\color{cyan}
Please do visit our official website
\end{document}
Output:
Conclusion
Highlighting a text catches the user’s attention, so it is a handy and cool feature that we can use in LaTeX. It helps if you try it to see how it works and add the beautiful colors to your LaTeX document. We explained the different ways to highlight a text in LaTeX. Make sure to use these ways accordingly because if you highlight almost everything in the document, it may create a confusion.