Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am an newbie looking to achieve a sort of two column effect with my LaTeX report - I am using LaTeX KOMA-script as a base.

I want my margin to appear in a different background color, (say) gray, and main text background is (say) blue and I want to put images, text, graphs and equations in this margin. These contents are synched with particular paragraphs, i.e. I don't want them floating around, just fixed with respect to particular paragraphs in the main text. So, how can I solve these two conditions?

Again,

  1. Different background color for main text and the margin contents. (See Similar questions panel in tex.stackexchange.com website)
  2. Make the contents of the margin par stay fixed with respect to the paragraphs of main text.

I have tried using a background image of two colors and stretching it across the entire page, but the effect is horrific... it does not align well with the main text and margins.

Any suggestions are really welcome.

share|improve this question
    
Welcome to TeX.sx! You don't have to sign with your name since it automatically appears in the lower right corner of your post. –  Werner Nov 17 '11 at 3:03
    
Could you specify "(See Similar questions panel in tex.stackexchange.com website)"? As it stands, it's not really a helpful piece of information. –  doncherry Nov 17 '11 at 12:57
    
Do it a in simple way by employing the parcolumns package, including the pdfcolparcolumns package. Sorry, I've got no time to elaborate, but this seems a simple solution to me. –  Keks Dose Nov 17 '11 at 15:04
    
Hi, Thanks a lot for the suggestions. To make it more elaborate, I just uploaded a picture of the template that i was trying to "copy" . !see-the-snapshot. –  Asif Nov 20 '11 at 23:49
add comment

1 Answer 1

up vote 3 down vote accepted

The color problem may be solved using eso-pic. Figures at the margin but not moving up or down may be done using marginnote. But sometimes moving would be recommended, so you should have a look at marginfix too. Here an example with even some more colors than asked for:

\documentclass{scrbook}% You may use any other KOMA-Script class or
                       % e.g. a standard class.

\usepackage[english]{babel}
\usepackage{blindtext}% for demo only

\usepackage[demo]{graphicx}% remove option `demo' at real life
\usepackage[svgnames]{xcolor}% to have colors (see http://ctan.org/pkg/xcolor)
\usepackage{eso-pic}% put things into background (see http://ctan.org/pkg/eso-pic)
\usepackage{marginnote}% non floating margin notes (see http://ctan.org/pkg/marginnote)

\AddToShipoutPicture{% from package eso-pic: put something to the background
  % 1. Background
  \AtPageLowerLeft{% put it at the left bottom of the page
    \color{LightGrey}\rule{\LenToUnit\paperwidth}{\LenToUnit\paperheight}%
  }%
  % 2. Headline
  \AtTextUpperLeft{% put it at the left top of the text area
    \put(0,\LenToUnit{\dimexpr\headsep-\dp\strutbox\relax}){% move it up
      \color{BurlyWood}\rule{\LenToUnit\textwidth}{\LenToUnit\headheight}%
    }%
  }%
  % 3. Text area
  \AtTextLowerLeft{% put it at the left bottom of the text area
    \color{LightSkyBlue}\rule{\LenToUnit\textwidth}{\LenToUnit\textheight}%
  }%
  % 4. Bottom
  \AtTextLowerLeft{% put it at the left bottom of the text area
    \put(0,\LenToUnit{\dimexpr-\footskip-\dp\strutbox\relax}){% move it down
      % Note: While there is no \footheight, I'm using \headheight here.
      \color{BurlyWood}\rule{\LenToUnit\textwidth}{\LenToUnit\headheight}%
    }%
  }%
}

\setcapindent{0pt}% The margin is too small for hanging captions.

\begin{document}
\chapter{Test}
\blindtext\marginnote{%
  \begin{minipage}{\marginparwidth}
    \includegraphics[width=\linewidth,height=5\baselineskip]{Test}\\
    \captionof{figure}{\hspace{0pt}Example figure}
  \end{minipage}
}

\blindtext

\blinddocument
\end{document}

Maybe using option mpinclude would be a good idea, if you have a lot of material at the margin (see KOMA-Script manual scrguien.pdf) for more information about this option). In this case, increasing \marginparwidth may or may not be a good idea.

If you would like to use text area + margin area for a figure or equation, you may use something like

\begin{addmargin*}[0pt]{\dimexpr \marginparsep+\marginparwidth\relax}
\begin{equation}
  f(x)=x^2
\end{equation}
\end{addmargin*}

addmargin and addmargin* are KOMA-Script environments. You may find them at the KOMA-Script manual.

I've used \dimexpr for some calculations at my example. You may find this at the e-TeX manual. An alternative would be to use package calc. To avoid all the \LenToUnit you may simply use package picture. Package picture extends LaTeX's picture environment and you may use lengths instead of numbers at \put, \makebox, \framebox etc.

share|improve this answer
    
Excellent. Just compiled it and looks quite similar to what i wanted. My heartfelt thanks. –  Asif Nov 17 '11 at 17:54
    
@Asif: In this case it would be nice, if you'd mark my answer to be the accepted answer. –  Schweinebacke Nov 18 '11 at 7:40
    
Just did that. Thanks a lot once again. –  Asif Nov 18 '11 at 22:54
    
The Colors are proper, although a bit misaligned to the text. However the margin image is not visible at all. Should I resize the margin or the image? –  Asif Nov 21 '11 at 0:50
    
In the Koma-SCript that I am using the margins are set specifically.. could this be the reason for misalignment\usepackage{vmargin} > \setpapersize{A4} > –  Asif Nov 21 '11 at 0:53
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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