在一系列圆中,一个圆的直径与其他圆的直径不同

在一系列圆中,一个圆的直径与其他圆的直径不同

我想构造一系列圆圈,它们在每个页脚中并排排列。圆圈的数量就是总页数,也就是说每个圆圈代表一页。每个圆圈的中心是当前页码。

\foreach如果所有这些圆的直径都相同,则很容易实现这一点pgf。但是,我希望代表当前页面的圆的直径更大。

排版就像以下 MWE 生成的附图一样。有人能帮我吗?

梅威瑟:

\documentclass{article}
\usepackage{fancyhdr,geometry,color,tikz}
\geometry{showframe}

\begin{document}
\pagestyle{fancy}
\fancyhf{}
\renewcommand{\footrulewidth}{0.4pt}
some text...

\cfoot{
\begin{tikzpicture}
  \draw[fill=gray,text=white,radius=0.5](0,0)circle node{1};
  \draw[fill=red,text=white,radius=1](1.5,0)circle node{2};
  \draw[fill=gray,text=white,radius=0.5](3,0)circle node{3};  
\end{tikzpicture}
}
\end{document}

在此处输入图片描述

答案1

类似这样的事?

\documentclass{article}
\usepackage{fancyhdr,geometry,lastpage,refcount,lipsum,tikz}
\geometry{showframe}
\usetikzlibrary{positioning}
\begin{document}
\pagestyle{fancy}
\fancyhf{}
\renewcommand{\footrulewidth}{0.4pt}
some text...
\newcounter{lastpagenumber}%
\setcounter{lastpagenumber}{\getrefbykeydefault{LastPage}{page}{1}}%

\cfoot{\begin{tikzpicture}
\coordinate (cn-0);
\foreach \X [remember=\X as \LastX (initially 0)] in {1,...,\thelastpagenumber}
{\ifnum\X=\thepage
 \node[circle,fill=red,text=white,minimum size=1cm,right=0pt of cn-\LastX] (cn-\X) {\X};
 \else
 \node[circle,fill=gray,text=white,minimum size=0.5cm,right=0pt of cn-\LastX] (cn-\X) {\X};
 \fi
}
\end{tikzpicture}
}
\lipsum[1-31]
\end{document}

在此处输入图片描述

当然,人们可以通过多种方式定制输出。

\documentclass{article}
\usepackage{fancyhdr,geometry,lastpage,refcount,lipsum,tikz}
\geometry{showframe}
\usetikzlibrary{positioning}
\begin{document}
\pagestyle{fancy}
\fancyhf{}
\renewcommand{\footrulewidth}{0.4pt}
some text...
\newcounter{lastpagenumber}%
\setcounter{lastpagenumber}{\getrefbykeydefault{LastPage}{page}{1}}%

\cfoot{\begin{tikzpicture}
\coordinate (cn-0);
\foreach \X [remember=\X as \LastX (initially 0)] in {1,...,\thelastpagenumber}
{\ifnum\X=\thepage
 \node[circle,draw,thick,font=\sffamily\Large\bfseries,fill=red,text=white,minimum size=1cm,right=0pt of cn-\LastX] (cn-\X) {\X};
 \else
 \node[circle,draw,font=\sffamily\bfseries,fill=gray,text=white,minimum size=0.5cm,right=0pt of cn-\LastX] (cn-\X) {\X};
 \fi
}
\end{tikzpicture}
}
\lipsum[1-31]
\end{document}

在此处输入图片描述

如果你觉得圆圈有点无趣,你可以

\documentclass{article}
\usepackage{fancyhdr,geometry,lastpage,refcount,lipsum,tikzducks,tikzlings}
\geometry{showframe}
\usetikzlibrary{positioning,backgrounds}
\begin{document}
\pagestyle{fancy}
\fancyhf{}
\renewcommand{\footrulewidth}{0.4pt}
some text...
\newcounter{lastpagenumber}%
\setcounter{lastpagenumber}{\getrefbykeydefault{LastPage}{page}{1}}%

\cfoot{\begin{tikzpicture}
\coordinate (cn-0);
\foreach \X [remember=\X as \LastX (initially 0)] in {1,...,\thelastpagenumber}
{\ifnum\X=\thepage
 \node[font=\sffamily\Large\bfseries,text=white,minimum size=1cm,right=0pt of cn-\LastX] (cn-\X) {\X};
 \begin{scope}[scale=0.4,on background layer,shift={(cn-\X.center)},yshift=-3em]
 \marmot
 \end{scope}
 \else
 \node[font=\sffamily\bfseries,text=black,minimum size=0.5cm,right=0pt of cn-\LastX] (cn-\X) {\X};
 \begin{scope}[scale=0.3,on background layer,shift={(cn-\X.center)},yshift=-3em]
 \koala
 \end{scope}
 \fi
}
\end{tikzpicture}
}
\lipsum[1-31]
\end{document}

在此处输入图片描述

相关内容