If you get an error message like

! Undefined control sequence.
<recently read> \nmid 

l.5 $\nmid
          $

it usually means that you've either misspelled the control sequence, or that is spelled correctly but defined elsewhere (in some package, for example).

In your case, \nmid is defined within amssymb. You can also identify this symbol within the Comprehensive LaTeX Symbol List.

Solution: Add \usepackage{amssymb} to your preamble.

Answer from Werner on Stack Overflow
🌐
Resurchify
resurchify.com › latex_tutorial › latex_error_undefined_control_sequence.php
Undefined control sequence Error in LaTeX | Resurchify
Another reason the compiler may throw Undefined Control Sequence error is the inappropriate use of backslash. For example, An error will be generated if we write the path of file as C:\Users\Files\Pictures · In the above example, LaTeX will interpret it as a command upon seeing the backslash \. But here, there is no command as \Users and therefore, the compiler will throw Undefined Control Sequence error.
🌐
Position Is Everything
positioniseverything.net › home › undefined control sequence latex: troubleshooting guide
Undefined Control Sequence Latex: Troubleshooting Guide - Position Is Everything
1 month ago - The undefined control sequence latex error can be caused by a mismatch in the dimensions of matrices in the assignment, an incorrect interpretation of data type, improper use of indexing, inconsistent dimensions in cell arrays, and undefined control sequence error...
🌐
LaTeX.org
latex.org › board index › document classes
Undefined control sequence - LaTeX.org
An undefined control sequence is an error thrown when the software can not identify the command! Please check if you have positioned the backslash properly! You can refer to this page for more info: https://www.overleaf.com/learn/latex/Er ...
🌐
Overleaf
overleaf.com › learn › latex › Errors › Undefined_control_sequence
Undefined control sequence - Overleaf, Online LaTeX Editor
The problem is that you have forgotten to include \usepackage{xspace} in the preamble. When this line is included, the error message will disappear as LaTeX now knows how to interpret the \xspace command.
🌐
LaTeX.org
latex.org › board index › general
Undefined control sequence error message - LaTeX.org
Undefined control sequence-errors are usually caused if you miss to load the package that provides it. For example, you have to load the marvellous package graphicx by David Carlisle et al. in order to use command includegraphics. As you didn't give any code (or complete error messages), i ...
Find elsewhere
🌐
LaTeX.org
latex.org › board index › latex editors › auctex
\RenewCommandCopy raises "Undefined control sequence" error - LaTeX.org
The "Undefined control sequence" error in AUCTeX may be due to `\RenewCommandCopy`. Try adding `\usepackage{letltxmacro}` in your "my_article.cls" file to resolve the issue.
🌐
Quora
quora.com › How-do-I-tell-pdflatex-to-ignore-one-specific-undefined-control-sequence
How to tell pdflatex to ignore one specific undefined control sequence - Quora
Answer: Undefined control sequence This error appears when LATEX does not understand one of the commands you have used. Common Examples Typo in a command: The most common causes of such an error are simple typos.
🌐
Reddit
reddit.com › r/latex › question on homework template "undefined control sequence. [\end{document}]"
r/LaTeX on Reddit: Question on Homework Template "Undefined control sequence. [\end{document}]"
February 26, 2019 -

Hi all,

I was trying to write my math homework on Latex and I used 'Homework' template from Overleaf. However, when I compile it offline on my sublime text3. It shows

Undefined control sequence. [\end{document}]

Underfull \hbox (badness 10000) in paragraph at lines 75--76

 []

