LaTeX Document Background

In some documents, the author may want to add a background to create a certain visual mood. In LaTeX, this can be done either with a full-page image or with a simple page color.

How to Add a Document Background in LaTeX
In LaTeX, we can add various backgrounds that cover the full page of the document.
Basic Requirements
Before starting, note the following:
- Include the
backgroundpackage in the document preamble. - Save the background image in the same folder as the
.texfile. - Write the document content as usual.
Besides images, we can also set a page color using the command \pagecolor{color}.
Steps to Create a Background in LaTeX
1. Open a Text Editor
Open your LaTeX editor, either offline or online such as Overleaf.
2. Define the Document Class
Use the desired document class. In this example, the article class is used.
\documentclass[a4paper,11pt]{article}3. Add the Required Packages
In the preamble, include graphicx, xcolor, and background.
\usepackage{graphicx}
\usepackage{xcolor}
\usepackage{background}4. Configure the Background
Then configure the background with the following command.
\backgroundsetup{
scale=1,
angle=0,
opacity=90,
contents={\includegraphics[width=\paperwidth,height=\paperheight]{kertaskuno}}
}In this part we can adjust the scale, rotation, and transparency of the background image.
5. Start the Document
Begin the document body with:
\begin{document}6. Write the Document Content
Write the document content as needed. In this example, a song lyric excerpt is used as the sample text.
\begin{center}
\color{blue}{\Huge CINTA DAN KALIMAH\\
\medskip
\Large Iklim}
\end{center}
\begin{verse}
Kasih sayang tak terpadam\\
Rindu pun tak terbilang\\
Bak malam dan siang\\
Hanya engkau kurindu\\
\hskip 8mm Bukan kerna kata-kata\\
\hskip 8mm Cinta yang subur di minda\\
\hskip 8mm Sucinya cintamu\\
\hskip 8mm Di cermin hati\\
Salji yang putih hitam mendidih\\
Andai kulupa padamu\\
Langit yang pijar kembali ceria\\
Indah kukecup keningmu\\
\hskip 8mm Dengan ratapan kutelan bisa\\
\hskip 8mm Pahit-manis madah pujangga\\
\hskip 8mm Menguntum rindu seiras wajahmu\\
\hskip 8mm Relung cinta dan kalimah\\
Terbuka pintu saujana kemaafan\\
Kau tersenyum mengirai mimpi\\
Salju terasa bersamamu, kekasih\\
Menyulamkan keindahan\\
Cinta dan kalimah\\
\end{verse}7. End the Document
Close the document with:
\end{document}8. Compile and Review the Result
Compile the document and check the result.
Example Result
Below is an example output from the steps above.
Additional Tip: Color Background and Keep Aspect Ratio
If you want to use a background that does not fully cover the page while preserving the image proportion, use keepaspectratio. You can also add a page background color using \pagecolor.
\documentclass{article}
\usepackage{background}
\backgroundsetup{
scale=1,
angle=0,
opacity=0.9,
contents={\includegraphics[width=\paperwidth,height=\paperheight,keepaspectratio]{root.png}}
}
\usepackage{lipsum}
\begin{document}
\pagecolor{blue!40}
\lipsum[1-5]
\end{document}The result will look like this.

Closing
That is the guide to adding a background to a LaTeX document using the background package. If you have corrections or suggestions, please leave them in the comments.




