[Tex/LaTex] Vertical (rotated) titles in margins

contextmarginsrotatingtitles

I want to write the chapter title or section subject in the margin of each page.

I eventually managed to get some working code :

\setuplayout[edge=3cm,margin=3cm,backspace=7cm,height=27cm]
\setuptexttexts[edge][subject][subject]
\setuptext[edge][style=\rmd\sc]
\starttext
  \rotate[rotate=270]{\subject{\rotate[rotation=90]{Some title}}}
\stoptext

I can play with the edge, margin and backspace width to adjust the position of the text with regard to the edge of the page and of the main text, but aren't there other/better options to fine-tune the position of the text within the margin or the edge ? I tried \setuptext[edge][after={\blank[2cm]}] without success.

But most of all, how can I make the title vertical in the edge/margin without having to define the title as rotated ? I.e., how do I define the rotation inside \setuptext and thus avoid the ugly double rotation (which has unwanted effect I did't try to solve when using the \section numbered version of \subject — the section number rotation is off by 90° ; it has also side effects when setting an image as the background of the title page) ?

Desired output

The title has a page of its own (where it's printed horizontally like normal text). On the other pages it should be written vertically on the side (like a header). E.g. for a left page :

Page example
(source: toile-libre.org)

On the right page the title should be oriented the opposite way (the top of the title always facing the nearest page border).

For future reference

It may be worth mentioning that \setuptexttexts and \setuptext are part of a series of commands :

  • \setuptoptexts and \setuptop ;
  • \setupheadertexts and \setupheader ;
  • \setuptexttexts and \setuptext ;
  • \setupfootertexts and \setupheader ;
  • \setupbottomtexts and \setupbottom.

See section 4.16 (Headers and footers) of the ConTeXt reference manual (svnversion 329, September 27, 2013) for further reading.

Update

I thought I had found the solution, \setuphead having a textcommand argument. However the following does not seem to have any effect :

\def\RotateTitle#1{\rotate[rotation=90]{#1}}
\setuptext[edge][style=\rmd\sc,color=white,textcommand={\RotateTitle}]

(neither do command or deeptextcommand arguments).

Best Answer

To get markings for the margins, you need:

\setuptexttexts[margin][...][...][...][...]

For example, the following show the section title on the left margin of the left page and right margin of the right page.

\setuppagenumbering[alternative=doublesided]
\setuptexttexts[margin][section][][][section]
\showlayout

\setuphead[subject][alternative=inmargin]

\showframe

\starttext
\section{Tufte}
\input tufte
\page
\section{Tufte}
\input tufte
\stoptext

Now, the rest is simply to figure out the correct rotation. I use \framed because it is easier to control the width of the box, but you can use \rotate and manual setting of the box width as well:

\setuppagenumbering[alternative=doublesided]
\setuptexttexts[margin][\setups{left}][][][\setups{right}]

\startsetups left
  \framed[strut=no,align=high,height=\rightmarginwidth, orientation=90]{\getmarking[section]}
\stopsetups

\startsetups right
  \framed[strut=no,align=high,height=\rightmarginwidth, orientation=-90]{\getmarking[section]}
\stopsetups

\setuplayout
  [
    backspace=1in,
    cutspace=1in,
    width=middle,
    leftmargin=0.75in,
    rightmargin=0.75in,
  ]

\setuphead[subject][alternative=inmargin]

\showframe

\starttext

\section{Tufte}
\input tufte
\page
\section{Tufte}
\input tufte
\section{Tufte}
\input tufte

\stoptext

which gives

enter image description here

If you want more control over the location, another option is to use \setlayer.

Related Question