0

I'm pretty new to TikZ and I'd like to make a page with a colored background with some circles on it.

I've already tried this:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[usenames,x11names,dvipsnames,svgnames]{xcolor}
\usepackage{graphicx,amsmath,latexsym,amssymb,amsthm,geometry}
\usepackage{tikz}
\usepackage{pagecolor}
\usepackage[dvipsnames]{xcolor}  
\usetikzlibrary{decorations, decorations.text,backgrounds}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}

%\pagecolor{blue}
\begin{document}

 \begin{tikzpicture}[background rectangle/.style={fill=cyan!10}, show background rectangle]

        \begin{scope}[blend group = soft light]
            \fill[red!30!white]   (0:0) circle (0.5);
            \fill[green!30!white] (0:0) circle (0.25);
            \fill[blue!30!white]  (330:2.2) circle (0.3);
            \fill[purple!30!white]  (251:0) circle (0.3);
            \fill[brown!30!white]  (297:21) circle (0.3);
        \end{scope}

    \end{tikzpicture}
\end{document}

The problem is that I can't get a proper A4 format, so i tried to cheat by putting circles in the corners but even with it, the format isn't the good one. I've also tried with \pagecolor but it doesn't change the background color.

I don't know if it's the right place to post but I didn't find good solutions for now.

  • You are not looking at the paper, but the figure. Removing the preview lines will tell you that. Your figure is not in a4 size. – user156344 Apr 15 '19 at 11:40
1

You are in preview mode, i.e. you are not looking at the page itself, but the TikZ environment, which is not in the size of an a4paper.

The best way to customize the page in this way is, of course, draw directly on the page, not draw an independent tikzpicture. With option remember picture,overlay, the current of the page is recognized as a node named current page. Now you can use its anchors (current page.north west for example) to draw everything you want to do.

\documentclass{article}
\usepackage{tikz}
\begin{document}
\thispagestyle{empty}
\begin{tikzpicture}[overlay,remember picture]
\fill[cyan!10] (current page.north west) rectangle (current page.south east);
\begin{scope}[shift={(-2,2)}]
    \fill[red!30!white]   (0:0) circle (0.5);
    \fill[green!30!white] (0:0) circle (0.25);
    \fill[blue!30!white]  (330:2.2) circle (0.3);
    \fill[purple!30!white]  (251:0) circle (0.3);
    \fill[brown!30!white]  (297:21) circle (0.3);
\end{scope}
\end{tikzpicture}
\end{document}

enter image description here

If you want to have your \maketitle works in the page, you have to prevent page break on this command, as described here. Go to that link to see why I put the whole story inside a group.

\documentclass{article}
\usepackage{tikz}
\title{Foo bar baz}
\author{Titu}
\date{\today}
\usepackage{lipsum}
\begin{document}
\begin{tikzpicture}[overlay,remember picture]
\fill[cyan!10] (current page.north west) rectangle (current page.south east);
\begin{scope}[shift={(-2,2)}]
    \fill[red!30!white]   (0:0) circle (0.5);
    \fill[green!30!white] (0:0) circle (0.25);
    \fill[blue!30!white]  (330:2.2) circle (0.3);
    \fill[purple!30!white]  (251:0) circle (0.3);
    \fill[brown!30!white]  (297:21) circle (0.3);
\end{scope}
\end{tikzpicture}

{\let\newpage\relax\maketitle}

\lipsum[1-3]
\end{document}

enter image description here

  • @titu Write everything after the TikZ picture. Because the picture will overlay everything in that page, so everything written before the picture will be hidden – user156344 Apr 18 '19 at 16:13
  • Thanks you, do you also know how to write on it ? Like using \title() because, whenever i try to write on it, the text doesn't show. – titu Apr 18 '19 at 16:14
  • @titu See my previous comment – user156344 Apr 18 '19 at 16:14
  • Ok, it works with \textbf{} for example, but still not with \title{}, i should maybe use an other command ? – titu Apr 18 '19 at 16:18
  • @titu I edited my answer – user156344 Apr 18 '19 at 16:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.