Package atveryend Info: Empty hook `BeforeClearDocument' on input line 79.
! Undefined control sequence.
\f@nch@olh ->\hwclass {} \hwlecture 
                                    \hwsection \strut 
l.79 \end{document}
                   
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.

! Undefined control sequence.
\f@nch@olh ->\hwclass {} \hwlecture \hwsection 
                                               \strut 
l.79 \end{document}
                   
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.

This is what shows up in the code log of my latex, and I was wondering how I can fix it and compile a pdf offline without Overleaf.

Below is the "homework" template cls file that I am using.

Thanks in advance.

\NeedsTeXFormat{LaTeX2e}
\LoadClassWithOptions{article}
\ProvidesClass{homework}[2014/12/16 Class file for homework assignments]

% ----- Options ---------------------------------------------------------------
\newcommand\@opanon{0}
\DeclareOption{anonymous}{\renewcommand\@opanon{1}}
\newcommand\@opnewpage{0}
\DeclareOption{newpage}{\renewcommand\@opnewpage{1}}
\newcommand\@oplargemargins{0}
\DeclareOption{largemargins}{\renewcommand\@oplargemargins{1}}
\ProcessOptions

% ----- Packages --------------------------------------------------------------

% Better fonts with accents
\RequirePackage[T1]{fontenc}

% Required for starred commands
\RequirePackage{suffix}

% Math symbols
\RequirePackage{amsmath}
\RequirePackage{amsfonts}
\RequirePackage{amsthm}
\RequirePackage{amssymb}
\RequirePackage{centernot}

% Nice lists
\RequirePackage{enumerate}
\RequirePackage{enumitem}

% Nice images, figures, and listings
\RequirePackage{graphicx}
\RequirePackage{grffile}
\RequirePackage[all]{xy}
\RequirePackage{wrapfig}
\RequirePackage{fancyvrb}
\RequirePackage{listings}

% Conditionals
\RequirePackage{ifthen}

% Header & Page Setup
\RequirePackage{fancyhdr}
\ifthenelse{\equal{\@oplargemargins}{1}}{}{\RequirePackage{fullpage}}

% Links
\RequirePackage{hyperref}

% ----- Questions -------------------------------------------------------------
\newcounter{questionCounter}
\newcounter{partCounter}[questionCounter]

% Prefix for questions
\newcommand{\questiontype}[0]{Question}

% Use this if your "written" questions are all under one section
% For example, if the homework handout has Section 5: Written Questions
% and all questions are 5.1, 5.2, 5.3, etc. set this to 5
% Use for 0 no prefix. Redefine as needed per-question.
\newcommand{\writtensection}[0]{0}

% Numbered question
\providecommand{\question}{}
\renewcommand{\question}[0]{%
  % Emit \newpage if option `newpage` is present
  \ifthenelse{\equal{\@opnewpage}{1}}{%
    \newpage
  }{}

  % Wrap in minipage so that we don't get a line break enywhere in between
  \begin{minipage}{\linewidth}%
    \stepcounter{questionCounter}%
      \vspace{.2in}%
      \ifx\writtensection\undefined{}
        \noindent{\bf \questiontype\ \arabic{questionCounter}.}%
        \else
          \ifnum\writtensection=0
          \noindent{\bf \questiontype\ \arabic{questionCounter}.}%
          \else
          \noindent{\bf \questiontype\ \writtensection.\arabic{questionCounter}}%
        \fi
      \vspace{0.3em} \hrule \vspace{.1in}%
  \end{minipage}
}

% Named question, takes one argument
\WithSuffix\providecommand\question*{}
\WithSuffix\renewcommand\question*[1]{%
  % Emit \newpage if option `newpage` is present
  \ifthenelse{\equal{\@opnewpage}{1}}{%
    \newpage%
  }{}%
  % Wrap in minipage so that we don't get a line break enywhere in between
  \begin{minipage}{\linewidth}%
    \addtocounter{questionCounter}{1}%
    \setcounter{partCounter}{0}%
    \vspace{.2in}%
    \noindent{\bf \arabic{questionCounter}. #1}%
    \vspace{0.3em} \hrule \vspace{.1in}%
  \end{minipage}
}

% Override normal section defintions
\renewcommand{\section}[0]{\question}
\WithSuffix\newcommand\section*[1]{\question*{#1}}

% ----- Question Parts --------------------------------------------------------

\newenvironment{alphaparts}[0]{%
  \begin{enumerate}[label=\textbf{(\alph{partCounter})}]%
}{\end{enumerate}}

\newenvironment{arabicparts}[0]{%
  \begin{enumerate}[label=\textbf{\arabic{questionCounter}.\arabic{partCounter}})]%
}{\end{enumerate}}

\newcommand{\questionpart}[0]{\stepcounter{partCounter}\item}

% ----- Induction Environment -------------------------------------------------

\newenvironment{induction}[0]{%
  \begin{description}
}{\end{description}}

\newcommand{\basecase}{\item[Base Case]\mbox{}\\}
\newcommand{\indhyp}{\item[Induction Hypothesis]\mbox{}\\}
\newcommand{\indstep}{\item[Induction Step]\mbox{}\\}

% ----- Answer Box ------------------------------------------------------------

\newcommand{\answerbox}[1]{%
\begin{framed}
\vspace{#1}
\end{framed}}

% ----- Page Setup ------------------------------------------------------------

% Use block style paragraphs
\setlength{\parindent}{0pt}
\setlength{\parskip}{5pt plus 1pt}

\def\indented#1{\list{}{}\item[]}
\let\indented=\endlist

% ----- Title & Header --------------------------------------------------------
\pagestyle{empty}
\pagestyle{fancy}

%\if\@opanon%
\ifthenelse{\equal{\@opanon}{0}}{%
  \renewcommand{\maketitle}[0]{%
    % Setup header
    \setlength{\headheight}{15.2pt}
    \setlength{\headsep}{0.2in}
    \lhead{\hwclass{} \hwlecture\hwsection}%
    \chead{\hwname{} (\hwemail)}%
    \rhead{\hwtype{} \hwnum}%

    % Setup hrule in header
    \renewcommand{\headrulewidth}{0pt}
    \headrule{}

    % Don't put header on first page
    \thispagestyle{plain}

    \begin{center}
      {\Large \hwclass{} \hwtype{} \hwnum}

      \hwname{} (\hwemail)

      \today
    \end{center}
    \renewcommand{\headrulewidth}{0.4pt}
  }

}%
{%
  \renewcommand{\maketitle}[0]{%
    % Make all pages plain
    \pagestyle{plain}

    % Put header on it's own page
    \begin{center}
      {\Large \hwclass{} \hwtype{} \hwnum}

      \hwname{} (\hwemail)

      \today
    \end{center}
    \renewcommand{\headrulewidth}{0.4pt}
    \newpage
  }
}

% ----- For usage with pandoc converted documents -----------------------------

\providecommand{\tightlist}{%
  \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}

% ----------------------------------------------------
🌐
Position Is Everything
positioniseverything.net › home › undefined control sequence: giving away instant solutions
Undefined Control Sequence: Giving Away Instant Solutions - Position Is Everything
June 9, 2025 - Think about it this way. You have entered some text that contains backslashes. In such a scenario, LaTex will consider the text following the backslash as a command and throw an undefined control sequence LaTeX table error.
🌐
McGill University
math.mcgill.ca › darmon › pub › Articles › Research › 16.Rigid-analytic › Appendix › appendix.log
Mcgill
We denote the $\ZZ $-linear dual of $M$\/ by The control sequence at the end of the top line of your error message was never \def'ed. If you have misspelled it (e.g., `\hobx'), type `I' and the correct spelling (e.g., `I\hbox'). Otherwise just continue, and I'll forget about whatever was undefined. LaTeX Font Info: Try loading font information for OMS+cmr on input line 237.
Top answer
1 of 1
2

In some cases it wasn't clear what the intended output was but this produces the output that I think you intended, with no errors or warnings. I put comments inline in the code where I made changes.

\documentclass[10pt]{article}
\usepackage[usenames]{color} %used for font color
\usepackage{amssymb} %maths
\usepackage{amsmath} %maths
\usepackage{graphicx}
\usepackage{booktabs}

% only if your images are at the root of the filesystem
% \graphicspath{/} 



% \begin{document} was missing
\begin{document}

%  \\ \\ \\ \\ \\ \\
% make badness 10000 warnings (which is the maximum badness)

% \section{1.6} makes 1 1.6 which looks weird
\setcounter{section}{1}
\setcounter{subsection}{6}
\subsection{}
\subsubsection*{6.}

\subsection{}
  \subsubsection*{8} Yes. 

$\overline{A \cup B} $\\
 \includegraphics[height=1em]{example-image} % missing file {vennd}


$\overline{A} \cap \overline{B} $\\
\includegraphics[height=1em]{example-image} % missing file {vennd}

\stepcounter{section}
\subsection{}
  \subsubsection*{6a} $ [0,2] \cup [0,3] \cup [0,4] \cup \dots = [0,\infty) $
  \subsubsection*{6b} $ [0,2] \cap [0,3] \cap [0,4] \cap \dots = [0,2] $

\subsection{}
  \subsubsection*{6} Statement is true.
  \subsubsection*{14} Not a Statement

\subsection{}
  \subsubsection*{8.} $ P = (x = 0) \\ \null \quad \quad Q = (y = y) \\ \null \quad \quad P \lor Q $

\subsection{}
  \subsubsection*{2} If a function is continuous, then it is differentiable.

\subsection{}
  \subsubsection*{4} $ a \in \mathbb{Q} \iff 5a \in \mathbb{Q} $

\subsection{}
  \subsubsection*{4}
    \begin{center}
      \begin{tabular}{|c|c|c|c|c|c|}
        $P$ & $Q$ & $P 
% \lor not \or
\lor
% spurious {
Q$ & $\lnot{(P \lor Q)}$ & $\lnot{P}$ & $\not(P \lor \lnot{P}$ \\ \midrule 
T & T & T & F & F & F \\
T & F & T & F & F & F \\
F & T & T & F & T & T \\
F & F & F & T & T & T \\
\end{tabular}
\end{center}

\subsubsection*{8}
  \begin{center}
    \begin{tabular}{cccccc}
      $P$ & $Q$ & $R$ & $\lnot{R}$ & $Q \land \lnot{R}$ & $P \lor )Q \land \lnot{R})$ \\midrule
T & T & T & F & F & T \\
T & T & F & T & T & T \\
T & F & T & F & F & F \\
T & F & F & T & F & T \\
F & T & T & F & F & F \\
F & T & F & T & T & T \\
F & F & T & F & F & F \\
F & F & F & T & F & F 
\end{tabular}
\end{center}
\subsubsection*{10} Suppose  $((P \land Q) \lor R) 
% \implies not \imlies 
\implies (R \lor S)$ is false. \\ Then, $ R = true must be false, therefore $$ R = false, S = false $. \\ Also, $ ((P \land Q) \lor R)$ must be t $ R = false $ then $ (P \land Q) $ must be true. Therefore $ P = true, Q = true $

\subsection{}
  \subsubsection*{2}
    \begin{center}
      \begin{tabular}{cccccc}
        $P$ & $Q$ & $R$ $Q\land R$ & $P \lor (Q \land R)$ & $P \lor Q$ & $(P \lor R) $ \\ \midrule
      \end{tabular}
      \end{center}
  \subsubsection*{10}
      Yes.% never use \\ before a display math or at the end of a paragraph
      \begin{equation}
        \begin{split}
         (P \implies Q) \lor R & \stackrel{?}{=} \lnot((O \land \lnot{Q})
\land \lnot{R}) \stackrel{?}{=} (\lnot (P \land \lnot{Q}) \lor R) \\
& \stackrel{?}{=} ((\lnot{P} \lor R) \\ (\lnot P 
% \\lor Q not \lorQ
\lor Q) \lor R & = ((\lnot{P} \lor Q) \lor R)
         \end{split}
      \end{equation}

      Since $ P\implies Q $ is logically equivalent to $ \lnot P \lor Q $ :
      \begin{center}
        \begin{tabular}{|c|c|c|c|c|}
          $P$ & $Q$ & $P \implies Q$ & $\lnot P$ & $ \lnot P \lor Q $ \\ \midrule
          T & T & T & F & T \\
          T & F & F & F & F \\
          F & T & T & T & T \\
          F & F & T & T & T \\

        \end{tabular}
       \end{center}
\end{document} 
🌐
Stack Overflow
stackoverflow.com › questions › 70769632 › undefined-control-sequence-textbf
latex - Undefined Control Sequence \TEXTBF - Stack Overflow
2 latex undefined control sequence with tableofcontents · 1 Creating Multirow Undefined Control Sequence · 4 Undefined control sequence \chapter · 0 ! Undefined control sequence. <argument> \mathindent in Rmarkdown · 0 How to Arrange a Figure in center of page using full width of page while using IEEEtran in LaTex?
🌐
Reddit
reddit.com › r/latex › undefined control sequence [\end{document}]?
r/LaTeX on Reddit: Undefined control sequence [\end{document}]?
November 14, 2017 -

I am working on updating my resume using a template from a colleague. When I try to build the file I get an error saying Undefined control sequence, so I have commented or removed where the errors were occurring. Even when stripping out everything of importance, the error I get is `Undefined control sequence [\end{document}]. Is there a reason this is occurring?

After removing almost all of my information, and leaving just the giving packages and formatting information, I found the problem to be the line:

\cfoot{\addressfont\itshape{Page \thepage}}

What must be changed to make this paper compile?