标题计数不标准且无缩进。如何实现?

标题计数不标准且无缩进。如何实现?

我想格式化标题,使其显示如下。但我不知所措。

在此处输入图片描述

到目前为止我已经:

% !TEX TS-program = pdflatex
% !TEX encoding = UTF-8 Unicode


\documentclass[11pt, oneside, ngerman]{report}

\usepackage[ngerman]{babel}
 
\usepackage{geometry}
\geometry{a4paper}

\usepackage[parfill]{parskip}


\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}


\usepackage{ragged2e}
\usepackage{lipsum}
\usepackage[center]{titlesec}

 
\titleformat{\part}[display]
  {\normalfont\large\bfseries}{Part\ \thepart}{0pt}{\large}
\titlespacing*{\part} 
  {0pt}{0pt}{0pt}
  
\titleformat{\chapter}[display]
    {\normalfont\bfseries}{}{0pt}{\large}
\titlespacing*{\chapter} 
  {0pt}{0pt}{0pt}
  
\titleformat{\section}[display]
    {\normalfont\bfseries}{}{0pt}{\large}
\titlespacing*{\section} 
  {0pt}{0pt}{0pt}
  
\titleformat{\subsection}[display]
    {\normalfont\bfseries}{}{0pt}{\large}
\titlespacing*{\subsection} 
  {0pt}{0pt}{0pt}
  
\titleformat{\subsubsection}[display]
    {\normalfont\bfseries}{}{0pt}{\large}
\titlespacing*{\subsubsection} 
  {0pt}{0pt}{0pt}


\titleclass{\part}{straight}
\titleclass{\chapter}{straight}



\begin{document}


\renewcommand\thechapter{\Alph{chapter}}
\renewcommand\thesection{\Roman{section}.}
\renewcommand\thesubsection{\arabic{subsection}}
\renewcommand\thesubsubsection{\alph{subsubsection})}

\part*{First Part: Test Paaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaart}

\bigskip


\chapter{A. Test Chapter}

\bigskip


\section{I. Test Section}

\bigskip


\subsection{1. Test Subsection}

\bigskip


\subsubsection{a) Test Subsubsection}

\bigskip

{\lipsum[1-3]}
\end{document}

是什么给了我:

在此处输入图片描述

如果它们能够按照给定的方案进行计数、长度为多行并正确缩进,并且像这样出现在目录中(没有额外的编号),那就太好了。

编辑:我成功改变了计数方法:

\renewcommand\thechapter{\Alph{chapter}}
\renewcommand\thesection{\Roman{section}.}
\renewcommand\thesubsection{\arabic{subsection}}
\renewcommand\thesubsubsection{\alph{subsubsection})}

但它们不会显示在标题名称之前

提前感谢 Jannis

答案1

既然您决定搬出 KOMA 土地,我现在可以提供帮助。:-)

您必须自己调整字体大小和间距。下面给出的内容希望可以帮助您入门。请参阅穿插的评论以获取详细解释。

但是我会指出该fmtcount包的用途:它提供了一种显示序数的方法(英语:first, second third;德语:erste, zweite,...)有关使用的详细信息,请参阅文档。我之所以包括这个,是因为你似乎想将这些部分写成“Erster Teil”等等。

\documentclass[11pt, oneside, ngerman]{report}

\usepackage[ngerman]{babel}
\usepackage{fmtcount}  % The fmtcount package provides the \ordinalstring macro
        % use \Ordinalstring for capitalized version. 
        % There's also an optional argument to specify gender.  

\usepackage{geometry}
\geometry{a4paper}

\usepackage[parfill]{parskip}


\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}


\usepackage{ragged2e}
\usepackage{lipsum}
\usepackage[center]{titlesec}


\setcounter{secnumdepth}{4}  % By default report only numbers to subsection
           % Need to add one more level to number subsubsection. 

% In your code you specified [display]; that does NOT reflect what you
% showed as the sample format you wish to recreate. I fixed it so now
% it uses [hang]
\titleformat{\part}[hang]  
{\normalfont\large\bfseries}{\ordinalstring{part} Part:}{0pt}{\large}
% note the use of \ordinalstring above
\titlespacing*{\part} 
  {0pt}{0pt}{0pt}
  
\titleformat{\chapter}[hang]
    {\normalfont\bfseries}{\thechapter.}{0pt}{\large}
