LaTeX forum ⇒ XeTeXColour coded Page Tabs

Information and discussion about XeTeX, an alternative for pdfTeX based on e-Tex
paulsp
Posts: 2
Joined: Wed Jun 26, 2013 12:24 pm

Colour coded Page Tabs

Postby paulsp » Fri Nov 15, 2013 6:53 pm

Hello,

could someone please offer some help? I'm trying to create colour coded page tabs in a report, so that when it is printed there will be different colour rectangles along the edge of each page. Different colours for each section. The name of the section will also appear in the tabs.

Here is the code I have so far. It almost works, but there are tabs appearing on blank pages. Also it does not seem to pick up the name of the section until a page or two after the section has started. Any Ideas anyone?

  1. \documentclass[10pt,x11names,svgnames,twoside]{book}
  2. \usetikzlibrary{calc}
  3. \usepackage{lipsum}
  4. \usepackage[
  5. a4paper,
  6. left=1.2in,
  7. right=1in,
  8. top=1in,
  9. bottom=1in,
  10. headheight=\baselineskip,
  11. headsep=9mm,
  12. footskip=13mm,
  13. showframe
  14. ]{geometry}
  15. \usepackage{tikz}
  16. \usetikzlibrary{shapes.misc}
  17.  
  18. \newcommand\MyColor{%
  19. \ifcase\thesection
  20. blue!30\or red!30\or olive!30\or magenta!30%
  21. \else
  22. green!30%
  23. \fi%
  24. }
  25.  
  26. \fancypagestyle{plain}{%
  27. %% Clear all headers and footers
  28. \fancyhf{}
  29.  
  30. %% Left headers on odd pages
  31. \fancyhead[LO]{%
  32. \rotatebox{90}{%
  33. \begin{tikzpicture}[overlay,remember picture]
  34. \node[
  35. fill=\MyColor,
  36. text=white,
  37. font=\small,
  38. inner ysep=2pt,
  39. inner xsep=2pt,
  40. outer sep=0,
  41. rectangle,
  42. anchor=west,
  43. xshift=-70mm,
  44. yshift=5mm,
  45. text width= 5.75cm,
  46. text height=0.75cm,
  47. minimum height=1cm,
  48. maximum height=1cm,
  49. minimum width=6cm,
  50. maximum width=6cm,
  51. ] at ($ (current page.north west) + (1cm,0cm) + (-1*\thesection cm,0cm) $)
  52. {\sffamily\itshape\small\nouppercase{\leftmark}};
  53. \end{tikzpicture}%
  54. }%
  55. }
  56.  
  57. %% Right headers on even pages
  58. \fancyhead[RE]{%
  59. \rotatebox{90}{%
  60. \begin{tikzpicture}[overlay,remember picture]
  61. \node[
  62. fill=\MyColor,
  63. text=white,
  64. font=\small,
  65. inner ysep=2pt,
  66. inner xsep=2pt,
  67. outer sep=0,
  68. rectangle,
  69. anchor=east,
  70. xshift=-51mm,
  71. yshift=-26mm,
  72. text width= 5.75cm,
  73. text height=0.75cm,
  74. minimum height=1cm,
  75. maximum height=1cm,
  76. minimum width=6cm,
  77. maximum width=6cm,
  78. ] at ($ (current page.north east) + (1cm,0cm) + (-1*\thesection cm,0cm) $)
  79. {\sffamily\itshape\small\nouppercase{\leftmark}};
  80. \end{tikzpicture}%
  81. }%
  82. }
  83. \renewcommand{\headrulewidth}{0pt}
  84. \renewcommand{\footrulewidth}{0pt}
  85. \fancyfoot[R]{\thepage}
  86.  
  87. \pagestyle{plain}
  88. \renewcommand\sectionmark[1]{\markboth{\thesection.~#1}{}}

Return to “XeTeX”

Who is online

Users browsing this forum: No registered users and 1 guest