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 print my document on A5 paper. I have a template with header and footer. Now, my laserjet printer is spoiling the page by leaving black marks on left margin. How can I draw a black vertical strip of 5 mm width on the left margin to hide these marks?

share|improve this question

2 Answers 2

up vote 8 down vote accepted

With background package.

\documentclass[a5paper]{article}

\usepackage{background}
\usetikzlibrary{calc}
\newsavebox\mybox
\sbox\mybox{%
\begin{tikzpicture}[remember picture]
    \fill[black] (current page.north west) rectangle ($(current page.south west) +(5mm,0)$);
\end{tikzpicture}%
}
\backgroundsetup{
angle=0,
scale=1,
opacity=1,
color=black,
contents={%
\begin{tikzpicture}[remember picture, overlay]
    \node[anchor=west] at  (current page.west) {\usebox{\mybox}};
\end{tikzpicture}%
}
}
\begin{document}

\section{A section}
Some text\newpage

\section{Another section}
Some text

\end{document} 

enter image description here

share|improve this answer
    
Why the extra box and the three levels of nesting tikzpictures (the package already uses one)? It's enough to say \backgroundsetup{ angle=0, scale=1, opacity=1, color=black, contents={ \begin{tikzpicture}[remember picture,overlay] \fill[black] (current page.north west) rectangle ([xshift=5mm]current page.south west); \end{tikzpicture} } }; the calc library also isn't required. –  Gonzalo Medina Mar 20 at 12:15
    
@GonzaloMedina box is used with an intention to reduce load. And xshift is a good idea. Using calc has been a habit for me though :) Thanks. :) –  Harish Kumar Mar 21 at 2:32

With the help of \AddToShipoutPictureBG from the eso-pic package, we draw a black rectangle at the shipout of every page.

MWE

\documentclass[a5paper]{article}

\usepackage{tikzpagenodes}
\usetikzlibrary{calc}

\usepackage{eso-pic}
\AddToShipoutPictureBG{%
\begin{tikzpicture}[remember picture, overlay]
    \fill[black] (current page.north west) --
                 ($(current page.north west) +(5mm,0)$) --
                 ($(current page.south west) +(5mm,0)$) --
                 (current page.south west);
\end{tikzpicture}%
}

\begin{document}

\section{A section}
Some text\newpage

\section{Another section}
Some text

\end{document} 

Output

enter image description here

share|improve this answer
    
Can we make the open side wavy ribbon like? –  Vaibhav Mar 19 at 9:56
    
@user34083 this goes beyond my tikz knowledge... Please ask a follow-up question for this. –  karlkoeller Mar 19 at 9:58

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.