如何制作侧面标签

如何制作侧面标签

如何制作和控制类似这样的侧标签?我用代码制作了这个示例:

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

我的方法是丑陋的黑客,仅适用于一个页面。我想像 fancyhdr 一样控制它(例如:在标题后打开,在末尾的 listoftables/listoffigures 中关闭)

示例图像

答案1

你不需要fancyhdr例如,您可以使用eso-pic可以任意在页面上放置内容。下面我构建了一个界面,可以根据需要在页面左侧放置内容:

在此处输入图片描述

\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>}更新打印在页面左侧的内容,而更新打印在文本中的\setsidelabelsep{<len>}长度。默认值为。<stuff>\marginparsep

答案2

这是使用 来实现此目的的方法fancyhdr\setsideheader使用 可以告诉您从该点开始应该打印哪些文本。

\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}

在此处输入图片描述

相关内容