Text FormattingTOC undefined control sequence suddenly?

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
koba8791
Posts: 8
Joined: Thu Apr 15, 2021 10:39 pm

TOC undefined control sequence suddenly?

Post by koba8791 »

Hey!

I am new to Latex and need some help. My TOC is suddenly getting an undefined control error. I believe I have contradicting packages.

I need the following format:
titles of loc,lot, lof, intro and conclusion to be size 12, bold font, Times New Roman and centred
all sections, subsections and subsections to be size 12, bold font, Times New Roman and left

Currently:
- am not getting sections and subsections are not working with the commands I currently have
- TOC is throwing an undefined control sequence

Thank you!



Code below.

Code: Select all

\documentclass[a4paper,12pt]{article}
\usepackage{graphicx}
\usepackage{graphicx,subfigure}
\usepackage{hyperref}
\usepackage{multirow}
\usepackage{multicol}
\usepackage{blindtext}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage[T1]{fontenc}
\usepackage{placeins}
\usepackage{tocloft}
\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand{\headrulewidth}{0pt}
\fancyhf{}
\fancyfoot[R]{\thepage}
\usepackage{times}
\usepackage{sectsty}
\sectionfont{\fontsize{12}{14}\selectfont}
\subsectionfont{\fontsize{12}{14}\selectfont}
\subsubsectionfont{\fontsize{12}{14}\selectfont}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{courier}
\usepackage{setspace}
\usepackage[table,svgnames]{xcolor}
\usepackage{fancyvrb}
\usepackage{listings}
\usepackage[labelsep=period]{caption}
\usepackage[justification=centering]{caption}
\usepackage[labelfont=bf]{caption}
\addto\captionsenglish{\renewcommand{\figurename}{Fig.}}
\DeclareCaptionFont{mysize}{\fontsize{11}{13}\selectfont}
\captionsetup{font=mysize, singlelinecheck=off}
\renewcommand{\cftfigfont}{Fig. }
\renewcommand{\cfttabfont}{Table }
\renewcommand{\cftfigaftersnum}{.}
\renewcommand{\cfttabaftersnum}{.}
\setlength{\cfttabindent}{0pt}
\setlength{\cftfigindent}{0pt}
\renewcommand{\cfttabaftersnumb}{\hspace{-1em}}
\usepackage{longtable}
\usepackage{relsize}
\usepackage{tfrupee}
\usepackage{rotating}
\usepackage{lipsum}
\usepackage{float}
\usepackage{aliascnt}
\usepackage{color}
\usepackage[nottoc]{tocbibind}
\usepackage[numbers,square]{natbib}
\setcitestyle{citesep={,}}
\bibliographystyle{ieeetr}
\newcommand*{\urlprefix}{Available from: }
\newcommand*{\urldateprefix}{Accessed }
\usepackage{setspace}
\usepackage{relsize}
\makeatletter
\newcommand\footnoteref[1]{\protected@xdef\@thefnmark{\ref{#1}}\@footnotemark}
\makeatother
\addto\captionsenglish{
\renewcommand{\contentsname}{\centering \bfseries \normal List of Contents}}
Last edited by Stefan Kottwitz on Fri Apr 16, 2021 1:02 am, edited 1 time in total.
Reason: code marked

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Bartman
Posts: 369
Joined: Fri Jan 03, 2020 2:39 pm

TOC undefined control sequence suddenly?

Post by Bartman »

Please get used to providing a Infominimal working example and marking the code.

The error messages could be avoided with the help of the information in section 2.1 "Package options" of the tocloft documentation.

subfigure is deprecated and was superseded by subfig (see description on the associated CTAN website). With the subcaption package, which is also noteworthy, the previously described solution to the problem should be omitted.

Section 2.2 "Changing the titles" of the tocloft documentation and egreg's answer may help you center the selected headings. The sectsty package can set the same font size for all section headings with one command.

More notes:

Packages only have to be loaded once and several options can be specified as a list.

hyperref should be loaded last, with a few exceptions.

times is out of date, use mathptmx (read l2tabu on CTAN) or newtx instead.
koba8791
Posts: 8
Joined: Thu Apr 15, 2021 10:39 pm

TOC undefined control sequence suddenly?

Post by koba8791 »

Hey Bartman,

Thanks for the reply and resources, very helpful!

Although, I still can't seem to change the titles for TOC, LOT and LOF. They remain large, bold and flush-left.

Along with References, I can't seem to get the title centred.

Thank you!
Post Reply