來源資料:

來源資料:

我將以下乳膠文檔編譯為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

主要問題似乎是\zhnum[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}

結果:

目錄

文件

相關內容