% It is better to put the period inside the \titleformat command
% rather than inside \thechapter, so that when cross referencing you 
% don't end up with spurious punctuation marks. 
% The numbers didn't show up in your version because you removed
% \thechapter, \thesection, etc from the \titleformat. Once 
% you restore them they show. 
\titlespacing*{\chapter} 
  {0pt}{0pt}{0pt}
  
\titleformat{\section}[hang]
    {\normalfont\bfseries}{\thesection.}{0pt}{\large}
\titlespacing*{\section} 
  {0pt}{0pt}{0pt}
  
\titleformat{\subsection}[hang]
    {\normalfont\bfseries}{\thesubsection.}{0pt}{\large}
\titlespacing*{\subsection} 
  {0pt}{0pt}{0pt}
  
\titleformat{\subsubsection}[hang]
        {\normalfont\bfseries}{\thesubsubsection)}{0pt}{\large}
\titlespacing*{\subsubsection} 
  {0pt}{0pt}{0pt}


\titleclass{\part}{straight}
\titleclass{\chapter}{straight}


\renewcommand\thechapter{\Alph{chapter}}
\renewcommand\thesection{\Roman{section}}
\renewcommand\thesubsection{\arabic{subsection}}
\renewcommand\thesubsubsection{\alph{subsubsection}}
 % There is no need to define your all version of \alpha
 % Especially since now we placed the parenthesis inside the \titleformat



\begin{document}
\part{Test Paaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaart} 
  % The reason you didn't have line breaks earlier is because
  % latex doesn't know how to break the non-word paaaa.....art into 
  % parts and hyphenate. I added some spaces to show that line
  % breaking works as expected with the [hang] option

\bigskip


\chapter{Test Chapter}

\bigskip


\section{Test Section}

\bigskip


\subsection{Test Subsection}

\bigskip


\subsubsection{Test Subsubsection}

\bigskip

{\lipsum[1-3]}
\end{document}

编译文件 在此处输入图片描述

编辑:我(提问者)采纳了你的建议,做了一些调整,并添加了缩进。以下是完整答案:

\documentclass[11pt, oneside, ngerman]{report}
\usepackage[ngerman]{babel}
\usepackage{geometry}
\geometry{a4paper}
\usepackage[parfill]{parskip}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[center]{titlesec}
\usepackage{fmtcount}
\usepackage{lipsum}
\setcounter{secnumdepth}{4}

\titleformat{\part}[hang]  
{\normalfont\large\bfseries}{\Ordinalstring{part} Teil: }{0pt}{\large}
\titlespacing*{\part} 
  {0pt}{0pt}{0pt}
  
\newcommand{\negphantom}[1]{\settowidth{\dimen0}{#1}\hspace*{-\dimen0}}
\newcommand{\SpacingA}{
    \hphantom{III.1.a)}\negphantom{xyzxy}
    }
\newcommand{\SpacingB}{
    \hphantom{A.III.1.a)}\negphantom{\Roman{section}.xyzxy}
    }
\newcommand{\SpacingC}{
    \hphantom{A.III.a)}\negphantom{xyzxy}
    }
\newcommand{\SpacingD}{
    \hphantom{A.III.1.}\negphantom{xyzxy}
    }

\titleformat{\chapter}[hang]
    {\normalfont\bfseries}{\thechapter.\SpacingA}{0pt}{\large}
\titlespacing*{\chapter} 
  {0pt}{0pt}{0pt}
  
\titleformat{\section}[hang]
    {\normalfont\bfseries}{\thesection.\SpacingB}{0pt}{\large}
\titlespacing*{\section} 
  {0pt}{0pt}{0pt}
  
\titleformat{\subsection}[hang]
    {\normalfont\bfseries}{\thesubsection.\SpacingC}{0pt}{\large}
\titlespacing*{\subsection} 
  {0pt}{0pt}{0pt}
  
\titleformat{\subsubsection}[hang]
        {\normalfont\bfseries}{\thesubsubsection)\SpacingD}{0pt}{\large}
\titlespacing*{\subsubsection} 
  {0pt}{0pt}{0pt}

\titleclass{\part}{straight}
\titleclass{\chapter}{straight}
\titleclass{\section}{straight}

\renewcommand\thechapter{\Alph{chapter}}
\renewcommand\thesection{\Roman{section}}
\renewcommand\thesubsection{\arabic{subsection}}
\renewcommand\thesubsubsection{\alph{subsubsection}}

编译:

在此处输入图片描述

相关内容