我正在准备论文模板。因此,我使用了许多软件包和代码。我需要目录中居中的部分(参见代码中的 mainsection),没有页码。我必须用土耳其语在主要部分的开头写上第一和第二个。我设法做到了这一点,但每个主要部分后的第一个部分/小节/小节/段落的目录中的书写不正确。此外,第一个部分/小节/小节/段落后的点没有出现/运行。我也需要这些点。你能帮我解决这个问题吗?MWE 及其输出如下:
\documentclass[a4paper,12pt]{article}
\renewcommand{\baselinestretch}{1.4}
\usepackage[left=3cm, top=3cm, right=2.5cm, bottom=2.5cm]{geometry}
\usepackage{mathptmx}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{imakeidx}
\makeindex
\usepackage{amsmath,amsthm,amssymb,enumerate,graphics,latexsym,fancyhdr,multicol,fleqn,multirow,tabu}
\usepackage{color,setspace,verbatim,graphicx,float,subcaption,sectsty,cite,sectsty,secdot,parskip,hanging,titletoc,indentfirst,afterpage} %,
\usepackage{tocloft}
\usepackage{url}
\usepackage{ltablex}
\usepackage{booktabs}
\usepackage[natbibapa]{apacite}
\usepackage{caption}
\usepackage{xstring}
\renewcommand\cftsecaftersnumb{\hfill}
\setlength{\cftbeforetoctitleskip}{50pt}
\setlength{\cftaftertoctitleskip}{3\baselineskip}
\dottedcontents{section}[0em]{}{2.9em}{0.25pc}
\dottedcontents{paragraph}[5.2em]{}{2.5em}{0.25pc}
\renewcommand{\thesubsection}{\thesection.\arabic{subsection}}
\renewcommand{\thesubsubsection}{\thesubsection.\arabic{subsubsection}}
\renewcommand{\paragraph}{\thesubsection.\thesubsubsection\arabic{paragraph}.}
\newcommand{\numyazi}[1]{
\IfEqCase{#1}{
{1}{XXX}
{2}{YYY}
{3}{ZZZ}
}[\PackageError{numyazi}{Undefined option to numyazi: #1}{}]
}%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcounter{secnum}
\setcounter{section}{0}
\newcommand{\mainsection}[1]
{
\stepcounter{secnum}
\stepcounter{section}
\section*{\numyazi{\arabic{secnum}} SECTION \\\vspace{0.2cm}#1}
\cftaddtitleline{toc}{section}{\protect\numberline{}\newline\parbox{15.5cm}{\parbox{15.5cm}{\protect\centering \protect\numyazi{\arabic{secnum}} SECTION}\newline\parbox{15.5cm}{\protect\centering #1}}}\newline{}}
\usepackage{titlesec}
\titleformat{\section}{\centering\normalfont\fontsize{12}{12}\bfseries}{\thesection}{1em}{}
\titlespacing{\section}{0pt}{6pt}{18pt} % {sol boşluk}{üst boşluk}{alt boşluk}
\titleformat{\subsection}[block]{\normalfont\fontsize{12}{12}\bfseries}{\hspace{1.25cm}\thesubsection.}{3pt}{\hangindent=0cm} % \hangindent=1cm \hangafter=-1
\titlespacing{\subsection}{0cm}{21pt}{18pt} % {sol boşluk}{üst boşluk}{alt boşluk}
\titleformat{\subsubsection}[block]{\normalfont\fontsize{12}{12}\bfseries}{\hspace{1.25cm}\thesubsubsection.}{3pt}{\hangindent=0cm} % \hangindent=1cm \hangafter=-1
\titlespacing{\subsubsection}{0cm}{21pt}{18pt} % {sol boşluk}{üst boşluk}{alt boşluk}
\titleformat{\paragraph}[block]{\normalfont\fontsize{12}{12}\bfseries}{\hspace{1.25cm}\thesubsubsection.}{3pt}{\hangindent=0cm} % \hangindent=1cm \hangafter=-1
\titlespacing{\paragraph}{0cm}{6cm}{*0} % {sol boşluk}{üst boşluk}{alt boşluk}
\cftsetindents{subsection}{0cm}{0.9\baselineskip}
\cftsetindents{subsubsection}{0.9cm}{1.3\baselineskip}
\makeatletter
\renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}%
{-2.5ex\@plus -8ex \@minus -.25ex}%
{1.25ex \@plus .25ex}%
{\normalfont\normalsize\bfseries}}
\makeatother
\begin{document}
\begin{onehalfspacing}
\tableofcontents
\end{onehalfspacing}
\newpage
\mainsection{FIRST MAIN SECTION TITLE}\setcounter{table}{0}
\subsection{First Subsection Title}
xxx
\subsection{Second Subsection Title}
xxx
\subsubsection{First Subsubsection Title}
xxx
\mainsection{SECOND MAIN SECTION TITLE}\setcounter{table}{0}
\subsubsection{First Subsubsection Title}
xxx
\subsection{First Subsection Title}
xxx
\end{document}
答案1
当我在 \mainsection 代码之后写入代码 \addtocontents{toc}{\protect\setcounter{}{}} 时,我解决了该问题,目录得到了更正。
\mainsection{FIRST MAIN SECTION TITLE}\addtocontents{toc}{\protect\setcounter{}{}}
\mainsection{SECOND MAIN SECTION TITLE}\addtocontents{toc}{\protect\setcounter{}{}}