我正在尝试使用 texmaker 以 PDFLaTeX 格式撰写我的硕士论文,由于我是 LaTeX 的新手,所以我的解决方案可能过于复杂,而它并没有给我我想要的结果。
我面临的问题:Wstęp(介绍)页码(在目录中生成)与目录中的其他页码不一致。
首选解决方案:目录页码全部对齐(在 1“列”中)
我很乐意接受有关如何修复我的代码的任何帮助:)提前谢谢您!
以下是我在 TexMaker 中用于生成文档的完整代码:
\documentclass[12pt,a4paper]{report}
% Are there any coding standards to adhere to?
% https://tex.stackexchange.com/questions/40775/are-there-any-coding-style-guidelines-for-latex
\usepackage[document]{ragged2e} % centering etc
\usepackage{charter} % [T1]{fontenc} {charter} allow to search words in pd
\usepackage[polish]{babel} %setting up polish language
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage[left=25mm, right=25mm, top=25mm, bottom=25mm]{geometry} % page margins set-up
% Packages for specific font sizes
\usepackage{mathptmx} % Times New Roman font
\usepackage{anyfontsize}
\usepackage{t1enc}
\usepackage[titles]{tocloft}
%Font Specifications
\ifdefined\directlua
\usepackage{fontspec}
\else
\usepackage[T1]{fontenc}
\usepackage[nomath]{lmodern}
\fi
\usepackage{xcolor}
\usepackage{titlesec}
\titleformat{\chapter}[display]
{\normalfont\chapfnt\bfseries}{\chaptertitlename\ \thechapter}{20pt}{\chapfnt}
\titleformat{\section}{\fontsize{12}{14.4}\bfseries\selectfont}
\titleformat{\subsection}{\fontsize{12}{14.4}\bfseries\selectfont}
\titleformat*{\section}{\fontsize{12}{14.4}\bfseries\selectfont}
\titleformat*{\subsection}{\fontsize{12}{14.4}\bfseries\selectfont}
% Package to add dots in ToC
\usepackage{titletoc}% http://ctan.org/pkg/titletoc
\titlecontents{chapter}% <section-type>
[0pt]% <left>
{\vspace{0,5cm}}% <above-code>
{\bfseries\MakeUppercase\chaptername\ \thecontentslabel\quad}% <numbered-entry-format>
{}% <numberless-entry-format>
{\space\titlerule*[1pc]{.}\contentspage} %<filler-page-format>
{}
%
%\dotfill\contentspage\vspace{0,5cm}
\titlecontents*{chapter}% <section-type>
[0pt]% <left>
{\vspace{0,5cm}}% <above-code>
{\bfseries\MakeUppercase\chaptername\ \thecontentslabel\quad}% <numbered-entry-format>
{}% <numberless-entry-format>
{\space\titlerule*[1pc]{.}\contentspage} %<filler-page-format>
{}
% Table of contents depth setting - to including subsections
\setcounter{secnumdepth}{4}
\setcounter{tocdepth}{3}
\renewcommand{\dotfill}{%
\leavevmode\cleaders\hbox to 0.7em{\hss .\hss }\hfill\kern0pt }
% \thecontentslabel
% Font sizes
% redefine pagestyle headings because in xetex, left and right in
% the headers are swapped.
% Redefining section to have adjusted font sizes
% setting chapter font size at 12
\newcommand{\chapfnt}{\fontsize{12}{14.4}}
%starting sections redefining parameters
% The arguments of \@startsection are:
% #1 name of the heading level (relevant for labels and references)
% #2 heading level (relevant for secnumdepth and tocdepth counters)
% #3 indent (\z@ is 0pt)
% #4 space before: when less than 0pt, no parindent is inserted after the heading, if greater or equal to 0pt, parindent is inserted. \@plus and \@minus add positive and negative glue, i.e., room for TeX to stretch or shrink vertical space(s) to fill the page down to the bottom
% #5 space after: values <0pt make inline headings with the amount as horizontal space, positive values make vertical space. Can also have glue.
% #6 are font switches like font family, font size, font weight, etc.
\makeatletter
\renewcommand\section{\@startsection {section}{1}{\z@}%
{-3.5ex \@plus -1ex \@minus -.2ex}%
{2.3ex \@plus.2ex}%
%defining font size of series %\normalsize
{\normalfont\fontsize{12}{14.4}\selectfont\bfseries}}
% defining chapter function
\def\@makechapterhead#1{%
\vspace*{50\p@}%
{\parindent \z@ \raggedright \normalfont
\ifnum \c@secnumdepth >\m@ne
% defining chapter font
% adding \centering for center display and \MakeUppercase for upper case
\chapfnt\bfseries\centering\MakeUppercase \@chapapp\space \thechapter
\par\nobreak
\vskip 20\p@
\fi
\interlinepenalty\@M
% adding \centering for center display and \MakeUppercase for upper case
\chapfnt \bfseries\centering\MakeUppercase #1\par\nobreak
\vskip 40\p@
}}
\renewcommand\tableofcontents{%
\section*{\centerline{\MakeUppercase{\contentsname}}
\@mkboth
{\MakeUppercase\contentsname}
{\MakeUppercase\contentsname}
}%
\@starttoc{toc}%
}
\makeatother
\makeatletter
\usepackage[unicode]{hyperref} % allowing hyperlinks
% Standard parameters
\author{Testeur TheTester}
\title{While testing this test became super test}
% New parameters
% Cannot have special characters in names - keep to lowercase and only characters
\newcommand\doccreator{Testeur TheTester}
\newcommand\doctitle{What is love - baby don't hurt me}
\newcommand\school{University of Mammon}
\newcommand\department{FIAT Department}
\newcommand\id{5517}
\newcommand\engtitle{Optimal Portfolio Allocation}
\newcommand\faculty{Shadow Economy}
\newcommand\thesistype{magisterska}
\newcommand\supervisora{dr Very Noble}
\newcommand\supervisorb{from Notre Dame Cathedral}
\newcommand\supervisorc{WNE UW}
\newcommand{\vertspace}{\vskip 1mm}
% https://tex.stackexchange.com/questions/30062/vspace-vs-vskip
\setlength{\cftchapindent}{2in}
\begin{document}
\linespread{1.5}
%Parametry dokumentu
\label{foo}
\begin{titlepage}%
\let\footnotesize\small
\let\footnoterule\relax
\let \footnote \thanks
\begin{center}%
{\fontsize{18pt}{21.6pt}\selectfont}
{\Huge \school\\ \department\par}
\vspace{2cm}
{\fontsize{14pt}{16.8pt}\selectfont}
{\Large \doccreator \par}
{\large ID: \id\par}
\vspace{2cm}
{\fontsize{20pt}{24pt}\selectfont}
{\Huge\textbf{\doctitle}\par}
\vspace{1cm plus 1fill}
{\large\ Praca \thesistype \\
na kierunku: \faculty } \\
\vspace{2cm plus 2fill}
\end{center}
\vspace{1cm plus 1.5fill}
\begin{flushright}
Praca wykonana pod kierunkiem\\
\supervisora \\
\supervisorb \\
\supervisorc
\end{flushright}
\vspace{1cm plus 0.8fill}
% miesiąc i~rok:
\begin{center}
Lipiec 2023
\end{center}
\end{titlepage}
\newpage
% starting numbering from 2nd page
\clearpage
\pagenumbering{arabic}
\textit{Oświadczenia kierującego pracą }
\vspace{10mm}
\begin{justify}
Oświadczam, że niniejsza praca została przygotowana pod moim kierunkiem i stwierdzam, że spełnia ona warunki do przedstawienia jej w postępowaniu o nadanie tytułu zawodowego.
\end{justify}
\vspace{15mm}
Data \hfill Podpis kierującego pracą
\vspace{3cm} \\
\textit{Oświadczenie autora pracy}
\vspace{10mm}
\begin{justify}
Świadom odpowiedzialności prawnej oświadczam, że niniejsza praca dyplomowa została napisana przeze mnie samodzielnie i nie zawiera treści uzyskanych w sposób niezgodny z obowiązującymi przepisami.
\end{justify}
\vspace{10mm}
\begin{justify}
Oświadczam również, że przedstawiona praca nie była wcześniej przedmiotem procedur związanych z uzyskaniem tytułu zawodowego w wyższej uczelni.
\end{justify}
\vertspace
\begin{justify}
Oświadczam ponadto, że niniejsza wersja pracy jest identyczna z załączoną wersją elektroniczną.
\end{justify}
\vspace{15mm}
Data \hfill Podpis autora pracy
\newpage
\vspace*{26pt}%
\begin{center}%
\textbf{Streszczenie} \\
Kiedy Kamil, kiedy Kamil był prezesem NBP hej
\end{center}
\vspace*{26pt}%
\begin{center}%
\textbf{Słowa kluczowe} \\
\#ŻYĆKO \#WYGRANKO \#MAGISTERKO
\end{center}
\vspace*{26pt}%
\begin{center}%
\textbf{Dziedzina pracy (kody wg programu Socrates-Erasmus)} \\
11.4 Sztuczna inteligencja
\end{center}
\vspace*{26pt}%
\begin{center}%
\textbf{Klasyfikacja tematyczna} \\
D. Software\\
D.127. Blabalgorithms\\
\end{center}
\vspace*{26pt}%
\begin{center}%
\textbf{Tytuł pracy w języku angielskim} \\
While this was developed something other entirely was created
\end{center}
\nobreak\vfil\null
\newpage
\tableofcontents
\newpage
\chapter*{WSTĘP}
\addcontentsline{toc}{chapter}{\textbf{WSTĘP}}
%\quad\protect
\addtocontents{toc}{\linebreak[1]}
\chapter{Who invented rap?}
\section{Historical Overview}
\chapter{Implementation}
\section{The CUDA Model}
\section{A Lattice Boltzmann Solver}
\subsection{Why and what - but especially where}
\listoffigures
\listoftables
\end{document}
答案1
尝试
\titlecontents{chapter*}% <section-type>
代替
\titlecontents*{chapter}% <section-type>
并删除
\addtocontents{toc}{\linebreak[1]}%