我想建立一系列在每個頁腳中並肩排列的圓圈。圓圈的數量就是總頁數,也就是說每個圓圈都代表一頁。每個圓圈的中心是目前頁碼。
如果所有這些圓的直徑都相同,\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}