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:
https://tex.stackexchange.com/questions/8546/section-heading-centering-problem
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}
Related
I'm new to LaTex and I wanted to know how I can change the Margins of my scrreport so that the chapter title, text and basically everythin starts a bit higher and ends a bit lower. In my opinion there is too much empty space before anything starts.
If I use this simple example:
\documentclass[12pt,a4paper,twoside]{scrreport}
\usepackage{blindtext}
\begin{document}
\chapter{First Chapter}
\blindtext
\end{document}
I think the margins from top and bottom are too big. So i want everything to move up a little bit.
Thanks!
Method 1:
Choose one of the predefined layouts. You'll find a list of available options in the koma script documentation.
\documentclass[12pt,a4paper,twoside,DIV=15]{scrreport}
\usepackage{blindtext}
\begin{document}
\chapter{First Chapter}
\blinddocument
\end{document}
Method 2:
Setting up the text area manually. You should be really sure that you know what you are doing to get an aesthetically pleasant result.
\documentclass[12pt,a4paper,twoside]{scrreport}
\areaset[current]{168.00mm}{250mm}
\usepackage{blindtext}
\begin{document}
\chapter{First Chapter}
\blinddocument
\end{document}
I am using the \twocolumn tag to use the two-column layout in LaTeX. The problem is that this does not work properly and the text seems not to be fixed between the borders. Not sure if that minimal example helps, but at least you can see my includes and the text with which it happens.
\documentclass[12pt,a4paper, abstracton]{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage[backend=biber, sorting=none]{biblatex}
\usepackage{hyperref}
\usepackage[hyphenbreaks]{breakurl}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}
\begin{document}
\twocolumn
\section{Introduction}
Glutamate carboxypeptidase II (GCPII), N-acetyl-L-aspartyl-L-glutamate peptidase I (NAALADase I), NAAG peptidase or prostate-specific membrane antigen (PSMA) \dots
\end{document}
Screenshot of left column in PDF that shows the problem
Why does LaTeX write from the first column into the second column and how can I fix that? I would like to avoid change each line separately, where that happens. I am looking for a global solution.
Since the workarounds of the accepted answer were not satisfactory to me, I kept searching and found a more adequate and fast workaround, adding to my preamble the following:
\setlength{\emergencystretch}{3em}
The length 3em can be changed as needed, just keep it as low as possible in order to preserve optimal appearance.
More details here.
Latex has trouble finding a suitable break point because words with multiple capital letters are normally assumed to be acronyms which should not be hyphenated.
Possible workarounds:
force a line break with \linebreak before the word. This might result in undesirable large spaces in the line, especially in your situation in with only a single white space in the line
tell latex where possible break points are with long\-word (I don't know if there are any possible hyphenation points in NAALADase). This can also be globally for the whole document with \hyphenation{long-word} in your preamble
rephrase the sentence
use another layout. Very short lines combined with very long and unbreakable words is a tough combination
\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage[backend=biber, sorting=none]{biblatex}
\usepackage{hyperref}
\usepackage[hyphenbreaks]{breakurl}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}
\begin{document}
\twocolumn
\section{Introduction}
Glutamate carboxypeptidase II (GCPII), N-acetyl-L-aspartyl-L-glutamate peptidase I \linebreak (NAALADase I), NAAG peptidase or prostate-specific membrane antigen (PSMA) \dots
\end{document}
I would like to have a table of content with numbering identical to the ones in text. So, in text each section/subsection/subsubsection is numerated as '1.' or '1.1.' or '1.1.1.'. However my table of content is not updating it, so it shows '1' or '1.1'.
I was following answer to this topic: https://superuser.com/questions/811779/how-to-add-a-dot-for-section-subsection-numbering-in-tex
So I am using 'secdot' package. I have tried using
\renewcommand{\thechapter}{\arabic{chapter}.}
\renewcommand{\thesection}{\thechapter\arabic{section}.}
but I keep getting '\the chapter undefined', 'No counter chapter defined' or 'Missing number, treated as zero' errors.
I would appreciate any tips on what's wrong.
EDIT:
\documentclass[11pt, a4paper, twoside]{article}
\usepackage{listings, lstautogobble}
\usepackage{ragged2e}
\usepackage{times}
\usepackage{secdot}
\sectiondot{subsection}
\usepackage{listings}
\usepackage[toc,page]{appendix}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\geometry{a4paper,
left=30mm,
top=25mm,
bottom=25mm,
right=20mm
}
\sectiondot{subsection}
\makenomenclature
\setlength{\parindent}{0.5 cm}
\renewcommand{\baselinestretch}{1.15}
\pagenumbering{roman}
\begin{document}
\setboolean{#twoside}{false}
\begin{figure}[H]
\begin{center}
\includegraphics[width=14cm,height=15cm,keepaspectratio]{./thesis- frontpagedesign}
\end{center}
\end{figure}
\begin{center}
\tableofcontents
\end{center}
\begin{center}
\listoffigures
\end{center}
\section{Introduction}
%sometext
\makeatletter
\def\#seccntformat#1{%
\expandafter\ifx\csname c##1\endcsname\c#section\else
\csname the#1\endcsname\quad
\fi}
\makeatother
\end{document}
Your current setup is confusing. For example,
\makeatletter
\def\#seccntformat#1{%
\expandafter\ifx\csname c##1\endcsname\c#section\else
\csname the#1\endcsname\quad
\fi}
\makeatother
removes the setting of any \section number. And mixing this with the use of secdot seems problematic.
The easiest way to achieve dots after sectional unit numbers within your text as well as the ToC is to adjust the representation of the respective counters:
\documentclass{article}
\renewcommand{\thesection}{\arabic{section}.}
\renewcommand{\thesubsection}{\thesection\arabic{subsection}.}
\renewcommand{\thesubsubsection}{\thesubsection\arabic{subsubsection}.}
\begin{document}
\tableofcontents
\section{Introduction}
\end{document}
This solution is sufficient, but will also affect \references. For example \ref{sec:introduction} would return 1. which may look odd in the middle of a sentence: ... from section~\ref{sec:introduction} we can see ....
If you don't want periods ending your \references, you can use
\usepackage{secdot}% Adds . after sectional unit numbers
\usepackage{etoolbox}
% \patchcmd{<cmd>}{<search>}{<replace>}{<success>}{<failure>}
\patchcmd{\numberline}{\hfil}{.\hfil}{}{}
You're already familiar with what secdot does. The patch to \numberline is thanks to etoolbox which changes the default definition
\def\numberline#1{\hb#xt#\#tempdima{#1\hfil}}
into
\def\numberline#1{\hb#xt#\#tempdima{#1.\hfil}}
effectively inserting an ending-period as part of the number that is printed within the ToC. Note that this will also affect how figures/tables are displayed within the LoF/LoT. However, one can change that using scoping:
\begingroup
% The following patch will only affect entries in the ToC
\patchcmd{\numberline}{\hfil}{.\hfil}{}{}
\tableofcontents
\endgroup
\listoffigures
\listoftables
I'm having a problem with the numbering of the sections in latex.
I want the numbering of the chapters and sections to be as
1 first chapter
1.1 first section
1.2 second section
the problem is that the numbering of the section appears only in the first section and I have no idea why is this happening!
this is the code that I used.
\documentclass [a4paper,12pt]{report}
\usepackage{times}
\usepackage{graphicx}
\usepackage{geometry}
\usepackage[utf8]{inputenc} % for numbering of pages
\usepackage{ragged2e}
\usepackage{indentfirst}
\usepackage{setspace}
\usepackage{titlesec}
\usepackage[english]{babel}
\renewcommand\thesection{\arabic{section}} % for the chapters numbering
%margins
%1 inch from top, buttom and right side of the page and 1.5 inch from left side of the page
\geometry{
a4paper,
left=1.5in,right=1in,top=1in,bottom=1in
}
\onehalfspacing
\centering
\pagenumbering{roman}
\titleformat{\section}
{\normalfont\fontsize{16}{15}\bfseries}{\thesection}{1em}{}
\titleformat{\subsection}
{\normalfont\fontsize{14}{15}\bfseries}{\thesection}{1em}{}
\titleformat{\subsubsection}
{\normalfont\fontsize{12}{15}\bfseries}{\thesection}{1em}{}
\renewcommand{\thesection}{\thechapter.\number\numexpr\value{section}\relax}
\renewcommand{\thesubsection}{\thesection.\number\numexpr\value{subsection}\relax}
\renewcommand{\thesubsubsection}{\thesubsection.\number\numexpr\value{subsubsection}\relax}
\setcounter{secnumdepth}{3}
\setcounter{chapter}{1}% Not using chapters, but they're used in the counte
\begin{document}
% this is the table of contents of the document
\renewcommand*\contentsname{Table of Contents}
%--------------------------------------------------
\tableofcontents
\newpage
\listoffigures
\newpage
\listoftables
% this is the introduction chapter
\newpage
\pagenumbering{arabic}
\chapter*{\centering \vspace{80 mm} Chapter One: Introduction}
\addcontentsline{toc}{chapter}{\numberline{}Chapter One: Introduction}%
\newpage
\justify
\setlength{\parindent}{5 ex}
\section{Introduction}
%write introduction here
\section{Problem Definition}
%write Problem Definition here
\section{Aim and Objectives}
%write Aim and Objectives here
\section{Methodology}
%write Methodology here
\section{Project Scope}
%write Project Scope here
\section{Project Timeline}
%write Project Timeline here
\section{Conclusion}
%write Conclusion here
\end{document}
the table of contentes shows the numbring however the numbers appear only in the first section (introduction). how can I make the numbers appear in the other sections as well ?
for some reason the following package and code affects the numbering of the section (I have no idea why is that happening). when I removed the following code the numbering of the sections appeared in the headings also.
\usepackage{titlesec}
\titleformat{\section}
{\normalfont\fontsize{16}{15}\bfseries}{\thesection}{1em}{}
\titleformat{\subsection}
{\normalfont\fontsize{14}{15}\bfseries}{\thesection}{1em}{}
\titleformat{\subsubsection}
{\normalfont\fontsize{12}{15}\bfseries}{\thesection}{1em}{}
now I need to find another way to change the font size of the headings. I would appreciate it if any one posts a better way to chanage the font size without using titlesec package.
I am writing my thesis in Latex, document class: report. I have got front matter containing of abstract, acknowledgement and so on.
I want to add header only to my main matter which starts with my first chapter:Introduction. I want the header to be the chapter number without the word "chapter" and the chapter title next to it. I also want the page number to appear in the centre on the bottom of the page in all pages of the main matter.
I don't want any header or line in any page of my front matter.
Can you please guide me? Thanks
Here it is the sample code that I am applying.
\documentclass[a4paper,12pt,titlepage]{report}
\usepackage{amsfonts}
\usepackage[english]{babel}
\usepackage{graphicx}
\usepackage{color}
\usepackage{colordvi}
\usepackage{amssymb}
\usepackage{natbib}
\usepackage[nottoc,notlot,notlof]{tocbibind}
\usepackage{setspace}
\usepackage{amsmath}
\usepackage{theorem}
\usepackage{lineno}
\usepackage{multirow}
\usepackage [toc,page]{appendix}
\usepackage{framed}
\usepackage{setspace}
\doublespacing
\usepackage[left=1.5in,top=2in,right=1in,bottom=2in]{geometry}
\begin{document}
\title{xxx}
\author{xxx}
\date{xxx}
\maketitle
\thispagestyle{empty}
\renewcommand{\thepage}{\roman{page}}
% here it comes my front matter for example:
\clearpage
\addcontentsline{toc}{chapter}{Abstract}
\chapter*{Abstract}
ABSTRACT CONTENTS
%then:
\clearpage
\cleardoublepage
\pagenumbering{arabic}
% here it starts my main matter:
\chapter{Introduction} %first chapter
\chapter{First Esssay in XXX} %second chapter
\end{document}
You have a number of options to set headers in a document. The most frequently-used package is fancyhdr.
First of all, you need to remove the word Chapter from the regular chapter mark. For this, add
\usepackage{etoolbox}
\makeatletter
%\newcommand{\updatechaptermark}{%
\appto\ps#fancy{%
\patchcmd{\chaptermark}% <cmd>
{\#chapapp\ }{}% <search><replace>
{}{}% <success><failure>
}%}
\makeatother
to your preamble. The above strips out \#chapapp\ (note the space) from \chaptermark as part of the call to \pagestyle{fancy}. That's required as fancyhdr may update \chaptermark upon calling \pagestyle{fancy}.
Second, you need to set the headers/footers. Here's a setting that yields what you're after:
\usepackage{fancyhdr}
\fancyhf{}% Clear header/footer
\fancyhead[C]{\leftmark}% Chapter mark
\fancyfoot[C]{\thepage}% Footer contains the page number
\renewcommand{\headrulewidth}{.4pt}% Header rule width
The above sets the header as \leftmark, which contains the \chaptermark setting (since \chaptermark actually issues \markboth{<leftmark>}{<rightmark>} with an empty <rightmark>).
\documentclass{report}
\usepackage{fancyhdr,lipsum}
\usepackage{etoolbox}
\makeatletter
%\newcommand{\updatechaptermark}{%
\appto\ps#fancy{%
\patchcmd{\chaptermark}% <cmd>
{\#chapapp\ }{}% <search><replace>
{}{}% <success><failure>
}%}
\makeatother
\fancyhf{}% Clear header/footer
\fancyhead[C]{\leftmark}
\fancyfoot[C]{\thepage}
\renewcommand{\headrulewidth}{.4pt}
\begin{document}
%\frontmatter
\pagenumbering{roman}
\title{xxx}
\author{xxx}
\date{xxx}
\maketitle
\thispagestyle{empty}
% here it comes my front matter for example:
\cleardoublepage
\tableofcontents
\cleardoublepage
\addcontentsline{toc}{chapter}{Abstract}%
\chapter*{Abstract} \lipsum[1]
\cleardoublepage
\pagenumbering{arabic}
\pagestyle{fancy}
\chapter{Introduction} \lipsum[1-50] % first chapter
\chapter{Methodology} \lipsum[1-50] % second chapter
\chapter{Conclusion} \lipsum[1-50] % last chapter
\end{document}
Note that \chapters are set by default using the plain style. If you wish this to be different, you'll have to redefine the plain page style.
You can achieve the same output using a different header/footer package like titleps.