简体   繁体   中英

How to disable numbering in latex?

I am new to latex and I wrote the below tex code on Texmaker editor.

What I want to do is to add the "University" section without any numbering preceeding it and to be centered horizontally, because when I run the code I find that the word "University" is displayed but it is preceeded by a number and I do not want to display any number preceeding that word.

code :

\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{graphicx}
\usepackage{kpfonts}
\author{Anan}
\pagestyle{plain}
\begin{document}
\section{University}
\end{document}
\section*{\centering University}
    % * removes numbering for _this_ \section instance, 
    % \centering within environment centres the title.

Note however, that this is a local solution, and that it's better practice (and easier for you to make later document-global changes) to re-define the \\section , \\subsection , ... environments using the titlesec package, as is described well in Alan Munn:s answer in the following tex.stackexchange thread:

All you have to do is to edit your line 9:

\section{University}

this way:

\section*{\centering University}

since the command \\section* produces unnumbered sections.

Further, if you want to to include an unnumbered section to your table of contents, you can add

\addcontentsline{toc}{section}{University}

(this time without \\centering ) just after. The resulting code:

\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{graphicx}
\usepackage{kpfonts}
\author{Anan}
\pagestyle{plain}
\begin{document}
\tableofcontents
\section*{\centering University}
\addcontentsline{toc}{section}{University}
Text.
\end{document}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM