源数据:

源数据:

我有以下已编译的乳胶文档org-mode

% Created 2020-03-29 Sun 00:33
% Intended LaTeX compiler: xelatex

\documentclass[12pt,a4paper]{article}

\usepackage{xeCJK}
%\usepackage[heading]{CJK}
\usepackage{zhnumber} % package for Chinese formatting of date time (use /zhtoday)
%\usepackage[yyyymmdd]{datetime} % set date time to numeric

\usepackage{titlesec}
\usepackage{titling}
\usepackage{fontspec} % packages for title and section-heading font setting.
\usepackage{newunicodechar}

% Set Header and Numbering Depth
\setcounter{tocdepth}{5}
\setcounter{secnumdepth}{5}

% Set Font.
\setCJKmainfont{MingLiU}
\setCJKsansfont{Kaiti TC} % Set Chinese font. NOTE: Remember to append CJK before of the font class. CJK HAS to be there for the font to show.
\setCJKmonofont{PingFang TC}

% Use Chinese numberals for section numbering

\renewcommand\thesection{\zhnum[style=Traditional]{section}}
\renewcommand\thesubsection{\zhnum{subsection}}
\renewcommand\thesubsubsection{\zhnum{subsubsection}}

% \renewcommand\thesection{\zhnum{section}}
% \renewcommand\thesubsection{\Alph{subsection}}
% \renewcommand\thesubsubsection{\arabic{subsubsection}}
\renewcommand*\theparagraph{\arabic{paragraph}}
\renewcommand*\thesubparagraph{\arabic{subparagraph}}

% Set formats for each heading level. 'sffamily' will point to the sans-serif font. In this case, 「楷體」.

\titleformat*{\section}{\Large\bfseries\sffamily\filcenter} % center heading
\titleformat*{\subsection}{\fontsize{18}{20}\bfseries\sffamily}
\titleformat*{\subsubsection}{\fontsize{16}{18}\bfseries\sffamily}

% The `titlesec` package is used over here to make use of `\paragraph` and `\subparagraph` as headings. Up to five levels of headings can be implemented this way.

\titleformat{name=\paragraph}[display]
    {\fontsize{14}{16}\bfseries\sffamily}{}{1em}{}
% New line after heading. (`\paragraph` and `\subparagraph` would not automatically generate a new line after the heading text. )
\titlespacing*{\paragraph}{\parindent}{3.25ex plus 1ex minus .2ex}{.75ex plus .1ex}

\titleformat{name=\paragraph,numberless}[display]
    {\fontsize{14}{16}\bfseries\sffamily}{\theparagraph}{1em}{}
% New line after heading. (`\paragraph` and `\subparagraph` would not automatically generate a new line after the heading text. )
\titlespacing*{\paragraph}{\parindent}{3.25ex plus 1ex minus .2ex}{.75ex plus .1ex}

\titleformat{name=\subparagraph}[display]
    {\fontsize{12}{14}\bfseries\sffamily}{\thesubparagraph}{1em}{}
\titlespacing*{\subparagraph}{\parindent}{3.25ex plus 1ex minus .2ex}{.75ex plus .1ex}

\titleformat{name=\subparagraph,numberless}[display]
    {\fontsize{12}{14}\bfseries\sffamily}{}{1em}{}
\titlespacing*{\subparagraph}{\parindent}{3.25ex plus 1ex minus .2ex}{.75ex plus .1ex}


% Set title font.
\renewcommand{\maketitlehooka}{\sffamily}

% Tweak default settings.
\renewcommand{\baselinestretch}{1.2} % Set line width.
\renewcommand{\contentsname}{目次} % Translate content page title to Chinese. (Could possibly be done automatically with '\usepackage[heading]{CJK}'. TODO experiment. )

% [FIXME] ox-latex 的設計不良導致 hypersetup 必須在這裡插入
\usepackage{hyperref}
\hypersetup{
  colorlinks=true, %把紅框框移掉改用字體顏色不同來顯示連結
  linkcolor=[rgb]{0,0.37,0.53},
  citecolor=[rgb]{0,0.47,0.68},
  filecolor=[rgb]{0,0.37,0.53},
  urlcolor=[rgb]{0,0.37,0.53},
  pagebackref=true,
  linktoc=all,}

