TeX - LaTeX Asked by Azireo on January 24, 2021
For some context, I recently learned about Cistercian numbering system. I’m loving it, and want to number the pages of my thesis with it.
Using tikz package, I can plot a 4 digit number with self made commands like cistercian{3751}.
The idea is to pass it the page number (padded with zeros) and draw it next to the page number in decimal. But I can’t seem to be able to pass it the page numbers. The error is on line 74 when calling cistercianpagenumber:
Missing character: There is no ; in font nullfont!
! Argument of XC@definec@lor has an extra }.
From my researchs, it may come from the fact that page number should not be passed as an argument, or something else, I’m lost here…
I put all the code below. It is not yet able to plot the page numbers at the right position, but this can be done after. This problem must be solved before going in the presentation details.
Thank you for your help.
Léo
documentclass[review]{article}
usepackage{tikz}
usepackage{ifthen}
usepackage{xstring}
usepackage{fmtcount}
begin{document}
%Define macros for drawing every 0-9 numbers at unit place
newcommand{zero}{draw[black, thick] (0,-0.5)--(0, 0.5)}
newcommand{one}{draw[black, thick] (0,0.5)--(0.25, 0.5)}
newcommand{two}{draw[black, thick] (0,0.25)--(0.25, 0.25)}
newcommand{three}{draw[black, thick] (0,0.5)--(0.25, 0.25)}
newcommand{four}{draw[black, thick] (0,0.25)--(0.25, 0.5)}
newcommand{five}{one; four;}
newcommand{six}{draw[black, thick] (0.25,0.25)--(0.25, 0.5)}
newcommand{seven}{one; six;}
newcommand{eight}{two; six;}
newcommand{nine}{one; two; six;}
%Define macros for drawing a number as a 1000, 100 or 10 digit place
newcommand{tens}[1]{begin{scope}[yscale= 1,xscale=-1]; #1; end{scope}}
newcommand{hundreds}[1]{begin{scope}[yscale=-1]; #1; end{scope}}
newcommand{thousands}[1]{begin{scope}[yscale=-1,xscale=-1]; #1; end{scope}}
%Draw the cistercian number using selfmade commands
newcommand{cistercianhard}[4]{%
zero;%
#4;%
tens{#3};%
hundreds{#2};%
thousands{#1};%
}
%From a number 0-9, returns the self made command corresponding to that number
newcommand{getnumber}[1]{%
ifthenelse{equal{#1}{0}}{zero;}{}%
ifthenelse{equal{#1}{1}}{one;}{}%
ifthenelse{equal{#1}{2}}{two;}{}%
ifthenelse{equal{#1}{3}}{three;}{}%
ifthenelse{equal{#1}{4}}{four;}{}%
ifthenelse{equal{#1}{5}}{five;}{}%
ifthenelse{equal{#1}{6}}{six;}{}%
ifthenelse{equal{#1}{7}}{seven;}{}%
ifthenelse{equal{#1}{8}}{eight;}%
ifthenelse{equal{#1}{9}}{nine;}%
}
%Draw Cistercian number from a 4 digit number
newcommand{cistercian}[1]{%
zero;%
StrChar{#1}{1}[thou];%
StrChar{#1}{2}[hund];%
StrChar{#1}{3}[tens];%
StrChar{#1}{4}[unit];%
thousands{getnumber{thou}};%
hundreds{getnumber{hund}};%
tens{getnumber{tens}};%
getnumber{unit};%
}
%Draw the Page number in Cistercian numerals
newcommand{cistercianpagenumber}{%
begin{tikzpicture}%
cistercian{padzeroes[4]{decimal{page}}};%
end{tikzpicture}%
}
%Test of the last macro
cistercianpagenumber
end{document}
I prefer an implementation with expl3
, which is a bit complicated by the mixture with TikZ.
documentclass{article}
usepackage{tikz}
%usepackage{xparse} % not needed for LaTeX 2020-10-01 or later
%Define macros for drawing every 0-9 numbers at unit place
NewDocumentCommand{cistercianzero}{}{draw[black, thick] (0,-0.5)--(0, 0.5)}
NewDocumentCommand{cistercianone}{}{draw[black, thick] (0,0.5)--(0.25, 0.5)}
NewDocumentCommand{cisterciantwo}{}{draw[black, thick] (0,0.25)--(0.25, 0.25)}
NewDocumentCommand{cistercianthree}{}{draw[black, thick] (0,0.5)--(0.25, 0.25)}
NewDocumentCommand{cistercianfour}{}{draw[black, thick] (0,0.25)--(0.25, 0.5)}
NewDocumentCommand{cistercianfive}{}{cistercianone; cistercianfour;}
NewDocumentCommand{cisterciansix}{}{draw[black, thick] (0.25,0.25)--(0.25, 0.5)}
NewDocumentCommand{cistercianseven}{}{cistercianone; cisterciansix;}
NewDocumentCommand{cistercianeight}{}{cisterciantwo; cisterciansix;}
NewDocumentCommand{cisterciannine}{}{cistercianone; cisterciantwo; cisterciansix;}
NewDocumentCommand{cisterciandigit}{mmm}{%
% #1 = xscale, #2 = yscale, #3 = digit
begin{scope}[xscale=#1,yscale=#2] #3; end{scope}%
}
% units: {1}{1}{digit}
% tens: {-1}{1}{digit}
% hundreds: {1}{-1}{digit}
% thousands: {-1}{-1}{digit
ExplSyntaxOn
NewDocumentCommand{cistercian}{O{1}m}
{% force digits; #1 is the optional scale
azireo_cistercian:ne { #1 } { int_to_arabic:n { #2 } }
}
cs_new_protected:Nn azireo_cistercian:nn
{% pad to four digits
__azireo_cistercian_split:ne { #1 } { prg_replicate:nn {4-tl_count:n{#2}}{0} #2 }
}
cs_generate_variant:Nn azireo_cistercian:nn { ne }
cs_new_protected:Nn __azireo_cistercian_split:nn
{% gather the digits
__azireo_cistercian_split:nNNNN { #1 } #2
}
cs_generate_variant:Nn __azireo_cistercian_split:nn { ne }
cs_new_protected:Nn __azireo_cistercian_split:nNNNN
{% the digit are used in reverse
__azireo_cistercian_print:nnnnn { #1 }
{ azireo_cistercian_digit:n { #5 } }
{ azireo_cistercian_digit:n { #4 } }
{ azireo_cistercian_digit:n { #3 } }
{ azireo_cistercian_digit:n { #2 } }
}
cs_new_protected:Nn azireo_cistercian_digit:n
{% choose the representation for the digit
int_case:nn { #1 }
{
%{0}{cistercianzero} % the base is already present, no need to repeat it
{1}{cistercianone}
{2}{cisterciantwo}
{3}{cistercianthree}
{4}{cistercianfour}
{5}{cistercianfive}
{6}{cisterciansix}
{7}{cistercianseven}
{8}{cistercianeight}
{9}{cisterciannine}
}
}
cs_new_protected:Nn __azireo_cistercian_print:nnnnn
{
begin{tikzpicture}[scale=#1]
cistercianzero; % base
cisterciandigit{ 1}{ 1}{#2}; % units
cisterciandigit{-1}{ 1}{#3}; % tens
cisterciandigit{ 1}{-1}{#4}; % hundreds
cisterciandigit{-1}{-1}{#5}; % thousands
end{tikzpicture}
}
ExplSyntaxOff
renewcommand{thepage}{cistercian{arabic{page}}} % this will print page numbers in Cistercian numerals
begin{document}
Page: cistercian{arabic{page}}
347: cistercian{347}
1234: cistercian{1234}
ExplSyntaxOn
From~1~to~100:~int_step_inline:nn { 100 } { cistercian[0.5]{#1}~ }
ExplSyntaxOff
end{document}
Be prepared that your thesis will be rejected. ;-)
Correct answer by egreg on January 24, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP