谢谢十十二进制页码 我不必问如何获取十二进制页码,我也设法用该方法获取了十二进制章节号。但我如何更改章节、子章节等以使其也以十二进制值显示?
\usepackage{xparse}
\ExplSyntaxOn
\NewDocumentCommand{\basetwelve}{m}
{ \duodec_convert:n { #1 } }
\tl_new:N \l_duodec_string_tl
\cs_new_protected:Npn \duodec_convert:n #1
{
\tl_set:Nx \l_duodec_string_tl { \int_to_base:nn { #1 } { 12 } }
\tl_replace_all:Nnn \l_duodec_string_tl { a } { ↊ } %I use XeLaTex, so these sings are no problem at all ;)
\tl_replace_all:Nnn \l_duodec_string_tl { b } { ↋ }
\tl_use:N \l_duodec_string_tl
}
\ExplSyntaxOff
\renewcommand{\thepage}{\basetwelve{\arabic{page}}}
\renewcommand{\thepart}{\basetwelve{\arabic{part}}}
\renewcommand{\thechapter}{\basetwelve{\arabic{chapter}}}
\renewcommand{\thesection}{\basetwelve{\arabic{section}}}
这会导致章节编号不带章节编号(1、2、3,而不是 5.1、5.2、5.3...)。如何仅使用十二进制值获得标准编号?我尝试过
\makeatletter
\renewcommand*{\p@section}{\thechapter.}
\renewcommand*{\p@subsection}{\p@section}
\renewcommand*{\p@subsubsection}{\p@section}
\renewcommand*{\p@paragraph}{\p@section}
\renewcommand*{\p@subparagraph}{\p@section}
\makeatother
维持养育子女的职能,但却没有取得任何成果。
明确地说,我希望所有自动编号(页面、章节等、图片、表格……)最终都采用十二进制值,而不改变格式。谢谢!
答案1
谢谢 David 的帮助!解决方案比我想象的要简单得多。
要获得我正在寻找的解决方案,您需要以下代码:
\documentclass[11pt,a4paper,final]{book}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}
\usepackage{graphicx} % I need this to rotate my numbers...
\usepackage{xparse} % this is the magic package...
\ExplSyntaxOn % for the missing numbers after 9 the package uses "a" and "b",
% but I want to use "↊" and "↋" as defined by the Dozenal
% Society of Great Britain. The following lines do that for me:
\NewDocumentCommand{\basetwelve}{m}
{ \duodec_convert:n { #1 } }
\tl_new:N \l_duodec_string_tl
\cs_new_protected:Npn \duodec_convert:n #1
{
\tl_set:Nx \l_duodec_string_tl { \int_to_base:nn { #1 } { 12 } }
\tl_replace_all:Nnn \l_duodec_string_tl { a } { \rotatebox[origin=c]{180}{2} }
% I rotate the numbers, because standard fonts don't contain ↊ and ↋.
\tl_replace_all:Nnn \l_duodec_string_tl { b } { \rotatebox[origin=c]{180}{3} }
\tl_use:N \l_duodec_string_tl
}
\ExplSyntaxOff % I got this code from the related question linked above.
\renewcommand{\thepage}{\basetwelve{\arabic{page}}}
\renewcommand{\thepart}{\basetwelve{\arabic{part}}}
\renewcommand{\thechapter}{\basetwelve{\arabic{chapter}}}
% No problems so far...
% This is how you get numbering formatted as chapter.section:
\renewcommand{\thesection}{\thechapter.\basetwelve{\arabic{section}}}
\renewcommand{\thesubsection}{\thesection.\basetwelve{\arabic{subsection}}}
% Dont put \thechapter here, it is already contained in \thesection!!!
\renewcommand{\thefigure}{\basetwelve{\arabic{figure}}}
% As I told you, I wanted to change the figcaptions too.
% But I don't need the chapter's number here.
\renewcommand{\labelenumi}{\basetwelve{\arabic{enumi}}.}
% And this is my first dozenal enumeration with a dot behind the number.
%let's see, if it works:
\begin{document}
\part{Quick demonstration}
\chapter{Here we go!}
Just scroll down...
\chapter{I}
\chapter{need}
\chapter{lots}
Whoops, nearly there...
\newpage
On this and on the following page you see the dozenal page numbers!
\chapter{of}
See? It works!
\chapter{pages}
\chapter{and}
\chapter{chapters}
\chapter{for}
\chapter{dozenal}
This is the dozenal number \rotatebox[origin=c]{180}{2}, equal to $ 10_{(10)} $.
\chapter{numbers.}
This is the second dozenal number: \rotatebox[origin=c]{180}{3}, it is just a turned 3 and equal to $ 11_{(10)} $.
\section{What are these symbols?!}
I use fonts like Times New Roman, they have symbols like \rotatebox[origin=c]{180}{2} and \rotatebox[origin=c]{180}{3} integrated as Unicode glyphs U+218A and U+218B. They are just rotated numbers too, basicly. These numbers are defined by the Dozenal Society of Great Britain and I like them. If you complie with XeLaTeX you can just copy and paste these signs: ↊ and ↋ (in this font they will probably be invisible).
\section{Why so many chapters?}
I need more than 12 pages and chapters for the numbers \rotatebox[origin=c]{180}{2} and \rotatebox[origin=c]{180}{3} to appear.
\section{Enumeration}
\begin{enumerate}
\item Just
\item a
\item very
\item short
\item demonstration
\item of
\item a
\item dozenal
\item enumeration
\item for
\item you
\item to
\item admire.
\end{enumerate}
\section{Just a random section}
\subsection{with a subsection}
\subsubsection{and a subsubsection}
These all work just finde with dozenal numbers aswell but I think the code is already long enough. And as you see, subsubsections usually don't have numbers at all.
\end{document}
现在我的整个文档都使用十二进制系统,我感觉已经是圣诞节了。谢谢!!!