1

How to make and control a side label similar like this? This example i made with code:

\multirow{1}{*}{\begin{sideways} {\small This is my very very very veryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryvery long message} \end{sideways}}

My method is ugly hack and works only for one page. And i want to control it similar like fancyhdr (example: turn on after title, and turn off in listoftables/listoffigures at the end)

Example image

1

You don't need fancyhdr for this. For example, you can use eso-pic to place content on the page arbitrarily. Below I've built an interface that places content on the left side of the page as needed:

enter image description here

\documentclass{report}
\usepackage{fancyhdr,lipsum,graphicx}
\usepackage{eso-pic}
\fancypagestyle{sidelabel}{% Not really needed
  \renewcommand{\headrulewidth}{0.4pt}
  \fancyfoot[C]{--\thepage--}
  }
\providecommand{\sidelabeltext}{}
\AddToShipoutPictureFG{% Place this content on the ForeGround of every page
  \AtTextCenter{%
    \hspace*{\dimexpr-.5\textwidth-\sidelabelsep}%
    \rotatebox{90}{%
      \makebox[0pt]{%
        \sidelabeltext%
      }%
    }%
  }%
}
\newlength{\sidelabelsep}
\setlength{\sidelabelsep}{\marginparsep}
\newcommand{\setsidelabeltext}[1]{\renewcommand{\sidelabeltext}{#1}}
\newcommand{\setsidelabelsep}[1]{\setlength{\sidelabelsep}{#1}}
\pagestyle{sidelabel}
\begin{document}
\setsidelabeltext{This is some side text}
\lipsum[1-6]
\setsidelabeltext{This is some very very very very very very very very very very very
  very very very very very very very very very very very very very long side text}%
\setsidelabelsep{0.5in}
\lipsum[1-6]
\setsidelabeltext{}
\lipsum[1-6]
\setsidelabeltext{This is some side text}%
\setsidelabelsep{20pt}
\lipsum[1-6]
\end{document}

\setsidelabeltext{<stuff>} updates what is printed on the left of the page, while \setsidelabelsep{<len>} updates the length that <stuff> is printed from the text. Default is \marginparsep.

| improve this answer | |
1

Here's a way to do it with fancyhdr. With \setsideheader you tell what text should be printed from the point on.

\documentclass[a4paper]{report}

\usepackage{fancyhdr}
\usepackage{graphicx}
\usepackage{lipsum}

\pagestyle{fancy}
\renewcommand{\headrulewidth}{0pt} % no rule
\fancyhf{} % clear all fields
\fancyhead[L]{\printcurrentsideheader}
\fancyfoot[C]{\thepage}

\newcommand\setsideheader[1]{\gdef\currentsideheader{#1}}

\newcommand{\printcurrentsideheader}{%
  \hspace*{-3em}%
  \smash{%
    \rotatebox[origin=Br]{90}{%
      \makebox[\textheight]{\currentsideheader}\hspace{\headsep}%
    }%
  }%
}

\begin{document}

\chapter{A title}
\setsideheader{Some long text that goes in the side margin}

\lipsum[1-20]

\chapter{A title}
\setsideheader{Some long text that goes in the side margin for chapter 2}

\lipsum[1-20]

\clearpage
\pagestyle{plain}

\tableofcontents

\end{document}

enter image description here

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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