我正在使用 LaTeX 撰写一篇文章。由于我以前从未使用过 LaTeX,因此我下载了一个可以重复使用的模板。首先,它使用了 \documentclass{Thesis}
要求文章使用章节的。但是,为了不需要章节(只需要部分),我将 更改documentclass
为“文章”,并将所有\chapter
标签更改为\section
,\section
将标签更改为\subsection
等等。
除了编号之外,一切都很顺利。每个部分的编号都以 0 为前缀。因此,第一部分的编号为 0.1,然后是 0.2,依此类推。
我怎样才能删除这个前缀 0?
%----------------------------------------------------------------------------------------
% PACKAGES AND OTHER DOCUMENT CONFIGURATIONS
%----------------------------------------------------------------------------------------
\documentclass[11pt, oneside]{article} % The default font size and one-sided printing (no margin offsets)
\graphicspath{{Pictures/}} % Specifies the directory where pictures are stored
\usepackage[official]{eurosym}
\usepackage[normalem]{ulem}
\usepackage[square, numbers, comma, sort&compress]{natbib} % Use the natbib reference package - read up on this to edit the reference style; if you want text (e.g. Smith et al., 2012) for the in-text references (instead of numbers), remove 'numbers'
\hypersetup{urlcolor=blue, colorlinks=true} % Colors hyperlinks in blue - change to black if annoying
\title{\ttitle} % Defines the thesis title - don't touch this
\begin{document}
\frontmatter % Use roman page numbering style (i, ii, iii, iv...) for the pre-content pages
\setstretch{1.3} % Line spacing of 1.3
% Define the page headers using the FancyHdr package and set up for one-sided printing
\fancyhead{} % Clears all page headers and footers
\rhead{\thepage} % Sets the right side header to show the page number
\lhead{} % Clears the left side page header
\pagestyle{fancy} % Finally, use the "fancy" page style to implement the FancyHdr headers
\newcommand{\HRule}{\rule{\linewidth}{0.5mm}} % New command to make the lines in the title page
% PDF meta-data
\hypersetup{pdftitle={\ttitle}}
\hypersetup{pdfsubject=\subjectname}
\hypersetup{pdfauthor=\authornames}
\hypersetup{pdfkeywords=\keywordnames}
%----------------------------------------------------------------------------------------
% TITLE PAGE
%----------------------------------------------------------------------------------------
\begin{titlepage}
\begin{center}
\textsc{\LARGE \univname}\\[1.5cm] % University name
\textsc{\Large Bachelor Thesis Pre Study}\\[0.5cm] % Thesis type
\HRule \\[0.4cm] % Horizontal line
{\huge \bfseries \ttitle}\\ % Thesis title
\HRule \\[1.5cm] % Horizontal line
\begin{minipage}{0.4\textwidth}
\begin{flushleft} \large
\emph{Author:}\\
{\authornames} % Author name - remove the \href bracket to remove the link
\end{flushleft}
\end{minipage}
\begin{minipage}{0.4\textwidth}
\begin{flushright} \large
\emph{Supervisor:} \\
\href{http://soft.vub.ac.be/~egonzale/egonzale/#/Home}{\supname} % Supervisor name - remove the \href bracket to remove the link
\end{flushright}
\end{minipage}\\[3cm]
\groupname\\\deptname\\[2cm] % Research group name and department name
{\large \today}\\[1cm] % Date
\includegraphics{Pictures/vub_logo} % University/department logo - uncomment to place it
\vfill
\end{center}
\end{titlepage}
%----------------------------------------------------------------------------------------
% ABSTRACT PAGE
%----------------------------------------------------------------------------------------
\addtotoc{Abstract} % Add the "Abstract" page entry to the Contents
\abstract{\addtocontents{toc}{\vspace{1em}} % Add a gap in the Contents, for aesthetics
The Thesis Abstract is written here (and usually kept to just this page). The page is kept centered vertically so can expand into the blank space above the title too\ldots
}
\clearpage % Start a new page
%----------------------------------------------------------------------------------------
% ACKNOWLEDGEMENTS
%----------------------------------------------------------------------------------------
\setstretch{1.3} % Reset the line-spacing to 1.3 for body text (if it has changed)
\acknowledgements{\addtocontents{toc}{\vspace{1em}} % Add a gap in the Contents, for aesthetics
The acknowledgements and the people to thank go here, don't forget to include your project advisor\ldots
}
\clearpage % Start a new page
%----------------------------------------------------------------------------------------
% LIST OF CONTENTS/FIGURES/TABLES PAGES
%----------------------------------------------------------------------------------------
\pagestyle{fancy} % The page style headers have been "empty" all this time, now use the "fancy" headers as defined before to bring them back
\lhead{\emph{Contents}} % Set the left side page header to "Contents"
\tableofcontents % Write out the Table of Contents
%----------------------------------------------------------------------------------------
% THESIS CONTENT - CHAPTERS
%----------------------------------------------------------------------------------------
\mainmatter % Begin numeric (1,2,3...) page numbering
\pagestyle{fancy} % Return the page headers back to the "fancy" style
% Include the chapters of the thesis as separate files from the Chapters folder
% Uncomment the lines as you write the chapters
\input{Chapters/Chapter1}
\input{Chapters/Chapter2}
\input{Chapters/Chapter3}
\input{Chapters/Chapter4}
\input{Chapters/Chapter5}
\input{Chapters/Chapter6}
\input{Chapters/Chapter7}
%----------------------------------------------------------------------------------------
% THESIS CONTENT - APPENDICES
%----------------------------------------------------------------------------------------
\addtocontents{toc}{\vspace{2em}} % Add a gap in the Contents, for aesthetics
\appendix % Cue to tell LaTeX that the following 'chapters' are Appendices
% Include the appendices of the thesis as separate files from the Appendices folder
% Uncomment the lines as you write the Appendices
\input{Appendices/AppendixA}
%\input{Appendices/AppendixB}
%\input{Appendices/AppendixC}
\addtocontents{toc}{\vspace{2em}} % Add a gap in the Contents, for aesthetics
\backmatter
%----------------------------------------------------------------------------------------
% BIBLIOGRAPHY
%----------------------------------------------------------------------------------------
\label{Bibliography}
\lhead{\emph{Bibliography}} % Change the page header to say "Bibliography"
\bibliographystyle{unsrtnat} % Use the "unsrtnat" BibTeX style for formatting the Bibliography
\bibliography{Bibliography} % The references (bibliography) information are stored in the file named "Bibliography.bib"
\end{document}
我所包含的“章节”如下:
%----------------------------------------------------------------------------------------
% Chapter 1
\section{Thesis description} % Main chapter title
\label{Chapter1} % For referencing the chapter elsewhere, use \ref{Chapter1}
\lhead{Chapter 1. \emph{Thesis description}} % This is for the header on each page - perhaps a shortened title
%----------------------------------------------------------------------------------------
\subsection{Introduction} \label{sec:ThesisIntro}
Bla bla bla
\subsection{Thesis goals}
.....
\subsection{Literature study}
...
%----------------------------------------------------------------------------------------
答案1
我认为您在这里误解了一些事情,我想向您展示您应该继续前进的方向。
你写了
“由于我以前从未使用过 LaTeX,所以我下载了一个可以重复使用的模板。”
我认为这正是问题所在:您使用了您不理解的代码。
因为你是 LaTeX 的初学者,所以我建议你去你大学/学校参加一个入门课程,或者先读一本介绍 LaTeX 的书或 pdf。例如,阅读lshort.pdf
(互联网、ctan)或在你的控制台上尝试texdoc lshort
。这并不不友好,我认为它可以帮助你不浪费太多时间……
开始学习 LaTeX 意味着不要使用你看不懂的模板。从一个简单的文档类开始book
,然后一步一步学习如何准备自己的文档。
为了使您的 MWE 可编译(我刚刚注释掉了所有导致错误的命令),请参见以下代码。由于原始代码中包含了很多命令,因此Thesis.cls
我不得不注释掉这些部分。(您使用的模板应该有一个如何使用它的介绍。您读过吗?)
代码:
\documentclass[11pt, oneside]{book} % The default font size and one-sided printing (no margin offsets)
%\graphicspath{{Pictures/}} % Specifies the directory where pictures are stored
\usepackage[official]{eurosym}
\usepackage[normalem]{ulem}
\usepackage[square, numbers, comma, sort&compress]{natbib}
\usepackage{fancyhdr} % <===============================================
\usepackage{hyperref} % <===============================================
\hypersetup{urlcolor=blue, colorlinks=true}
%\title{\ttitle} % Defines the thesis title - don't touch this
\begin{document}
\frontmatter
%\setstretch{1.3} % Line spacing of 1.3
% Define the page headers using the FancyHdr package and set up for one-sided printing
\fancyhead{} % Clears all page headers and footers
\rhead{\thepage} % Sets the right side header to show the page number
\lhead{} % Clears the left side page header
\pagestyle{fancy} % Finally, use the "fancy" page style to implement the FancyHdr headers
\newcommand{\HRule}{\rule{\linewidth}{0.5mm}} % New command to make the lines in the title page
% PDF meta-data
%\hypersetup{pdftitle={\ttitle}}
%\hypersetup{pdfsubject=\subjectname}
%\hypersetup{pdfauthor=\authornames}
%\hypersetup{pdfkeywords=\keywordnames}
%----------------------------------------------------------------------------------------
% TITLE PAGE
%----------------------------------------------------------------------------------------
%\begin{titlepage}
%\begin{center}
%
%\textsc{\LARGE University name}\\[1.5cm] % University name
%\textsc{\Large Bachelor Thesis Pre Study}\\[0.5cm] % Thesis type
%
%\HRule \\[0.4cm] % Horizontal line
%{\huge \bfseries \ttitle}\\ % Thesis title
%\HRule \\[1.5cm] % Horizontal line
%
%\begin{minipage}{0.4\textwidth}
%\begin{flushleft} \large
%\emph{Author:}\\
%{\authornames} % Author name - remove the \href bracket to remove the link
%\end{flushleft}
%\end{minipage}
%\begin{minipage}{0.4\textwidth}
%\begin{flushright} \large
%\emph{Supervisor:} \\
%\href{http://soft.vub.ac.be/~egonzale/egonzale/#/Home}{\supname} % Supervisor name - remove the \href bracket to remove the link
%\end{flushright}
%\end{minipage}\\[3cm]
%
%\groupname\\\deptname\\[2cm] % Research group name and department name
%
%{\large \today}\\[1cm] % Date
%\includegraphics{Pictures/vub_logo} % University/department logo - uncomment to place it
%
%\vfill
%\end{center}
%
%\end{titlepage}
%----------------------------------------------------------------------------------------
% ABSTRACT PAGE
%----------------------------------------------------------------------------------------
%\addtotoc{Abstract} % Add the "Abstract" page entry to the Contents
%\abstract{\addtocontents{toc}{\vspace{1em}} % Add a gap in the Contents, for aesthetics
%
%The Thesis Abstract is written here (and usually kept to just this page). The page is kept centered vertically so can expand into the blank space above the title too\ldots
%}
\clearpage % Start a new page
%----------------------------------------------------------------------------------------
% ACKNOWLEDGEMENTS
%----------------------------------------------------------------------------------------
%\setstretch{1.3} % Reset the line-spacing to 1.3 for body text (if it has changed)
%\acknowledgements{\addtocontents{toc}{\vspace{1em}} % Add a gap in the Contents, for aesthetics
%
%The acknowledgements and the people to thank go here, don't forget to include your project advisor\ldots
%}
%\clearpage % Start a new page
%----------------------------------------------------------------------------------------
% LIST OF CONTENTS/FIGURES/TABLES PAGES
%----------------------------------------------------------------------------------------
\pagestyle{fancy} % The page style headers have been "empty" all this time, now use the "fancy" headers as defined before to bring them back
\lhead{\emph{Contents}} % Set the left side page header to "Contents"
\tableofcontents % Write out the Table of Contents
%----------------------------------------------------------------------------------------
% THESIS CONTENT - CHAPTERS
%----------------------------------------------------------------------------------------
\mainmatter % Begin numeric (1,2,3...) page numbering
\pagestyle{fancy} % Return the page headers back to the "fancy" style
% Include the chapters of the thesis as separate files from the Chapters folder
% Uncomment the lines as you write the chapters
%----------------------------------------------------------------------------------------
\chapter{Test to show} % <=============================================
% Chapter 1
\section{Thesis description} % Main chapter title
\label{Chapter1} % For referencing the chapter elsewhere, use \ref{Chapter1}
\lhead{Chapter 1. \emph{Thesis description}} % This is for the header on each page - perhaps a shortened title
%----------------------------------------------------------------------------------------
\subsection{Introduction} \label{sec:ThesisIntro}
Bla bla bla
\subsection{Thesis goals}
.....
\subsection{Literature study}
...
%----------------------------------------------------------------------------------------
%\input{Chapters/Chapter2}
%\input{Chapters/Chapter3}
%\input{Chapters/Chapter4}
%\input{Chapters/Chapter5}
%\input{Chapters/Chapter6}
%\input{Chapters/Chapter7}
%----------------------------------------------------------------------------------------
% THESIS CONTENT - APPENDICES
%----------------------------------------------------------------------------------------
\addtocontents{toc}{\vspace{2em}} % Add a gap in the Contents, for aesthetics
\appendix % Cue to tell LaTeX that the following 'chapters' are Appendices
% Include the appendices of the thesis as separate files from the Appendices folder
% Uncomment the lines as you write the Appendices
%\input{Appendices/AppendixA}
%\input{Appendices/AppendixB}
%\input{Appendices/AppendixC}
\addtocontents{toc}{\vspace{2em}} % Add a gap in the Contents, for aesthetics
\backmatter
%----------------------------------------------------------------------------------------
% BIBLIOGRAPHY
%----------------------------------------------------------------------------------------
\label{Bibliography}
\lhead{\emph{Bibliography}} % Change the page header to say "Bibliography"
\bibliographystyle{unsrtnat} % Use the "unsrtnat" BibTeX style for formatting the Bibliography
\bibliography{Bibliography} % The references (bibliography) information are stored in the file named "Bibliography.bib"
\end{document}
请研究我的更改。检查我注释掉的部分。试着理解原因。请注意,由于缺少 bib 文件,因此无法构建参考书目。上面的代码编译时没有错误,但当然缺少完整的标题页(我不得不将其注释掉)。
<===================
查看代码中标记的主要变化...