0

enter image description here

\documentclass[twoside]{book}
\usepackage{fancyhdr}

\makeatletter
\newenvironment{tablehere}
{\def\@captype{table}}
{}
\makeatother


\fancyhead{}
\fancyhead[RO, LE]{\framebox[9\width][s]{se separan}}


\fancyfoot{}
\fancyfoot[LE, RO]{\thepage}
\fancyfoot[LO, CE]{Chapter \thechapter}

\makeatletter
\let \ps@plain\ps@fancy
\makeatother

\pagestyle{fancy}

\begin{document}
%  \input{title}

  \chapter{Introduction}
  ...

  \chapter{Background}
  ...

  \chapter{Conclusion}
  ...

  \newpage
  afjdajf
  \newpage
  sagfajg

\end{document}

enter image description here

2
  • 1
    Please don't shout in the question title (avoid ALL UPPERCASE text). And skip the “please help me” bit: People will be less inclined to help because of it. Skip the “thank you” as well: The way to thank people around here is to upvote and/or accept their answer if you find it useful. Also, if you indent your code by four spaces, it will be appropriately displayed. You can achieve that very simply by selecting the code and hitting the { } button above the input field. (I see that a helpful person has already implemented my advice. Good.) Sep 25, 2018 at 20:28
  • OKEY @HaraldHanche-Olsen. Sep 25, 2018 at 20:54

1 Answer 1

2

For diagonal lines, you need TikZ. Also, fancyhdr tends to change \headheight from one page to the next, so I used \myheight instead. (TikZ draws slightly outside the bounds.) The strut is used to align the page number and "Chapter".

Needless to say, you can always adjust the position of the text relative to the tikz coordinates.

\documentclass[twoside]{book}
\usepackage{fancyhdr}
\usepackage{tikz}

\makeatletter
\newenvironment{tablehere}
{\def\@captype{table}}
{}
\makeatother

\newlength{\myheight}% fancyhdr changes \headheight from one page to the next.
\setlength{\myheight}{\dimexpr \ht\strutbox+\dp\strutbox+.666em}
\setlength{\headheight}{\dimexpr \myheight+0.5pt}% width of tikz lines

\fancyhead{}
\fancyhead[CE]{\begin{tikzpicture}
  \path[draw=black,fill=orange]  
    (0,0) -- (.7\textwidth,0) -- (.8\textwidth,\myheight) -- (0,\myheight) -- cycle;
  \path[draw=black,fill=gray]
    (.7\textwidth,0) -- (\textwidth,0) -- (\textwidth,\myheight) -- (.8\textwidth,\myheight) -- cycle;
  \path (0,0) node[above right] {\chaptername~\thechapter\strut}
    (\textwidth,0) node[above left] {\thepage\strut};
  \end{tikzpicture}}
\fancyhead[CO]{\begin{tikzpicture}\path[draw=black,fill=gray]
    (0,0) -- (.3\textwidth,0) -- (.2\textwidth,\myheight) -- (0,\myheight) -- cycle;
  \path[draw=black,fill=orange]
    (.3\textwidth,0) -- (\textwidth,0) -- (\textwidth,\myheight) -- (.2\textwidth,\myheight) -- cycle;
  \path (0,0) node[above right] {\thepage\strut}
    (\textwidth,0) node[above left] {\chaptername~\thechapter\strut};
  \end{tikzpicture}}

\makeatletter
\let \ps@plain\ps@fancy
\makeatother

\pagestyle{fancy}

\begin{document}
%  \input{title}

  \chapter{Introduction}
  ...

  \chapter{Background}
  ...

  \chapter{Conclusion}
  ...

  \newpage
  afjdajf
  \newpage
  sagfajg

\end{document}
1
  • merci @John Kormylo Sep 26, 2018 at 10:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .