如何将页码作为侧注?

如何将页码作为侧注?

可能重复:
页码在外页边距垂直居中

我想将数字放在页面边缘,但与顶部边缘保持一定距离(可能也符合规则)。下图显示了一个示例(来自 MS Word...:

在此处输入图片描述

答案1

您可以使用 tikz 和 scrpage2。我得到了以下结果:

在此处输入图片描述

代码如下:

\documentclass[twoside]{scrartcl}
% also works with oneside option and with non Koma Class like article

% Package used for custom page numbers
\usepackage{scrpage2}

% package for drawing
\usepackage{tikz}

% package used for tests
\usepackage{etoolbox}

% Define lemon color
\definecolor{lemon}{HTML}{cedead}

% Sep up Page numbering font
\renewcommand*{\pnumfont}{%
    \normalfont\sffamily\Large\color{black!40}}

% create new custom page style "fancy"
\newpagestyle{fancy}{%
    {} %head twoside even
    {} %head twoside odd
    {} %head oneside
    }{%
    {\tikzpagemark[e]} %foot twoside even
    {\hfill\tikzpagemark} %foot twoside odd
    {\hfill\tikzpagemark} %foot oneside}
} 

% This command creates the custom page numbers
% If optional parameter is used \tikzpagemark creates pagemark for the left side
\newcommand{\tikzpagemark}[1][]{%
    \begin{tikzpicture}[overlay]
    \node at (\notblank{#1}{-}{}3mm,\textheight+\footskip-3pt)
    [minimum width=1.1cm,minimum height=1.1cm,
    below \notblank{#1}{left}{right}](n)
    {\pagemark};
    \draw[color=lemon,line width=3pt] (n.north east) -- (n.north west);
    \draw[color=lemon,line width=1pt] (n.south east) -- (n.south west);
    \end{tikzpicture}}

\pagestyle{fancy}   

\usepackage{lipsum}
\begin{document}
This is some text

Some more text.

\lipsum[1-10]
\end{document}

相关内容