I want to print text as you would a header on a page but rotated in the left/right margins of the page following a typical book format (print right on odd pages and print left on even pages) using class book and package fancyhdr. This includes page numbers.
A previous answer was a good start (found here: Rotated, running text in right margin?) and works as posted. However, it does not seem to work in my MWE.
My MWE produces:
- No text in margin on page 1 (text should be in right margin)
- A centered page number on page 1 (page number should be east)
- Text in margin appears on page 2 (this is correct)
- Page number on page 2 is east (should be west)
Similar issues with pages 3 and 4.
\documentclass[11pt,letterpaper]{book}
\usepackage[margin=1.00in,showframe]{geometry}
\usepackage{multicol}
\usepackage{fancyhdr}
\usepackage{lipsum}
\usepackage{calc}
\usepackage{varwidth}
\usepackage{tikz}
\usetikzlibrary{shapes.misc,calc}
\begin{document}
% PAGE MARGINS HEADER/FOOTER
\fancypagestyle{sideheading}{%
%% Clear all headers and footers
\fancyhf{}
%% Right headers on odd pages
\fancyhead[RO]{%
\begin{tikzpicture}[overlay,remember picture]
\node[text=black,
inner ysep=12pt, inner xsep=20pt,
rounded rectangle,
execute at begin node={\begin{varwidth}{\textheight}},%<====
execute at end node={\end{varwidth}},
rotate=-90]
at ([xshift=-13mm,yshift=0mm]current page.east)
{\Gid};
\end{tikzpicture}
}
%% Left headers on even pages
\fancyhead[LE]{%
\begin{tikzpicture}[overlay,remember picture]
\node[text=black,
inner ysep=12pt, inner xsep=20pt,
rounded rectangle,
execute at begin node={\begin{varwidth}{\textheight}},%<====
execute at end node={\end{varwidth}},
rotate=90]
at ([xshift=13mm,yshift=0mm]current page.west)
{\Gid};
\end{tikzpicture}
}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\fancyfoot[R]{\thepage}
}
\newcommand{\Gid}{}
\fancyhf{}
\chead{\Gid}
\pagestyle{sideheading}
\linespread{0.0}
\renewcommand{\Gid}{{\bf \Large MARGIN TEXT 1}}
\chapter{Insert Coin(s) To Begin}
\begin{multicols*}{2}
\lipsum
\end{multicols*}
\renewcommand{\Gid}{{\bf \Large MARGIN TEXT 2}}
\chapter{How To Handle Loss}
\begin{multicols*}{2}
\lipsum
\end{multicols*}
\end{document}




