Page numbering in the middle of a line

A possible solution is based on the following packages:

  • tikzpagenodes
  • background

Basically, by means of tikzpagenodes it is possible to access to current page footer area:

\newcommand{\myfooterstyle}[2][]{%
\tikz[remember picture,overlay]{%
   \draw[#1]
   ($(current page footer area.south west)!0.25!(current page footer area.north west)$)
   --
   ($(current page footer area.south)!0.25!(current page footer area.north)-(#2,0)$)
   ($(current page footer area.south)!0.25!(current page footer area.north)+(#2,0)$)
   --
   ($(current page footer area.south east)!0.25!(current page footer area.north east)$)
   ;
  }%
}

The mandatory argument specifies how much distant is the rule from the page number while the optional argument let you access possible customization like colors or rule width. Because of the options [remember picture, overlay] two compilation runs are necessary.

Then, by means of the background package, the command will be executed everytime:

\AddEverypageHook{%
\myfooterstyle{1em}
\BgMaterial}

The complete code:

\documentclass{article}
\usepackage{tikzpagenodes}
\usetikzlibrary{calc}
\usepackage[contents={}]{background}

\usepackage{lipsum}% for dummy text

\newcommand{\myfooterstyle}[2][]{%
\tikz[remember picture,overlay]{%
   \draw[#1]
   ($(current page footer area.south west)!0.25!(current page footer area.north west)$)
   --
   ($(current page footer area.south)!0.25!(current page footer area.north)-(#2,0)$)
   ($(current page footer area.south)!0.25!(current page footer area.north)+(#2,0)$)
   --
   ($(current page footer area.south east)!0.25!(current page footer area.north east)$)
   ;
  }%
}

\AddEverypageHook{%
\myfooterstyle{1em}
\BgMaterial}

\begin{document}
\lipsum[1-8]
\end{document}

How it looks:

enter image description here


I would take the \Vhrulefill macro for this (posted by Gonzalo Medina in Vertically centered horizontal rule filling the rest of a line?)

I appended a working example:

\documentclass{article}
\usepackage{fancyhdr}
\usepackage{lipsum}
\pagestyle{fancy}
\def\Vhrulefill{\leavevmode\leaders\hrule height 0.7ex depth \dimexpr0.4pt-0.7ex\hfill\kern0pt}
\fancyfoot{\Vhrulefill~\thepage~\Vhrulefill}
\begin{document}
\lipsum
\end{document}