\usepackage{hyperref}
\usepackage[utf8x]{inputenc}
\usepackage{fixltx2e}
\usepackage{graphicx}
\usepackage{longtable}
\usepackage{float}
\usepackage{wrapfig}
\usepackage{rotating}
\usepackage[normalem]{ulem}
\usepackage{amsmath}
\usepackage{textcomp}
\author{Test}
\date{\today}
\title{}
\begin{document}

\tableofcontents \clearpage

\section{Section}
\label{sec:org9101c0e}
some text
\subsection{Subsection}
\label{sec:org8fa5441}
some text
\subsubsection{Subsubsection}
\label{sec:orgba871aa}
some text
\paragraph{Paragraph}
\label{sec:orgeb7d238}
some text
\subparagraph{Subparagraph}
\label{sec:org7791480}
some text


\section{Section}
\label{sec:org27630bd}
some text
\subsection{Subsection}
\label{sec:orgabf9df6}
some text
\subsubsection{Subsubsection}
\label{sec:org648c2c5}
some text
\paragraph{Paragraph}
\label{sec:org1ee8ae9}
some text
\subparagraph{Subparagraph}
\label{sec:org1056bb1}
some text
\end{document}

我希望\paragraph\subparagraph不被编号但仍出现在目录中。

如果可能的话,我还想对每个编号(子)标题使用不同的编号样式。

具体来说,我想用于\\zhnum[style=Traditional,Financial]{section}级别\section标题;

壹、heading
貳、heading
參、heading

\\zhnum{subsection}用于\subsection标题;

一、heading
二、heading
三、heading

\\zhnum{subsubsection}在括号中标明\subsubsection标题;

(一)heading
(二)heading
(三)heading

我希望结果看起来像这样:

在此处输入图片描述

在此处输入图片描述

如何用代码实现这一点?


源数据:

#+OPTIONS: H:5 num:t

* Section
some text
** Subsection
some text
*** Subsubsection
some text
**** Paragraph
some text
***** Subparagraph
some text


* Section
some text
** Subsection
some text
*** Subsubsection
some text
**** Paragraph
some text
***** Subparagraph
some text

答案1

主要问题似乎是\zhnumwith [style={Traditional,Financial}](顺便说一下,请注意参数周围的括号)与目录配合使用效果不佳,每个部分都显示零(零)。对我来说,这看起来像是包中的一个错误zhnumber;作为一种快速解决方法,我为该部分使用了一个自定义计数器,该计数器在 中增加\thesection

我还更改了代码的其他部分以符合您的想法,但您可能需要稍微调整与间距相关的内容(例如,我不知道\paragraph和的间距\subparagraph)。不过,我尝试尽可能少地修改地方。

我删除了你的所有评论,并且你在下面的代码中发现的每个评论都是我应用的更改:

\documentclass[12pt,a4paper]{article}

\usepackage{xeCJK}
\usepackage{zhnumber}

\usepackage{titlesec}
\usepackage{titling}
\usepackage{fontspec}
\usepackage{newunicodechar}
\usepackage{tocloft} % adding the tocloft package for toc customization

\setcounter{tocdepth}{5}
\setcounter{secnumdepth}{5}

% note: I'm using different fonts only because I don't have yours
\setCJKmainfont{Noto Serif CJK TC}
\setCJKsansfont{Noto Sans CJK TC}
\setCJKmonofont{Noto Mono CJK TC}

% in your example the titles in the toc are all sans serif, so I'll just add that here
% feel free to leave that out in your original document,
% it's just for visual comparability
\renewcommand{\cftsecfont}{\bfseries\sffamily}
\renewcommand{\cftsubsecfont}{\sffamily}
\renewcommand{\cftsubsubsecfont}{\sffamily}
\renewcommand{\cftparafont}{\sffamily}
\renewcommand{\cftsubparafont}{\sffamily}

