StartLaTeX faqLaTeX for Beginners F.A.Q.LaTeX topicsLaTeX courseSearch

In LaTeX, it's possible to create a colored frame around text using the xcolor package, as demonstrated in a previous post regarding colored text.

To utilize a colored frame, you'll need to include the xcolor package, just like you did for colored text.

The command syntax for creating a colored frame is:

\fcolorbox{Frame Color}{Background Color}{Text for which the colored frame is desired}

Examples

Here's an example of text with a red frame around it:

\documentclass{article}
\usepackage{xcolor}
\begin{document}
\fcolorbox{red}{white}{Text with colored frame}
\end{document}

And here's an example of text with a red frame on a blue background:

\documentclass{article}
\usepackage{xcolor}
\begin{document}
\fcolorbox{red}{blue}{Text with colored frame}
\end{document}

If a background color other than white is chosen, it's advisable to adjust the text color as well to improve readability:

\documentclass{article}
\usepackage{xcolor}
\begin{document}
\fcolorbox{red}{blue}{\textcolor{white}{Text with colored frame}}
\end{document}

In this example, we've applied a white text color to ensure readability against a blue background.

Contact   Privacy Policy   disclosures

accept decline

This website uses cookies and pixel tags to ensure you get the best experience on our website. By using this website, you consent to the use of cookies.learn more about cookies see also our privacy policy