[Tex/LaTex] Rotated, running text in right margin

rotating

I want to place some (large) text, rotated -90 degrees and running the right-hand margin.

After reviewing Chapter Title in rotated vertical box at the margin and the somewhat related (albeit for tables rather than standard text) post Rotated text in side margin, these aren't quite what I need.

It was suggested that I split this out as a stand-alone question, hence my post.

Best Answer

This is a tikz + fancyhdr way of getting things done. Here the text is automatically put on right of odd and left of even pages.

\documentclass[12pt,x11names,svgnames,twoside]{article}
\usepackage{tikz}
\usepackage{calc}
\usetikzlibrary{shapes.misc}
\usepackage{varwidth}
\usepackage{lipsum,fancyhdr}
\usepackage[a4paper,bindingoffset=.2in,left=1in,right=1in,top=1in,bottom=1in,headheight=\baselineskip,
   headsep=9mm,footskip=13mm,showframe]{geometry}

\fancypagestyle{sideheading}{%
  %% Clear all headers and footers
  \fancyhf{}
    %% Right headers on odd pages
  \fancyhead[RO]{%
      \begin{tikzpicture}[overlay,remember picture]
      \node[fill=NavyBlue!50,text=white,
      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)
      {\sffamily\nouppercase{Rotated, right margin running text which is
vertically centered and only for odd pages and this is going to be long}};
    \end{tikzpicture}
        }
        %% Left headers on even pages
\fancyhead[LE]{%
\begin{tikzpicture}[overlay,remember picture]
      \node[fill=magenta!50,text=white,
      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)
      {\sffamily\nouppercase{Rotated, right margin running text which is
vertically centered and only for even pages}};
    \end{tikzpicture}
        }
  \renewcommand{\headrulewidth}{0pt}
  \renewcommand{\footrulewidth}{0pt}
  \fancyfoot[R]{\thepage}
}
% ----------------------------------------------------------------
\pagestyle{sideheading}
\begin{document}
\lipsum[1-12]
\end{document} 

enter image description here

Related Question