# My own page number from file {counters}

I would like to add my own page number in my publications.

I have file: numerki.tex

zzzero
jEden
dWa
trZy
cztery
...
etc......


How I can add counter \counter\cyferki from file. each line is next counter

0=zzzero
1=jEden
2=dWa .....


(numbers are in utf-8 and different capitalic)

And next put it to page number in my specific font.

• Maybe this helps: tex.stackexchange.com/q/24657 – Count Zero Apr 18 '13 at 13:53
• No, because next value are not romanic, string, arabic etc. it is a randomly text and mathematical formula. Each line is a small TeX code with different font and color – jak Apr 18 '13 at 13:56
• Welcome to TeX.sx! – Mensch Apr 18 '13 at 14:08

pages.txt:

One
Two (2)
3
FFFFOOOOUUUURRRR
five gold rings


document:

\documentclass{article}

\pdfpageheight\paperheight

\makeatletter

%%%%%
% filler text
\def\txt#1#2{%
\count@#1\relax
\@tempcnta#2\relax
\@txt}
\def\@txt{%
\let\MessageBreak\space\fontencoding{T1}\selectfont
\ifnum\numexpr(\count@/7)*7=\count@\@eha\space \@ehb\space\fi
\ifnum\numexpr(\count@/5)*5=\count@\@eha\space \@ehc\space\fi
\ifodd\count@ Red yellow blue green balck white. \fi
\ifnum\numexpr(\count@/9)*9=\count@ One two three four five. \fi
\ifnum\@tempcnta>\count@
\expandafter\@txt
\fi
}

%%%%%%%%%%%

\openin\pagenofile=pages.txt
\count@\z@
\loop
\ifeof\pagenofile
\else
\expandafter\let\csname page=\the\count@\endcsname\tmp
%%%debugging\expandafter\show\csname page=\the\count@\endcsname
\repeat

\renewcommand\thepage{\csname page=\arabic{page}\endcsname}

\begin{document}

\txt{1}{100}

\end{document}

• @jak are your numbers in pages.txt in the current directory? – David Carlisle Apr 18 '13 at 14:28
• @jak oh I left in a \show debugging line (I have those so often I didn't think to remove it:-) I have updated the code with that line commented out. The above is the whole code! – David Carlisle Apr 18 '13 at 14:31
• Please download code. github.com/jak00/test-counter-how is @ David Carlisle github.com/jak00/test-counter-line is @ Steven B. Segl any not working – jak Apr 18 '13 at 14:57
• Your code on github works but it is in utf8 so you have to add \usepackage[utf8]{inputenc} to the tex file and the last number in the file would make any text following the page number bold change \bf{five} to \textbf{five} as \bf does not take an argument (and is not even defined by default in latex) – David Carlisle Apr 18 '13 at 15:21
• @jak Your file works fine in xelatex, but xelatex is utf8 already so you don't need (and can't use) inputenc – David Carlisle Apr 18 '13 at 20:02

For this numerki.tex file:

$x^2=\ln y$
zzzero
jEden
dWa
trZy
cztery
...
etc......


it works:

\documentclass{article}
\usepackage{lipsum}

\renewcommand\thepage{\csname arg\roman{page}\endcsname}

\begin{document}
\getargsC{\mypagenum}

\section{Test chapter one}
\lipsum[1-8]
\section{Test chapter two}
\lipsum[1-8]

\end{document}


Confirmed it works for math mode in pages, since user mentioned that.

This alternate version below, while a bit longer in code, will allow the use of regular spaces in your input lines without requiring you to change them to hardspaces.

\documentclass{article}
\usepackage{lipsum}

\makeatletter
\def\first@row{T}%
\def\first@plane{T}%
\catcode\endlinechar=10\relax%
\def#2{}%
\openin\file=#1%
\loop\unless\ifeof\file%
\protected@edef#2{#2\fileline}%
\if T\first@row\getargsC{#2}\setcounter{@col}{\numexpr(\narg-1)}%
\edef\ncols{\arabic{@col}}\def\first@row{F}\setcounter{@row}{1}%
\else%
\if T\first@plane\getargsC{\fileline}\ifthenelse{\equal{\narg}{1}}{%
\edef\nrows{\arabic{@row}}\def\first@plane{F}}{%
\fi
\fi%
\expandafter\protected@edef\csname record\roman{@row}\endcsname{%
\fileline}%
\repeat%
\closein\file%
\catcode\endlinechar=5\relax%
}
\makeatother

\renewcommand\thepage{\csname record\roman{page}\endcsname}

\begin{document}

\section{Test chapter one}
\lipsum[1-8]
\section{Test chapter two}
\lipsum[1-8]

\end{document}

• Hm.... You answer not working on my TeX I have gist.github.com/anonymous/5413128 file name pages.txt each line is code in TeX. In Your Ansver i get LaTeX Error: File readarray.sty' not found. & ! Undefined control sequence. l.8 \readdef {numerki.tex}{\mypagenum} – jak Apr 18 '13 at 14:26
• @jak The \getargsC command grabs words, not lines. Thus, if you wish to have spaces in your page numbers, use hardspaces (~). And if you use a math formula, there can be no softspaces in it, or \getargsC` will break the formula into multiple words (which for math mode, does not work out well). – Steven B. Segletes Apr 18 '13 at 14:29
• readarray.sty is necesary? I havent this style. please send me Your code to e-mail or pastebin. – jak Apr 18 '13 at 14:43