Page LayoutHow to add text/image in the left/right margin on every page

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
kumthekar
Posts: 2
Joined: Fri Apr 29, 2011 12:58 am

How to add text/image in the left/right margin on every page

Post by kumthekar »

Hi all:

I am trying to repeat some text (or even an image) in the left and right margins of every page. I am new to LaTeX. Is there any package that will let me do this? I am aware of fancyhdr, but as far as I could see it affects only headers and footers on each page.

Thanks for your help.

Regards,
Bala.

Recommended reading 2024:

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

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

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Stefan Kottwitz
Site Admin
Posts: 10328
Joined: Mon Mar 10, 2008 9:44 pm

How to add text/image in the left/right margin on every page

Post by Stefan Kottwitz »

Hi Bala,

welcome to the board!
You could use atbegshi or everyshi.

As you mentioned fancyhdr: it would be possible using fancyhdr or scrpage2 as well, for example together with TikZ and the current page node. Here are examples: Fancy chapter headings with TikZ.

Stefan
LaTeX.org admin
kumthekar
Posts: 2
Joined: Fri Apr 29, 2011 12:58 am

How to add text/image in the left/right margin on every page

Post by kumthekar »

Hi Stefan,

Thanks a lot for your pointers. I am able to get *almost* what I am looking for with atbegshi. Here is the code:

Code: Select all

\documentclass[12pt]{exam}
\usepackage[latin1]{inputenc}
\usepackage{atbegshi}
\usepackage{textpos}
\usepackage{shadow}
\usepackage{draftwatermark}
\usepackage{rotating}

\usepackage[english]{babel}
\usepackage{blindtext}

\TPGrid{8}{11}
\AtBeginShipout{%
  \begin{textblock}{3}(-0.5,4)
    \begin{turn}{-90}
      Text on the left margin
    \end{turn}
  \end{textblock}
  \begin{textblock}{3}(6,4)
    \begin{turn}{-90}
      Text on the right margin
    \end{turn}
  \end{textblock}%
}
\begin{document}
\pagestyle{headandfoot}
\header{\bfseries Txt 1}{\bfseries Txt 2}{\bfseries Txt 3}
\headrule
\footrule
\footer{}{\copyright whatever}{\thepage/\numpages}

\hfill
\shabox{\parbox[l]{2in}{X1: \\X2: August 21, 2009\\X3: }}

  \blinddocument

\end{document}
I can see the text in the margins starting from page 2. Why is that? What am I missing? Why not starting from page 1? Also, there is an extra empty page number 4 where at the bottom right corner it says 4/3, which is not correct.

Thanks for your help.

Regards,
Bala.
Post Reply