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.

here's my MWE:

\documentclass{book}
\usepackage{lipsum}
\usepackage{fmtcount}
\FCloadlang{ngerman}
\usepackage[many]{tcolorbox}
\usepackage{calc}
\usetikzlibrary{positioning,shapes.misc,calc}
\usepackage[scale=1,angle=0,opacity=1]{background}
\usepackage{ifthen}
\usepackage{xcolor}

\definecolor{mp}{RGB}{240,240,240}

\SetBgScale{1}
\SetBgAngle{0}
\SetBgOpacity{1}
\SetBgContents{}

\newcounter{partshift}
\addtocounter{partshift}{-1}
\newcommand{\maxpart}{9}

\makeatletter
  \newcommand{\parttitle}{}
  \def\@part[#1]#2{%
    \renewcommand{\parttitle}{#1}\pf
      \ifnum \c@secnumdepth >-2\relax
        \refstepcounter{part}%
        \addcontentsline{toc}{part}{\bfseries\color{gray}\Ordinalstring{part}~\partname:\hspace{0.5em}#1}%
      \else
        \addcontentsline{toc}{part}{#1}%
      \fi
      \markboth{}{}%
      {\centering
       \interlinepenalty \@M
       \normalfont
       \ifnum \c@secnumdepth >-2\relax
         \huge\Ordinalstring{part}\nobreakspace\partname
         \par
         \vskip 20\p@
       \fi
       \bfseries\color{gray}\fontsize{28}{30}\selectfont #2\par}%
      \@endpart}

\newcommand\pf{%
  \AddEverypageHook{%
    \ifthenelse{\isodd{\thepage}}
    {\SetBgContents{%
      \begin{tikzpicture}[overlay,remember picture]
      \node[
                fill=mp,
                inner sep=0pt,
                rounded rectangle,
                text width=5mm,
        text height=\paperheight/\maxpart,
                align=center,
                anchor=north east] at
                    ($ (current page.north east) + (1mm,-\thepartshift*\paperheight/\maxpart) $){};
      \end{tikzpicture}}%
    }
    {\SetBgContents{%
      \begin{tikzpicture}[overlay,remember picture]
      \node[
                fill=mp,
                inner sep=0pt,
                rounded rectangle,
                text width=5mm,
        text height=\paperheight/\maxpart,
                align=center,
                anchor=north west] at 
                    ($ (current page.north west) + (-1mm,-\thepartshift*\paperheight/\maxpart) $){};
      \end{tikzpicture}}
    }
    \bg@material}%
    \stepcounter{partshift}
}
\makeatother

\begin{document}

\part{A}
\chapter{a1}

\part{B}
\chapter{b1}
\lipsum[1-7]

\part{C}
\chapter{c1}
\lipsum[1-7]

\end{document}

enter image description here

I'd like to make it look like the right one

enter image description here

How can I do that?

share|improve this question
    
Can you please describe in a little more detail what exactly do you want? Do you want all your pages to have a decoration like the one on the image to the right? The decoration is just the oval figure or also the darker stripe extending all the paper height? –  Gonzalo Medina Apr 30 at 2:18
    
I just added one more picture. I just want to change the shape to look like a real rounded rectangle (and not a circle) –  Moldevort Apr 30 at 2:20
    
why are you using the old syntax for background? What version of the package are you using? By the way, I posted an answer drawing the exact shape required, in case you are interested. –  Gonzalo Medina Apr 30 at 2:51
    
What old syntax do you mean? It is working, the way I posted and Harish Kumar replied. Is there any reason, I should use the new one? –  Moldevort Apr 30 at 12:59
    
The \SetBg... family of commands were the ones I used for the first versions of the package; since version 2.0 I changed to a more convenient syntax using a key=value mechanism (in my answer you can see the code using the new syntax). The old commands are still fully functional though, but modern document should use the new syntax. (Cont.) –  Gonzalo Medina Apr 30 at 17:23

2 Answers 2

up vote 5 down vote accepted

You can use

            rectangle,
            rounded corners=2ex,  %% adjust 2ex

to get it. I have also increased the minimum width and the coordinates as in

 minimum width=1cm,
 .
 .
 anchor=north east] at
                ($ (current page.north east) + (5mm,-\thepartshift*\paperheight/\maxpart) $){};

Note 5mm and -5mm (in even page). You may adjust these values accordingly.

\documentclass{book}
\usepackage{lipsum}
\usepackage{fmtcount}
\FCloadlang{ngerman}
\usepackage[many]{tcolorbox}
\usepackage{calc}
\usetikzlibrary{positioning,shapes.misc,calc}
\usepackage[scale=1,angle=0,opacity=1]{background}
\usepackage{ifthen}
\usepackage{xcolor}

\definecolor{mp}{RGB}{240,240,240}

\SetBgScale{1}
\SetBgAngle{0}
\SetBgOpacity{1}
\SetBgContents{}

\newcounter{partshift}
\addtocounter{partshift}{-1}
\newcommand{\maxpart}{9}

\makeatletter
  \newcommand{\parttitle}{}
  \def\@part[#1]#2{%
    \renewcommand{\parttitle}{#1}\pf
      \ifnum \c@secnumdepth >-2\relax
        \refstepcounter{part}%
        \addcontentsline{toc}{part}{\bfseries\color{gray}\Ordinalstring{part}~\partname:\hspace{0.5em}#1}%
      \else
        \addcontentsline{toc}{part}{#1}%
      \fi
      \markboth{}{}%
      {\centering
       \interlinepenalty \@M
       \normalfont
       \ifnum \c@secnumdepth >-2\relax
         \huge\Ordinalstring{part}\nobreakspace\partname
         \par
         \vskip 20\p@
       \fi
       \bfseries\color{gray}\fontsize{28}{30}\selectfont #2\par}%
      \@endpart}

\newcommand\pf{%
  \AddEverypageHook{%
    \ifthenelse{\isodd{\thepage}}
    {\SetBgContents{%
      \begin{tikzpicture}[overlay,remember picture]
      \node[
                fill=mp,
                inner sep=0pt,
                rectangle,
                rounded corners=2ex,
                text width=5mm,
                minimum width=1cm,
        text height=\paperheight/\maxpart,
                align=center,
                anchor=north east] at
                    ($ (current page.north east) + (5mm,-\thepartshift*\paperheight/\maxpart) $){};
      \end{tikzpicture}}%
    }
    {\SetBgContents{%
      \begin{tikzpicture}[overlay,remember picture]
      \node[
                fill=mp,
                inner sep=0pt,
                rectangle,
                rounded corners=2ex,
                text width=5mm,
                minimum width=1cm,
        text height=\paperheight/\maxpart,
                align=center,
                anchor=north west] at
                    ($ (current page.north west) + (-5mm,-\thepartshift*\paperheight/\maxpart) $){};
      \end{tikzpicture}}
    }
    \bg@material}%
    \stepcounter{partshift}
}
\makeatother

\begin{document}

\part{A}
\chapter{a1}

\part{B}
\chapter{b1}
\lipsum[1-7]

\part{C}
\chapter{c1}
\lipsum[1-7]

\end{document}

enter image description here

share|improve this answer

Here's a solution which doesn't imply guessing lengths and draws the exact required shape (This other answer just draws a full rectangle but half of it falls outside the page). This solution also uses the new syntax for the background package:

\documentclass{book}
\usepackage{lipsum}
\usepackage{fmtcount}
\FCloadlang{ngerman}
\usepackage[many]{tcolorbox}
\usepackage{calc}
\usetikzlibrary{positioning,shapes.misc,calc}
\usetikzlibrary{chains,qrr.shapes.openrectangle}
\usepackage[scale=1,angle=0,opacity=1,contents={}]{background}
\usepackage{xcolor}

\definecolor{mp}{RGB}{240,240,240}

\newcounter{partshift}
\addtocounter{partshift}{-1}
\newcommand{\maxpart}{9}

\makeatletter
  \newcommand{\parttitle}{}
  \def\@part[#1]#2{%
    \renewcommand{\parttitle}{#1}\pf
      \ifnum \c@secnumdepth >-2\relax
        \refstepcounter{part}%
        \addcontentsline{toc}{part}{\bfseries\color{gray}\Ordinalstring{part}~\partname:\hspace{0.5em}#1}%
      \else
        \addcontentsline{toc}{part}{#1}%
      \fi
      \markboth{}{}%
      {\centering
       \interlinepenalty \@M
       \normalfont
       \ifnum \c@secnumdepth >-2\relax
         \huge\Ordinalstring{part}\nobreakspace\partname
         \par
         \vskip 20\p@
       \fi
       \bfseries\color{gray}\fontsize{28}{30}\selectfont #2\par}%
      \@endpart}

\newcommand\pf{%
\AddEverypageHook{%
  \ifodd\value{page}\relax
  \backgroundsetup{contents={%
      \begin{tikzpicture}[overlay,remember picture]
      \node[
                shape=open rectangle,
                rounded corners=20pt,
                open rectangle fill=mp,
                open rectangle sides=nws,
                align=center,
                inner sep=0pt,
                text width=10mm,
                text height=\paperheight/\maxpart,
                anchor=north east,
                ] at
                    ( $ (current page.north east) + (1mm,-\thepartshift*\paperheight/\maxpart) $){};
      \end{tikzpicture}}}%
    \else
  \backgroundsetup{contents={%
      \begin{tikzpicture}[overlay,remember picture]
      \node[
                shape=open rectangle,
                rounded corners=20pt,
                open rectangle fill=mp,
                open rectangle sides=ens,
                text width=10mm,
                text height=\paperheight/\maxpart,
                align=center,
                anchor=north west
                ] at 
                    ($ (current page.north west) + (-1mm,-\thepartshift*\paperheight/\maxpart) $){};
      \end{tikzpicture}}}
    \fi  
    \BgMaterial}%
    \stepcounter{partshift}
}
\makeatother

\begin{document}

\part{A}
\chapter{a1}

\part{B}
\chapter{b1}
\lipsum[1-7]

\part{C}
\chapter{c1}
\lipsum[1-7]

\end{document}

enter image description here

The code used the libraries:

written by Qrrbrbirlbel.

Following the links, download the files and save them somewhere TeX can find them (the current working directory is the easiest place).

share|improve this answer

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.