Quelldaten:

Quelldaten:

Ich habe das folgende Latex-Dokument in kompiliert 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}

Ich möchte \paragraph, \subparagraphdass es nicht nummeriert ist, aber trotzdem im Inhaltsverzeichnis erscheint.

Ich würde wenn möglich auch gerne für jeden nummerierten (Unter-)Titel einen anderen Nummerierungsstil verwenden.

Insbesondere möchte ich \\zhnum[style=Traditional,Financial]{section}für \sectionEbenenüberschriften verwenden;

壹、heading
貳、heading
參、heading

\\zhnum{subsection}für \subsectionÜberschriften;

一、heading
二、heading
三、heading

Und \\zhnum{subsubsection}in Klammern für \subsubsectionÜberschriften;

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

Das Ergebnis soll ungefähr so ​​aussehen:

Bildbeschreibung hier eingeben

Bildbeschreibung hier eingeben

Wie kann dies mit dem Code realisiert werden?


Quelldaten:

#+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

Antwort1

Das Hauptproblem scheint zu sein, dass \zhnumzusammen mit [style={Traditional,Financial}](beachten Sie übrigens die Klammern um das Argument) nicht sehr gut mit dem Inhaltsverzeichnis funktioniert und für jeden Abschnitt 零 (Null) anzeigt. Für mich sieht das nach einem Fehler im zhnumberPaket aus; als schnelle Problemumgehung verwende ich einen benutzerdefinierten Zähler für den Abschnitt, der in erhöht wird \thesection.

Ich habe auch noch ein paar andere Teile deines Codes deinen Vorstellungen entsprechend geändert, aber wahrscheinlich musst du die Abstände noch ein bisschen anpassen (die Abstände für \paragraphund waren mir zum Beispiel nicht bekannt \subparagraph). Ich habe aber versucht, so wenig Stellen wie möglich zu ändern.

Ich habe alle Ihre Kommentare entfernt und jeder Kommentar, den Sie im folgenden Code finden, ist eine Änderung, die ich vorgenommen habe:

\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}

Ergebnis:

Inhaltsverzeichnis

Dokument

verwandte Informationen