Graphics, Figures & TablesRectangle on every page at the same position

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
Palilicium
Posts: 4
Joined: Fri Jan 03, 2014 9:06 pm

Rectangle on every page at the same position

Post by Palilicium »

Hello,

Since this is my first post, I would like to thank you all in advance for your help. It is also more than possible, that my English is at times wrong, since it is not my native language. Of course I'm also going to post a short introduction in the respective "New Members" category.

But enough words regarding the introduction. As the thread title suggests I'm looking for a way to get a rectangle (filled or not does not matter) on every page at the same position of the page.

To make things more complicated, it would be nice if it is possible to embed the rectangle in a way, so that the text would go around the rectangle, but this feature is not a must.

So far I was only able to insert this simple command:

Code: Select all

Code, edit and compile here:
\begin{figure}[htbp]
\centering
\rule{3cm}{3cm}
\end{figure}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
This gives me of course a rectangle in the middle of the text if written at the right position, but that is all.

I hope I expressed myself clearly and you can help me with my "problem".

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Rectangle on every page at the same position

Post by Johannes_B »

figure environments are able to float around. That's not what you want.

You could have a look at package textpos or section 16.13.2 (Absolute Positioning) of the tikz package.

If you need more help, a minimal working example would be great.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Rectangle on every page at the same position

Post by cgnieder »

This could also be a task for the brand new KOMA-Script package scrlayer (since KOMA-Script v3.12 2013/12/19):

Code: Select all

Code, edit and compile here:
\documentclass{article}
\usepackage{scrlayer,xcolor}
\usepackage[automark]{scrlayer-scrpage}
\DeclareNewLayer[
background,
align=tl,
area={0pt}{0pt}{1in}{1in},
contents={\rule{1in}{1in}}
]{box-tl}
\DeclareNewLayer[
background,
align=tl,
area={\dimexpr\paperwidth-1in\relax}{0pt}{1in}{1in},
contents={\color{red}\rule{1in}{1in}}
]{box-tr}
\DeclareNewLayer[
background,
align=tl,
area={0pt}{\dimexpr\paperheight-1in\relax}{1in}{1in},
contents={\color{yellow}\rule{1in}{1in}}
]{box-bl}
\DeclareNewLayer[
background,
align=tl,
area={\dimexpr\paperwidth-1in\relax}{\dimexpr\paperheight-1in\relax}{1in}{1in},
contents={\color{blue}\rule{1in}{1in}}
]{box-br}
\AddLayersToPageStyle{scrheadings}{box-tl,box-tr,box-bl,box-br}
% \AddLayersToPageStyle{scrplain}{box-tl,box-tr,box-bl,box-br}
% \AddLayersToPageStyle{empty}{box-tl,box-tr,box-bl,box-br}
% \pagestyle{scrplain}
\usepackage{blindtext}
\begin{document}
\blinddocument
\end{document}
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
scrlayer.png
scrlayer.png (73.44 KiB) Viewed 5049 times
Regards
site moderator & package author
Palilicium
Posts: 4
Joined: Fri Jan 03, 2014 9:06 pm

Re: Rectangle on every page at the same position

Post by Palilicium »

Thank you both very much for the answers. As soon as I get home, I will try to implement your suggestions.
Palilicium
Posts: 4
Joined: Fri Jan 03, 2014 9:06 pm

Re: Rectangle on every page at the same position

Post by Palilicium »

Ok I have tried both options and I must admit that I prefer the one using the package scrlayer, as I don't see any advantages provided by textpos. The only thing is, that both don't consider the actual text "below", so both are overlaying the text, when placed in the middle of a page. Is there another way, so that if I place the object in the middle of the page, the text skips this region of the page, like it is done with the figure command?

If not it is not that big of a deal, as I would then just position the rectangle on top of the page and change the margins of the text.

Finally a big Thank You to the both of you!
Post Reply