% zhnum[style={Traditional,Financial}] doesn't work with the section counter,
% so we define our own counter and increase it every time in \thesection
\newcounter{mysec}[section]
\renewcommand\thesection{%
    \addtocounter{mysec}{1}%
    \zhnum[style={Traditional,Financial}]{mysec}、}
\renewcommand\thesubsection{\zhnum{subsection}、} % added a 、
\renewcommand\thesubsubsection{(\zhnum{subsubsection})} % added parentheses
% (full-width, don't know if that's what you want)
\renewcommand\theparagraph{} % you don't want paragraph numbers
\renewcommand\thesubparagraph{} % nor subparagraph numbers

% we have to adjust the spacing in the toc because the section label is longer than usual
\addtolength\cftsecnumwidth{1em}
\addtolength\cftsubsecindent{1em}
\addtolength\cftsubsubsecindent{1em}

% here we need to make sure the normal section counter is accessed
\titleformat{\section}{\Large\bfseries\sffamily\filcenter}
    {\zhnum[style={Traditional,Financial}]{section}、}{.5em}{}
% not really sure what you intend to achieve with \fontsize but I'll leave it here
\titleformat*{\subsection}{\fontsize{18}{20}\bfseries\sffamily} 
\titleformat*{\subsubsection}{\fontsize{16}{18}\bfseries\sffamily}

% no extra version for numberless is necessary since no numbers are used anyways
% also you get newlines from omitting the [display] in \titleformat already
\titleformat{\paragraph}
    {\fontsize{14}{16}\bfseries\sffamily}{}{0em}{} 
\titleformat{\subparagraph}
    {\fontsize{12}{14}\bfseries\sffamily}{}{0em}{}
% we need the following so that they don't indent (second argument, 0em);
% you'll have to adjust the spacing though since this is not display style anymore:
\titlespacing*{\paragraph}{0em}{3.25ex plus 1ex minus .2ex}{.75ex plus .1ex} 
\titlespacing*{\subparagraph}{0em}{3.25ex plus 1ex minus .2ex}{.75ex plus .1ex}

\renewcommand{\maketitlehooka}{\sffamily}

\renewcommand{\baselinestretch}{1.2}
\renewcommand{\contentsname}{目次}

\usepackage{hyperref}
\hypersetup{
  colorlinks=true,
  linkcolor=[rgb]{0,0.37,0.53},
  citecolor=[rgb]{0,0.47,0.68},
  filecolor=[rgb]{0,0.37,0.53},
  urlcolor=[rgb]{0,0.37,0.53},
  % pagebackref=true, % this is ignored
  linktoc=all}

\usepackage{hyperref}
% \usepackage[utf8x]{inputenc} do not use inputenc with XeTeX
% \usepackage{fixltx2e} not required any more
\usepackage{graphicx}
\usepackage{longtable}
\usepackage{float}
\usepackage{wrapfig}
\usepackage{rotating}
\usepackage[normalem]{ulem}
\usepackage{amsmath}
\usepackage{textcomp}
\author{Test}
\date{\today}
\title{}
\begin{document}
% your document appears to be completely sans serif so I just set it here
\sffamily
%% from here on I haven't changed anything
\tableofcontents \clearpage

\section{Section}
\label{sec:org9101c0e}
some text
\subsection{Subsection}
\label{sec:org8fa5441}
some text
\subsubsection{Subsubsection}
\label{sec:orgba871aa}
some text
\paragraph{Paragraph}
\label{sec:orgeb7d238}
some text
\subparagraph{Subparagraph}
\label{sec:org7791480}
some text


\section{Section}
\label{sec:org27630bd}
some text
\subsection{Subsection}
\label{sec:orgabf9df6}
some text
\subsubsection{Subsubsection}
\label{sec:org648c2c5}
some text
\paragraph{Paragraph}
\label{sec:org1ee8ae9}
some text
\subparagraph{Subparagraph}
\label{sec:org1056bb1}
some text
\end{document}

结果:

目录

文档

相关内容