1

I am creating a document with the titleps package and was wondering if anyone could suggest a code that replicates a faded grey headrule such as that created with fancyhdr in fading tikz fancyhdr problem in book printing. The code below gives the basic structure of the headers in my document

\setheadrule{0pt}% Header rule
\sethead[\textbf{\thepage} Abstract Algebra]% even left
[]% even centre
[]% even right
{}% odd left
{}% odd centre
{\chaptertitle \textbf{\thepage}}% odd right

I tried to make a new command with \makeheadrule but to no avail. Tikz seems to be the way forward but I'm having trouble figuring it out. I'd like the faded line to be the same length as the bit of text in the header which it underlines, as in the link provided.

2

enter image description here

enter image description here

\documentclass{book}
\usepackage{amssymb}
\usepackage{titleps}
\usepackage{tikz}
\usetikzlibrary{fadings}

\newpagestyle{main}%
  {\sethead
   [\textbf{\thepage} Abstract Algebra]% even left
   []% even centre
   []% even right
   {}% odd left
   {}% odd centre
   {\chaptertitle\ $\thicksim$ \textbf{\thepage}}% odd right
  }
\pagestyle{main}

\renewcommand\makeheadrule
  {\raisebox{-.3\baselineskip}%
    {\ifodd\count0%
       \makebox[\textwidth][r]%
         {\tikz\fill[darkgray,path fading=west] (0,0) rectangle (4.98,0.02);}%
     \else
       \makebox[\textwidth][l]%
         {\tikz\fill[darkgray,path fading=east] (0,0) rectangle (4.98,0.02);}%
     \fi
    }%
  }

\usepackage{blindtext}
\begin{document}
\chapter{First chapter}
\Blindtext[20]
\end{document}

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.