1

I want to draw a colored rectangle that contain left, top and bottom margins. Like this picture (border is not real). \Thanks :) enter image description here

\documentclass{book}
\usepackage{showframe}
\usepackage{tikz}
\begin{document}
    \begin{tikzpicture}[scale=0.88]
    \draw [color=blue,fill=blue] (0,-16.9) rectangle (4,5)  ;
    \end{tikzpicture}
\end{document}
3
  • 1
    \documentclass{article} \usepackage{tikz} \usepackage{eso-pic} \begin{document} \AddToShipoutPictureBG*{% \begin{tikzpicture}[remember picture,overlay] \fill[blue] (current page.north west) rectangle ([xshift=4cm]current page.south west); \end{tikzpicture}} Hello! \end{document}
    – user121799
    Aug 9, 2019 at 18:07
  • Excuse me, how can I add another yellow colored rectangle in center of blue rectangle? Thanks alot Aug 9, 2019 at 18:41
  • \documentclass{article} \usepackage{tikz} \usepackage{eso-pic} \begin{document} \AddToShipoutPictureBG*{% \begin{tikzpicture}[remember picture,overlay] \fill[blue] (current page.north west) rectangle ([xshift=4cm]current page.south west) node[midway,fill=yellow,minimum width=2cm,minimum height=5cm]{}; \end{tikzpicture}} Hello! \end{document}, where minimum width and minimum height specify the dimensions of the yellow rectangle.
    – user121799
    Aug 9, 2019 at 18:43

2 Answers 2

3

From my comment above:

\documentclass{article}
\usepackage{tikz}
\usepackage{eso-pic}
\begin{document}
\AddToShipoutPictureBG*{%
    \begin{tikzpicture}[remember picture,overlay]
    \fill[blue] (current page.north west) rectangle
    ([xshift=4cm]current page.south west) node[midway,fill=yellow,minimum
    width=2cm,minimum height=5cm]{};
\end{tikzpicture}}
Hello!
\end{document}

enter image description here

It is true that you do not need tikz for only that but as soon as you want to have something slightly more fancy, it is very convenient, if not necessary.

2

You don't need a sledgehammer like TikZ to crack this nut:

\documentclass[12pt]{article}
\usepackage[svgnames]{xcolor}
\usepackage{eso-pic}
\usepackage{ebgaramond}

\begin{document}

\AddToShipoutPictureBG*{%\AtPageLowerLeft{%
\color{NavyBlue!80}\rule{\dimexpr1in + \oddsidemargin}{\paperheight}}
Fiddle dee dee!

\end{document} 

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .