我想在我的出版物中添加自己的页码。
我有文件:numerki.tex
zzzero
jEden
dWa
trZy
cztery
...
dwadzIescia
etc......
如何从文件中添加计数器\counter\cyferki
。每行都是下一个计数器
0=zzzero
1=jEden
2=dWa .....
(数字采用 utf-8 编码且大小写不同)
接下来用我的特定字体将其添加到页码中。
答案1
页面.txt:
One
Two (2)
3
FFFFOOOOUUUURRRR
five gold rings
文档:
\documentclass{article}
\advance\textheight-20\baselineskip
\advance\paperheight-20\baselineskip
\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
\advance\count@\@ne
\ifnum\@tempcnta>\count@
\expandafter\@txt
\fi
}
%%%%%%%%%%%
\newread\pagenofile
\openin\pagenofile=pages.txt
\count@\z@
\loop
\advance\count@\@ne
\ifeof\pagenofile
\else
\read\pagenofile to \tmp
\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}
答案2
对于此 numerki.tex 文件:
$x^2=\ln y$
zzzero
jEden
dWa
trZy
cztery
...
dwadzIescia
etc......
有用:
\documentclass{article}
\usepackage{readarray}
\usepackage{lipsum}
\renewcommand\thepage{\csname arg\roman{page}\endcsname}
\begin{document}
\readdef{numerki.tex}{\mypagenum}
\getargsC{\mypagenum}
\section{Test chapter one}
\lipsum[1-8]
\section{Test chapter two}
\lipsum[1-8]
\end{document}
由于用户提到过这一点,因此确认它适用于页面中的数学模式。
下面这个替代版本,虽然代码稍微长一点,但允许在输入行中使用常规空格,而不需要将它们更改为硬空格。
\documentclass{article}
\usepackage{readarray}
\usepackage{lipsum}
\makeatletter
\renewcommand\readdef[2]{%
\def\first@row{T}%
\def\first@plane{T}%
\catcode\endlinechar=10\relax%
\def#2{}%
\newread\file%
\openin\file=#1%
\loop\unless\ifeof\file%
\read\file to\fileline % Reads a line of the file into \fileline%
\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}}{%
\addtocounter{@row}{1}}%
\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}
\readdef{numerki.tex}{\mypagenum}
\section{Test chapter one}
\lipsum[1-8]
\section{Test chapter two}
\lipsum[1-8]
\end{document}