3
                                                                           0001

Consectetur vestibulum dictum sagittis lacinia vehicula per urna parturient blandit parturient adipiscing imperdiet cubilia enim rhoncus praesent a eu a facilisi facilisis lobortis dui ad metus scelerisque cum faucibus. Felis eros libero rutrum adipiscing a pulvinar praesent a parturient vivamus cras himenaeos sodales adipiscing mi ligula pretium diam aptent nisi ullamcorper a rhoncus nisl et id erat condimentum. Posuere mi non a est scelerisque consequat ultrices vehicula ullamcorper cras aliquam etiam augue ac parturient ac a lobortis habitant at consectetur posuere placerat placerat. Vestibulum id at ullamcorper ullamcorper nisi cursus mus a nec nam habitant elit odio a fusce himenaeos nibh gravida iaculis ullamcorper. Nascetur suspendisse penatibus est laoreet ullamcorper tincidunt ad vestibulum lorem donec nisl ac proin mi suscipit quam ac morbi condimentum nostra gravida eu semper ultrices feugiat ad ullamcorper sodales. Vestibulum augue suspendisse convallis himenaeos ullamcorper felis posuere vestibulum mi netus mus condimentum est suscipit rutrum consectetur sapien a quis maecenas vestibulum eu aenean hendrerit risus vestibulum est etiam.

                                                                            0002

Rhoncus a vestibulum parturient neque quis lectus a suspendisse enim praesent pretium per orci a taciti vitae a scelerisque a cras vestibulum natoque feugiat curabitur arcu a. Vitae habitasse hac sem accumsan feugiat justo senectus habitasse nunc lobortis parturient arcu facilisi litora sed primis dignissim suspendisse mus enim. Nec a venenatis consectetur in faucibus sit vestibulum nisl ultricies nisi interdum convallis a condimentum scelerisque at nostra sit faucibus ad iaculis cubilia mattis.

  • 1
    What a strange page numbering... – user31729 Apr 21 '17 at 10:46
  • Can we get the above type of page numbering christian-hupfer? – Biki Teron Apr 21 '17 at 10:49
  • 3
    \def\thepage{\ifnum\value{page}<1000\relax0\ifnum\value{page}<100\relax\ifnum\value{page}<10\relax0\fi\fi\thepage\else\thepage\fi} – TeXnician Apr 21 '17 at 10:50
  • where do we need to place your code kindly tell us TeXnician? – Biki Teron Apr 21 '17 at 10:56
  • 2
    The definition would have bin as \def\thepagea or something a call for your header. But Christian Hupfer already provided the answer containing a working version. – TeXnician Apr 21 '17 at 11:04
7

This uses fancyhdr and places the modified page number after a query on the right side of the page.

The code assumes that there will never be more than 1000 pages.

\documentclass{article}

\usepackage{blindtext}

\usepackage{fancyhdr}


\renewcommand{\headrulewidth}{0pt}
\fancypagestyle{plain}{%
  \fancyhf{}
\fancyhead[R]{%
  \ifnum\value{page}<10\relax%
  000\arabic{page}%
  \else
  \ifnum\value{page}<100\relax%
  00\arabic{page}%
  \else
  0\arabic{page}%
  \fi
  \fi
}
}



\begin{document}
\pagestyle{plain}
\blindtext[1000]
\end{document}

enter image description here

  • @BikiTeron: If this answers your request, consider to accept the answer please – user31729 Apr 21 '17 at 11:23
2

Here's a LuaLaTeX-based solution.

If your document has more than 9999 pages (but also fewer than 10000 [!] pages), simply change "%04d" to "%05d" in the Lua function fourdigits.

% !TeX program = lualatex
\documentclass{article}
\usepackage{lipsum} % for filler text

\usepackage{luacode} % for 'luacode' environment
\begin{luacode}
function fourdigits ( n )  
    tex.sprint ( string.format ( "%04d", n ) ) -- pad with leading zeros
end
\end{luacode}
\renewcommand\thepage{\directlua{fourdigits(\arabic{page})}}

\pagestyle{myheadings} % place page number in top right

\begin{document}
\section{Hello World}
\lipsum[1-20] % 20 paragraphs of filler text
\end{document}

enter image description here

  • 2
    Still addicted to Lua? We can cure it! ;-) – user31729 Apr 21 '17 at 12:47
  • @ChristianHupfer - You know how it is: Once you've learned how to program in Lua, aka tasted the fruit from the tree of knowledge of good and evil, there's no returning to the old ways... – Mico Apr 21 '17 at 12:54
  • 2
    But now your tasting the fruits from the Tree of Evilua only :-P – user31729 Apr 21 '17 at 12:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.