How can I draw this is figure?
\documentclass[12pt]{book}
\usepackage[top=25mm,bottom=25mm,left=25mm,right=25mm]{geometry}
\usepackage[all]{background}
\usepackage{ptext,xcolor}
%\usepackage{showframe}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{changepage}
\strictpagecheck
\usepackage{fancyhdr}
\fancyhf{}
\fancyhead[LO,RE]{\thepage}
\fancyhead[LE]{عنوان کتاب}
\fancyhead[RO]{\leftmark}
\renewcommand{\headrulewidth}{0pt}
\pagestyle{fancy}
\usepackage{xepersian}
\settextfont[Scale=1.2]{Yas}
\linespread{1.5}
\newcommand*{\vsp}{2cm}
\newcommand*{\hsp}{2.5cm}
\newcommand{\MyTikzLogo}{%
\begin{tikzpicture}[remember picture,overlay]
\checkoddpage
\ifoddpage
\draw [color=magenta,line width=1mm] ($(\paperwidth+\hsp,-\vsp)$) --($(\hsp,-\vsp)$);
\else
\draw [color=cyan,line width=1mm] ($(0,-\vsp)$) --($(\paperwidth-\hsp,-\vsp)$);
\fi
\end{tikzpicture}
}
\SetBgContents{\MyTikzLogo}
\SetBgPosition{current page.north west}
\SetBgOpacity{1.0}
\SetBgAngle{0.0}
\SetBgScale{1.0}
\begin{document}
\chapter{titel}
\section{sec }
\ptext[1-40]
\end{document}
Best Answer
I would not use the background in this case. My proposal is to stick the decoration in the command that prints the page number, and use a
tikzpicture
with a controlled bounding box.The following is a start --- I did only the upper part, the bottom one should be easier. I removed the Parsi things (I do not have the fonts).
To obtain:
The trick here is the
use as bounding box
thing (you can use it in ascope
if you need more thing) so thatfancyhdr
is convinced that the size of the picture is just the size of the diamond with the page number.I had to increase the size of the header, obviously, too. The code should be cleaned upt to not to use all these constants, but hey, that's left as an exercise to the reader...
update with a new shape --- this shows the use of anchors, so it's quite educational, I think... changing:
will give you: