Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question

5 Answers 5

up vote 9 down vote accepted

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

share|improve this answer
    
Nice solution, and it works across multiple pages. –  JohnD May 8 '12 at 13:45

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}

enter image description here

share|improve this answer
    
Thanks, I have not used the background package before. –  JohnD May 8 '12 at 2:32

You can redefine new headings for these particular pages:

enter image description here

\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}
% redefine headings
\def\ps@samplepage{\let\@mkboth\@gobbletwo
 \let\@oddhead\odd@samplepage\def\@oddfoot{\reset@font\hfil\thepage}
 \let\@evenhead\even@samplepage\def\@evenfoot{\reset@font\thepage\hfil}}
%%
%% 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}
share|improve this answer
    
Using rotating.sty is new to me. I will try this too. Thanks! –  JohnD May 8 '12 at 3:24

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,

enter image description here

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

framed version

share|improve this answer
    
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

In this example, using the background package, we can place text anywhere on the page, for this two commands \Texta and \Textb to indicate the texts that go into odd and even pages are created respectively. (fancy can be used specifically for headers and footers)

Código

\documentclass[11pt,twoside,fleqn]{book} 
\usepackage[top=2.4cm,bottom=2.5cm,left=2.5cm,right=2.5cm,headsep=15pt,a4paper]{geometry} % page margins
\usepackage{lipsum} 
\usepackage{palatino} %font
\usepackage{xcolor} % for colors
%----------------------------------------
\usepackage{ifthen}
\definecolor{Extrem}{rgb}{0.79,0.06,0.28}
\usepackage[contents={},opacity=1,scale=1.5,color=Extrem]{background}
\newcommand\Texta{\bf\large text on the right side of the page} % odd page
\newcommand\Textb{\bf\large text on the left side of the page} % even pages
%-----------------------------------------
\AddEverypageHook{%
\ifthenelse{\isodd{\value{page}}}% impar
{\backgroundsetup{
angle=90,
position={0.72\textwidth,-0.3\textheight},
contents={\Texta}
}%
}%
%-----------------------------------------
{\backgroundsetup{
angle=90,
position={-0.05\textwidth,-0.3\textheight},
contents={\Textb}
}%
}%
\BgMaterial}
%-----------------------------------------
\begin{document}
\lipsum[1-20]
\end{document}

vista previa

share|improve this answer
2  
Could you elaborate in terms of your answer rather than just pasting code? –  Werner Sep 14 at 1:28
1  
Please add some explanatory context to help readers understand your attempt. –  Jesse Sep 14 at 2:48

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.