# Rotated, running text in right margin?

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.

-

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}

%% Clear all headers and footers
\fancyhf{}
%% Right headers on odd pages
\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
\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{\footrulewidth}{0pt}
\fancyfoot[R]{\thepage}
}
% ----------------------------------------------------------------
\begin{document}
\lipsum[1-12]
\end{document}


-
Nice solution, and it works across multiple pages. –  JohnD May 8 '12 at 13:45

You can redefine new headings for these particular pages:

\documentclass{scrbook}
\usepackage{lipsum,xcolor}
\IfFileExists{rotating.sty}{\RequirePackage{rotating}}{}
\makeatletter
\def\even@samplepage{%
\begin{picture}(0,0)
\put(\Xeven,\Yeven){\turnbox{90}{\Huge \textcolor{\watermark@textcolor}{\watermark@text}}}
\end{picture}
}
%% Define a macro to print SAMPLE PAGE IN THE MARGIN
\def\odd@samplepage{%
\begin{picture}(0,0)
\put(\Xodd,\Yodd){\turnbox{90}{\Huge \textcolor{\watermark@textcolor}{\watermark@text}}}
\end{picture}
}
%  Define the watermark words
\def\watermarktext#1{\gdef\watermark@text{\fontfamily{phv}\selectfont#1}}
\def\watermarktextcolor#1{\gdef\watermark@textcolor{#1}}
\watermarktext{SAMPLE PAGE}
\watermarktextcolor{purple}
\def\ps@samplepage{\let\@mkboth\@gobbletwo
%%
%% We define two macros to position the watermark on the page
\def\Xodd{500}
\def\Xeven{-70}\def\Yeven{-810}
\def\Yeven{-\expandafter\strip@pt\textheight}
\let\Yodd\Yeven
\makeatother
\begin{document}
\pagestyle{samplepage}
\lipsum
\end{document}


You can change the text and color using:

  \watermarktext{SAMPLE PAGE}
\watermarktextcolor{blue}

-
Using rotating.sty is new to me. I will try this too. Thanks! –  JohnD May 8 '12 at 3:24

The background package lets you place any kind of material (in particular, text) in any given position of somo or all of the pages of your document, and gives you complete and easy control over the attributes of the material to be displayed; here's a simple example:

\documentclass{book}
\usepackage[centering]{geometry}
\usepackage{background}
\usepackage{lipsum}

\definecolor{textcolor}{HTML}{0A75A8}
\newcommand\Text{Some text that should appear in the right margin}

\SetBgColor{textcolor}
\SetBgOpacity{1}
\SetBgAngle{90}
\SetBgPosition{current page.center}
\SetBgVshift{-0.36\textwidth}
\SetBgScale{1.8}
\SetBgContents{\sffamily\Text}

\begin{document}

\lipsum[1-20]

\end{document}


-
Thanks, I have not used the background package before. –  JohnD May 8 '12 at 2:32

Here's a basic solution using tikz, in case it helps someone else...

\documentclass{exam}
\usepackage{tikz}
\usepackage{lipsum}

\pagestyle{empty}

\begin{document}

\tikz[remember picture, overlay]\node at (current page.east)
[xshift=-1cm, rotate=-90]{\bf \LARGE Rotated, right margin running text which is
vertically centered.};

\lipsum[1-8]

\newpage

\tikz[remember picture, overlay]\node at (current page.east)
[xshift=-1cm, rotate=-90]{\fboxrule=1pt
\framebox[1.05\width][c]{\bf \LARGE Rotated, right margin running text,
vertically centered, with a frame.}};

\lipsum[1-8]

\end{document}


I was interested in both a regular, un-framed version,

as well as a framed version, so I'll show both.

-
Note that the background package internally uses TikZ. –  Gonzalo Medina May 8 '12 at 2:47
You have to redefine that text for every page (big disadvantage). See my answer. –  Harish Kumar May 8 '12 at 7:44
You are right, Harish. However, in my instance, I only needed it on one page. Of course, others' mileage may vary. –  JohnD May 8 '12 at 13:44