Hi I'm writing an ebook in org-mode that includes a separate .tex file for styles. What I'd like to do is create a box that contains the current chapter and section name on a background image that runs down the left hand side of each page. This side bar should be on each page except the title page, table of contents pages and the first page of a new chapter.

At the moment I'm using memoir and I'm guessing that this might have something to do with makechapterstyle. However last week was the first time I ever looked at LaTeX so I'm a bit lost! I'd really appreciate some insight into how one would think about solving this with LaTeX, rather than a canned solution - although, obviously I'd appreciate that too :-)

On side note - searching for "latex wallpaper" gets some interesting, but not particularly relevant images!

Edit based on Christian's comments

I'm writing a pdf ebook and I'm using the oneside option to memoir. What I want is a thin (1cm or so) image running down the left hand side of every non title page with the name of the section rotated 90˚ overlaid. The title pages will have a slightly wider image and a little bit of blurb. Here's a screenshot of my inspiration:

Side Projects book

  • I would just add it to the page style and place it with a picture environment, sadly a bit busy at the moment to create an example – daleif Nov 14 '12 at 11:54
  • If setting a background image looks like a solution you may have a look at this thread – A.G. Nov 14 '12 at 15:18

Here is a start (some work still left to do):

This uses the background package (which internally usues tikz) to draw the required frame:

enter image description here

A few variables can be tweaked as desired (all distances are in cm):

  • \FrameXStart is horizontal distance from edge of page to outer edge of frame
  • \FrameXEnd is horizontal distance from edge of page to inner edge of frame
  • \FrameYClip is vertical distance from edge of page to top/bottom of the frame
  • \FrameTextShift is vertical distance of the text from the top edge of page
  • \PageNumberLocation is vertical distance from bottom of page to page number


  • Two compile runs are required, the first to obtain the coordinates, the second to do the actual drawing.


Further Enhancements:

  • This will appear on every page so need checks for detect:
    1. title page,
    2. table of contents pages, and
    3. the first page of a new chapter.




%% Customization:
\newcommand*{\FrameXStart}{0.0}% in cm
\newcommand*{\FrameXEnd}{2.0}% in cm
\newcommand*{\FrameYClip}{0.0}% shift in cm of the frame, both from top and bottom
\newcommand*{\FrameTextShift}{-1.5}% shift in cm from the top
\newcommand*{\PageNumberLocation}{4.5}% in cm, from bottom

% Need to store the name of the chapter and section. This might be able   
% to be simplified but the simplification might be class dependent.



\newcommand*{\FrameTitle}{\ChapterName: \SectionName}%

% Style for frame
\tikzset{Frame Style/.style={fill=blue, draw=none, fill opacity=0.5, shade, top color=blue, bottom color=green}}
\tikzset{Title Style/.style={scale=2.75, text=white, rotate=-90, anchor=west}}
\tikzset{Title Top Shift/.style={xshift=\Midpoint cm, yshift=\FrameTextShift cm}}
\tikzset{Title Bottom Shift/.style={xshift=-\Midpoint cm, yshift=\FrameTextShift cm}}

% Style for page numbers in frame
\tikzset{Page Number Style/.style={scale=2.0, text=white, draw=none}}
\tikzset{Page Number Odd Shift/.style={ xshift= \Midpoint cm, yshift=\PageNumberLocation cm}}
\tikzset{Page Number Even Shift/.style={xshift=-\Midpoint cm, yshift=\PageNumberLocation cm}}

\newcommand{\MyGraphicLogo}{% For imported graphic logo
\begin{tikzpicture}[remember picture,overlay]
    \draw [Frame Style] 
            ($(current page.north west)+(\FrameXStart cm,-\FrameYClip cm)$) rectangle
            ($(current page.south west)+(\FrameXEnd   cm, \FrameYClip cm)$);
    \node [Title Top Shift, Title Style] at (current page.north west) {\FrameTitle};
    \node [Page Number Odd Shift, Page Number Style] at (current page.south west) {\thepage};
    \draw [Frame Style] 
        ($(current page.north east)+(-\FrameXStart cm,-\FrameYClip cm)$) rectangle
        ($(current page.south east)+(-\FrameXEnd   cm, \FrameYClip cm)$);
    \node [Title Bottom Shift, Title Style] at (current page.north east) {\FrameTitle};
    \node [Page Number Even Shift, Page Number Style] at (current page.south east) {\thepage};

\SetBgContents{\MyGraphicLogo}% Select frame to be drawn

%\SetBgPosition{current page.north west}% Select location
\SetBgOpacity{1.0}% Select opacity
\SetBgAngle{0.0}% Select roation of logo
\SetBgScale{1.0}% Select scale factor of logo

\chapter{Chapter Title}
\section{Section Title 1}
\section{Section Title 2}
  • Turns out that detecting the page where the chapter starts is not quite that straightforward. I had two ideas, both of which I was sure would work, but sadly they did not. Will file a follow up question if I can't figure it out. Am thinking that it might be related to an old unanswered question of mine: How to change header to list first section on page and not last section. I remember reading something then about this issue, so will have to find it again... – Peter Grill Nov 16 '12 at 8:59

I tried to do something similar once. I didn't like it so I didn't polish the code but maybe it's a good starting point for you or for someone else. Since you're using memoir, you should be able to just copy this in your preamble:



This is what it looks like in my document (sorry for the crappy resolution):

preview of above code

memoir automatically defines several other pagestyles that are used on title pages etc. so those exceptions should work automatically.

I'm not totally sure what you mean by "background image" and "box". Do you want some kind of ornamentation behind the text? Maybe this question helps: How to superimpose LaTeX on a picture?

Edit: If you really want the text in the left margin on both odd and even pages (which I personally wouldn't recommend; you might want to read the page layout introduction in the memoir documentation), replace the \makeoddhead line with something like this:


The -2em are totally guessed and you might have to tinker with this value until it looks good for your document.

  • Thanks Christian. I've updated the question to clarify the effect I'm trying to achieve. – Ben Ford Nov 16 '12 at 5:43

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.