1

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}
MattAllegro
  • 6,455
  • 5
  • 45
  • 52
Amrmsmb
  • 1
  • 27
  • 104
  • 226

2 Answers2

2
\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:

Community
  • 1
  • 1
dfrib
  • 70,367
  • 12
  • 127
  • 192
1

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}
MattAllegro
  • 6,455
  • 5
  • 45
  • 52